Drawing method, electronic device and related apparatus

By dividing the drawing area into blocks and storing the texture data associated with the handwriting, the problems of large memory consumption and incomplete undoing in the existing technology are solved, realizing efficient handwriting undo and redo, and improving drawing efficiency and user experience.

WO2025189987A9PCT designated stage Publication Date: 2025-11-27HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/076053
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-03-13
Filing Date
2025-02-06
Publication Date
2025-11-27

AI Technical Summary

Technical Problem

In the existing technology, electronic devices need to save the content of the drawing area after each drawing operation, resulting in excessive memory usage, and the overwritten strokes cannot be effectively recovered when the operation is undone.

Method used

The texture segmentation method is adopted to divide the drawing area into multiple sub-regions, save only the texture data of the sub-regions associated with the handwriting, and restore the texture data of the sub-regions to their original state when the undo operation is performed, thereby reducing memory usage and ensuring the integrity of handwriting undo.

Benefits of technology

By saving the texture data of the sub-regions associated with the handwriting, memory usage is reduced, and handwriting can be effectively undone and restored, improving drawing efficiency and user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025076053_27112025_PF_FP_ABST
    Figure CN2025076053_27112025_PF_FP_ABST
Patent Text Reader

Abstract

The present application provides a drawing method, an electronic device and a related apparatus. In the method, when a user draws an ink stroke in a drawing area, an electronic device can save texture data of a sub-area associated with the ink stroke instead of saving texture data of the whole drawing area, thereby reducing the memory occupation. In addition, when saving the texture data of said sub-area, the electronic device can save the texture data of said sub-area in the drawing area before drawing the ink stroke, so that when the user triggers to undo the ink stroke, the electronic device can undo the ink stroke on the basis of the texture data of said sub-area in the drawing area before drawing the ink stroke.
Need to check novelty before this filing date? Find Prior Art

Description

Drawing method, electronic device and related apparatus

[0001] This application claims priority from the Chinese patent application No. 202410291161.4 filed on March 13, 2024, and entitled "Drawing method, electronic device and related apparatus", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD

[0002] Embodiments of the present application relate to the technical field of terminal, and in particular, to a drawing method, an electronic device and related apparatus. BACKGROUND

[0003] In a drawing application (APP), a user can draw strokes in a drawing area, and the content drawn by the user can include, but is not limited to, text, patterns, etc. When a drawing error occurs, the user can perform a undo operation to undo the strokes this time, and the drawing area can display the content drawn last time.

[0004] At present, the electronic device can save the content in the drawing area each time the user performs a drawing. When the user performs a undo operation, the electronic device can find the content saved last time and display the content in the drawing area. However, in this solution, the electronic device needs to save the content in the drawing area after each drawing of the user, which occupies a large amount of memory. SUMMARY

[0005] Embodiments of the present application provide a drawing method, an electronic device and related apparatus, which can save the texture data of the sub-area associated with the strokes, thereby reducing the memory occupation.

[0006] In a first aspect, embodiments of the present application provide a drawing method, and the execution subject of the drawing method can be an electronic device or a chip, a processor, etc. in the electronic device, and the following description takes the electronic device as an example.

[0007] The user performs a first drawing operation in a drawing area, and in response to the first drawing operation, the electronic device displays first strokes corresponding to the first drawing operation in the drawing area. The electronic device can save first texture data and information of the first strokes. It should be understood that in embodiments of the present application, the electronic device can divide the drawing area into a plurality of sub-areas by using a texture blocking method. The first texture data includes texture data of a first sub-area in a first work state. The first work state is the state of the work in the drawing area before the first strokes are displayed. The first sub-area is a sub-area associated with the first strokes in the drawing area. The first sub-area associated with the first strokes can be understood as a sub-area containing the first strokes in the drawing area. In some examples, the information of the first strokes can include an identifier of the first sub-area, coordinates of a plurality of track points in the first strokes, and attributes of the first strokes, etc.

[0008] The user performs a second drawing operation in the drawing area, and in response to the second drawing operation, the electronic device displays a second stroke corresponding to the second drawing operation in the drawing area. In addition, the electronic device can add second texture data to the first texture data, and save information of the second stroke. The second texture data includes texture data of a second sub-area in the first work state. The second sub-area is a sub-area associated with the second stroke in the drawing area. In some examples, the information of the second stroke can include an identifier of the second sub-area, coordinates of multiple track points in the second stroke, and attributes of the second stroke, and the like.

[0009] The user can perform a cancel operation to cancel the second stroke. In the embodiments of the present application, in response to the cancel instruction, the electronic device can restore the texture data of the second sub-area to the drawing area, so that the drawing area does not display the second stroke. In the embodiments of the present application, because the first work state does not contain the second stroke, the electronic device restores the texture data of the second sub-area in the first work state to the drawing area, and the second sub-area can display the stroke in the first work state, that is, the drawing area does not display the second stroke. In this way, the electronic device can achieve the purpose of canceling the second stroke.

[0010] In the embodiments of the present application, when saving the texture data or adding the texture data, the electronic device does not save the texture data of the entire drawing area, but saves the texture data of the sub-area associated with the stroke. Compared with saving the texture data of all sub-areas of the drawing area, the memory occupied by the texture data can be reduced. In addition, when saving the texture data of the stroke, the electronic device can save the texture data of the previous work state of the stroke, so that when the user triggers the cancel operation of the stroke, the electronic device can cancel the stroke based on the texture data of the previous work state of the stroke.

[0011] In a possible implementation, the electronic device can save the texture data every few strokes, rather than saving the texture data every time the user draws a stroke, which can reduce the memory occupation. In this implementation, in response to the second drawing operation or after displaying the second stroke in the drawing area, the electronic device can detect whether the number of strokes whose information has been saved, starting from the information of the first stroke, reaches a first threshold, that is, whether the electronic device has drawn the first threshold number of strokes. The electronic device detects whether the number of strokes whose information has been saved reaches the first threshold, and the first stroke is included. When the electronic device determines that the number of strokes whose information has been saved, starting from the information of the first stroke, does not reach the first threshold, the electronic device can update the first texture data, that is, the electronic device adds the second texture data to the first texture data, and saves the information of the second stroke.

[0012] In a possible implementation, the second handwriting covers part of the first handwriting (or all of the first handwriting), so that there is an overlapping sub-region between the first sub-region and the second sub-region. In some examples, the sub-region overlapping between the first sub-region and the second sub-region can be referred to as a third sub-region. In this implementation, when the electronic device adds the second texture data on the basis of the first texture data, the second texture data can include: texture data of the sub-region of the second sub-region other than the third sub-region in the first work state. That is, in the case where the third sub-region overlaps between the first sub-region and the second sub-region, because the electronic device has saved the texture data of the third sub-region when saving the first texture data, the electronic device can not include the texture data of the third sub-region in the second texture data when adding the second texture data, which can further reduce the memory occupation. In other words, when the electronic device adds the second texture data on the basis of the first texture data, the electronic device can save the texture data of the sub-region of the second sub-region other than the third sub-region in the first work state on the basis of the first texture data, which can also reduce the memory occupation.

[0013] In this implementation, when the electronic device cancels the second handwriting, the electronic device restores the texture data of the second sub-region associated with the second handwriting to the drawing region. Because the first work state does not contain the second handwriting, the electronic device restores the texture data of the second sub-region in the first work state to the drawing region, and the second sub-region can display the handwriting in the first work state, that is, the drawing region does not display the second handwriting. However, because the second handwriting covers the first handwriting, when the electronic device cancels the second handwriting, the handwriting of the first handwriting covered by the second handwriting is also canceled, that is, the electronic device also cancels the handwriting of the first handwriting in the third sub-region. In this application, in order to achieve the purpose of canceling only the second handwriting by the electronic device, in a possible implementation, the electronic device can redraw the handwriting of the first handwriting in the third sub-region, so as to ensure that the electronic device only cancels the second handwriting without mistakenly canceling the first handwriting. In some embodiments, the electronic device can draw the handwriting of the first handwriting in the third sub-region according to the coordinates of the plurality of track points in the first handwriting and the attributes of the first handwriting.

[0014] In a possible implementation, in order to reduce the drawing workload of the electronic device and improve the drawing speed and efficiency, because the electronic device cancels the first handwriting in the third sub-region, the electronic device does not need to redraw all of the first handwriting, but can redraw the handwriting of the first handwriting in the third sub-region. In some embodiments, the electronic device can use a template test method, set an identifier of the third sub-region, and draw the handwriting of the first handwriting in the third sub-region according to the coordinates of the plurality of track points in the first handwriting and the attributes of the first handwriting.

[0015] It can be understood that when the electronic device determines that there is no third sub-region overlapping between the first sub-region and the second sub-region, the electronic device can not need to perform the operation of drawing the first handwriting.

[0016] As described above, the electronic device cancels the second handwriting, and in some embodiments, the user can also perform a recovery operation to recover the second handwriting. In this example, in response to a recovery instruction, the electronic device can draw the second handwriting according to the information of the second handwriting, and display the second handwriting in the drawing area. In this way, the purpose of recovering the second handwriting by the electronic device can be achieved. In some embodiments, the electronic device can draw the second handwriting according to the coordinates of the plurality of track points in the second handwriting and the attributes of the second handwriting. In some embodiments, the electronic device can set the identifier of the third sub-region by using a template test method, and draw the second handwriting according to the coordinates of the plurality of track points in the second handwriting and the attributes of the second handwriting.

[0017] In a possible implementation, in response to the first drawing operation, the electronic device displays the first handwriting in the drawing area, and the electronic device can save the first texture data and the information of the first handwriting. After the first handwriting, the user can draw a third handwriting in the drawing area, and accordingly, in response to a third drawing operation, the electronic device displays the third handwriting in the drawing area. Similarly, the electronic device can add third texture data to the first texture data, and save the information of the third handwriting. The third texture data includes texture data of the fourth sub-region in the first work state. In some embodiments, the third texture data includes texture data of a sub-region in the fourth sub-region that does not overlap with the first sub-region and the second sub-region in the first work state.

[0018] In response to the third drawing operation, or after the third handwriting is displayed in the drawing area, the electronic device can detect whether the number of handwritings whose information has been saved starting from the information of the first handwriting reaches a first threshold value. When the electronic device determines that the number of handwritings whose information has been saved starting from the information of the first handwriting does not reach the first threshold value, the electronic device can add third texture data to the first texture data, and save the information of the third handwriting. After the third handwriting, the user can draw a second handwriting in the drawing area. Accordingly, in response to a second drawing operation, the electronic device displays the second handwriting in the drawing area. In this example, the user draws three handwritings, and in response to the second drawing operation or after the second handwriting is displayed in the drawing area, the electronic device can detect whether the number of handwritings whose information has been saved starting from the information of the first handwriting reaches the first threshold value. When the electronic device determines that the number of handwritings whose information has been saved starting from the information of the first handwriting does not reach the first threshold value, because the electronic device has added the third texture data to the first texture data, the electronic device can add second texture data to the first texture data and the third texture data.

[0019] In this example, when the electronic device undoes the second handwriting, in response to the undo instruction, the electronic device can acquire the texture data of the second sub-region from the first texture data, the third texture data, and the second texture data according to the identification of the second sub-region. After the electronic device acquires the texture data of the second sub-region, the electronic device can restore the texture data of the second sub-region to the drawing region. Wherein, because the first work state does not contain the second handwriting, the electronic device restores the texture data of the second sub-region in the first work state to the drawing region, and the second sub-region can display the handwriting in the first work state, that is, the drawing region does not display the second handwriting.

[0020] In this example, the electronic device restores the texture data of the second sub-region in the first work state to the drawing region, in order to avoid the electronic device mistakenly undoing the first handwriting, and / or, the third handwriting, the electronic device can also detect whether there is an overlapping sub-region between the second sub-region and the first sub-region, and the sub-region associated with the third handwriting. In a possible implementation manner, the second handwriting covers the first handwriting, and / or, the second handwriting covers the third handwriting, that is, there is an overlapping third sub-region between the second sub-region and the first sub-region, and / or, there is an overlapping sixth sub-region between the second sub-region and the sub-region associated with the third handwriting. In this way, the electronic device restores the texture data of the second sub-region to the drawing region, which also undoes the first handwriting in the third sub-region, and / or, undoes the third handwriting in the sixth sub-region, and the electronic device needs to redraw the first handwriting, and / or, the third handwriting. In this example, the electronic device can draw the handwriting of the first handwriting in the third sub-region, and / or, the electronic device can draw the handwriting of the third handwriting in the sixth sub-region. In this example, the electronic device can achieve the purpose of only undoing the second handwriting, and can avoid mistakenly undoing the first handwriting, and / or, the third handwriting, and can guarantee the integrity of the first handwriting and the third handwriting.

[0021] In a possible implementation, after the user draws the second stroke in the drawing area, the user can continue to draw a fourth stroke in the drawing area. Correspondingly, in response to the fourth drawing operation, the electronic device displays the fourth stroke in the drawing area. In addition, the electronic device can detect whether the number of strokes whose information has been saved, starting from the information of the first stroke, reaches a first threshold. When the electronic device determines that the number of strokes whose information has been saved, starting from the information of the first stroke, reaches the first threshold, the electronic device can save the fourth texture data and the information of the fourth stroke. The fourth texture data includes texture data of a fifth sub-area in a second work state. The second work state is a state of the work in the drawing area before the fourth stroke is displayed. The fifth sub-area is a sub-area associated with the fourth stroke in the drawing area. In some examples, the information of the fourth stroke includes an identifier of the fifth sub-area associated with the fourth stroke, coordinates of a plurality of track points in the fourth stroke, and attributes of the fourth stroke, and the like. In this implementation, the electronic device does not save the texture data of a stroke each time the user draws a stroke, but saves the texture data of a stroke when the number of strokes drawn by the user reaches the first threshold, which can reduce the memory occupancy.

[0022] In a possible implementation, the electronic device can save the texture data and the information of the stroke in the memory. In some embodiments, the electronic device can save the information of the stroke in the form of a stack. For example, the electronic device can stack the information of each stroke as a stack element each time the user draws a stroke. For example, the electronic device can stack the information of the first stroke as a first stack element. The electronic device stacks the information of the second stroke as a second stack element. The electronic device stacks the information of the third stroke as a third stack element. The electronic device stacks the information of the fourth stroke as a fourth stack element. In some embodiments, the electronic device can stack the information of the stroke as a stack element in the order in which the user draws the stroke. In the embodiments of the present application, when the electronic device stacks the information of the fourth stroke as a fourth stack element, the top element of the stack is the fourth stack element.

[0023] In some embodiments, in order to reduce the memory occupancy of the texture data, the electronic device can write the texture data in the memory to the hard disk. Taking the first texture data and the second texture data as an example, after the electronic device adds the second texture data to the first texture data, the electronic device can write the first texture data and the second texture data to the hard disk. In this example, because the first texture data and the second texture data have been written to the hard disk, the electronic device needs to write the first texture data and the second texture data in the hard disk to the memory when the electronic device uses the first texture data and the second texture data. However, the process of reading the first texture data and the second texture data from the hard disk and writing the first texture data and the second texture data to the memory has a long time delay, which affects the speed of undoing the stroke.

[0024] In this implementation, the electronic device can write the first texture data and the second texture data in the hard disk into the memory before the user performs the undo operation, that is, before the electronic device receives the undo instruction. In this way, when the electronic device receives the undo instruction, the first texture data and the second texture data in the memory can be directly used, avoiding the time delay of reading and writing the first texture data and the second texture data, improving the speed of undoing the handwriting, and improving the user experience.

[0025] In a possible implementation, the electronic device can write the first texture data and the second texture data in the hard disk into the memory when at least one of the following conditions is met:

[0026] 1) The current top element is between the first stack element and the fourth stack element, and the number of times of receiving the undo instruction reaches a third threshold value within a preset time. In this example, when the user performs the undo operation continuously for multiple times in a short time, the probability of the user continuing to perform the undo operation is high, so the electronic device can preload the texture data, and the time delay of the subsequent undo operation can be reduced.

[0027] 2) The number of stack elements between the current top element and the first stack element is less than or equal to a fourth threshold value. In this example, the interval between the current stack element and the stack element corresponding to the last texture data or the next texture data is small, so that the electronic device can write the texture data in the hard disk into the memory in advance in order to respond to the user performing the restore operation in time. In this way, when the user performs the undo operation, the electronic device can directly restore the texture data in the memory to the drawing area to realize fast recovery of the handwriting.

[0028] 3) The user performs a preset drawing operation. In this example, when the user performs the preset drawing operation, the user has performed the undo operation for multiple times in the past, so it is highly probable that the user will perform the undo operation again. Therefore, the electronic device can write the texture data in the hard disk into the memory in advance in order to respond to the user performing the restore operation in time. In this way, when the user performs the undo operation, the electronic device can directly restore the texture data in the memory to the drawing area to realize fast recovery of the handwriting.

[0029] In a second aspect, the embodiments of the present application provide a drawing method, which introduces a scenario in which a second block for drawing a second handwriting does not overlap with a first block for drawing a first handwriting. The block can correspond to the sub-region in the above embodiments, the first block can correspond to at least one sub-region, and the second block can also correspond to at least one sub-region.

[0030] In the method, the electronic device can display a first image, the first image including a plurality of blocks. The image can be understood as a work drawn by a user in a drawing area, and the first image can include or not include a handwriting. The user can draw in a first block, and in response to a first drawing operation on the first block, the electronic device can display a second image. The user draws on the basis of the first image, and the second image newly includes a first handwriting corresponding to the first drawing operation, that is, the second image includes the first image and the first handwriting. The electronic device can save information of the first block and the first handwriting based on the first image. The information of the first handwriting can include but is not limited to an identifier of the first block, coordinates of a plurality of track points in the first handwriting, and attributes of the first handwriting, and the like. The electronic device saving the first block based on the first image can be understood as that the electronic device saves texture data of the first block based on the first image. In other words, the electronic device can save the texture data of the first block in the first image. After the user draws the first handwriting in the first block, the user can continue to draw a handwriting. In response to a second drawing operation on a second block, the electronic device can display a third image. The user draws on the basis of the second image, and the third image newly includes a second handwriting corresponding to the second drawing operation, that is, the third image includes the second image and the second handwriting corresponding to the second drawing operation. In other words, compared with the second image, the third image newly includes the second handwriting, and the second handwriting occupies the second block.

[0031] In the embodiments of the present application, the first block and the second block do not overlap, and the first block and the second block are in the same layer. The layer can be understood as a layer created by the user in a drawing application. The electronic device can save information of the second block and the second handwriting based on the first image. The information of the second handwriting can include but is not limited to an identifier of the second block, coordinates of a plurality of track points in the second handwriting, and attributes of the second handwriting, and the like. In some embodiments, the electronic device can save the information of the handwriting in the form of a stack, for example, the electronic device can stack the information of the first handwriting. The electronic device saving the second block based on the first image can be understood as that the electronic device saves texture data of the second block based on the first image. In other words, the electronic device can save the texture data of the second block in the first image.

[0032] In a possible implementation, the user can perform a cancel operation to cancel the second handwriting. Correspondingly, in response to a cancel instruction, the electronic device can process the third image based on the second block to display the second image. The electronic device can cancel the second handwriting in the third image based on the second block.

[0033] In a possible implementation, the user can also perform a recovery operation to recover the second handwriting. Correspondingly, in response to a recovery instruction, the electronic device can draw the second handwriting based on the information of the second handwriting to display the third image.

[0034] In a third aspect, the embodiments of the present application provide a drawing method. The drawing method introduces a scenario in which a block in which a second handwriting is drawn overlaps a block in which a first handwriting is drawn. The block can correspond to the sub-region in the above embodiments, and the first block can correspond to at least one sub-region. In the method, the electronic device displays a first image, and the first image includes a plurality of blocks. In response to a first drawing operation on the first block, the electronic device can display a second image, and the second image includes the first image and information of the first handwriting corresponding to the first drawing operation. The electronic device can save the first block based on the first image and the information of the first handwriting.

[0035] In this implementation, unlike the second aspect, the user draws the second handwriting in the first block when drawing the second handwriting, and the first block is also the block in which the user draws the first handwriting. That is, the block of the second handwriting overlaps the block of the first handwriting. In this example, in response to a second drawing operation on the first block, the electronic device displays a third image, and the third image includes the second image and the second handwriting corresponding to the second drawing operation. In this example, because the block of the second handwriting overlaps the block of the first handwriting, and both are the first block, the electronic device has already saved the first block based on the first image when saving the texture data. Therefore, after the user draws the second handwriting, the electronic device does not need to save the first block based on the first image, but saves the information of the second handwriting, which can reduce the memory occupation.

[0036] In a possible implementation, the user can perform a cancel operation to cancel the second handwriting. Correspondingly, in response to a cancel instruction, the electronic device can process the third image based on the first block and the information of the first handwriting to display the second image. Specifically, in response to the cancel instruction, the electronic device can cancel the second handwriting in the third image based on the first block, and draw the first handwriting in the first block based on the information of the first handwriting.

[0037] In a possible implementation, the user can also perform a recovery operation to recover the second handwriting. Correspondingly, in response to a recovery instruction, the electronic device can draw the second handwriting based on the information of the second handwriting to display the third image.

[0038] In a fourth aspect, the embodiments of the present application provide an electronic device. The electronic device includes a processor and a memory. The memory is configured to store code instructions, and the processor is configured to execute the code instructions to perform the method described in the first aspect to the third aspect, or any possible implementation of the first aspect to the third aspect.

[0039] In a fifth aspect, an embodiment of the present application provides a computer readable storage medium, which stores a computer program or instructions, and when the computer program or instructions are run on a computer, the computer is caused to execute the method described in the first aspect to the third aspect, or any possible implementation manner of the first aspect to the third aspect.

[0040] In a sixth aspect, an embodiment of the present application provides a computer program product including a computer program, and when the computer program is run on a computer, the computer is caused to execute the method described in the first aspect to the third aspect, or any possible implementation manner of the first aspect to the third aspect.

[0041] In a seventh aspect, the present application provides a chip or a chip system, which includes at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, the at least one processor is configured to run a computer program or instructions to execute the method described in the first aspect to the third aspect, or any possible implementation manner of the first aspect to the third aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.

[0042] In a possible implementation, the chip or the chip system described in the present application further includes at least one memory, and the at least one memory stores instructions. The memory can be a storage unit inside the chip, for example, a register, a cache, etc., or a storage unit of the chip (for example, a read-only memory, a random access memory, etc.).

[0043] It should be understood that the second aspect to the seventh aspect of the present application correspond to the technical solution of the first aspect of the present application, and the beneficial effects obtained by each aspect and the corresponding possible implementation manner are similar, which will not be described herein again. BRIEF DESCRIPTION OF DRAWINGS

[0044] FIG. 1 is a schematic diagram of a scenario to which the drawing method provided by an embodiment of the present application is applied;

[0045] FIG. 2 is a schematic diagram of a stack;

[0046] FIG. 3 is a schematic diagram of texture partitioning of a drawing area;

[0047] FIG. 4 is a schematic diagram of erasing a handwriting;

[0048] FIG. 5 is a schematic diagram of saving texture data;

[0049] FIG. 6 is a schematic diagram of saving texture data and drawing data;

[0050] FIG. 7 is another schematic diagram of saving texture data and drawing data;

[0051] FIG. 8 is a flowchart illustrating an embodiment of a drawing method according to an embodiment of the present application;

[0052] FIG. 9A is a schematic diagram illustrating information of texture data and handwriting according to an embodiment of the present application;

[0053] FIG. 9B is another schematic diagram illustrating information of texture data and handwriting according to an embodiment of the present application;

[0054] FIG. 10 is a flowchart illustrating another embodiment of a drawing method according to an embodiment of the present application;

[0055] FIG. 11 is a schematic diagram illustrating a method of undoing handwriting according to an embodiment of the present application;

[0056] FIG. 12A is a flowchart illustrating another embodiment of a drawing method according to an embodiment of the present application;

[0057] FIG. 12B is a flowchart illustrating another embodiment of a drawing method according to an embodiment of the present application;

[0058] FIG. 12C is a flowchart illustrating another embodiment of a drawing method according to an embodiment of the present application;

[0059] FIG. 12D is a flowchart illustrating another embodiment of a drawing method according to an embodiment of the present application;

[0060] FIG. 13A is a schematic diagram illustrating texture data and a stack stored by an electronic device according to an embodiment of the present application;

[0061] FIG. 13B is a schematic diagram illustrating preloading of texture data according to an embodiment of the present application;

[0062] FIG. 13C is another schematic diagram illustrating preloading of texture data according to an embodiment of the present application;

[0063] FIG. 14 is a schematic diagram illustrating an electronic device according to an embodiment of the present application;

[0064] FIG. 15 is another schematic diagram illustrating an electronic device according to an embodiment of the present application. DETAILED DESCRIPTION

[0065] FIG. 1 is a schematic diagram illustrating a scenario in which a drawing method according to an embodiment of the present application is applied. FIG. 1 illustrates a drawing process, undo operation and restore operation. It should be understood that the interface in FIG. 1 does not limit the interface of a drawing application (APP). In FIG. 1, an electronic device is taken as an example of a tablet.

[0066] Referring to a of FIG. 1, a drawing interface 101 of an APP can include a menu area 11 and a drawing area 12. Exemplarily, a user can draw strokes in the drawing area 12 using a finger, a joint, or a stylus, etc. The medium used by the user to draw strokes is not limited in the embodiments of the present application. "The user draws strokes in the drawing area" or "the user draws strokes" described in the following embodiments can be understood as the user draws strokes in the drawing area using a finger, a joint, or a stylus, etc. In some embodiments, the stylus can be referred to as a handwriting pen.

[0067] The menu area 11 can include at least one icon, each of which corresponds to a different function. The functions can include, but are not limited to, an eraser function, an undo function, a restore function, a brush function, a layer function, a figure function, etc. The eraser function is used to erase strokes in the drawing area 12. The undo function is used to undo drawn strokes. The restore function is used to restore undone strokes. The brush function is used to provide different types of brushes. For example, the brushes can include, but are not limited to, a pencil, a brush pen, an oil painting brush, a crayon, etc. The layer function is used to create a new layer, delete a layer, insert a layer, etc. The figure function is used to provide different shapes. For example, the shapes can include, but are not limited to, a square, a rectangle, a circle, an ellipse, a triangle, etc.

[0068] It should be understood that a of FIG. 1 takes the menu area 11 located above the drawing interface 101 as an example. For example, the menu area 11 can include an icon 111 of the eraser function, an icon 112 of the undo function, an icon 113 of the restore function, an icon 114 of the brush function, an icon 115 of the layer function, and an icon 116 of the figure function.

[0069] In some embodiments, different functions in the menu area 11 can be arranged at different positions of the drawing interface 101. Exemplarily, for example, the brush function can be arranged at the left side of the drawing interface 101, and the eraser function, the undo function, the restore function, the layer function, etc. can be arranged above the drawing interface 101. The arrangement of the menu area 11 is not limited in the embodiments of the present application.

[0070] In some embodiments, the drawing interface 101 can further include other contents, for example, a close control, a save control, etc. The embodiments of the present application do not limit this.

[0071] Referring to a of FIG. 1, a user draws strokes 1 and strokes 2 in the drawing area 12, and the strokes 2 are later than the strokes 1. The user operates the icon 112 of the undo function, and the tablet computer can undo the strokes 2. The drawing area 12 displays the content before the strokes 2 are drawn, that is, the drawing area 12 displays the strokes 1, as shown in b of FIG. 1. The user operates the icon 113 of the restore function, and the tablet computer can restore the strokes 2. The drawing area 12 displays the strokes 1 and the strokes 2, as shown in c of FIG. 1.

[0072] It should be understood that the strokes drawn by the user in the drawing area 12 can constitute text, patterns, and the like. In other words, the drawing method provided by the embodiments of the present application can be applied in the scenarios of drawing text, patterns, and the like. Specifically, the drawing method provided by the embodiments of the present application can be applied in the scenarios of note taking, drawing, and the like.

[0073] For the convenience of understanding, the related terms and concepts involved in the embodiments of the present application are introduced below in conjunction with FIG. 1:

[0074] 1. Undo: In the drawing scenario, undo can cancel the strokes drawn by the user, and the drawing area displays the content before the strokes are drawn.

[0075] 2. Redo: In the drawing scenario, redo can restore the canceled strokes to the drawing area, that is, the drawing area can display the canceled strokes again.

[0076] 3. Pixel: A unit of image display.

[0077] 4. Texture data: Color information of at least one pixel. In some embodiments, the color information can include three-channel red (R), green (G), and blue (B) information. In some embodiments, yellow can be used instead of green, and the color information can include red, yellow (Y), and blue information, referred to as RYB information. The embodiments of the present application do not limit the number of channels of the pixel, for example, the channel can be four channels or even more channels. For example, a transparency channel can also be included.

[0078] Taking the drawing area 12 in FIG. 1 as an example, the drawing area 12 is composed of a plurality of pixels. For example, the drawing area 12 can be composed of m rows and n columns of pixels. Wherein, m is an integer greater than 1, and n is an integer greater than 1. The texture data of the drawing area 12 can include the color information of each pixel in the drawing area 12.

[0079] 5. Stack: A structure for storing linear data. Referring to FIG. 2, the first end of the stack can be referred to as the top of the stack, and the second end can be referred to as the bottom of the stack. In some embodiments, the data stored at the top of the stack can be referred to as the top element of the stack, and the data stored at the bottom of the stack can be referred to as the bottom element of the stack. Wherein, inserting data into a stack can be referred to as pushing, entering or stacking, and the inserted data can be placed on top of the stack to become the new top of the stack. Deleting data from a stack can be referred to as popping or de-stacking, and deleting data is to delete the data at the top of the stack, and the data adjacent to the bottom of the stack becomes the new top of the stack.

[0080] In the embodiments of the present application, the electronic device can use a stack to save data, and details can be referred to the description in the following embodiments.

[0081] 6, Stack element: each element constituting a stack. For example, the data in one of the boxes shown in FIG. 2 can be regarded as a stack element, and the stack in FIG. 2 includes four stack elements.

[0082] 7, Discarding: refers to writing data in the memory to the hard disk of the electronic device. In some embodiments, in order to reduce memory usage, the data in the memory can also be deleted after writing the data in the memory to the hard disk of the electronic device.

[0083] In the embodiments of the present application, discarding the texture data means writing the texture data in the memory to the hard disk of the electronic device, and deleting the texture data in the memory. When the electronic device reuses the texture data, the electronic device can write the texture data in the hard disk to the memory.

[0084] 8, Texture tiling: referring to FIG. 3a, the drawing area 12 displays a handwriting. At present, when the electronic device saves the texture data of the drawing area 12, it needs to save the full amount of texture data, which includes the color information of each pixel in the drawing area 12. It should be understood that the menu area 11 is not shown in FIG. 3.

[0085] In some embodiments, texture tiling can also be referred to as texture partitioning, texture slicing, etc.

[0086] Texture tiling is that the electronic device divides the drawing area into N sub-areas, and each sub-area contains a number of pixels.

[0087] Among them, the handwriting-related sub-area can be understood as a sub-area containing the handwriting. In this way, when the electronic device saves the texture data of the drawing area 12, it can save the color information of each pixel in the handwriting-related sub-area, which can greatly reduce the data amount of the texture data and reduce the memory occupied by the texture data. Wherein, N is an integer greater than or equal to 2.

[0088] It should be understood that the attributes of the N sub-areas can be the same or different, and the attributes can include but are not limited to size, shape, etc. In some embodiments, for example, the size of each sub-area can be the same, and each sub-area can be rectangular. For example, the size of each sub-area can be 64pixel×64pixel, or 32pixel×32pixel, or 128pixel×128pixel.

[0089] Taking each sub-region as a rectangle as an example, referring to b in FIG. 3, the drawing region 12 can be divided into 12 sub-regions, namely, sub-region 1, sub-region 2, …, and sub-region 12. The sub-regions related to the handwriting 1 include: sub-region 1, sub-region 2, sub-region 6, sub-region 7, sub-region 11, and sub-region 12. When saving the texture data, the electronic device can save the color information of each pixel in the sub-region 1, sub-region 2, sub-region 6, sub-region 7, sub-region 11, and sub-region 12, and does not save the color information of each pixel in the blank regions (sub-region 3, sub-region 4, sub-region 5, sub-region 8, sub-region 9, and sub-region 10). In this way, the texture tiling can avoid the electronic device to save a large amount of blank data, which can be understood as the texture data of the sub-region that does not contain the handwriting.

[0090] In some embodiments, when the electronic device performs the texture tiling on the drawing region, the electronic device can generate an identifier of each sub-region, which is used to distinguish different sub-regions. In some embodiments, the identifier can also be referred to as a number, an ID, and the like.

[0091] In some embodiments, from the perspective of an image or a work, the texture tiling can be to divide the image or the work into multiple blocks, which correspond to the sub-regions in the above examples. For a block, it can include a part of the image or the work; or for a block, it can include a part of the background of the image or the work; or for a block, it can also include a part of the image or the work and a part of the background of the image or the work.

[0092] In some embodiments, the background of the image or the work can be a solid color background or other images or other works, and the like; the background can be a software preset background, or can also be a user modified background.

[0093] 9. Stencil test: in response to the operation of the user drawing the handwriting in the drawing region, the electronic device needs to perform drawing, rendering, layer compositing, and display, and the like, so that the drawing region displays the handwriting. The stencil test refers to: before the electronic device draws the handwriting, the target sub-region that takes effect for this drawing can be set in advance, so that this drawing only takes effect in the target sub-region, and the drawing outside the target sub-region does not take effect. In other words, the electronic device can draw the handwriting in the target sub-region, and does not draw the handwriting in other sub-regions, which can reduce the drawing workload of the electronic device. Correspondingly, the target sub-region can display the handwriting of this drawing, and other sub-regions do not display the handwriting. Wherein, the sub-region can refer to the description in the texture tiling.

[0094] 10、The electronic device in the embodiments of the present application can be referred to as a user equipment (UE), a terminal, etc. The electronic device in the embodiments of the present application can provide a drawing function, which can be provided by a system APP or a third-party APP in the electronic device. For example, the electronic device can be a mobile phone, a tablet computer, a personal digital assistant (PDA), a vehicle-mounted device, or a wearable device, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in a smart home, etc., and the form of the electronic device is not limited in the embodiments of the present application.

[0095] For an electronic device carrying a stylus, the electronic device and the stylus can be interconnected through a communication network to realize handwriting drawing. For example, the communication network can be, but is not limited to, a WI-FI hotspot network, a WI-FI peer-to-peer (P2P) network, a Bluetooth network, a zigbee network, or a near field communication (NFC) network, etc.

[0096] More and more users use electronic devices to draw and take notes. In the drawing process, the undo operation and the restore operation are two high-frequency operations. For the undo and restore of drawing, the electronic device cannot be simply processed to achieve it. The reason is that the handwriting drawn by the user covers the previous handwriting, which causes the texture data of the covered handwriting to be lost, and when the user performs the undo operation, the electronic device cannot restore the covered part of the handwriting.

[0097] For example, referring to a in FIG. 4, a user draws handwriting 1 in a drawing area 12. The drawing area 12 can display the handwriting 1, and the electronic device can save the texture data of the drawing area 12, such as texture data 1. Referring to b in FIG. 4, the user draws a rectangle in the drawing area 12. The drawing area 12 can display the rectangle, and the rectangle covers part of the handwriting 1. The electronic device can update the texture data of the drawing area 12, such as texture data 2. In this way, after the user draws the rectangle in the drawing area 12, the electronic device only saves the texture data 2, and the texture data 2 does not contain the texture data of the covered part of the handwriting 1. When the user performs the undo operation, because the electronic device does not save the texture data of the covered part of the handwriting 1, the electronic device cannot restore the complete handwriting 1, as shown in c in FIG. 4.

[0098] In order to ensure that the electronic device can realize the functions of undoing the handwriting and restoring the handwriting, three existing methods for saving the texture data are introduced as follows:

[0099] First, before introducing the methods for saving the texture data, a stack for saving the texture data is introduced.

[0100] In the drawing process, if all the operations performed by the user are composed into a stack, the user's operation can trigger the electronic device to save the operation data as a stack element. The operation data saved into the stack can include the drawing data. In some embodiments, the drawing data can include the information of the handwriting in this drawing, and the information of the handwriting can include but is not limited to the coordinates of the track points in the handwriting and the handwriting attributes, etc. The handwriting attributes can include but are not limited to the handwriting color, the handwriting thickness, the handwriting line type, etc.

[0101] In the scenario of saving the operation data in the stack, the user's execution of the undo operation can be regarded as the top element of the stack being out of the stack. The user's execution of the restore operation can be regarded as the out-of-stack stack element being re-stored into the stack.

[0102] The work refers to the content displayed in the drawing area. The initial state of the work can be understood as the state of the work when the drawing APP is opened and the user has not performed any drawing operation. The initial state of the work + all the operation data saved in the stack is the current state of the work.

[0103] Three existing methods for saving the texture data are introduced as follows:

[0104] 1. Method 1 for saving the texture data

[0105] The user performs a drawing operation, and the electronic device saves the texture data of the current work once, that is, the electronic device saves the texture data of the drawing area once. In other words, the user performs a drawing operation, and the electronic device can store the texture data of the current work into the stack.

[0106] For example, when the user does not perform the drawing operation, the stack can be empty. Referring to a of FIG. 5, the user draws a stroke 1 in the drawing area, and the texture data of the drawing area can be texture data 1. The electronic device stacks the texture data 1. The texture data 1 is the first stack element in the stack, and the texture data 1 can also be referred to as the top element of the stack. Referring to b of FIG. 5, the user draws a stroke 2 in the drawing area, and the texture data of the drawing area can be texture data 2. The electronic device stacks the texture data 2, and the top element of the stack is updated to the texture data 2. Similarly, referring to c of FIG. 5, the user draws a stroke 3 in the drawing area, and the texture data of the drawing area can be texture data 3. The electronic device stacks the texture data 3, and the top element of the stack is updated to the texture data 3. Similarly, referring to d of FIG. 5, the user draws a circle 4 in the drawing area, and the texture data of the drawing area can be texture data 4. The electronic device stacks the texture data 4, and the top element of the stack is updated to the texture data 4.

[0107] In this method, when the user performs the undo operation, the electronic device can pop the top element of the stack, and restore the saved previous texture data to the drawing area, so as to realize the undo of the stroke. When the user performs the restore operation, the electronic device can restore the popped element to the drawing area, so as to realize the restore of the stroke.

[0108] For example, referring to d of FIG. 5, after the user draws the circle 4 in the drawing area, the user performs the undo operation. The electronic device can pop the top element "texture data 4" of the stack, and restore the saved previous texture data "texture data 3" to the drawing area. The drawing area can display the stroke 1, the stroke 2, and the stroke 3, as shown in e of FIG. 5. Referring to e of FIG. 5, when the user performs the restore operation, the electronic device can restore the popped "texture data 4" to the drawing area. In addition, the electronic device can stack the "texture data 4". In this way, the drawing area can display the stroke 1, the stroke 2, the stroke 3, and the circle 4, as shown in f of FIG. 5.

[0109] It should be understood that the electronic device restoring the texture data to the drawing area means that the electronic device displays the texture data, so that the drawing area displays the corresponding stroke.

[0110] In some embodiments, when the electronic device saves the texture data, the electronic device can save the texture data in a first space of the memory. The electronic device restoring the texture data to the drawing area means that the electronic device copies the texture data in the first space, writes the copied texture data into a second space of the memory, and displays the texture data in the second space, so that the drawing area displays the corresponding stroke. The second space is used to store the texture data to be displayed.

[0111] In some embodiments, when saving the texture data, the electronic device can save the texture data in a first space of the memory, and to avoid high memory occupation, the electronic device can write the texture data in the first space to a hard disk. In this example, the electronic device restoring the texture data to the rendering area means that the electronic device writes the texture data in the hard disk to a third space of the memory, which can be the same as or different from the first space, and the electronic device copies the texture data in the third space and writes the copied texture data to a second space of the memory, and sends the texture data in the second space for display, so that the rendering area displays the corresponding strokes.

[0112] However, in this method, the electronic device needs to save the texture data of the rendering area after each execution of the drawing operation by the user, and the memory occupation is large. In some embodiments, to reduce the memory occupied by the texture data, the electronic device can write part or all of the texture data to the hard disk, but when the user performs the undo operation, the electronic device needs to first write the texture data in the hard disk to the memory, and the reading and writing process can cause undo lag, too long loading time, and other problems. In addition, when the texture data of the work is large, and the user needs to undo hundreds of drawing operations, the texture data written from the hard disk to the memory by the user each time the undo operation or the restore operation is performed can reach several tens of GB, which is a great challenge to the storage space of the hard disk.

[0113] 2. Texture data saving method 2

[0114] To reduce the memory occupied by the texture data, in some embodiments, the electronic device can save the texture data of the rendering area once when the drawing APP is opened. In this method, when the drawing APP is opened, the rendering area can contain strokes or not contain strokes. In this method, the user performs the drawing operation, and the electronic device does not save the texture data of the rendering area, but saves the drawing data, i.e., stacks the drawing data.

[0115] For example, referring to a in FIG. 6, when the drawing APP is opened, the electronic device can save the texture data of the drawing area, such as texture data 0. Referring to b in FIG. 6, the user draws stroke 1 in the drawing area, and the electronic device stacks the information of stroke 1. The information of stroke 1 can include the coordinates of the plurality of track points in stroke 1 and the attributes of stroke 1, etc. The information of stroke 1 is the first stack element in the stack, and can also be referred to as the top element of the stack. Referring to c in FIG. 6, the user draws stroke 2 in the drawing area, and the electronic device stacks the information of stroke 2. The top element of the stack is updated to the information of stroke 2. Referring to d in FIG. 6, the user draws stroke 3 in the drawing area, and the electronic device stacks the information of stroke 3. The top element of the stack is updated to the information of stroke 3. The information of stroke 2 and the information of stroke 3 can refer to the description of the information of stroke 1. Referring to e in FIG. 6, the user draws circle 4 in the drawing area, and the electronic device stacks the information of circle 4. The top element of the stack is updated to the information of circle 4. The information of circle 4 can include the attributes of the circle, which can include but are not limited to the line color, thickness, line type of the circle, the color of the inner filling of the circle, and the coordinates of the circle, etc.

[0116] In this method, when the user wants to undo the Mth stroke, the electronic device can perform steps 1)-2) as follows. It can be understood that in FIG. 6, after the user draws circle 4 in the drawing area, the user draws 4 strokes, and M is equal to 4. Wherein, M is an integer greater than or equal to 1.

[0117] Step 1): Find the texture data when the drawing APP is opened, such as texture data 0.

[0118] Step 2): According to the order from the bottom of the stack to the top of the stack, re-perform the drawing operation according to the 1st stack element to the (M-1)th stack element. When the electronic device finishes the drawing operation according to the (M-1)th stack element, the Mth stroke can be undone.

[0119] In this example, after the electronic device undoes the Mth stroke, the user performs a recovery operation, and the electronic device can perform a drawing operation according to the Mth stack element to recover the Mth stroke.

[0120] Compared with the saving method 1, in the saving method 2, the electronic device only needs to save the texture data of the drawing area once when the drawing APP is opened, and each time the user performs a drawing operation, the electronic device only needs to save the drawing data of this time, without saving the full amount of texture data, thereby reducing the memory occupation. However, when M is large, the electronic device needs to re-perform the drawing operation according to the first stack element to the (M-1)th stack element, which takes a long time and causes problems such as lag, delay and the like in the undo operation. In addition, for a drawing scene with several thousand or even tens of thousands of strokes, the time taken to re-perform the drawing operation in the undo method in the saving method 2 is seconds or even minutes, which is poor in user experience.

[0121] 3. Saving method 3 of texture data:

[0122] The saving method 3 combines the advantages of the saving method 1 and the saving method 2. When the drawing APP is opened, the electronic device can save the texture data of the drawing area, and every X stack elements, the electronic device can save the texture data of the drawing area again. In addition, each time the user performs a drawing operation, the electronic device can stack the drawing data of the drawing operation. Wherein, X is an integer greater than or equal to 2.

[0123] The saving method 3 avoids the problem that the texture data of the drawing area needs to be saved after each drawing in the saving method 1, and can reduce the memory occupied by the texture data. In addition, every X stack elements, the electronic device can save the texture data of the drawing area again, compared with the saving method 2, when the electronic device performs the undo operation, it does not need to return to the texture data saved when the drawing APP is opened, and perform the drawing operation in all stack elements, but return to the last saved texture data, and perform the drawing operation from the stack element corresponding to the texture data, thereby reducing the drawing workload and improving the drawing efficiency.

[0124] Taking X as 2 as an example, refer to Fig. 7a, when the drawing APP is opened, the electronic device can save the texture data of the current work, such as texture data 0. Refer to Fig. 7b, the user draws stroke 1 in the drawing area, and the electronic device stacks the information of stroke 1. Refer to Fig. 7c, the user draws stroke 2 in the drawing area, and the electronic device stacks the information of stroke 2. At this time, two stack elements are added in the stack, X reaches 2, and the electronic device can save the texture data of the drawing area, such as texture data 2.

[0125] Refer to Fig. 7d, the user draws stroke 3 in the drawing area, and the electronic device stacks the information of stroke 3. Refer to Fig. 7e, the user draws circle 4 in the drawing area, and the electronic device stacks the information of circle 4. At this time, two stack elements are added in the stack again, X reaches 2, and the electronic device can save the texture data of the drawing area, such as texture data 4.

[0126] In this method, when the user performs the undo operation, the electronic device can restore the last saved texture data to the drawing area, and start to re-perform the drawing operation according to the stack element. For example, after the user draws the circle 4 in the drawing area, the user performs the undo operation, and the electronic device can perform the following steps 1)-3):

[0127] 1) Obtain the last saved texture data, such as the texture data 2.

[0128] 2) Restore the texture data 2 to the drawing area, and the drawing area displays the content before the drawing stroke 3.

[0129] 3) According to the information of the stroke 3, re-perform the operation of drawing the stroke 3, so that the drawing area displays the work before the drawing stroke 4, that is, the purpose of undoing the circle 4 is achieved.

[0130] However, the saving method 3 also has the following disadvantages:

[0131] In the scene where the texture data of the drawing area is large and the drawing load is heavy, if the X value is too large, the electronic device needs to re-perform multiple drawing operations when performing the undo operation, and the drawing workload is large. If the X value is too small, the electronic device still needs to save a large amount of texture data, resulting in large memory occupation. In summary, in the saving method 3, the electronic device is difficult to balance the memory requirement and the performance.

[0132] To solve the above problems, the embodiments of the present application provide a drawing method. Based on the methods, the electronic device can perform texture tiling processing on the drawing area. When the electronic device saves the texture data, instead of saving the full amount of texture data, the electronic device saves the texture data of the sub-area associated with the stroke. Compared with the full amount of texture data, the texture data of the sub-area can reduce the memory occupation. In addition, when the electronic device re-performs the drawing operation according to the drawing data, instead of drawing the complete stroke, the electronic device can use the template test method to pre-set the target sub-area of this drawing, so that this drawing only takes effect in the target sub-area and does not take effect outside the target sub-area, thereby reducing the drawing workload of the electronic device. In summary, the drawing method provided by the embodiments of the present application can balance the memory requirement and the performance of the electronic device.

[0133] The drawing method provided by the embodiments of the present application will be described below in combination with specific embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes can not be described in some embodiments.

[0134] FIG. 8 is a flowchart of an embodiment of the drawing method provided by the embodiments of the present application. Referring to FIG. 8, the drawing method provided by the embodiments of the present application can include:

[0135] S801, when the drawing APP is opened, the electronic device displays a drawing interface of the drawing APP, and the drawing interface includes a drawing area.

[0136] The desktop of the electronic device can display an icon of the drawing APP, and the user can operate the icon of the drawing APP to trigger the drawing APP to open. The drawing interface of the drawing APP can be as shown in FIG. 1, and the drawing interface includes a drawing area 12. In some embodiments, the drawing area can be understood as an area on the screen for providing a drawing trace and displaying the trace. For example, the drawing area can be a partial area or the entire area of the drawing interface.

[0137] When the drawing APP is opened, the drawing area can include a trace or not include a trace. In some embodiments, the content displayed in the drawing area can be referred to as a work, and when the drawing APP is opened, the work is in a first work state or an initial work state.

[0138] The work state is used to indicate the trace contained in the current work, and the first work state is used to indicate the trace contained in the work when the drawing APP is opened. The traces contained in the work in different work states can be different.

[0139] S802, in response to the user drawing a first pen trace in the drawing area, the electronic device saves texture data 1 and stacks the information of the first pen trace.

[0140] In some examples, the texture data 1 can include texture data of a first sub-area in the first work state, and the first sub-area is a sub-area associated with the first pen trace.

[0141] In the embodiments of the present application, the user drawing the first pen trace in the drawing area can trigger the electronic device to save texture data once, i.e., the texture data 1. The texture data 1 is the texture data of the first sub-area in the first work state, i.e., the color information of each pixel in the first sub-area in the first work state. It can be understood that the user draws the first pen trace in the drawing area, and the drawing area increases the first pen trace, and the state of the work in the drawing area is the second work state.

[0142] In the embodiments of the present application, the electronic device can perform texture tiling processing on the drawing area, i.e., the electronic device can divide the drawing area into N sub-areas. The first sub-area is a sub-area associated with the first pen trace, which means a sub-area containing the first pen trace. In other words, the texture data 1 is the texture data of the sub-area containing the first pen trace in the first work state.

[0143] In the embodiments of the present application, after the user draws the first pen stroke in the drawing area, the electronic device does not save the full amount of texture data, but saves the texture data of the sub-area associated with the first pen stroke in the first work state, that is, saves the texture data of the sub-area associated with the first pen stroke before drawing the first pen stroke.

[0144] Compared with saving the full amount of texture data, the electronic device saves the texture data of part of the sub-areas of the drawing area, which can reduce the memory occupation. In particular, when there are many strokes in the first work state, the electronic device saves a large amount of memory by saving the full amount of texture data. In the embodiments of the present application, the electronic device saves the texture data of the sub-area associated with the first pen stroke before drawing the first pen stroke, that is, the texture data of the sub-area associated with the first pen stroke in the first work state. When the electronic device performs the undo operation, the electronic device can restore the texture data of the sub-area associated with the first pen stroke to the first work state, so that the undo operation can be realized, and the operation is simple.

[0145] In the embodiments of the present application, in addition to the coordinates of the plurality of track points in the first pen stroke and the attributes of the first pen stroke, the information of the first pen stroke can also include the identifier of the first sub-area. The first sub-area can be at least one sub-area.

[0146] For example, in the first work state, the drawing interface does not include any stroke, that is, the first work state does not include any stroke. It should be understood that in the drawings of the embodiments of the present application, the electronic device divides the drawing area into 12 sub-areas, as shown in a of FIG. 9A. Referring to b of FIG. 9A, the user draws stroke 1 in the drawing area. The stroke 1 can be referred to as the first pen stroke. For example, the stroke 1 is associated with three sub-areas, namely sub-area 5, sub-area 6 and sub-area 7. In b of FIG. 9A, the sub-areas associated with the stroke 1 are represented by solid boxes.

[0147] In the embodiments of the present application, the electronic device can save the texture data of the three sub-areas associated with the stroke 1 in the first work state. Because the first work state does not include any stroke, the texture data of the three sub-areas associated with the stroke 1 can be blank data. In addition, the electronic device can stack the information of the stroke 1. The information of the stroke 1 can include the identifiers of the three sub-areas associated with the stroke 1, the coordinates of the plurality of track points in the stroke 1, and the attributes of the stroke 1.

[0148] S803, in response to the user drawing the second pen stroke in the drawing area, the electronic device detects whether the newly stacked stack element reaches the first threshold. If yes, S804 is performed, and if no, S805 is performed.

[0149] The newly-stacked stack element refers to a stack element that is stacked after the stack element corresponding to the texture data 1 (including the stack element corresponding to the texture data 1). The stack element corresponding to the texture data 1 is information of the first stroke. For example, in response to the user drawing the second stroke in the drawing area, the electronic device detects that the number of newly-stacked stack elements is 1, and the newly-stacked stack element is information of the first stroke.

[0150] The first threshold value can be pre-set. In some embodiments, when the first threshold value is equal to 1, after the user draws the second stroke in the drawing area, the electronic device detects that the number of newly-stacked stack elements is 1, reaching the first threshold value. In some embodiments, in order to reduce the amount of data of the texture data saved by the electronic device, the first threshold value can be greater than or equal to 2.

[0151] S804, the electronic device saves the texture data 2, and stacks information of the second stroke.

[0152] In some examples, the texture data 2 is texture data of the second sub-region in the third work state, and the second sub-region is a sub-region associated with the second stroke.

[0153] When the first threshold value is equal to 1, after the user draws the second stroke in the drawing area, the newly-stacked stack elements reach the first threshold value, and the electronic device can save the texture data 2 and stack the information of the second stroke. In other words, after the user draws the second stroke in the drawing area and before the information of the second stroke is stacked, the electronic device can detect that the number of newly-stacked stack elements is 1, reaching the first threshold value.

[0154] The second stroke is drawn in the drawing area after the user draws the second stroke in the drawing area, and at this time, the state of the work in the drawing area can be referred to as a third work state.

[0155] The texture data 2 is texture data of the second sub-region in the third work state. The second sub-region is a sub-region associated with the second stroke, which refers to a sub-region containing the second stroke. In other words, the texture data 2 is texture data of a sub-region containing the second stroke in the third work state. The information of the second stroke can include an identifier of the second sub-region, coordinates of a plurality of track points in the second stroke, and attributes of the second stroke.

[0156] It should be understood that strokes in different work states can be different, and therefore strokes contained in the same sub-region in different work states can also be different. In the embodiments of the present application, after the user draws the second stroke in the drawing area, the electronic device can save the texture data of the second sub-region in the third work state when saving the texture data, which facilitates the electronic device to perform the undo operation and the restore operation according to the texture data 2.

[0157] For example, referring to c in FIG. 9A, the user draws strokes 2 in the drawing area, which can be referred to as second pen strokes, and the third work state includes the strokes 1 and the strokes 2. For example, the strokes 2 are associated with 2 sub-areas, which are represented by a dashed box in c in FIG. 9A and are sub-area 8 and sub-area 12. After the user draws the strokes 2 in the drawing area, the electronic device detects that the newly-stacked stack element is the information of the strokes 1, and the newly-stacked stack element reaches the first threshold 1, and the electronic device can save the texture data 2 and stack the information of the strokes 2. The texture data 2 includes: texture data of the 2 sub-areas associated with the strokes 2 in the third work state. The information of the strokes 2 can include: the identification of the 2 sub-areas associated with the strokes 2, the coordinates of the plurality of track points in the strokes 2, and the attributes of the strokes 2.

[0158] After the electronic device stacks the information of the strokes 2, the stack includes 2 stack elements.

[0159] S805, the electronic device updates the texture data 1 according to the texture data 3.

[0160] When the first threshold is greater than or equal to 2, after the user draws the second pen strokes in the drawing area, the electronic device detects that the number of newly-stacked stack elements is 1, which does not reach the first threshold, and the electronic device can no longer save new texture data but update the saved texture data 1. In the embodiment of the present application, the electronic device can update the texture data 1 according to the texture data 3.

[0161] The texture data 3 is: texture data of the third sub-area in the first work state. The third sub-area is not directly a sub-area associated with the second pen strokes but a sub-area associated with the second pen strokes and not contained in the first sub-area.

[0162] The texture data 1 contains texture data of the first sub-area associated with the first pen strokes. When the second pen strokes cover the first pen strokes, the sub-area associated with the second pen strokes overlaps the first sub-area, and the texture data 1 already contains texture data of the overlapping sub-area in the first work state. When the electronic device updates the texture data, it is not necessary to store the texture data of the overlapping sub-area again but to store the texture data of the sub-area associated with the second pen strokes and not contained in the first sub-area, which can avoid saving repeated texture data and reduce memory occupation.

[0163] The electronic device updates the texture data 1 according to the texture data 3 can be understood as: the electronic device increases the saved texture data 3 on the basis of the texture data 1 to update the texture data 1. The updated texture data 1 includes: the texture data 1 and the texture data 3.

[0164] S806, the electronic device stacks the information of the second pen strokes.

[0165] It should be understood that S805 and S806 have no order distinction, and both can be executed at the same time.

[0166] It should be understood that the first threshold value is 1 in FIG. 9A, and the first threshold value is 2 in the following example, and the first threshold value is 2 in FIG. 9B. For example, referring to a in FIG. 9B, when the APP is opened, the drawing interface of the APP includes two strokes, that is, the first work state includes two strokes. Referring to b in FIG. 9B, the user draws stroke 1A in the drawing area. The stroke 1A can be referred to as the first stroke. For example, the stroke 1A is associated with four sub-regions, which are sub-region 5, sub-region 6, sub-region 7 and sub-region 8. In b in FIG. 9B, the four sub-regions associated with the stroke 1A are represented by solid line boxes. The electronic device can save the texture data of the three sub-regions associated with the stroke 1A in the first work state, and stack the information of the stroke 1A. The information of the stroke 1A can refer to the related description of the information of the stroke in the above embodiment.

[0167] Referring to c in FIG. 9B, the user draws stroke 2A in the drawing area. The stroke 2A can be referred to as the second stroke. For example, the stroke 2A is associated with three sub-regions, which are sub-region 4, sub-region 8 and sub-region 12. In c in FIG. 9B, the three sub-regions associated with the stroke 2A are represented by dashed line boxes, and the three sub-regions overlap one sub-region with the four sub-regions associated with the stroke 1A, which is sub-region 8. In c in FIG. 9B, the overlapping sub-region is represented by a gray shadow.

[0168] After the user draws the stroke 2A in the drawing area, the electronic device detects that the newly stacked stack element is only the information of the stroke 1A, which does not reach the first threshold value 2. Therefore, the electronic device can update the texture data 1. Referring to c in FIG. 9B, the electronic device can add and save the texture data 3 on the basis of the texture data 1, and stack the information of the stroke 2A. The texture data 3 includes the texture data of the two sub-regions associated with the stroke 2A in the first work state, which are sub-region 4 and sub-region 12. The information of the stroke 2A can include the identification of the three sub-regions associated with the stroke 2A, the coordinates of the multiple track points in the stroke 2A, and the attributes of the stroke 2A.

[0169] S807, in response to the user drawing a third stroke in the drawing area, the electronic device detects whether the newly stacked stack element reaches the first threshold value. If yes, S808 is executed, and if no, S809 is executed.

[0170] In some embodiments, the electronic device performs S807 after performing S804, and the newly-stacked stack element is the stack element that is stacked from the stack element corresponding to the texture data 2. The stack element corresponding to the texture data 2 can be the information of the second stroke, and the newly-stacked stack element is the information of the second stroke.

[0171] In some embodiments, the electronic device performs S807 after performing S805-S806, and the newly-stacked stack element is the stack element that is stacked from the stack element corresponding to the texture data 1. The stack element corresponding to the texture data 1 can be the information of the first stroke, and the newly-stacked stack element includes the information of the first stroke and the information of the second stroke.

[0172] In summary, the newly-stacked stack element refers to the stack element that is stacked from the stack element corresponding to the last saved texture data. The stack element corresponding to the last saved texture data can be understood as the stack element that is stacked when the last saved texture data is saved.

[0173] For example, when the electronic device performs S807 after performing S804, and the first threshold is 1, the newly-stacked stack element reaches the first threshold 1. For example, when the electronic device performs S807 after performing S805-S806, and the first threshold is 2, the newly-stacked stack element reaches the first threshold 2. For example, when the electronic device performs S807 after performing S805-S806, and the first threshold is greater than 2, the newly-stacked stack element does not reach the first threshold.

[0174] S808, the electronic device saves the texture data 4 and stacks the information of the third stroke.

[0175] In some examples, the texture data 4 includes the texture data of the fourth sub-region in the fourth work state, and the fourth sub-region is a sub-region associated with the third stroke.

[0176] In the embodiment of the present application, after the user draws the third stroke in the drawing area, if the newly-stacked stack element reaches the first threshold, the electronic device can save the texture data 4 and stack the information of the third stroke. At this time, the drawing area adds the third stroke, and the state of the work in the drawing area can be referred to as the fourth work state.

[0177] The texture data 4 is the texture data of the fourth sub-region in the fourth work state. The fourth sub-region is a sub-region associated with the third stroke, in other words, the texture data 4 is the texture data of the sub-region associated with the third stroke in the fourth work state.

[0178] The information of the third stroke can include the identifier of the fourth sub-region, the coordinates of the plurality of track points in the third stroke, and the attribute of the third stroke.

[0179] For example, referring to d in FIG. 9B, the user draws the stroke 3A in the drawing area, which can be referred to as the third pen stroke. For example, the stroke 3A is associated with 3 sub-areas, and d in FIG. 9B represents the 4 sub-areas associated with the stroke 3 in a dotted box. After the user draws the stroke 3A in the drawing area, the electronic device detects that the number of newly stacked stack elements is 2, i.e., the information of the stroke 1A and the information of the stroke 2A, which reaches the first threshold 2, and the electronic device can save the texture data 4 and stack the information of the stroke 3A. The texture data 4 is the texture data of the 4 sub-areas associated with the stroke 3A in the fourth work state. The information of the stroke 3A can refer to the description of the information of the stroke in the above embodiments.

[0180] S809, the electronic device updates the texture data 1 according to the texture data 5.

[0181] When the first threshold is greater than or equal to 3, after the user draws the third pen stroke in the drawing area, the electronic device detects that the number of newly stacked stack elements is 2, which does not reach the first threshold, and the electronic device can no longer save new texture data, but continue to update the texture data 1. In the embodiment of the present application, the electronic device can update the texture data 1 according to the texture data 5.

[0182] The texture data 5 is the texture data of the fifth sub-area in the first work state. The fifth sub-area is not the sub-area associated with the third pen stroke, but the sub-area associated with the third pen stroke and not contained in the first sub-area and the second sub-area. In other words, the fifth sub-area is the sub-area associated with the third pen stroke and not saved in the first work state.

[0183] In the embodiment of the present application, the electronic device updates the texture data 1 according to the texture data 5 can be understood as: on the basis of the saved texture data 1 (i.e., the texture data 1 updated once), the texture data 5 is saved to update the texture data 1 again. The saved texture data 1 can include the texture data 1 and the texture data 3. The texture data 1 updated this time includes the texture data 1, the texture data 3, and the texture data 5.

[0184] S810, the electronic device stacks the information of the third pen stroke.

[0185] It should be understood that S809 and S810 have no order distinction, and both can be executed at the same time.

[0186] It can be understood that if the user continues to draw the handwriting, the electronic device can iteratively perform the steps in the above embodiments. For example, if the user continues to draw the handwriting, the electronic device can continue to detect whether the newly-stacked stack element reaches the first threshold. If the newly-stacked stack element does not reach the first threshold, the electronic device can save the new texture data and stack the information of the pen handwriting. If the newly-stacked stack element does not reach the first threshold, the electronic device can update the last saved texture data and stack the information of the pen handwriting.

[0187] In the embodiments of the present application, in the drawing scene, the electronic device can save the texture data once every first threshold stack element. The texture data saved by the electronic device is not the full texture data, but the texture data of the sub-region associated with the handwriting at the current work state, which can reduce the memory occupied by the texture data. In addition, after the user draws the handwriting each time, if the newly-stacked stack element does not reach the first threshold, the electronic device can incrementally save the texture data of the sub-region associated with the handwriting and not saved before on the basis of the last saved texture data to update the last saved texture data, so as to facilitate the electronic device to implement the undo operation and the recovery operation, which can be referred to the description in the following embodiments.

[0188] The following takes the scene in which the electronic device performs S805-S806 as an example to introduce the process in which the electronic device undoes the second pen handwriting.

[0189] Referring to FIG. 10, the drawing method provided by the embodiments of the present application can include:

[0190] S1001, when the drawing APP is opened, the electronic device displays a drawing interface of the drawing APP, and the drawing interface includes a drawing area.

[0191] S1002, in response to the user drawing the first pen handwriting in the drawing area, the electronic device saves the texture data 1 and stacks the information of the first pen handwriting.

[0192] S1003, in response to the user drawing the second pen handwriting in the drawing area, the electronic device detects whether the newly-stacked stack element reaches the first threshold.

[0193] S1004, when the newly-stacked stack element does not reach the first threshold, the electronic device updates the texture data 1 according to the texture data 3 and stacks the information of the second pen handwriting.

[0194] S1001-S1004 can refer to the description in S801-S803 and S805-S806.

[0195] S1005, receiving an undo instruction.

[0196] For example, referring to FIG. 1, on the drawing interface 101, the user can operate the identifier 112 of the undo function to trigger the electronic device to receive the undo instruction. In the embodiments of the present application, the manner in which the user triggers the undo instruction is not limited, for example, the user can also use the voice to say the voice of "undo the handwriting" to trigger the electronic device to receive the undo instruction.

[0197] In S1006, the electronic device restores the texture data of the second sub-region associated with the second pen handwriting in the first work state to the drawing region.

[0198] In response to the undo instruction, the electronic device can find the last saved texture data. In the embodiments of the present application, before the electronic device receives the undo instruction, the electronic device has updated the texture data 1 once, and therefore the last saved texture data includes the texture data 1 and the texture data 3.

[0199] The electronic device can obtain the texture data of the second sub-region associated with the second pen handwriting from the texture data 1 and the texture data 3, and restore the texture data of the second sub-region to the drawing region.

[0200] In some embodiments, because the top element of the stack is the information of the second pen handwriting, and the information of the second pen handwriting includes the identifier of the second sub-region associated with the second pen handwriting, the electronic device can obtain the identifier of the second sub-region from the top element. It should be understood that the texture data 1 and the texture data 3 include the texture data of the sub-region, and the sub-regions in the texture data 1 and the texture data 3 can overlap, and therefore the electronic device can obtain the texture data associated with the second sub-region from the texture data 1 and the texture data 3 according to the identifier of the second sub-region.

[0201] The electronic device restoring the texture data of the second sub-region to the drawing region refers to the electronic device rendering the texture data of the second sub-region. In some embodiments, when the electronic device saves the texture data of the second sub-region, the electronic device can save the texture data of the second sub-region in the first space of the memory. The electronic device restoring the texture data of the second sub-region to the drawing region refers to the electronic device copying the texture data of the second sub-region in the first space, writing the copied texture data into the second space of the memory, and rendering the texture data in the second space to make the drawing region display the second pen handwriting.

[0202] Because the texture data of the second sub-region is the texture data of the second sub-region in the first work state, and because the second pen handwriting is not included in the second sub-region in the first work state, the electronic device rendering the texture data of the second sub-region can make the drawing region undo the texture data of the second sub-region, that is, undo the second pen handwriting.

[0203] S1007, when the first sub-region associated with the first stroke of handwriting and the second sub-region associated with the second stroke of handwriting exist overlap, the electronic device redraws the first stroke of handwriting.

[0204] It should be noted that when the first sub-region associated with the first stroke of handwriting and the second sub-region associated with the second stroke of handwriting do not exist overlap, the electronic device displays the texture data of the second sub-region in the first work state, and the drawing area can not display the second stroke of handwriting in the second sub-region, that is, the second stroke of handwriting is cancelled. However, when the first sub-region associated with the first stroke of handwriting and the second sub-region associated with the second stroke of handwriting exist overlap, the electronic device displays the texture data of the second sub-region in the first work state, and the drawing area does not display the second stroke of handwriting in the second sub-region, and also does not display the first stroke of handwriting in the sub-region where the first sub-region and the second sub-region overlap, and the first stroke of handwriting is short, at this time, the electronic device needs to redraw the first stroke of handwriting to realize the cancellation of only the second stroke of handwriting.

[0205] Because the information of the first stroke of handwriting in the stack includes the identification of the first sub-region associated with the first stroke of handwriting, and the information of the second stroke of handwriting includes the identification of the second sub-region associated with the second stroke of handwriting, in some embodiments, after the electronic device restores the texture data of the second sub-region associated with the second stroke of handwriting to the drawing area, the electronic device can query the stack elements, such as the electronic device can query the information of the first stroke of handwriting and the information of the second stroke of handwriting, and detect whether the first sub-region associated with the first stroke of handwriting and the second sub-region associated with the second stroke of handwriting exist overlap. When the first sub-region and the second sub-region exist overlap, the electronic device can redraw the first stroke of handwriting according to the information of the first stroke of handwriting.

[0206] In some embodiments, in order to reduce the drawing workload of the electronic device, the electronic device can determine the identification of the sub-region between the first sub-region and the second sub-region according to the information of the first stroke of handwriting and the information of the second stroke of handwriting. The electronic device can use the template test method to set the identification of the overlapping sub-region, so that the operation of the electronic device redrawing the first stroke of handwriting only takes effect in the overlapping sub-region.

[0207] It can be understood that in this example, 2 stack elements are taken as an example in the stack, when there are multiple stack elements in the stack, the electronic device can determine whether the second sub-region and the sub-region associated with each stroke of handwriting exist overlap according to the information of the second stroke of handwriting and the information of each stroke of handwriting. When there is overlap, the electronic device determines the identification of the sub-region where the second sub-region and the sub-region associated with each stroke of handwriting overlap. In this way, the electronic device can use the template test method to set the identification of the overlapping sub-region when redrawing different strokes of handwriting, and redraw the stroke of handwriting in the overlapping region corresponding to the stroke of handwriting.

[0208] For example, after the user draws the handwriting 1B, the electronic device saves the texture data 1, and the user draws the handwriting 2B and the handwriting 3B in sequence. The electronic device can update the texture data 1. The method in which the electronic device saves the texture data 1 and updates the texture data 1 can refer to the description of the embodiment in FIG. 8. After the user draws the handwriting 3B, the user performs the undo operation, and the electronic device can restore the texture data of the sub-region associated with the handwriting 3B in the first work state to the drawing region.

[0209] The electronic device detects whether the sub-region associated with the handwriting 1B overlaps the sub-region associated with the handwriting 3B according to the information of the handwriting 1B and the information of the handwriting 3B stored in the stack, and detects whether the sub-region associated with the handwriting 2B overlaps the sub-region associated with the handwriting 3B according to the information of the handwriting 2B and the information of the handwriting 3B stored in the stack. It is assumed that the sub-region associated with the handwriting 1B overlaps the sub-region associated with the handwriting 3B by one sub-region, which is the sub-region 1, and the sub-region associated with the handwriting 2B overlaps the sub-region associated with the handwriting 3B by two sub-regions, which are the sub-region 2 and the sub-region 3.

[0210] After the electronic device restores the texture data of the sub-region associated with the handwriting 3B in the first work state to the drawing region, the electronic device can set the identifier of the sub-region 1 and redraw the handwriting 1B by using the template test method, so that the handwriting 1B takes effect in the sub-region 1. Similarly, the electronic device can set the identifiers of the sub-region 2 and the sub-region 3 and redraw the handwriting 2B by using the template test method, so that the handwriting 2B takes effect in the sub-region 2 and the sub-region 3. In this way, the electronic device can undo the handwriting 3B.

[0211] Here, taking the example in FIG. 9B as an example, the process in which the electronic device performs the undo operation is introduced. Referring to a in FIG. 11, the drawing region includes two handwritings that already exist when the drawing APP is opened, the handwriting 1A, and the handwriting 2A. The user operates the identifier 112 of the undo function, which can trigger the electronic device to receive the undo instruction. In response to the undo instruction, the electronic device searches for the texture data that is saved most recently, which includes the texture data 1 and the texture data 3.

[0212] The texture data 1 is the texture data of the first sub-region in the first work state, and the first sub-region is the four sub-regions associated with the handwriting 1A. The texture data 3 is the texture data of the third sub-region in the first work state, and the third sub-region is the sub-region associated with the handwriting 2A and not included in the first sub-region, and the third sub-region has two sub-regions. The first sub-region overlaps the third sub-region by one sub-region. In the embodiment of the present application, the electronic device can obtain the texture data of the three sub-regions associated with the handwriting 2A from the texture data 1 and the texture data 3 according to the identifier of the second sub-region associated with the second handwriting at the top of the stack.

[0213] The electronic device restores the texture data of the 3 sub-regions associated with the stroke 2A to the drawing region, and the drawing region displays the content as shown in FIG. 11b. It is worth noting that, because the 4 sub-regions associated with the stroke 1A overlap with the 3 sub-regions associated with the stroke 2A in the sub-region 8, when the electronic device restores the texture data of the 3 sub-regions associated with the stroke 2A to the drawing region, the texture data in the sub-region 8 in the stroke 1A in the first work state is also restored to the drawing region.

[0214] Because the first work state does not contain the stroke 1A and the stroke 2A, when the texture data of the 3 sub-regions associated with the stroke 2A is restored to the drawing region, no stroke is displayed in the 3 sub-regions associated with the stroke 2A, and referring to FIG. 11b, the stroke 1A is missing in the sub-region 8. The electronic device needs to redraw the stroke 1A to achieve the purpose of only undoing the stroke 2A.

[0215] In some embodiments, the electronic device can redraw the strokes according to the stack elements saved in the stack. For example, the electronic device can redraw the stroke 1A according to the first stack element “information of the stroke 1A”. After the electronic device re-executes the drawing operation, the drawing region can display the stroke 1A completely, as shown in FIG. 11c.

[0216] Because the electronic device restores the texture data of the 3 sub-regions associated with the stroke 2A to the drawing region, only the part of the stroke in the first sub-region associated with the stroke 1A in the overlapping sub-region is affected, in some embodiments, in order to reduce the drawing workload of the electronic device, the electronic device can determine the identifier of the overlapping sub-region in the 4 sub-regions associated with the stroke 1A and the 3 sub-regions associated with the stroke 2A according to the first stack element “information of the stroke 1A” and the second stack element “information of the stroke 2A”. The electronic device can set the identifier of the overlapping sub-region by using the template test method, so that the operation of the electronic device redrawing the stroke 1A is only effective in the overlapping sub-region.

[0217] It can be understood that, when the electronic device undoes the second stroke, if the user performs a recovery operation, the electronic device can redraw the second stroke according to the information of the second stroke in the stack, and the embodiments of the present application do not make a detailed description of this.

[0218] It can be conceived that, after the user performs an undo operation once, if the user continues to perform the undo operation, the electronic device can perform S1106 in response to the undo instruction this time, and continue to perform S1107 after S1106:

[0219] S1107, the electronic device restores the texture data of the first sub-region in the first work state to the drawing region.

[0220] S1107 can refer to the related description in S1106.

[0221] In the scenario of canceling the handwriting, the electronic device can query the last saved texture data, restore the texture data of the sub-region associated with the handwriting of the first pen in the first work state to the drawing region, and thus the handwriting of the first pen can be canceled. In addition, when the sub-region associated with the handwriting of the first pen overlaps with the sub-region associated with the handwriting of the previous pen, the electronic device can also use the stencil test method to redraw the handwriting of the overlapping region in the overlapping sub-region, which not only reduces the drawing workload, but also enables the drawing region to display the previous handwriting completely, and thus the canceling operation is achieved.

[0222] As described in the above embodiments, when the user performs the first several pen operations after the drawing APP is opened, the electronic device saves the texture data, stacks, and cancels the operation, and the method in the above embodiments can be applied to any drawing operation. In summary, the drawing method in the embodiments of the present application is summarized as follows:

[0223] Referring to FIG. 12A, the drawing method provided by the embodiments of the present application can include:

[0224] S1201, in response to a first drawing operation, displaying first handwriting in the drawing region.

[0225] The first drawing operation can be regarded as a drawing operation of the user in the drawing region. In response to the first drawing operation, the electronic device can display the first handwriting in the drawing region. For example, the first drawing operation is that the user draws the first pen handwriting after the drawing APP is opened, and the first handwriting can be the first pen handwriting. For example, the first drawing operation is that the user draws the second pen handwriting, and the first handwriting can be the second pen handwriting.

[0226] S1202, save the first texture data and the information of the first handwriting.

[0227] In some examples, the first texture data includes: texture data of the first sub-region in the first work state, the first work state is: a state of the work in the drawing region before the first handwriting is displayed, and the first sub-region is: a sub-region associated with the first handwriting in the drawing region.

[0228] For example, when the first handwriting is the first pen handwriting, the first texture data is texture data 1, the first work state is the work state when the drawing APP is opened, and the first sub-region is the sub-region associated with the first pen handwriting in the drawing region. This example can refer to the description in S802.

[0229] For example, the first stroke is a second pen stroke, and the newly pushed stack element reaches the first threshold, the electronic device can include the first texture data. In this example, the first texture data is texture data 2, the first work state is a work state before the second pen stroke is drawn, and the first sub-region is a sub-region associated with the second pen stroke in the drawing region. This example can be understood with reference to the description of S804.

[0230] In some embodiments, the electronic device can save the first texture data and information of the first stroke in the memory. The information of the first stroke can be understood with reference to the description of the above embodiments.

[0231] In some embodiments, the electronic device can save the information of the first stroke in the form of a stack. For example, the electronic device can push the information of the first stroke as a first stack element. In some embodiments, the stack can be saved in the memory of the electronic device.

[0232] S1203, in response to the second drawing operation, displaying the second stroke in the drawing region.

[0233] S1203 can be understood with reference to the description of S1201.

[0234] In some embodiments, the second drawing operation can be an operation adjacent to the first drawing operation. For example, the first stroke is a first pen stroke, and the second stroke can be a second pen stroke. For example, the first stroke is a second pen stroke, and the second stroke can be a third pen stroke.

[0235] S1204, on the basis of the first texture data, adding second texture data, and saving information of the second stroke.

[0236] The second texture data includes texture data of the second sub-region in the first work state.

[0237] In some embodiments, the second sub-region is a sub-region associated with the second stroke in the drawing region. The sub-region associated with the second stroke can be understood as a sub-region in the drawing region that contains the second stroke.

[0238] In some embodiments, the electronic device can save one texture data, such as the first texture data, and in the process of subsequent user drawing, the electronic device can no longer save new texture data, but constantly update the first texture data based on the user's drawing operation. In this example, in response to the second drawing operation, the electronic device displays the second stroke in the drawing region, adds the second texture data on the basis of the first texture data, and saves the information of the second stroke. It can be understood that in this example, in response to the user's undo operation, the electronic device can use the method of undoing the stroke in FIG. 10 to undo the stroke.

[0239] In some embodiments, in response to the second drawing operation, the electronic device can detect whether the number of strokes that have saved information reaches a first threshold value starting from the information of the first stroke. Wherein, the information of the first stroke needs to be taken into account when the electronic device detects whether the number of strokes that have saved information reaches the first threshold value.

[0240] In this example, when the number of strokes that have saved information does not reach the first threshold value starting from the information of the first stroke, the electronic device does not save new texture data, but updates the first texture data. In the embodiments of the present application, the electronic device can add second texture data on the basis of the first texture data to achieve the purpose of updating the first texture data.

[0241] In some embodiments, when the information of the strokes is stored in the form of a stack, the electronic device can stack the information of the second stroke as a second stack element, and at this time, the top element of the stack is the information of the second stroke.

[0242] In this example, S1204 can include S1205 before it:

[0243] S1205, detecting whether the number of strokes that have saved information reaches a first threshold value starting from the information of the first stroke.

[0244] It should be understood that in some embodiments, S1205 is an optional step, so S1205 is represented by a dashed line in FIG. 12A.

[0245] Correspondingly, when it is determined that the number of strokes that have saved information does not reach the first threshold value starting from the information of the first stroke, the electronic device adds second texture data on the basis of the first texture data, and saves the information of the second stroke.

[0246] In some embodiments, when the information of the strokes is saved in the form of a stack, the electronic device can stack the information of the strokes as stack elements when saving the information of the strokes. For example, in S1202, the electronic device can stack the information of the first stroke as a first stack element. In this example, in response to the second drawing operation, the electronic device can detect whether the newly stacked stack elements reach a first threshold value starting from the first stack element.

[0247] Wherein, when the newly stacked stack elements do not reach the first threshold value starting from the first stack element, the electronic device can update the first texture data. In the embodiments of the present application, the electronic device can add second texture data on the basis of the first texture data to achieve the purpose of updating the first texture data.

[0248] For example, referring to the description in S805 and S806, when the first stroke is the first pen stroke, the second stroke is the second pen stroke, and the first threshold is greater than or equal to 2, the second texture data is the texture data 3, which can be referred to the description in S805.

[0249] S1206, in response to the revocation instruction, restoring the texture data of the second sub-region to the drawing region, so that the drawing region does not display the second stroke.

[0250] In some embodiments, when saving the texture data, the electronic device can save the identifier of the sub-region corresponding to the texture data. For example, when the electronic device saves the first texture data, it can be understood that the electronic device saves the first texture data and the identifier of the first sub-region. For example, when the electronic device adds the second texture data on the basis of the first texture data, it can be understood that the electronic device adds the saving of the second texture data and the identifier of the second sub-region on the basis of the saving of the first texture data and the identifier of the first sub-region. In this embodiment, the electronic device can obtain the second texture data from the saved texture data according to the identifier of the second sub-region.

[0251] In some embodiments, the electronic device can obtain the identifier of the sub-region associated with the second stroke from the information of the second stroke (i.e., the second stack element). The electronic device obtains the texture data of the sub-region associated with the second stroke from the last saved texture data (the first texture data and the second texture data) according to the identifier of the sub-region associated with the second stroke. After the electronic device obtains the texture data of the sub-region associated with the second stroke, the electronic device can restore the texture data of the sub-region associated with the second stroke to the drawing region.

[0252] The top element of the stack is the information of the second stroke, and the information of the second stroke includes: the identifier of the second sub-region, the coordinates of the plurality of track points in the second stroke, and the attributes of the second stroke. For example, the data of the second stroke can include but is not limited to: the color and thickness of the second stroke. The electronic device can obtain the identifier of the sub-region associated with the second stroke from the top element of the stack, and obtain the texture data of the second sub-region from the first texture data and the second texture data according to the identifier of the second sub-region.

[0253] Because the first texture data and the second texture data are both texture data of the sub-region in the first work state, in the case that there is an overlapping third sub-region between the second sub-region and the first sub-region, the electronic device has already saved the texture data of the third sub-region when saving the first texture data. In some embodiments, the first sub-region can include the third sub-region, or the first sub-region is the third sub-region.

[0254] In some embodiments, in order to reduce the data amount of the texture data stored by the electronic device, and in order to reduce the memory occupation, when updating the first texture data, the electronic device can add the second texture data, which can include the texture data of the sub-regions in the second sub-region except the third sub-region in the first work state.

[0255] In this embodiment, the first texture data contains the texture data of part of the second sub-region (such as the third sub-region), and the second texture data contains the texture data of part of the second sub-region. In response to the undo instruction, the electronic device can obtain the identifier of the second sub-region associated with the second pen mark in the information of the second pen mark, and obtain the texture data of the second sub-region in the first texture data and the second texture data according to the identifier of the second sub-region. In this way, the electronic device can restore the texture data of the second sub-region to the drawing area, so that the drawing area does not display the second pen mark, achieving the purpose of undoing the second pen mark.

[0256] In some embodiments, when the second pen mark overlaps with the first pen mark, and there is an overlapping third sub-region between the first sub-region and the second sub-region, when the electronic device restores the texture data of the second sub-region associated with the second pen mark in the first state to the drawing area, the electronic device can also undo the pen mark in the third sub-region, that is, the pen mark in the first sub-region is also undone, that is, part of the first pen mark is also undone, resulting in a shortage of the first pen mark. The electronic device can redraw the first pen mark, so that the drawing area can display the first pen mark completely when the second pen mark is undone.

[0257] In this example, with reference to FIG. 12B, after performing S1206, the electronic device can further perform the following steps:

[0258] S1207, drawing the pen mark of the first pen mark in the third sub-region.

[0259] The first stack element is the information of the first pen mark, and the information of the first pen mark includes the identifier of the first sub-region, the coordinates of the plurality of track points in the first pen mark, and the attribute of the first pen mark. The second stack element is the information of the second pen mark, and the information of the second pen mark includes the identifier of the second sub-region, the coordinates of the plurality of track points in the second pen mark, and the attribute of the second pen mark.

[0260] In some embodiments, when the electronic device stores the texture data, and also stores the identifier of the sub-region corresponding to the texture data, the electronic device can detect whether there is an overlapping third sub-region between the first sub-region corresponding to the first texture data and the second sub-region corresponding to the second texture data according to the identifier of the first sub-region corresponding to the first texture data and the identifier of the second sub-region corresponding to the second texture data.

[0261] In some embodiments, the electronic device can query the first stack element and the second stack element, and detect whether there is an overlapped third sub-region between the first sub-region and the second sub-region according to the identification of the first sub-region and the identification of the second sub-region. It should be understood that when there is a same identification in the identification of the first sub-region and the identification of the second sub-region, the electronic device determines that the sub-region corresponding to the identification is an overlapped sub-region.

[0262] In the embodiments of the present application, when there is an overlapped third sub-region between the first sub-region and the second sub-region, the electronic device can draw the handwriting of the first handwriting in the third sub-region, so that the drawing region can completely display the first handwriting.

[0263] In some embodiments, the electronic device can set the identification of the third sub-region by using a template test method. In this way, the electronic device can draw the handwriting according to the coordinates of the plurality of track points in the first handwriting and the attribute of the first handwriting, and the drawn handwriting is effective in the third sub-region. In other words, after the electronic device sets the identification of the third sub-region by using the template test method, the electronic device can draw the handwriting of the first handwriting in the third sub-region.

[0264] It can be envisaged that the user performs a recovery operation, which can trigger the electronic device to recover the second handwriting. Correspondingly, in response to the recovery instruction, the electronic device can draw the second handwriting according to the information of the second handwriting, so that the drawing region displays the second handwriting.

[0265] It should be understood that the embodiments of the present application summarize the drawing methods in FIG. 8 and FIG. 10, and the embodiments of the present application have the same technical effects as the above-mentioned embodiments, and the description in the above-mentioned embodiments can be referred to.

[0266] In some embodiments, the second drawing operation can be an operation that is not adjacent to the first drawing operation. For example, the first handwriting is a first pen handwriting, and the second handwriting can be a third pen handwriting. In this example, the user can draw a plurality of pen handwritings in the drawing region, and the electronic device can perform the drawing method in the following embodiments.

[0267] In a possible scenario, for example, in the scenario that the user draws a third pen handwriting between the first handwriting and the second handwriting, in response to the first drawing operation, the electronic device displays the first handwriting in the drawing region. The electronic device can save the first texture data and stack the first stack element. In response to the third drawing operation, the electronic device displays the third handwriting in the drawing region.

[0268] In some embodiments, in response to the second drawing operation, the electronic device can add third texture data on the basis of the first texture data, and save the information of the third handwriting.

[0269] In some embodiments, in response to the second drawing operation, the electronic device can detect whether the newly-stacked stack elements starting from the first stack element reach a first threshold. When the newly-stacked stack elements do not reach the first threshold, the electronic device can add third texture data to the first texture data, and save information of the third stroke.

[0270] In some embodiments, the third texture data includes texture data of the fourth sub-region in the first work state. The fourth sub-region is a sub-region associated with the third stroke in the drawing region.

[0271] In some embodiments, to reduce the memory occupied by the texture data, the third texture data includes texture data of a sub-region in the fourth sub-region that does not overlap with the first sub-region and the second sub-region in the first work state. The third texture data can refer to the related description of the second texture data.

[0272] In some embodiments, when the information of the strokes is stored in the form of a stack, the electronic device can stack the information of the third stroke as a third stack element. The information of the third stroke can include an identifier of the fourth sub-region associated with the third stroke, coordinates of the plurality of track points in the third stroke, and attributes of the third stroke.

[0273] In response to the second drawing operation, the electronic device displays the second stroke in the drawing region, and detects whether the newly-stacked stack elements starting from the first stack element reach the first threshold. When the newly-stacked stack elements do not reach the first threshold, the electronic device can add second texture data to the first texture data and the third texture data, and stack the second stack element.

[0274] For example, the first stroke is a first pen stroke, the third stroke is a second pen stroke, and the second stroke is a third pen stroke.

[0275] In this scenario, in response to the undo instruction, the electronic device can obtain texture data of the second sub-region from the first texture data, the third texture data, and the second texture data according to the identifier of the second sub-region, and restore the texture data of the second sub-region to the drawing region.

[0276] In some embodiments, the electronic device can detect, according to the identification of the second sub-region and the identification of the fourth sub-region, whether there is an overlapping sixth sub-region between the second sub-region and the fourth sub-region, and detect, according to the identification of the first sub-region and the identification of the second sub-region, whether there is an overlapping third sub-region between the second sub-region and the first sub-region. When there is an overlapping fourth sub-region between the second sub-region and the first sub-region, the electronic device can draw the first stroke in the fourth sub-region. When there is an overlapping sixth sub-region between the second sub-region and the fourth sub-region, the electronic device can draw the third stroke in the sixth sub-region. For details, please refer to the description of "the electronic device draws the first stroke in the third sub-region".

[0277] In the embodiments of the present application, in the scenario where the user draws multiple strokes, when the electronic device restores the texture data of the second sub-region to the drawing area, the electronic device can determine, according to the information of the second stroke and the information of each stroke, whether the second sub-region overlaps with the sub-region associated with each stroke. When there is an overlap, the electronic device can use the template test method to set the identification of the overlapping sub-region when redrawing different strokes, and redraw the stroke in the overlapping area corresponding to the different strokes, so as to achieve the purpose of canceling only the second stroke.

[0278] The above embodiments describe the scenario where the electronic device detects that the newly stacked stack element does not reach the first threshold from the first stack element. In some embodiments, after the second stack element is stacked, the electronic device displays the fourth stroke in the drawing area in response to the fourth drawing operation. In this example, the electronic device can detect whether the newly stacked stack element reaches the first threshold from the first stack element.

[0279] When the newly stacked stack element reaches the first threshold, the electronic device can save the fourth texture data and stack the fourth stack element. The fourth texture data includes: the texture data of the fifth sub-region in the second work state, the second work state is the state of the work in the drawing area before the fourth stroke is displayed, the fifth sub-region is the sub-region associated with the fourth stroke in the drawing area, and the fourth stack element is the information of the fourth stroke.

[0280] For details, please refer to the description of S804 and S808.

[0281] In summary, the following describes the drawing method provided by the embodiments of the present application from the perspective of images or works. It should be understood that the scenario where the second block for drawing the second stroke does not overlap with the first block for drawing the first stroke is introduced in FIG. 12C, and the scenario where the block for drawing the second stroke overlaps with the block for drawing the first stroke is introduced in FIG. 12D, for example, the block for drawing the second stroke and the block for drawing the first stroke are both the first block.

[0282] It should be understood that the block can correspond to the sub-region in the above embodiments, the first block can correspond to at least one sub-region, and the second block can also correspond to at least one sub-region.

[0283] Referring to FIG. 12C, the drawing method provided by the embodiments of the present application can include:

[0284] S1201C, displaying a first image, the first image including a plurality of blocks.

[0285] The image can be understood as a work drawn by the user. The first image can include a trace or not include a trace. Illustratively, the first image can be an image displayed by the drawing area when the drawing APP is opened, which can include a trace drawn by the user or not include a trace. Illustratively, the first image can be an image displayed by the drawing area after the user draws a few traces after the drawing APP is opened.

[0286] S1202C, in response to a first drawing operation on a first block, displaying a second image, the second image including the first image and a first trace corresponding to the first drawing operation.

[0287] The first block is included in the plurality of blocks. In some embodiments, the first block can correspond to at least one sub-region, and the sub-region can be understood with reference to the description in the above embodiments.

[0288] The user can draw in the first block, and the electronic device can display the second image in response to the first drawing operation on the first block. The second image includes the first image and a first trace corresponding to the first drawing operation. In other words, compared with the first image, the second image adds the first trace, and the first trace occupies the first block.

[0289] S1203C, saving information of the first block based on the first image and the first trace.

[0290] The electronic device can save information of the first block based on the first image and the first trace. The information of the first trace can include but is not limited to: an identifier of the first block, coordinates of a plurality of track points in the first trace, and attributes of the first trace, etc.

[0291] The electronic device saving the first block based on the first image can be understood as: the electronic device saving texture data of the first block based on the first image. In other words, the electronic device can save the texture data of the first block in the first image.

[0292] S1204C, in response to a second drawing operation on a second block, displaying a third image, the third image including the second image and a second trace corresponding to the second drawing operation, the first block and the second block not overlapping.

[0293] After the user draws the first stroke in the first block, the user can continue to draw strokes. In response to a second drawing operation on the second block, the electronic device can display a third image. The third image includes the second image and a second stroke corresponding to the second drawing operation. In other words, the third image adds the second stroke to the second image, and the second stroke occupies the second block.

[0294] In some embodiments, the first block and the second block do not overlap.

[0295] In some embodiments, the first block and the second block are in the same layer. The layer can be understood as a layer created by the user in the drawing APP.

[0296] S1205C, save information of the second block and the second stroke based on the first image.

[0297] In the case where the first block and the second block do not overlap, the electronic device can save information of the second block and the second stroke based on the first image. The information of the second stroke can include but is not limited to the identification of the second block, the coordinates of the plurality of track points in the second stroke, and the attributes of the second stroke, etc. In some embodiments, the electronic device can save the information of the stroke in the form of a stack, for example, the electronic device can stack the information of the first stroke.

[0298] The electronic device saves the second block based on the first image, which can be understood as that the electronic device saves the texture data of the second block based on the first image. In other words, the electronic device can save the texture data of the second block in the first image.

[0299] In this embodiment, after S1205C, it can further include:

[0300] S1206C, in response to the undo instruction, processing the third image based on the second block, and displaying the second image.

[0301] After the user draws the second stroke in the second block, the user can also perform an undo operation. In response to the undo instruction, the electronic device can process the third image based on the second block and display the second image, so as to achieve the purpose of undoing the second stroke in the third image.

[0302] In the embodiment of the present application, in response to the undo instruction, the electronic device can undo the second stroke in the third image based on the second block, so that the electronic device can display the second image. In other words, the electronic device can undo the second stroke in the third image based on the saved texture data of the second block.

[0303] It can be understood that the user can also perform a recovery operation to recover the second handwriting, and accordingly, the electronic device can draw the second handwriting based on the information of the second handwriting in response to the recovery instruction, so that the electronic device can display the third image.

[0304] It should be understood that the embodiments of the present application have the same technical effects as those of FIGS. 12A and 12B, and the descriptions in the above embodiments can be referred to.

[0305] Referring to FIG. 12D, the drawing method provided by the embodiments of the present application can include:

[0306] S1201D, displaying a first image, the first image including a plurality of blocks.

[0307] S1202D, in response to a first drawing operation on a first block, displaying a second image, the second image including the first image and information of a first handwriting corresponding to the first drawing operation.

[0308] S1203D, saving the information of the first handwriting based on the first block of the first image.

[0309] S1201D-S1203D can refer to the descriptions in S1201C-S1203C.

[0310] S1204D, in response to a second drawing operation on the first block, displaying a third image, the third image including the second image and a second handwriting corresponding to the second drawing operation.

[0311] Different from the embodiment shown in FIG. 12C, in the embodiments of the present application, the user draws the second handwriting in the first block when drawing the second handwriting, and the first block is also the block in which the user draws the first handwriting, that is, the block of the second handwriting overlaps the block of the first handwriting.

[0312] In this example, in response to the second drawing operation on the first block, the third image is displayed, and the third image includes the second image and the second handwriting corresponding to the second drawing operation.

[0313] S1205D, saving the information of the second handwriting.

[0314] In this example, because the block of the second handwriting overlaps the block of the first handwriting, both are the first block, and the electronic device has already saved the first block based on the first image when saving the texture data, therefore, after the user draws the second handwriting, in order to reduce the memory occupation, the electronic device does not need to save the first block based on the first image, but saves the information of the second handwriting.

[0315] In some embodiments, the electronic device can save the information of the handwriting in the form of a stack, for example, the electronic device can stack the information of the second handwriting.

[0316] In this embodiment, after S1205D, the method can further include:

[0317] S1206D, in response to the undo instruction, processing the third image based on the information of the first block and the first handwriting, and displaying the second image.

[0318] After the user draws the second handwriting in the first block, the user can further perform an undo operation. In this example, because the block of the second handwriting overlaps with the block of the first handwriting, both are the first block, the electronic device can undo the second handwriting in the third image based on the first block. But because the block of the second handwriting overlaps with the block of the first handwriting, the electronic device saves the first block based on the first image, and the first block in the first image does not exist the first handwriting and the second handwriting, so when the electronic device undoes the second handwriting in the third image based on the first block, the first handwriting in the third image will also be undone.

[0319] In this embodiment, in order to achieve the purpose of only undoing the second handwriting and not undoing the first handwriting, the electronic device can further draw the first handwriting in the first block based on the information of the first handwriting, so as to ensure that the electronic device displays the second image.

[0320] It can be understood that the user can also perform a recovery operation to recover the second handwriting, and correspondingly, in response to the recovery instruction, the electronic device can draw the second handwriting based on the information of the second handwriting, and display the third image.

[0321] It should be understood that the embodiments of the present application have the same technical effects as the above-mentioned FIG. 12A and FIG. 12B, and can refer to the description in the above-mentioned embodiments.

[0322] As in the above embodiments, the electronic device can save the texture data and the stack in the memory. For example, the electronic device can save the texture data and the stack in the first space of the memory. However, when the number of drawing operations is large, the texture data saved by the electronic device is also large, which reduces the available memory of the electronic device. In some embodiments, in order to avoid the problem that the texture data occupies a large amount of memory, the electronic device can write the texture data in the memory to the hard disk, and delete the texture data in the memory.

[0323] For example, the electronic device can write the texture data in the memory to the hard disk every time the texture data is saved or updated in the memory. For example, when the memory occupied by the texture data reaches a second threshold, the electronic device can write the texture data in the memory to the hard disk.

[0324] For example, the electronic device can save the texture data of the last Z times in the memory and write the previously saved texture data to the hard disk. Alternatively, when the memory occupied by the texture data reaches a second threshold, the electronic device can save the texture data of the last Z times in the memory and write the previously saved texture data to the hard disk. Z is an integer greater than or equal to 2.

[0325] Embodiments of the present application do not limit the timing of writing the texture data in the memory to the hard disk by the electronic device, as exemplified above.

[0326] Referring to the embodiment shown in FIG. 12A, in response to the undo instruction, the electronic device restores the texture data of the sub-region associated with the second handwriting to the drawing region, but if the texture data of the sub-region associated with the second handwriting is written to the hard disk, the electronic device needs to first write the texture data of the sub-region associated with the second handwriting in the hard disk to the memory, and then restore the texture data of the sub-region associated with the second handwriting to the drawing region. Wherein, the electronic device reading data from the hard disk and writing to the memory will increase the time delay of the undo operation, which will cause problems such as undo lag, delay, etc.

[0327] To solve this problem, in embodiments of the present application, the electronic device can write the texture data of the sub-region associated with the second handwriting in the hard disk to the memory in advance before using the texture data of the sub-region associated with the second handwriting, so that when the electronic device performs the undo operation, it does not need to perform the reading operation, but directly restores the texture data of the sub-region associated with the second handwriting in the memory to the drawing region, reducing the time spent on the reading operation. In other words, the electronic device can preload the texture data of the sub-region associated with the second handwriting to reduce the time spent on the reading operation and avoid problems such as undo lag, delay, etc.

[0328] The following embodiments introduce methods for the electronic device to preload texture data:

[0329] Method 1:

[0330] In some embodiments, the electronic device can preload the texture data when the number of times of receiving the undo instruction reaches a third threshold within a preset time. In other words, when the user continuously performs multiple undo operations in a short period of time, the probability of the user continuing to perform the undo operation is high, so the electronic device can preload the texture data to reduce the time delay of the subsequent undo operation.

[0331] FIG. 13A shows a schematic diagram of the electronic device saving texture data. Referring to FIG. 13A, taking the first threshold value of 3 as an example, after the user draws the first pen stroke, the electronic device can save texture data once, such as texture data 1, and stack the information of the first pen stroke. After the user draws the second pen stroke, the electronic device can update the texture data 1, and stack the information of the second pen stroke. After the user draws the third pen stroke, the electronic device can update the texture data 1, and stack the information of the third pen stroke. Wherein, the method of the electronic device saving the texture data 1 and updating the data 1 can refer to the description in the above embodiments.

[0332] After the user draws the fourth pen stroke, the electronic device determines that the newly stacked stack elements reach 3, and the electronic device can save texture data again, such as texture data 2, and stack the information of the fourth pen stroke. After the user draws the fifth pen stroke, the electronic device can update the texture data 2, and stack the information of the fifth pen stroke. After the user draws the sixth pen stroke, the electronic device can update the texture data 2, and stack the information of the sixth pen stroke.

[0333] In this way, after the user draws multiple pen strokes, the texture data saved by the electronic device and the stack can be as shown in FIG. 13A.

[0334] Taking the electronic device writing all the texture data to the hard disk as an example, referring to FIG. 13B, taking the information of the sixth pen stroke as the current top element of the stack as an example, that is, the current top element is between the information of the fourth pen stroke and the information of the seventh pen stroke in the stack, in some embodiments, the fourth pen stroke can be regarded as the first stack element, and the seventh pen stroke can be regarded as the fourth stack element.

[0335] Taking the third threshold value of 2 as an example, when the electronic device receives the number of undo instructions within the preset time reaches 2, that is, the user continuously performs the undo operation twice in a short time, the electronic device undoes the sixth pen stroke and the fifth pen stroke. In this scenario, the electronic device determines that the probability of the user continuing to perform the undo operation is high, and the electronic device can preload the texture data 2, that is, the texture data 2 in the hard disk is written to the memory in advance before the user performs the undo operation again, so that when the user performs the undo operation again, the electronic device can directly restore the texture data 2 to the drawing area, and realize undoing the fourth pen stroke.

[0336] Similarly, in some embodiments, when the electronic device receives the recovery instruction for a third threshold number of times within a preset time, the electronic device can preload the texture data. For example, taking the information of the second stroke as the top element of the current stack and taking 2 as the third threshold, when the electronic device receives the recovery instruction for 2 times within the preset time, that is, the user continuously performs the recovery operation for 2 times in a short time, the electronic device recovers the second stroke and the third stroke. In this scenario, the electronic device determines that the probability of the user continuing to perform the recovery operation is high, and the electronic device can preload the texture data 2, that is, the electronic device writes the texture data 2 in the hard disk into the memory in advance before the user performs the recovery operation again. In this way, when the user performs the recovery operation again, the electronic device can directly recover the texture data 2 to the drawing area, thereby realizing the recovery of the fourth stroke.

[0337] Method 2:

[0338] In some embodiments, when the interval between the current top element and the adjacent target stack element reaches x stack elements, the electronic device preloads the texture data. The target stack element can be: the stack element corresponding to the last saved texture data, or the stack element corresponding to the next saved texture data. The stack element corresponding to the texture data can be understood as: the stack element that is entered when the texture data is saved.

[0339] For example, referring to FIG. 13C, taking the information of the sixth stroke as the top element of the current stack and taking 1 as the third threshold, the interval between the current top element and the stack element corresponding to the last saved texture data (i.e., the information of the fourth stroke) is 1 stack element (i.e., the information of the fifth stroke). In order to respond to the user's execution of the undo operation at this time in a timely manner, the electronic device can write the texture data 2 in the hard disk into the memory in advance. In this way, when the user performs the undo operation, the electronic device can directly recover the texture data 2 to the drawing area, thereby realizing the undo of the sixth stroke.

[0340] Similarly, the current top element is the information of the sixth stroke, and the current top element is adjacent to the stack element corresponding to the next saved texture data (i.e., the information of the seventh stroke). In order to respond to the user's execution of the recovery operation at this time in a timely manner, the electronic device can write the texture data 3 in the hard disk into the memory in advance. In this way, when the user performs the undo operation, the electronic device can directly recover the texture data 3 to the drawing area, thereby realizing the recovery of the seventh stroke.

[0341] Method 3:

[0342] In some embodiments, the electronic device can also preload the texture data according to the user's drawing habits. For example, the electronic device can constantly update the user's drawing habits according to the user's historical drawing data. The process of how the electronic device obtains the user's drawing habits is not described in detail in the embodiments of the present application, for example, model training or statistical methods can be used.

[0343] For example, the user will perform multiple undo operations when using a certain specific function, and the electronic device can preload the texture data. For example, when the user uses the eraser function, the user will make mistakes or erase too much, and the user will perform multiple undo operations. In this example, when the user uses the eraser function, the electronic device can preload one or more texture data before the current top element.

[0344] For example, the user will perform multiple undo operations when using a certain type of brush, and in this example, when the user uses a certain type of brush function, the electronic device can preload one or more texture data before the current top element.

[0345] It should be understood that in the embodiments of the present application, at least one of the method 1, the method 2, and the method 3 can be set in the electronic device in advance, so that the electronic device can preload the texture data.

[0346] It should be noted that based on the difference of the third threshold value, or the difference of the method logic set in the electronic device, the electronic device can preload one or more texture data before or after the current top element when preloading.

[0347] In the embodiments of the present application, before the user performs the undo operation or the restore operation, the electronic device can preload the texture data to be used, so that the electronic device can restore the texture data to the drawing area, implement the undo operation or the restore operation, reduce the time delay of the undo operation or the restore operation, and improve the user experience.

[0348] In some embodiments, the software system of the electronic device can adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. FIG. 14 is a structural schematic diagram of an electronic device provided by an embodiment of the present application. The layered architecture divides the software system of the electronic device into several layers, and each layer has a clear role and division of labor. Layers can communicate with each other through software interfaces.

[0349] In some embodiments, the software hierarchy of the electronic device can include an application layer and an application framework layer. In addition, the electronic device can also include a hardware layer. It should be understood that the present embodiments do not limit the layering of the software structure of the electronic device. The modules included in each layer in the following embodiments are the modules involved in the present embodiments, and the modules included in each layer in the following embodiments do not constitute a limitation on the structure of the electronic device, and the hierarchy of the deployment of the modules (example explanation) also does not constitute a limitation on the structure of the electronic device.

[0350] The application layer can include a series of application packages, and the application layer runs the application by calling the application programming interface (API) provided by the application framework layer.

[0351] Referring to FIG. 14, the application layer can include a work management module, a layer management module, and an operation stack. The work management module is used to manage the works in the drawing APP, and the works can be notes, drawings, etc. recorded by the user. The layer management module is used to manage the layers in the drawing APP, such as creating a new layer, deleting a layer, inserting a layer, etc. It should be understood that the layer is a layer visible to the user in the drawing APP.

[0352] The operation stack can be understood as the stack described in the above embodiments, and the stack can save information of the handwriting.

[0353] The application framework layer provides the API and programming framework for the application of the application layer. The application framework layer includes some pre-defined functions.

[0354] Referring to FIG. 14, the application framework layer can include a drawing engine system. The drawing engine system can include a brush drawing, a layer composition, a rendering pipeline, etc. The brush drawing is used to assist the electronic device to draw the handwriting. The layer composition is used to assist the electronic device to realize the layer composition of the handwriting in different layers. It should be understood that the layer is a layer in an image. The rendering pipeline is used to assist the electronic device to realize the handwriting rendering.

[0355] The drawing engine system can provide the API interface of the brush drawing, the layer composition, the free drawing, and the rendering pipeline, so as to avoid the interaction between the application and the API interface of the bottom layer. The API interface of the bottom layer includes but is not limited to the central processing unit (CPU) interface and the graphics processing unit (GPU) interface.

[0356] Referring to FIG. 14, the hardware layer can include a CPU and a GPU. The CPU can execute the steps performed by the electronic device in FIGS. 8, 10, 12A-12D of the above-described embodiments by calling a CPU interface. The GPU can call a GPU interface to render the handwriting when drawing the handwriting so that the drawing area can display the handwriting.

[0357] In other words, the CPU is mainly responsible for processing and maintaining various data structures, such as structure maintenance of an operation stack, stack element push and pop, current stack structure maintenance, texture data maintenance, etc. The GPU is mainly responsible for rendering the handwriting to output the handwriting to the drawing area.

[0358] It can be understood that the structure shown in FIG. 14 does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device can include more or fewer components than shown, or combine certain components, or split certain components, or different component arrangements. The illustrated components can be implemented in hardware, software, or a combination of software and hardware.

[0359] It should be noted that the data involved in the present application (including but not limited to data for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation portal for user to choose authorization or refusal.

[0360] In an embodiment, the present application also provides an electronic device. Referring to FIG. 15, the electronic device can include a processor 1501 (such as a CPU) and a memory 1502. The memory 1502 can include a high-speed random-access memory (RAM) and can also include a non-volatile memory (NVM), such as at least one disk memory. The memory 1502 can store various instructions for completing various processing functions and implementing the method steps of the present application.

[0361] Optionally, the electronic device involved in the present application can also include a power supply 1503, a communication bus 1504, and a communication port 1505. The communication port 1505 is used to realize the connection and communication between the electronic device and other external devices. In the embodiments of the present application, the memory 1502 is used to store computer executable program codes, and the program codes include instructions; when the processor 1501 executes the instructions, the instructions make the processor 1501 of the electronic device perform the actions in the above method embodiments, and the implementation principles and technical effects are similar, which will not be described here.

[0362] Optionally, the electronic device can further include a display screen 1506. The display screen 1506 is configured to display an interface of the electronic device.

[0363] It should be noted that the modules or components described in the above embodiments can be one or more integrated circuits configured to implement the above methods, for example, one or more application specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field programmable gate arrays (FPGAs), etc. For another example, when a certain module above is implemented in the form of a processing element scheduling code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of invoking program code, such as a controller. For another example, these modules can be integrated together to implement a system-on-a-chip (SOC).

[0364] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer readable storage medium or transferred from one computer readable storage medium to another computer readable storage medium, for example, the computer instructions can be transferred from one website, computer, server or data center to another website, computer, server or data center through wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) mode. The computer readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. integrated with one or more available media. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)), etc.

[0365] The term "multiple" in the present document refers to two or more. The term "and / or" in the present document is only used to describe the relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent three cases: A exists alone, A and B exist together, and B exists alone. In addition, the character " / " in the present document generally represents an "or" relationship between the associated objects before and after it; in the formula, the character " / " represents a "division" relationship between the associated objects before and after it.

[0366] It can be understood that various numerical numbers involved in the embodiments of the present application are only distinguished for convenience of description, and are not used to limit the scope of the embodiments of the present application.

[0367] It can be understood that the size of the serial number of each process in the embodiments of the present application does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

Claims

1. A rendering method, characterized by, The method comprises: displaying a first stroke in a drawing area in response to a first drawing operation; saving first texture data and information of the first stroke, the first texture data comprising texture data of a first sub-area in a first work state, the first work state being a state of a work in the drawing area before the first stroke is displayed, the first sub-area being a sub-area associated with the first stroke in the drawing area; displaying a second stroke in the drawing area in response to a second drawing operation; adding second texture data to the first texture data and saving information of the second stroke, the second texture data comprising texture data of a second sub-area in the first work state, the second sub-area being a sub-area associated with the second stroke in the drawing area; restoring the texture data of the second sub-area to the drawing area to make the drawing area not display the second stroke in response to a cancel instruction.

2. The method of claim 1, wherein, The adding of the second texture data to the first texture data and the saving of the information of the second stroke comprises: adding the second texture data to the first texture data and saving the information of the second stroke when the number of strokes whose information has been saved starting from the information of the first stroke does not reach a first threshold.

3. The method according to claim 1 or 2, characterized in that, The first sub-area and the second sub-area have a third sub-area overlapping therebetween, and the second texture data specifically comprises texture data of a sub-area in the second sub-area excluding the third sub-area in the first work state.

4. The method of claim 3, wherein, The method further comprises: drawing the first stroke in the third sub-area.

5. The method of claim 4, wherein, The information of the first stroke further comprises coordinates of a plurality of track points in the first stroke and attributes of the first stroke, and the drawing of the first stroke in the third sub-area comprises: setting an identifier of the third sub-area by using a template test method; drawing the first stroke in the third sub-area according to the coordinates of the plurality of track points in the first stroke and the attributes of the first stroke.

6. The method according to any one of claims 1-5, characterized in that, The method further comprises: drawing the second stroke according to the information of the second stroke in response to a restore instruction; and displaying the second stroke in the drawing area.

7. The method according to any one of claims 1 to 6, characterized in that, Before the displaying of the second stroke in the drawing area in response to the second drawing operation, the method further comprises: displaying a third stroke in the drawing area in response to a third drawing operation; adding third texture data to the first texture data and saving information of the third stroke, the third texture data comprising texture data of a fourth sub-area in the first work state, the fourth sub-area being a sub-area associated with the third stroke in the drawing area and not saved in the first work state.

8. The method of claim 7, wherein, The adding of the third texture data to the first texture data and the saving of the information of the third stroke comprises: adding the third texture data to the first texture data and saving the information of the third stroke when the number of strokes whose information has been saved starting from the information of the first stroke does not reach a first threshold.

9. The method according to any one of claims 1-8, characterized in that, The method further comprises: In response to a fourth drawing operation, display a fourth stroke in the drawing area; Determine that the number of saved strokes reaches a first threshold value from the information of the first stroke, save fourth texture data and information of the fourth stroke, the fourth texture data comprising: texture data of a fifth sub-region in a second work state, the second work state being a state of the work in the drawing area before the fourth stroke is displayed, the fifth sub-region being a sub-region associated with the fourth stroke in the drawing area.

10. A rendering method, characterized by, Comprise: Display a first image, the first image comprising a plurality of blocks; In response to a first drawing operation on a first block, display a second image, the second image comprising the first image and a first stroke corresponding to the first drawing operation; Save information based on the first block of the first image and the first stroke; In response to a second drawing operation on a second block, display a third image, the third image comprising the second image and a second stroke corresponding to the second drawing operation, the first block and the second block not overlapping; Save information based on the second block of the first image and the second stroke.

11. The method of claim 10, wherein, The method further comprises: In response to a cancel instruction, process the third image based on the second block, display the second image.

12. The method of claim 11, wherein, The processing of the third image based on the second block comprises: Based on the second block, cancel the second stroke in the third image.

13. The method according to claim 11 or 12, characterized in that, The method further comprises: In response to a restore instruction, draw the second stroke based on the information of the second stroke, display the third image.

14. The method according to any one of claims 10-13, characterized in that, The first block and the second block are in the same layer.

15. A rendering method, characterized by, Comprise: Display a first image, the first image comprising a plurality of blocks; In response to a first drawing operation on a first block, display a second image, the second image comprising the first image and information of a first stroke corresponding to the first drawing operation; Save information based on the first block of the first image and the first stroke; In response to a second drawing operation on the first block, display a third image, the third image comprising the second image and a second stroke corresponding to the second drawing operation; Save information of the second stroke.

16. The method of claim 15, wherein, The method further comprises: In response to a cancel instruction, process the third image based on the information of the first block and the first stroke, display the second image.

17. The method of claim 16, wherein, The processing of the third image based on the information of the first block and the first stroke comprises: Based on the first block, cancel the second stroke in the third image; Based on the information of the first stroke, draw the first stroke in the first block.

18. The method according to claim 16 or 17, characterized in that, The method further comprises: In response to a restore instruction, draw the second stroke based on the information of the second stroke, display the third image.

19. The method according to any one of claims 10-18, characterized by, The information of the first stroke comprises: an identifier of the first block, coordinates of a plurality of track points in the first stroke, and attributes of the first stroke.

20. An electronic device, comprising: The electronic device comprises: one or more processors and a memory; The memory is coupled with the one or more processors, and is configured to store computer program codes including computer instructions, and the one or more processors are configured to invoke the computer instructions to cause the electronic device to perform the method according to any one of claims 1-19.

21. A chip system, characterized by The chip system is applied to an electronic device, and the chip system includes one or more processors configured to invoke computer instructions to cause the electronic device to perform the method according to any one of claims 1-19.

22. A computer-readable storage medium, characterized in that, The computer readable storage medium includes computer instructions, and when the computer instructions run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1-19.

23. A computer program product, characterised in that, The computer program product includes computer program codes, and when the computer program codes run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1-19.