Paintbrush drawing method and device, terminal equipment and storage medium

By marking the color layer and result layer as writable in the off-screen rendering buffer, and only reading local textures for blending calculations and brush stroke processing, the problem of drawing performance bottleneck on hardware devices is solved, achieving efficient, smooth and high-quality brush drawing effects.

CN121544770APending Publication Date: 2026-02-17SHENZHEN HONGHE INNOVATION INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511595765.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-31
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

On hardware devices with limited CPU computing power and low GPU performance, there is a performance bottleneck in achieving smooth and realistic electronic handwriting drawing. This leads to frequent data exchanges and complex calculations during the drawing process, resulting in significant rendering delays and affecting the user experience.

Method used

By marking the color layer and result layer as writable in the off-screen rendering buffer, only the historical and current area textures are read for color blending calculations, and then blended with predefined brush stroke textures to generate brush stroke effects, which are then directly written to the result layer and finally output to the screen.

Benefits of technology

Despite limited CPU computing power, this system achieves efficient brush drawing, reduces data processing and computational load, improves drawing response speed, ensures the continuity of brush color mixing and the texture of brush strokes, avoids color mixing deviations, and ensures drawing quality and smoothness.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121544770A_ABST
    Figure CN121544770A_ABST
Patent Text Reader

Abstract

The invention is applicable to the technical field of intelligent equipment, and provides a paintbrush drawing method and device, terminal equipment and a storage medium, the method comprises the following steps: when a drawing instruction is generated according to a touch point, marking a color layer and a result layer in an off-screen rendering buffer area as a writable state; reading a historical region texture corresponding to a historical touch point and a current region texture corresponding to a current touch point in the color layer; performing color mixing calculation on the texture of the historical region and the texture of the current region to obtain a mixing result, and writing the mixing result into the color layer; carrying out mixing processing on the mixing result and a predefined paintbrush stroke texture to generate a stroke effect, and writing the stroke effect into the result layer; and outputting the texture content of the result layer to a screen. According to the method, efficient paintbrush drawing can be realized on low-performance hardware equipment, and meanwhile, the paintbrush drawing quality is guaranteed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart device technology, and in particular to a drawing method, apparatus, terminal device and storage medium. Background Technology

[0002] On smart devices, achieving smooth and realistic electronic handwriting drawing has always been a key focus of technological development. Users expect brush tools to not only simulate rich color mixing effects, but also to display textured brushstrokes, such as the dry brush effect of a calligraphy brush or the grainy texture of a pencil.

[0003] However, achieving these high-quality rendering effects typically involves high computational complexity. On hardware devices with limited CPU computing power and low GPU performance, complex graphics rendering processes can easily become performance bottlenecks. Frequent data exchanges and complex calculations during the rendering process can lead to significant rendering delays, manifesting as stuttering and lag in the handwriting, severely impairing the user's drawing experience. Summary of the Invention

[0004] This application provides a pen drawing method, apparatus, terminal device, and storage medium, which can achieve efficient pen drawing even when the CPU computing power of the hardware device is limited, while ensuring the quality of pen drawing.

[0005] In a first aspect, embodiments of this application provide a pen drawing method, including: When drawing instructions are generated based on touch points, the color layer and result layer in the off-screen rendering buffer are marked as writable. Read the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer; A color blending calculation is performed on the historical region texture and the current region texture to obtain a blending result, and the blending result is written into the color layer; The blending result is blended with a predefined brush stroke texture to generate a brush stroke effect, and the brush stroke effect is written into the result layer; Output the texture content of the resulting layer to the screen.

[0006] In one possible implementation of the first aspect, the method further includes, prior to drawing: Generate the off-screen rendering buffer and set the off-screen rendering buffer as the current rendering target; A texture layer is created and attached to the off-screen rendering buffer. The texture layer includes a background layer, a color layer, and a result layer.

[0007] In one possible implementation of the first aspect, the method further includes the following initialization step: The background layer and the result layer are marked as writable, and the color layer is marked as non-writable. Perform a background drawing operation, writing the background content to both the background layer and the result layer simultaneously, thus completing the background initialization.

[0008] In one possible implementation of the first aspect, the creation and attachment of the texture layer on the off-screen rendering buffer further includes a brush stroke layer; In the initialization step, the pen stroke layer is marked as non-writable; When drawing instructions are generated based on touch points, the pen touch layer is marked as writable. The brushstroke effect is written into the result layer at the same time as the brushstroke layer.

[0009] In one possible implementation of the first aspect, while marking the color layer and the result layer as writable, the background layer in the off-screen rendering buffer is marked as non-writable.

[0010] In one possible implementation of the first aspect, reading the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer includes: Based on the touch point trajectory, the area corresponding to the brush width range of the previous touch point is extracted from the color layer as the historical area texture; Extract the region corresponding to the current touch point's brush width range from the color layer as the current region texture; The step of performing color blending calculations on the historical region texture and the current region texture to obtain the blending result includes: The historical region texture and the current region texture are passed to the fragment shader for color blending calculation to obtain the blending result.

[0011] In one possible implementation of the first aspect, the process of blending the blending result with a predefined brush stroke texture to generate a brush stroke effect includes: The fragment shader performs a multiply operation on the color values ​​in the blending result and the corresponding pixel values ​​of the predefined brush stroke texture to generate a brush stroke effect with the blended brush color.

[0012] Secondly, embodiments of this application provide a pen drawing device, comprising: The drawing processing unit is configured to: mark the color layer and result layer in the off-screen rendering buffer as writable when a drawing instruction is generated based on the touch point; read the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer; perform color mixing calculations on the historical region texture and the current region texture to obtain a mixing result, and write the mixing result into the color layer; and perform mixing processing on the mixing result with a predefined brush stroke texture to generate a brush stroke effect, and write the brush stroke effect into the result layer. The drawing output unit is used to output the texture content of the result layer to the screen.

[0013] Thirdly, embodiments of this application provide a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the pen drawing method as described in the first aspect above.

[0014] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the pen drawing method as described in the first aspect above.

[0015] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the terminal device to execute the pen drawing method described in the first aspect above.

[0016] In this embodiment, when generating drawing instructions based on touch points, marking the color layer and result layer in the off-screen rendering buffer as writable effectively restricts read / write operations on redundant layers that do not require modification, reducing resource consumption and data interaction overhead. Instead of processing the entire screen texture, the mixing result is obtained by reading only the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer and performing color mixing calculations, significantly reducing data processing volume and computational load, thereby improving drawing response speed. Simultaneously, the mixing result is written back to the color layer in real time, ensuring the continuity of brush color mixing through precise mixing of historical and current region textures. To ensure accuracy and avoid color mixing deviations affecting drawing quality, the mixed result is then blended with predefined brush stroke textures to generate textured brush stroke effects, which are directly written into the result layer. This ensures brush stroke consistency and clarity while eliminating subsequent additional compositing steps, enabling simultaneous color mixing updates and final image construction in a single process, further reducing computational power consumption. Finally, the texture content of the result layer is directly output to the screen, avoiding complex operations such as multiple rendering passes or multiple texture overlays. This reduces hardware operating pressure while ensuring real-time rendering of the drawing effect, thus enabling efficient brush drawing even when hardware CPU computing power is limited, while effectively guaranteeing brush drawing quality. Attached Figure Description

[0017] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0018] Figure 1 This is a flowchart illustrating the implementation of the brush drawing method provided in this application embodiment; Figure 2 This is a flowchart illustrating a specific implementation of the brush drawing method provided in this application, which involves creating and attaching a texture layer. Figure 3 This is a flowchart illustrating a specific implementation of the initialization process in the pen drawing method provided in this application embodiment; Figure 4 This is a flowchart illustrating a specific implementation of color mixing in the brush drawing method provided in this application embodiment; Figure 5 This is a structural block diagram of the pen drawing device provided in the embodiments of this application; Figure 6 This is a schematic diagram of the terminal device provided in the embodiments of this application. Detailed Implementation

[0019] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0020] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0021] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0022] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0023] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0024] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0025] By way of example and not limitation, the pen drawing method provided in this application is applicable to various types of terminal devices that need to perform pen drawing. Specific terminal devices may include mobile phones, tablets, wearable devices, laptops, ultra-mobile personal computers (UMPCs), desktop computers, interactive large screens, and servers, etc. This application does not impose any restrictions on the specific type of terminal device.

[0026] Figure 1 The implementation flow of the brush drawing method provided in this application embodiment is illustrated. The method flow includes steps S101 to S105. The specific implementation principle of each step is as follows: Step S101: When generating drawing instructions based on touch points, mark the color layer and result layer in the off-screen rendering buffer as writable.

[0027] When a user's finger or stylus touches or moves on the screen, the operating system generates a series of touch points. Based on these touch points, the operating system or application generates a specific drawing instruction at the graphics API (such as OpenGL) level, which the GPU can execute. This drawing instruction contains information such as the coordinates and pressure of the current touch point. This drawing instruction marks the start of the drawing process. For example, when a user draws a line with their finger on a tablet, the screen samples a series of touch points at a preset frequency. Each new touch point triggers the execution of this method, thus achieving real-time drawing of the handwriting.

[0028] The off-screen render buffer, also known as the off-screen frame buffer (FBO), is a hardware resource used to temporarily store rendering data outside the screen, handling content that is not directly rendered on the screen. The off-screen render buffer is an invisible drawing area; it is not directly displayed on the screen but serves as an intermediate workspace, allowing developers to output multi-step drawing results to a custom texture instead of directly to the screen, thus avoiding screen flickering caused by drawing directly in the screen buffer.

[0029] The color layer and the result layer are two core texture layers managed in the off-screen rendering buffer.

[0030] When drawing instructions are generated based on touch points, the writable state of the color layer and the result layer is configured by activating the color attachment corresponding to the off-screen framebuffer object. By configuring the writable state, the graphics processor (GPU) is notified that only texture layers marked as writable can receive and store pixel data calculated by the fragment shader.

[0031] In this embodiment, by precisely activating the color layer and result layer required for the current drawing, the rendering target is precisely controlled, eliminating the unavoidable frame buffer switching overhead and redundant compositing calculations in traditional multi-channel rendering from the source. This avoids any potential write operations to layers unrelated to the current drawing, and the GPU does not need to allocate computing resources and memory bandwidth for unrelated layers, reducing the data management overhead and memory bandwidth usage within the GPU. This provides the most fundamental guarantee for achieving high-response brush drawing on low-performance devices or when the CPU computing power of the hardware device is limited.

[0032] As one possible implementation of this application Figure 2 The following is a detailed implementation flow of creating and attaching a texture layer in the brush drawing method provided in this application embodiment: A1: Generate the off-screen rendering buffer and set it as the current rendering target. In one possible implementation, the off-screen rendering buffer is generated by creating and binding an off-screen framebuffer object. This object is a container that can have multiple textures or rendering buffer objects attached to it.

[0033] By generating the off-screen rendering buffer, separate from the default screen buffer used for direct display, the rendering process avoids directly occupying screen buffer resources. By setting the off-screen rendering buffer as the current rendering target, the GPU is instructed to send all drawing commands to the off-screen rendering buffer instead of the default screen buffer from this moment until the rendering target is switched.

[0034] One possible implementation is to create an FBO using glGenFramebuffers and bind the FBO to the current rendering target using glBindFramebuffer, thus informing the GPU that all subsequent rendering operations (such as texture drawing and color blending) should be performed on this off-screen rendering buffer, rather than other buffers.

[0035] A2: Create and attach a texture layer on the off-screen rendering buffer, the texture layer including a background layer, a color layer and a result layer.

[0036] The texture layer is the image carrier that carries the specific drawing content. Among them, the background layer is used to store the basic background content of the brush drawing; the color layer is used to store and update the color strokes of the brush (without brush stroke effects). It is a readable and writable texture layer that not only preserves the colors of historical strokes but also writes the newly mixed colors; the result layer is used to store the final image to be output to the screen. It is the result of the combination of background, color strokes, and brush stroke effects.

[0037] In one possible implementation, textures are attached to color attachments in an off-screen rendering buffer via a graphics API. Different texture layers are associated with different color attachments in the same off-screen rendering buffer, allowing each texture layer to be stored independently and called collaboratively within the same buffer.

[0038] For example, the background layer, color layer, and result layer are associated with three different color attachments of the off-screen framebuffer object using glFramebufferTexture2D. The background layer is attached to the first color attachment (e.g., GL_COLOR_ATTACHMENT0) to store the static background; the color layer is attached to the second color attachment (e.g., GL_COLOR_ATTACHMENT1) as the working canvas for dynamic color mixing; and the result layer is attached to the third color attachment (e.g., GL_COLOR_ATTACHMENT2) as the compositing area for the final image.

[0039] When multiple off-screen rendering buffers correspond to different texture layers, the off-screen rendering buffers need to be switched repeatedly, which can easily generate a lot of transmission overhead and cause GPU pauses. For example, if the background layer and color layer belong to different off-screen rendering buffers, the background layer texture needs to be copied to the color layer buffer during drawing to achieve the initial synthesis of the background and handwriting. This process generates a lot of data transmission overhead. In the embodiments of this application, all necessary texture layers are attached in a single off-screen rendering buffer. Multiple texture layers are managed in the same off-screen rendering buffer. During subsequent drawing, each texture layer can be called directly in a single off-screen rendering buffer without copying data across buffers. This greatly reduces the time spent on data interaction between the CPU and GPU of the hardware device and avoids generating a lot of transmission overhead that could cause GPU pauses.

[0040] As one possible implementation of this application Figure 3 This application illustrates a specific implementation flow of the initialization process in the pen drawing method provided in this embodiment, detailed below: B1: Mark the background layer and the result layer as writable, and mark the color layer as non-writable.

[0041] In one possible implementation, glDrawBuffers is used to activate the color attachments corresponding to the background layer and the result layer, respectively. Marking the color layer as non-writable disables the corresponding color attachments. Enabling or disabling the color attachments corresponding to the texture layer controls whether the texture layer's write access is enabled or disabled. Marking the background layer and the result layer as writable means that subsequent drawing operations can modify both texture layers simultaneously, while marking the color layer as non-writable restricts the GPU from writing to that texture layer.

[0042] During the initialization phase, only the write permissions of the two necessary texture layers are activated. This reduces the GPU's state detection and resource allocation for unused layers, thereby reducing the GPU's idle power consumption and data processing redundancy. Disabling the write permissions of the color layers prevents data from being accidentally written to the color layers during background drawing and avoids the need to clean up residual background data before subsequent color mixing.

[0043] B2: Perform background drawing operation, write the background content to both the background layer and the result layer simultaneously, and complete the background initialization.

[0044] Background drawing operations generate texture data from the background content using rendering instructions (such as drawing a full-screen quadrilateral), and write the corresponding color attachments to the background layer and the result layer in parallel. A single background drawing operation generates background backup data for the background layer and initial display data for the result layer.

[0045] In this embodiment, the independence of each texture layer is ensured by controlling the write permissions of the texture layer, while the parallel writing of the background layer and the result layer can reduce the number of operation steps. By performing a single operation, the background layer and the result layer can have the same background content, thus completing the background initialization. This avoids the need for two calls and two full-screen renderings required to draw the background layer and the result layer separately, reducing the CPU instruction overhead and the GPU drawing load, and improving the efficiency of background initialization. At the same time, the backup data stored in the background layer can also provide a basis for recovery if the result layer is abnormal, ensuring the stability of the drawing.

[0046] As one possible implementation of this application, while marking the color layer and the result layer as writable, the background layer in the off-screen rendering buffer is marked as non-writable. By actively disabling the write permission of the background layer, it is ensured that the background layer, which serves as the drawing base, remains unchanged after initialization. The GPU does not need to allocate cache resources and memory bandwidth required for writing to the background layer, thus ensuring stable and reliable drawing effects.

[0047] As one possible implementation of this application, the texture layer created and attached on the off-screen rendering buffer also includes a brush stroke layer; in the initialization step, the brush stroke layer is marked as non-writable; when drawing instructions are generated based on touch points, the brush stroke layer is marked as writable; while the brush stroke effect is written to the result layer, the brush stroke effect is also written to the brush stroke layer.

[0048] In this embodiment, while creating the background layer, color layer, and result layer, a fourth texture layer—the brushstroke layer—is additionally created and attached to the off-screen rendering buffer. This brushstroke layer carries color-mixed brushstroke textures with brushstroke effects. The brushstroke layer shares the same off-screen rendering buffer with the background layer, color layer, and result layer, forming a four-layer texture plus single FBO management architecture. During background initialization, write permissions for the brushstroke layer are disabled simultaneously with those for the color layer. This ensures that the brushstroke layer is not accidentally written to by background drawing data during the background initialization phase, maintaining the purity of the brushstroke layer's initial state.

[0049] For example, the stroke layer can be associated with a color attachment of an off-screen framebuffer object via glFramebufferTexture2D. For instance, the stroke layer can be attached to a fourth color attachment (such as GL_COLOR_ATTACHMENT3) as a storage area for a stroke effect texture with color blending.

[0050] In this embodiment of the application, by incorporating the pen stroke layer into a single FBO for unified management, subsequent pen stroke-related operations do not need to switch rendering targets and can be completed directly in the current off-screen rendering buffer, which can significantly reduce the probability of GPU pipeline pauses on low-performance devices (such as low-end Android tablets).

[0051] Step S102: Read the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer.

[0052] Historical touch points are the last touch positions that triggered drawing (such as the previous pen tip landing point during handwriting), while current touch points are the current touch positions that triggered drawing (such as the current pen tip landing point). Reading historical and current area textures essentially extracts local textures from the color attachments corresponding to the color layer in the off-screen rendering buffer, rather than the entire screen texture. If the entire screen texture of the color layer were read, low-performance devices (such as low-end tablets) would need to load a large amount of irrelevant texture data (such as blank areas where no handwriting is drawn), leading to increased memory usage and data transmission latency. By only reading historical and current area textures, the memory load and data transmission pressure on low-performance devices can be significantly reduced, reducing subsequent computational complexity and effectively avoiding drawing stutters caused by excessive computation on low-performance devices.

[0053] Step S103: Perform color mixing calculations on the historical region texture and the current region texture to obtain a mixing result, and write the mixing result into the color layer.

[0054] Color blending calculation utilizes a predefined blending algorithm to perform parallel pixel processing on historical and current region textures. This predefined blending algorithm simulates the blending effect of real pigments, and then writes the blending result into the corresponding color attachment of the color layer to achieve brush color blending drawing.

[0055] In one possible implementation, linear or non-linear interpolation is performed between the historical color of the historical region texture and the current color of the current region texture based on the pressure or transparency of the current brush stroke to obtain a blending result. This blending result is the final color that merges the historical brush stroke color and the current brush stroke color. The blending result is written to the position corresponding to the current region texture in the color layer, and the drawing color is updated in real time.

[0056] As one possible implementation of this application Figure 4 A specific implementation flow of color mixing in the brush drawing method provided in this application embodiment is shown below: C1: Based on the touch point trajectory, extract the area corresponding to the brush width range of the previous touch point from the color layer as the historical area texture.

[0057] C2: Extract the region corresponding to the current touch point's brush width range from the color layer as the current region texture.

[0058] The historical area texture and the current area texture are not full-screen textures of the color layer, but local textures. Only the local texture around the touch point that is adapted to the pen width is extracted as the area texture. For example, when the pen width is 2mm, only the texture within a 1mm radius of the center of the previous touch point is read as the historical area texture, and the texture within a 1mm radius of the center of the current touch point is read as the current area texture, instead of reading the entire color layer, to avoid redundant data occupying resources. C3: Pass the historical region texture and the current region texture into the fragment shader for color blending calculation to obtain the blending result.

[0059] Fragment shaders are the core units in GPUs responsible for pixel-level processing and are adept at parallel computing. In this embodiment, historical region textures and current region textures are passed to the fragment shader as Uniform parameters for mixed calculation, and pixel-level overlay calculation based on RGBA color channels can be used.

[0060] By leveraging the parallel computing capabilities of GPU fragment shaders, pixel-level blending can be completed quickly, avoiding computational latency caused by CPU processing.

[0061] In this embodiment, reading local textures reduces the hardware load on low-performance devices, while using fragment shaders to perform color mixing calculations improves color mixing efficiency and ensures color mixing quality. This helps to achieve efficient and high-quality brush drawing on low-performance hardware platforms or when the CPU computing power of hardware devices is limited.

[0062] Step S104: Blend the blending result with a predefined brush stroke texture to generate a brush stroke effect, and write the brush stroke effect into the result layer.

[0063] The blending result includes color data without brushstroke effects, obtained by mixing historical region textures with current region texture colors. Predefined brushstroke textures are textures with specific brushstroke styles stored in the system beforehand, such as pencil grain textures, brush smudging textures, and marker gradient textures. This color data is blended with the predefined brushstroke textures, fusing the color information of the blending result with the effect information of the brushstroke texture at the pixel level to generate a brushstroke effect. This brushstroke effect includes color blending continuity and possesses the stylistic characteristics of the predefined brushstrokes. This brushstroke effect is then written to the corresponding color attachment in the result layer, ensuring that the result layer is synchronized in real-time with the latest complete data for the background, color blending, and brushstrokes.

[0064] This application embodiment obtains the brush stroke effect by mixing the blending result with a predefined brush stroke texture, and directly writes the brush stroke effect into the result layer, thereby integrating brush stroke generation and image composition. Each frame of drawing achieves the highest visual fidelity with minimal computational cost, ensuring smooth and high-quality brush drawing on low-performance devices.

[0065] As one possible implementation of this application, a fragment shader performs a multiply operation on the color values ​​in the blending result and the corresponding pixel values ​​of the predefined brush stroke texture to generate a brush stroke effect with the blended brush color. The multiply operation is a pixel-based blending algorithm that does not change the blended color while clearly presenting the brush stroke characteristics, effectively avoiding the problem of brush stroke effects overriding the blended color. The multiply operation can be replaced with other blending algorithms as needed, such as overlay algorithms, soft light algorithms, and color filtering algorithms.

[0066] Step S105: Output the texture content of the result layer to the screen.

[0067] In this embodiment, the current rendering target is switched from the off-screen rendering buffer to the default screen buffer to avoid the drawn content still being written to the off-screen rendering buffer, resulting in no display on the screen. Since the result layer has integrated all the drawn content, there is no need to composite other layers; the complete texture data of the result layer can be directly transferred to the default screen buffer.

[0068] As can be seen from the above, in this embodiment, when generating drawing instructions based on touch points, marking the color layer and result layer in the off-screen rendering buffer as writable effectively restricts read and write operations on redundant layers that do not require modification, reducing resource consumption and data interaction overhead. By only reading the historical area texture corresponding to the historical touch point and the current area texture corresponding to the current touch point in the color layer and performing color mixing calculations to obtain the mixing result, instead of processing the entire screen texture, the amount of data processing and computational load are greatly reduced, thereby improving the drawing response speed. At the same time, the mixing result is written back to the color layer in real time, and the accurate mixing of the historical area texture and the current area texture ensures the color mixing of the brush. Continuity and accuracy are ensured to avoid color mixing deviations affecting the drawing quality. The mixed result is then blended with predefined brush stroke textures to generate textured brush stroke effects, which are directly written into the result layer. While ensuring brush stroke consistency and clarity, this eliminates the need for additional subsequent compositing steps, enabling simultaneous color mixing updates and final image construction in a single process, further reducing computational power consumption. Finally, the texture content of the result layer is directly output to the screen, avoiding complex operations such as multiple rendering passes or multiple texture overlays. This reduces the hardware's operating pressure while ensuring real-time rendering of the drawing effect. Thus, even with limited hardware CPU computing power, efficient brush drawing can still be achieved, while effectively guaranteeing the quality of brush drawing.

[0069] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0070] Corresponding to the brush drawing method described in the above embodiments, Figure 5 A structural block diagram of the pen drawing device provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0071] Reference Figure 5 The drawing device includes: a drawing processing unit 51 and a drawing output unit 52, wherein: The drawing processing unit 51 is configured to, when generating a drawing instruction based on a touch point, mark the color layer and the result layer in the off-screen rendering buffer as writable; read the historical region texture corresponding to the historical touch point and the current region texture corresponding to the current touch point in the color layer; perform color mixing calculations on the historical region texture and the current region texture to obtain a mixing result, and write the mixing result into the color layer; and perform mixing processing on the mixing result with a predefined brush stroke texture to generate a brush stroke effect, and write the brush stroke effect into the result layer. The drawing output unit 52 is used to output the texture content of the result layer to the screen.

[0072] As one possible implementation of this application, the drawing device further includes: The generation and creation unit is used to generate an off-screen rendering buffer and set the off-screen rendering buffer as the current rendering target; a texture layer is created and attached to the off-screen rendering buffer, which includes a background layer, a color layer and a result layer.

[0073] As one possible implementation of this application, the drawing device further includes: The initialization unit is used to mark the background layer and the result layer as writable and the color layer as non-writable; it performs the background drawing operation, writing the background content to both the background layer and the result layer simultaneously, thus completing the background initialization.

[0074] As one possible implementation of this application, the texture layer created and attached on the off-screen rendering buffer also includes a brush stroke layer; During the initialization process, the pen stroke layer is marked as non-writable; When drawing instructions are generated based on touch points, the pen touch layer is marked as writable. Write the brush stroke effect to the result layer at the same time as writing the brush stroke effect to the brush stroke layer.

[0075] As one possible implementation of this application, while marking the color layer and the result layer as writable, the background layer in the off-screen rendering buffer is marked as non-writable.

[0076] As one possible implementation of this application, the drawing processing unit 51 is specifically used for: Based on the touch point trajectory, the area corresponding to the brush width range of the previous touch point is extracted from the color layer as the historical area texture; Extract the area corresponding to the current touch point's brush width range from the color layer and use it as the current area texture; The historical region texture and the current region texture are passed to the fragment shader for color blending calculation to obtain the blending result.

[0077] As one possible implementation of this application, the drawing processing unit 51 is further specifically used for: The blending result is then blended with a predefined brush stroke texture to generate brush stroke effects, including: The fragment shader performs a multiply operation on the color values ​​in the blending result and the corresponding pixel values ​​of the predefined brush stroke texture to generate a brush stroke effect with the blended brush color.

[0078] As can be seen from the above, in this embodiment, when generating drawing instructions based on touch points, marking the color layer and result layer in the off-screen rendering buffer as writable effectively restricts read and write operations on redundant layers that do not require modification, reducing resource consumption and data interaction overhead. By only reading the historical area texture corresponding to the historical touch point and the current area texture corresponding to the current touch point in the color layer and performing color mixing calculations to obtain the mixing result, instead of processing the entire screen texture, the amount of data processing and computational load are greatly reduced, thereby improving the drawing response speed. At the same time, the mixing result is written back to the color layer in real time, and the accurate mixing of the historical area texture and the current area texture ensures the color mixing of the brush. Continuity and accuracy are ensured to avoid color mixing deviations affecting the drawing quality. The mixed result is then blended with predefined brush stroke textures to generate textured brush stroke effects, which are directly written into the result layer. While ensuring brush stroke consistency and clarity, this eliminates the need for additional subsequent compositing steps, enabling simultaneous color mixing updates and final image construction in a single process, further reducing computational power consumption. Finally, the texture content of the result layer is directly output to the screen, avoiding complex operations such as multiple rendering passes or multiple texture overlays. This reduces the hardware's operating pressure while ensuring real-time rendering of the drawing effect. Thus, even with limited hardware CPU computing power, efficient brush drawing can still be achieved, while effectively guaranteeing the quality of brush drawing.

[0079] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0080] This application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements... Figures 1 to 4 The steps of any brush drawing method are represented.

[0081] This application embodiment also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements... Figures 1 to 4 The steps of any brush drawing method are represented.

[0082] This application also provides a computer program product that, when run on a terminal device, causes the terminal device to execute the implementation of... Figures 1 to 4 The steps of any brush drawing method are represented.

[0083] Figure 6 This is a schematic diagram of a terminal device provided in one embodiment of this application. Figure 6As shown, the terminal device 6 in this embodiment includes: a processor 60, a memory 61, and a computer program 62 stored in the memory 61 and executable on the processor 60. When the processor 60 executes the computer program 62, it implements the steps in the various pen drawing method embodiments described above, for example... Figure 1 Steps S101 to S105 are shown. Alternatively, when the processor 60 executes the computer program 62, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 5 The functions of units 51 and 52 shown.

[0084] For example, the computer program 62 may be divided into one or more modules / units, which are stored in the memory 61 and executed by the processor 60 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer program 62 in the terminal device 6.

[0085] The terminal device 6 may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will understand that... Figure 6 This is merely an example of terminal device 6 and does not constitute a limitation on terminal device 6. It may include more or fewer components than shown, or combine certain components, or different components. For example, terminal device 6 may also include input / output devices, network access devices, buses, etc.

[0086] The processor 60 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0087] The memory 61 can be an internal storage unit of the terminal device 6, such as a hard disk or memory of the terminal device 6. The memory 61 can also be an external storage device of the terminal device 6, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 6. Furthermore, the memory 61 can include both internal and external storage units of the terminal device 6. The memory 61 is used to store the computer program and other programs and data required by the terminal device. The memory 61 can also be used to temporarily store data that has been output or will be output.

[0088] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0089] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0090] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0091] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0092] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A brush rendering method, characterized by, comprises: marking a color layer and a result layer in an off-screen rendering buffer as writable when a drawing instruction is generated according to a touch point; reading a historical region texture corresponding to a historical touch point and a current region texture corresponding to a current touch point in the color layer; performing color blending calculation on the historical region texture and the current region texture to obtain a blending result, and writing the blending result into the color layer; mixing the blending result with a predefined brush stroke texture to generate a stroke effect, and writing the stroke effect into the result layer; outputting texture content of the result layer to a screen.

2. The method of claim 1, wherein, Before drawing, the method further comprises: generating the off-screen rendering buffer and setting the off-screen rendering buffer as a current rendering target; creating and attaching texture layers on the off-screen rendering buffer, the texture layers comprising a background layer, a color layer, and a result layer.

3. The method of claim 2, wherein, The method further comprises the following initialization steps: marking the background layer and the result layer as writable, and marking the color layer as unwritable; performing a background drawing operation to write background content into the background layer and the result layer simultaneously, and completing background initialization.

4. The method of claim 3, wherein, The texture layers created and attached on the off-screen rendering buffer further comprise a stroke layer; in the initialization step, marking the stroke layer as unwritable; marking the stroke layer as writable when a drawing instruction is generated according to a touch point; writing the stroke effect into the result layer while writing the stroke effect into the stroke layer.

5. The method of claim 1, wherein, Marking the background layer in the off-screen rendering buffer as unwritable while marking the color layer and the result layer as writable.

6. The method according to any one of claims 1 to 5, characterized in that, The reading of the historical region texture corresponding to a historical touch point and the current region texture corresponding to a current touch point in the color layer comprises: according to a touch point trajectory, cutting a region corresponding to a brush width range of a previous touch point from the color layer as the historical region texture; cutting a region corresponding to a brush width range of a current touch point from the color layer as the current region texture; The color blending calculation on the historical region texture and the current region texture to obtain a blending result comprises: inputting the historical region texture and the current region texture into a fragment shader for color blending calculation to obtain a blending result.

7. The method according to any one of claims 1 to 5, characterized in that, The mixing of the blending result with a predefined brush stroke texture to generate a stroke effect comprises: performing a positive superimposition operation on color values in the blending result and corresponding pixel values of the predefined brush stroke texture through a fragment shader to generate a stroke effect with mixed color brush colors.

8. A brush drawing device, characterized by comprises: a drawing processing unit, configured to mark a color layer and a result layer in an off-screen rendering buffer as writable when a drawing instruction is generated according to a touch point; reading a historical region texture corresponding to a historical touch point and a current region texture corresponding to a current touch point in the color layer; performing color blending calculation on the historical region texture and the current region texture to obtain a blending result, and writing the blending result into the color layer; mixing the mixing result with a predefined brush stroke texture to generate a stroke effect, and writing the stroke effect into the result layer; a drawing output unit, configured to output texture content of the result layer to a screen.

9. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The processor implements the brush drawing method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, the computer program comprising instructions that, when executed by a computer, cause the computer to perform the method of any one of claims 1 to 9. The computer program, when executed by a processor, implements the brush drawing method according to any one of claims 1 to 7.