Method for implementing shadow function of server decoration window based on wlroots

By utilizing the window's extended hidden area in wlroots to convert and render eight image textures, the complexity of implementing the server-side decorative window shadow function was resolved, resulting in improved code consistency and aesthetics.

CN116091685BActive Publication Date: 2026-04-21KYLIN CORP
View PDF 4 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
KYLIN CORP
Filing Date
2022-12-26
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

When implementing the shadow function of the server-side decorative window, wlroots' existing methods are complex and not conducive to unified code management, and increase the complexity of node traversal and the difficulty of event response.

Method used

By utilizing the window's expanded hidden area, eight images are converted into textures and associated with rect nodes in sequence. The shadow effect is then rendered using the existing graphics compositing process, avoiding the need to add buffer nodes or modify shaders and backend functions.

Benefits of technology

The code for shadow functionality was made more consistent and aesthetically pleasing, improving the user experience and avoiding the increase in nodes and complexity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116091685B_ABST
    Figure CN116091685B_ABST
Patent Text Reader

Abstract

The method for realizing the shadow function of the server decoration window based on wlroots comprises the following steps: preparing eight pictures for realizing the shadow function and placing the pictures under the root directory; converting the pictures into a shadow_element structure; converting the pictures into a buffer, calling the width, height, step and format data of the pictures from the buffer, and filling the data into the structure of the pictures; converting the structure into a corresponding texture; rendering a rect node, associating the texture of the pictures with the rect node according to the sequence; calculating the actual position of the shadow on the screen; cutting to form a cutting area; and rendering the texture to the cutting area to form the shadow function. The method fully utilizes the existing extended hidden area of the window, does not need to increase the buffer and the rect node, does not need to separately modify the shader and the backend function, ensures the code uniformity, and realizes the shadow function.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Wayland shadow functionality implementation optimization technology, specifically to a method for implementing shadow functionality in a server-side decorative window based on wlroots. Background Technology

[0002] Wayland is an open-source project designed to create a new display server architecture for Linux. Wayland aims to replace X, providing a simple, efficient, lightweight display server architecture that meets the requirements of modern desktops. A key feature of modern desktops is window composition. Wayland addresses this by using a compositor to communicate directly with applications and video hardware, forwarding events to them. In this process, the application renders graphics into its buffer, and then the compositor, or display server, composites these graphics and displays them on the screen (the application's window).

[0003] wlroots is an implementation of the Wayland framework synthesizer. wlroots provides independent implementations of many Wayland interfaces, primarily from wayland.xml and various protocol extensions, promoting standardization for portable extensions across many synthesizers.

[0004] wlroots provides powerful, standalone, and optional tools that implement many components common to synthesizers, such as output permutations in physical space.

[0005] Chinese Invention Patent (201510233251.9, A Method and Apparatus for Generating Shadow Effect Images) discloses a method and apparatus for generating shadow effect images. The method includes: receiving a user's shadow effect addition instruction and determining a target shadow effect; creating a new target canvas; creating a first copy of a target image on the new target canvas, wherein the offset parameter of any pixel coordinate in the first copy of the target image relative to the corresponding pixel coordinate in the target image is the same as the offset parameter of the target shadow effect, wherein the offset parameter includes: offset direction and offset distance; replacing the color parameters of each pixel in the first copy of the target image with the color parameters of the target shadow effect; creating a second copy of the target image at a position on the target canvas with the same coordinates as the target image, such that the second copy of the target image covers the first copy of the target image after the color parameter replacement, thereby generating the shadow effect image of the target image. Compared with the prior art, the shadow effect is more realistic.

[0006] Chinese Invention Patent (202010763065.7, Method and Apparatus for Generating Image Samples Based on Local Shadow Effects) discloses a method, apparatus, computer device, and storage medium for generating image samples based on local shadow effects. It relates to artificial intelligence technology and includes: calling a contrast and brightness adjustment algorithm to adjust the contrast and brightness of an input image to obtain corresponding dark and bright images; obtaining the original image size of the input image; initializing an initial blurred positive uniform lighting image based on the original image size; performing Gaussian blur on the initial image to obtain the current blurred positive uniform lighting image; applying Gaussian blur to the current blurred positive uniform lighting image to obtain a Gaussian-blurred image; and synthesizing the corresponding dark and bright images and the Gaussian-blurred image to obtain an image sample corresponding to the input image. This invention expands the image sample based on local shadow effects, reducing the difficulty of obtaining ID card image samples. Furthermore, the expanded image samples closely resemble samples taken in real-world scenes, solving the problem of small sample sizes.

[0007] Chinese Invention Patent (201110126820.1, A Method and System for Implementing Dynamic Two-Dimensional Subtitles with Shadows) discloses a method and system for implementing dynamic two-dimensional subtitles with shadows, mainly relating to the production and processing of subtitle effects in the field of broadcast television program production and broadcasting. The method includes: 1) collecting pixel information and shadow parameters within the subtitle window; 2) assigning values ​​to the shadow areas involved according to the shadow parameters; 3) establishing a correlation between the playback frame and the shadow area assignment; 4) rendering each frame according to the correlation based on the frame order. The system includes: a subtitle window information acquisition unit, a shadow parameter acquisition unit, a shadow area generation and correlation unit, and a rendering and assignment unit. The subtitle window information acquisition unit and the shadow parameter acquisition unit input parameters to the shadow area generation and correlation unit, and the shadow area generation and correlation unit outputs to the rendering and assignment unit for pixel rendering within the subtitle window. This invention dynamically obtains shadow deformation function parameters by using the basic size parameters of the original subtitle window and the basic size of the deformed subtitle window, thereby dynamically and linearly solving the problem of dynamic display of shadow effects. Through light trajectories, it provides more display effects of shadow lighting.

[0008] Currently, wlroots does not implement server-side shadow functionality for decorative windows. Other mainstream compositors offer two approaches: First, convert the image to a texture and then modify the shader, using a separate backend OpenGL function `smoothstep` or a custom function interface to achieve the gradient effect. Second, convert the image to a buffer and attach it to a buffer node during rendering to implement the shadow functionality. Currently, wlroots uses a unified backend for its rendering and compositing workflow. Using method 1 to implement shadow functionality, which involves separately modifying the shader and backend, is complex, difficult to handle in areas where the window's rectangle overlaps, resulting in unsatisfactory shadow effects, overlap, and hindering code management and scalability. Using method 2 would add eight buffer-type nodes. Currently, wlroots rendering is based on a tree and node architecture, already having a large number of nodes; adding eight more buffer nodes increases traversal complexity and makes event handling more difficult. The key challenge is how to implement shadow functionality without adding buffer nodes or modifying the shader and backend. Summary of the Invention

[0009] To address the shortcomings of existing technologies, this invention provides a method for implementing shadow functionality in a server-side decorative window based on wlroots, comprising the following steps:

[0010] Step S1: Prepare eight images to implement the shadow function and place these eight images in the root directory;

[0011] Step S2: Convert all eight images into shadow_element structures and initialize the relevant parameters in the structure;

[0012] Step S3: Retrieve the width, height, stride, and format data of each image from the image buffer, and fill these data into the shadow_element structure of each image respectively;

[0013] Step S4: Convert the shadow_element structure of the eight images into corresponding textures;

[0014] Step S5: Render the rect node and associate the textures of the eight images with the rect node in sequence;

[0015] Step S6: Calculate the actual position of the shadow on the screen;

[0016] Step S7: Cut out the actual position from step S6 to form the cutting area;

[0017] Step S8: Render the texture from step S4 onto the clipping area to create a shadow function.

[0018] In step S1, the eight prepared images correspond to the four sides and four rounded corners of the window for which the shadow function is to be implemented.

[0019] In step S2, the eight images are converted into shadow_element structures using the Cairo_image_surface_create_from_png function.

[0020] In step S3, the width, height, and format of the eight images are obtained using the following functions:

[0021] cairo_image_surface_get_width;

[0022] cairo_image_surface_get_height;

[0023] cairo_image_surface_get_format;

[0024] The step length is four times the width.

[0025] In step S4, the shadow_element structures of the eight images are converted into corresponding textures using the whr_texture_from_pixels function interface.

[0026] In step S5, the rect nodes belonging to the extended hidden area are determined by the predefined index parameter, and the correspondence between the rect nodes and the eight images in order is determined.

[0027] In step S6, the actual position of the shadow on the screen is calculated using an orthogonal matrix function.

[0028] In step S8, the texture is rendered onto the clipping area according to the repeat attribute to form a shadow function.

[0029] The present invention provides a method for implementing shadow functionality in a server-side decorative window based on wlroots. This method makes full use of the existing extended hidden area of ​​the window, without adding buffer and rect nodes, and without separately modifying the shader and backend functions, thus ensuring code consistency and implementing shadow functionality. Attached Figure Description

[0030] Figure 1 This is a schematic diagram of the overall logic of the present invention.

[0031] Figure 2 This is a flowchart illustrating the specific implementation of the present invention. Detailed Implementation

[0032] To gain a better understanding of the technical solution and beneficial effects of the present invention, the technical solution of the present invention and its beneficial effects are described in detail below with reference to the accompanying drawings.

[0033] The terms used in this invention are explained as follows:

[0034] Wayland: Wayland implements a library for communication between display servers and clients based on domain sockets, and defines an extensible communication protocol in XML format. This protocol is divided into the Wayland core protocol and extension protocols.

[0035] Wlroots: Wlroots is a framework for building Wayland compositors. It implements a wide variety of Wayland compositor functionalities and is currently the most mature Wayland compositor framework. It provides an abstraction backend for the underlying display and input hardware, including KMS / DRM, libinput, and Wayland. Extend_area: Extend_area is the window's extended area. This extended area is hidden and invisible, occupying 8 pixels wide. The window manager can adjust the width of this area.

[0036] To address the lack of shadow functionality in server-side decorative windows on wlroots, this invention discloses a method for implementing shadow functionality based on the Wayland compositor. This method leverages the existing graphics compositing workflow and window management of the Wayland compositor, effectively utilizing the window's own extended hidden area without adding nodes or modifying shaders or the backend, to convert images into textures and render them onto the extended hidden area.

[0037] Figure 1 Here is the overall logical flow diagram of this invention: When wlroots renders the window, it also renders the extended hidden area. The extended hidden area consists of 8 rect type nodes, which are right next to the edge of the window and are invisible. To implement the shadow function here, there is no need to add extra nodes. Using the 8 rect nodes, the 8 images are buffered through the function and then the corresponding textures are applied to the 8 rects in a clockwise order, which is the extended hidden area. This completes the implementation of the shadow function of the server-side decorative window.

[0038] Figure 2 This is a flowchart illustrating the specific implementation of the present invention, as follows: Figure 2As shown, the implementation process of the shadow function of the server-side decorative window based on wlroots in this invention is as follows:

[0039] Step 1: Prepare 8 images and place them in the root directory: 4 for the border (15x1 pixels and 1x15 pixels) and 4 for the rounded corners (15x15 pixels). These 8 images are the 8 small images needed to create the shadow effect. These 8 small images are converted into textures and then pasted onto the invisible, hidden areas of the window to create the shadow effect. A window without a shadow effect appears to the naked eye as consisting of 4 sides and 4 rounded corners. To implement a shadow effect, the window also needs 4 sides and 4 rounded corners. The top and bottom sides need 15x1 (15 pixels wide, 1 pixel high) images, the left and right sides need 1x15 (1 pixel wide, 15 pixels high) images, and the 4 rounded corners need 15x15 pixel images.

[0040] Step 2: Define the `shadow_element` structure based on `wlroots`. Convert all eight images into `shadow_element` structures. This structure contains parameters such as image format, RGBA data, image width, height, stride, texture, and render. Initialize the relevant parameters of the structure. Specifically, use the `Cairo_image_surface_create_from_png` function to convert all eight images into `shadow_element` structures. This function is provided by the Cario graphics library and is used to create a new image surface content from a given PNG file.

[0041] Step 3: Load the images using a function, converting the eight physical images into a buffer. The buffer contains the image's RGBA data, width, height, and other parameters. Extract the width, height, stride, and format data of the eight images from the buffer and fill these data into their respective `shadow_element` structures. Specifically, obtain the width, height, and format of each of the eight images using the following functions:

[0042] cairo_image_surface_get_width;

[0043] cairo_image_surface_get_height;

[0044] cairo_image_surface_get_format;

[0045] The step length is four times the width.

[0046] The above function interfaces are all APIs provided by the Cario graphics library.

[0047] Step 4: Obtain the textures. Use the whr_texture_from_pixels function interface to convert the shadow_element structure of the 8 images into the corresponding textures.

[0048] Step 5: When rendering rect type nodes using the `scene_node_render` function, associate the texture with the rect node. Before this step, the window manager pre-defines the `index` parameter to indicate which 8 rect nodes belong to the extended hidden area. Simultaneously, it determines the correspondence between the 8 rect nodes and the 8 images: `index` indicates the order, with a value from 0 to 7. In other words, there are 8 images; they are not randomly placed but need to be placed in a specific order to avoid situations where images on edges are placed on rounded corners. The window manager uses the `index` parameter to determine the placement order, i.e., which edge or corner the current image corresponds to.

[0049] Step 6: Calculate the actual position of the shadow on the screen using an orthogonal matrix function.

[0050] Step 7: Crop the area above to form a cropped area. Only the pixels in the cropped area can be modified.

[0051] Step 8: Rendering. Render the texture to the clipping area according to the repeat property to create a shadow effect.

[0052] The technical effects of this invention are as follows:

[0053] 1. The originality of the implementation method makes full use of the existing extended hidden area of ​​the window. Without adding buffer and rect nodes, there is no need to modify the shader and backend functions separately, which ensures code consistency and implements the shadow function.

[0054] 2. The effect is obvious. After adding the server-side decorative window shadow function, the window changes are more beautiful and the user experience is better.

[0055] Although the present invention has been described using the above preferred embodiments, it is not intended to limit the scope of protection of the present invention. Any changes and modifications made by those skilled in the art to the above embodiments without departing from the spirit and scope of the present invention shall still fall within the scope of protection of the present invention. Therefore, the scope of protection of the present invention shall be defined by the claims.

Claims

1. A method for implementing shadow functionality in a server-side decorative window based on wlroots, characterized in that, Includes the following steps: Step S1: Prepare eight images to implement the shadow function and place these eight images in the root directory; Step S2: Convert all eight images into shadow_element structures and initialize the relevant parameters in the structure; Step S3: Retrieve the width, height, stride, and format data of each image from the image buffer, and fill these data into the shadow_element structure of each image respectively; Step S4: Convert the shadow_element structure of the eight images into corresponding textures; Step S5: Render the rect node and associate the textures of the eight images with the rect node in sequence; Step S6: Calculate the actual position of the shadow on the screen; Step S7: Cut out the actual position from step S6 to form the cutting area; Step S8: Render the texture from step S4 onto the clipping area to create a shadow effect; In step S5, wlroots renders an extended hidden area when rendering the window. The extended hidden area consists of 8 invisible rect type nodes that are attached to the edge of the window. Using the 8 rect type nodes, 8 images are buffered through a function and then the corresponding textures are applied to these 8 rect type nodes in a clockwise order.

2. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S1, the eight prepared images correspond to the four sides and four rounded corners of the window for which the shadow function is to be implemented.

3. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S2, the Cairo_image_surface_create_from_png function converts all eight images into shadow_element structures.

4. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S3, the width, height, and format of the eight images are obtained using the following functions: cairo_image_surface_get_width; cairo_image_surface_get_height; cairo_image_surface_get_format; The step length is four times the width.

5. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S4, the shadow_element structures of the eight images are converted into corresponding textures through the whr_texture_from_pixels function interface.

6. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S5, the rect nodes belonging to the extended hidden area are determined by the predefined index parameter, and the correspondence between the rect nodes and the eight images in order is determined.

7. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S6, the actual position of the shadow on the screen is calculated using an orthogonal matrix function.

8. The method for implementing the shadow function of the server-side decorative window based on wlroots as described in claim 1, characterized in that, In step S8, the texture is rendered onto the clipping area according to the repeat attribute to form a shadow function.

Citation Information

Patent Citations

  • Shadow effect picture generating method and apparatus

    CN104851122A

  • Image Sample Generation Method and Apparatus Based on Local Shadow Effect

    CN111914934B

  • Method and system for realizing dynamic two-dimensional subtitle of shadow

    CN102739976A

  • Dynamic rendering of soft shadows for interface elements

    US9576393B1