Drawing method, electronic equipment and related device

By dividing the drawing area into sub-areas and saving the texture data associated with the handwriting, the problems of large memory usage and incomplete undo in the existing technology are solved, and efficient memory management and handwriting recovery are achieved.

CN120653171APending Publication Date: 2025-09-16HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410291161.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-03-13
Publication Date
2025-09-16

AI Technical Summary

Technical Problem

In the prior art, electronic devices need to save the content of the drawing area after each drawing operation, resulting in excessive memory usage and inability to effectively restore covered handwriting during an undo operation.

Method used

The texture partitioning method is used to divide the drawing area into multiple sub-areas. Only the texture data of the sub-areas associated with the handwriting is saved, and the texture data is restored to the original state when the operation is undone, reducing memory usage and ensuring the integrity of the handwriting.

Benefits of technology

By saving the sub-region texture data associated with the handwriting, memory usage is reduced, the efficiency of undoing and restoring handwriting is improved, and the user experience is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120653171A_ABST
    Figure CN120653171A_ABST
Patent Text Reader

Abstract

The invention provides a drawing method, electronic equipment and a related device, in the method, when a user draws handwriting in a drawing area, the electronic equipment can store texture data of a sub-area associated with the handwriting instead of storing texture data of the whole drawing area, and memory occupation can be reduced. Besides, when the electronic equipment stores the texture data of the sub-region associated with the handwriting, the texture data of the sub-region associated with the handwriting in the drawing region before the handwriting is drawn can be stored, so that when the user triggers to cancel the handwriting, the electronic equipment can cancel the handwriting based on the texture data of the sub-region associated with the handwriting in the drawing region before the handwriting. And cancelling the handwriting.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of terminal technology, and in particular to a drawing method, electronic equipment, and related devices. Background Art

[0002] In a drawing application (APP), users can draw in the drawing area. The content drawn by the user can include but is not limited to text, patterns, etc. If a drawing error is made, the user can perform an undo operation to undo the drawing, and the drawing area can display the content after the previous drawing.

[0003] Currently, each time a user draws, the electronic device saves the contents of the drawing area. When the user undoes a drawing, the electronic device retrieves the previously saved contents and displays them in the drawing area. However, this solution requires the electronic device to save the contents of the drawing area after each drawing, which consumes a lot of memory. Summary of the Invention

[0004] The embodiments of the present application provide a drawing method, an electronic device, and related devices. The method can save texture data of sub-areas associated with handwriting and reduce memory usage.

[0005] In a first aspect, an embodiment of the present application provides a drawing method. The execution subject of the drawing method may be an electronic device or a chip or processor in the electronic device. The following description will be made using an electronic device as an example.

[0006] The user performs a first drawing operation in the drawing area, and in response to the first drawing operation, the electronic device displays the first handwriting corresponding to the first drawing operation in the drawing area. The electronic device can save the first texture data and the information of the first handwriting. It should be understood that in an embodiment of the present application, the electronic device can adopt a texture block method to divide the drawing area into multiple sub-areas. Among them, the first texture data includes: the texture data of the first sub-area in the first work state. The first work state is: the state of the work in the drawing area before the first handwriting is displayed. The first sub-area is: the sub-area associated with the first handwriting in the drawing area. The sub-area associated with the first handwriting can be understood as: the sub-area in the drawing area that contains the first handwriting. In some examples, the information of the first handwriting may include: the identifier of the first sub-area, the coordinates of multiple trajectory points in the first handwriting, and the attributes of the first handwriting, etc.

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

[0008] The user can perform an undo operation to undo the second handwriting. In this embodiment of the present application, in response to the undo command, 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 handwriting. In this embodiment of the present application, because the first work state does not contain the second handwriting, the electronic device restores the texture data of the second sub-area in the first work state to the drawing area. The second sub-area can display the handwriting in the first work state, that is, the drawing area does not display the second handwriting. In this way, the electronic device can achieve the purpose of undoing the second handwriting.

[0009] In an embodiment of the present application, when saving texture data or adding new texture data, the electronic device does not save the texture data for the entire drawing area, but instead saves the texture data for the sub-area associated with the handwriting. Compared to saving the texture data for all sub-areas of the drawing area, this can reduce the memory occupied by the texture data. In addition, when saving the texture data of the handwriting, the electronic device can also save the texture data of the previous work state of the handwriting, so that when the user triggers to undo the handwriting, the electronic device can undo the handwriting based on the texture data of the previous work state of the handwriting.

[0010] In one possible implementation, the electronic device can save texture data every few handwriting strokes, rather than saving texture data every time the user draws a handwriting, which can reduce memory usage. In this implementation, 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 with saved information has not reached the first threshold starting from the information of the first handwriting, that is, detect whether the electronic device has drawn the first threshold handwriting. The electronic device detects whether the number of handwritings with saved information has reached the first threshold, and the first handwriting needs to be included. When the electronic device determines that the number of handwritings with saved information has not reached the first threshold starting from the information of the first handwriting, the electronic device can update the first texture data, that is, the electronic device adds the second texture data on the basis of the first texture data, and saves the information of the second handwriting.

[0011] In one 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 that overlaps between the first sub-region and the second sub-region can be called 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: the texture data of the sub-region of the second sub-region except the third sub-region in the first work state. That is to say, in the case where there is an overlapping third sub-region 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 texture data of the third sub-region may not be included in the second texture data when the electronic device adds the second texture data, which can further reduce memory usage. 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 except the third sub-region in the first work state on the basis of the first texture data, which can also reduce memory usage.

[0012] In this implementation, when the electronic device cancels the second handwriting, the electronic device restores the texture data of the second sub-area associated with the second handwriting to the drawing area. Because the second handwriting is not included in the first work state, 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 handwriting in the first work state, that is, the drawing area does not display the second handwriting. However, because the second handwriting covers the first handwriting, when the electronic device cancels the second handwriting, it also cancels the handwriting covered by the second handwriting in the first handwriting, that is, the electronic device also cancels the handwriting of the first handwriting in the third sub-area. In this application, in order to achieve the purpose of the electronic device only canceling the second handwriting, in a possible implementation, the electronic device can redraw the first handwriting to ensure that the electronic device only cancels the second handwriting and does not mistakenly cancel the first handwriting. In some embodiments, the electronic device can draw the handwriting of the first handwriting in the third sub-area based on the coordinates of multiple track points in the first handwriting and the attributes of the first handwriting.

[0013] In one possible implementation, to reduce the electronic device's drawing workload and improve drawing speed and efficiency, the electronic device cancels the first handwriting in the third sub-region, eliminating the need for the electronic device to redraw all of the first handwriting. Instead, the electronic device can redraw the first handwriting in the third sub-region. In some embodiments, the electronic device can employ a template testing method to set an identifier for the third sub-region and draw the first handwriting in the third sub-region based on the coordinates of multiple track points in the first handwriting and the attributes of the first handwriting.

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

[0015] As described above, the method for an electronic device to cancel the second handwriting is described. In some embodiments, the user can also perform a restore operation to restore the second handwriting. In this example, in response to the restore instruction, the electronic device can draw the second handwriting based on the information of the second handwriting, and display the second handwriting in the drawing area. This can achieve the purpose of the electronic device restoring the second handwriting. In some embodiments, the electronic device can draw the second handwriting based on the coordinates of multiple track points in the second handwriting and the attributes of the second handwriting. In some embodiments, the electronic device can use a template test method to set the identifier of the third sub-area, and draw the second handwriting based on the coordinates of multiple track points in the second handwriting and the attributes of the second handwriting.

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

[0017] In response to a third drawing operation, or after the third handwriting is displayed in the drawing area, the electronic device may detect whether the number of handwritings with saved information starting from the first handwriting information has reached a first threshold. When the electronic device determines that the number of handwritings with saved information starting from the first handwriting information has not reached the first threshold, the electronic device may add third texture data based on the first texture data and save the third handwriting information. After the third handwriting, the user may draw a second handwriting in the drawing area. Accordingly, in response to the second drawing operation, the electronic device displays the second handwriting in the drawing area. In this example, the user draws three handwritings. In response to the second drawing operation or after the second handwriting is displayed in the drawing area, the electronic device may detect whether the number of handwritings with saved information starting from the first handwriting information has reached a first threshold. When the electronic device determines that the number of handwritings with saved information starting from the first handwriting information has not reached the first threshold, because the electronic device has already added the third texture data based on the first texture data, the electronic device may add the second texture data based on the first and third texture data.

[0018] In this example, when the electronic device undoes the second handwriting, in response to the undo instruction, the electronic device can obtain the texture data of the second sub-area from the first texture data, the third texture data, and the second texture data based on the identifier of the second sub-area. After obtaining the texture data of the second sub-area, the electronic device can restore the texture data of the second sub-area to the drawing area. Since the second handwriting is not included in the first work state, the electronic device restores the texture data of the second sub-area in the first work state to the drawing area. The second sub-area can then display the handwriting in the first work state, i.e., the drawing area does not display the second handwriting.

[0019] In this example, the electronic device restores the texture data of the second sub-area in the first work state to the drawing area. In order to prevent the electronic device from mistakenly canceling the first handwriting and / or the third handwriting, the electronic device can also detect whether there is an overlapping sub-area between the second sub-area and the sub-area associated with the first sub-area and the third handwriting. In a possible implementation, the second handwriting covers the first handwriting, and / or the second handwriting covers the third handwriting, that is, there is an overlapping third sub-area between the second sub-area and the first sub-area, and / or there is an overlapping sixth sub-area between the sub-area associated with the second sub-area and the third handwriting. In this way, the electronic device restores the texture data of the second sub-area to the drawing area, and also cancels the first handwriting in the third sub-area, and / or cancels the third handwriting in the sixth sub-area. 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-area, and / or the electronic device can draw the handwriting of the third handwriting in the sixth sub-area. In this example, the electronic device can achieve the purpose of canceling only the second handwriting, and can avoid accidentally canceling the first handwriting and / or the third handwriting, and can ensure the integrity of the first handwriting and the third handwriting.

[0020] In one possible implementation, after a user draws a second handwriting in the drawing area, they may continue to draw a fourth handwriting in the drawing area. Accordingly, in response to the fourth drawing operation, the electronic device displays the fourth handwriting in the drawing area. Furthermore, the electronic device may detect whether the number of handwritings with stored information, starting from the first handwriting, has reached a first threshold. When the electronic device determines that the number of handwritings with stored information, starting from the first handwriting, has reached the first threshold, it may save fourth texture data and information about the fourth handwriting. The fourth texture data includes texture data for a fifth sub-area in a second artwork state. The second artwork state is the state of the artwork in the drawing area before the fourth handwriting is displayed. The fifth sub-area is the sub-area associated with the fourth handwriting in the drawing area. In some examples, the fourth handwriting information includes an identifier for the fifth sub-area associated with the fourth handwriting, coordinates of multiple trajectory points within the fourth handwriting, and attributes of the fourth handwriting. In this implementation, the electronic device does not save the handwriting texture data each time the user draws a handwriting. Instead, it saves the texture data once the number of handwritings drawn by the user reaches the first threshold, thereby reducing memory usage.

[0021] In one possible implementation, the electronic device may store the texture data and handwriting information in a memory. In some embodiments, the electronic device may store the handwriting information in the form of a stack. For example, each time the user draws a handwriting, the electronic device may push the handwriting information as a stack element. Exemplarily, the electronic device may push the information of the first handwriting as a first stack element. The electronic device pushes the information of the second handwriting as a second stack element. The electronic device pushes the information of the third handwriting as a third stack element. The electronic device pushes the information of the fourth handwriting as a fourth stack element. In some embodiments, the electronic device may push the handwriting information as stack elements in the order in which the user draws the handwriting. In an embodiment of the present application, after the electronic device pushes the information of the fourth handwriting as the fourth stack element, the top element of the stack is the fourth stack element.

[0022] In some embodiments, in order to reduce the memory occupied by 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 on the basis of 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, when the electronic device uses the first texture data and the second texture data, the electronic device needs to first write the first texture data and the second texture data in the hard disk into the memory. However, there is a long delay in the process of the electronic device 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 into the memory, which will affect the speed of undoing handwriting.

[0023] In this implementation, the electronic device can write the first and second texture data from the hard disk to the memory before the user performs an undo operation, that is, before the electronic device receives the undo instruction. Thus, when the electronic device receives the undo instruction, it can directly use the first and second texture data from the memory, avoiding the delay in reading and writing the first and second texture data, speeding up the undo operation and improving the user experience.

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

[0025] 1) The current top element of the stack is between the first and fourth elements, and the number of undo commands received within a preset time reaches a third threshold. In this example, when a user performs multiple undo operations in a short period of time, the probability of the user continuing to perform undo operations is high. Therefore, the electronic device can preload texture data to reduce the latency of subsequent undo operations.

[0026] 2) The number of stack elements between the current top stack element and the first stack element is less than or equal to a fourth threshold. In this example, the distance between the current stack element and the stack element corresponding to the previous or next texture data is small. To promptly respond to the user's restore operation, the electronic device can pre-write the texture data from the hard disk to the memory. This way, when the user performs an undo operation, the electronic device can directly restore the texture data in the memory to the drawing area, enabling rapid handwriting recovery.

[0027] 3) The user performs a preset drawing operation. In this example, the user has previously performed undo operations multiple times while performing the preset drawing operation. Therefore, when the user performs the preset drawing operation, they are likely to perform undo operations again. To promptly respond to the user's restore operation, the electronic device can pre-write the texture data from the hard disk to the memory. This way, when the user performs an undo operation, the electronic device can directly restore the texture data in the memory to the drawing area, enabling quick recovery of the handwriting.

[0028] Secondly, embodiments of the present application provide a drawing method that describes 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 blocks may correspond to the subregions described in the above embodiments; the first block may correspond to at least one subregion, and the second block may also correspond to at least one subregion.

[0029] In this method, an electronic device may display a first image comprising multiple blocks. The image can be understood as a user's artwork drawn in a drawing area, and the first image may or may not include handwriting. The user may draw in the first block. In response to a first drawing operation on the first block, the electronic device may display a second image. The user draws on the first image, and the second image is added with the first handwriting corresponding to the first drawing operation. Thus, the second image includes the first image and the first handwriting. The electronic device may store information based on the first image and the first handwriting. Information about the first handwriting may include, but is not limited to, an identifier for the first block, coordinates of multiple points within the first handwriting, and attributes of the first handwriting. Saving the first block based on the first image can be understood as saving texture data for the first block based on the first image. In other words, the electronic device may store texture data for the first block in the first image. After the user draws the first handwriting in the first block, they may continue drawing. In response to a second drawing operation on the second block, the electronic device may display a third image. The user draws on the second image, and the third image includes the 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 to the second image, the third image includes the second handwriting, which occupies the second block.

[0030] In an embodiment 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 about the second block and the second handwriting based on the first image. The information about the second handwriting may include but is not limited to: an identifier of the second block, coordinates of multiple trajectory points in the second handwriting, and attributes of the second handwriting, etc. In some embodiments, the electronic device can save the handwriting information in the form of a stack, for example, the electronic device can push the information of the first handwriting into the stack. The electronic device saving the second block based on the first image can be understood as: the electronic device saving 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.

[0031] In one possible implementation, the user can perform an undo operation to undo the second handwriting. Accordingly, in response to the undo instruction, the electronic device can process the third image based on the second block and display the second image. The electronic device can undo the second handwriting in the third image based on the second block.

[0032] In a possible implementation, the user may also perform a restoration operation to restore the second handwriting. Accordingly, in response to the restoration instruction, the electronic device may draw the second handwriting based on the information of the second handwriting and display a third image.

[0033] In a third aspect, an embodiment of the present application provides a drawing method, which introduces a scenario in which a block for drawing a second handwriting overlaps a block for drawing a first handwriting. The blocks may correspond to the subregions in the above-described embodiments, and the first block may correspond to at least one subregion. In this method, an electronic device displays a first image, the first image including a plurality of blocks. In response to a first drawing operation on the first block, the electronic device may display a second image, the second image including the first image and information about the first handwriting corresponding to the first drawing operation. The electronic device may save information about the first block and the first handwriting based on the first image.

[0034] In this implementation, what is different from the second aspect is that when the user draws the second handwriting, he draws the second handwriting in the first block, which is also the block where the user draws the first handwriting. That is, the block of the second handwriting overlaps with the block of the first handwriting. In this example, in response to the 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 with the block of the first handwriting, both are first blocks, the electronic device has already saved the first block based on the first image when saving 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 memory usage.

[0035] In one possible implementation, the user can perform an undo operation to undo the second handwriting. Accordingly, in response to the undo instruction, the electronic device can process the third image based on the first block and the information about the first handwriting, and display the second image. Specifically, in response to the undo instruction, the electronic device can undo the second handwriting in the third image based on the first block, and then, based on the information about the first handwriting, draw the first handwriting in the first block.

[0036] In a possible implementation, the user may also perform a restoration operation to restore the second handwriting. Accordingly, in response to the restoration instruction, the electronic device may draw the second handwriting based on the information of the second handwriting and display a third image.

[0037] In a fourth aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory, the memory being used to store code instructions, and the processor being used to run the code instructions to execute the method described in any possible implementation of the first to third aspects, or the first to third aspects.

[0038] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is run on a computer, the computer executes the method described in any possible implementation of the first to third aspects, or the first to third aspects.

[0039] In a sixth aspect, an embodiment of the present application provides a computer program product comprising a computer program, which, when the computer program runs on a computer, enables the computer to execute the method described in any possible implementation of the first to third aspects, or the first to third aspects.

[0040] In a seventh aspect, the present application provides a chip or chip system, which includes at least one processor and a communication interface, wherein the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to perform the method described in any possible implementation of the first to third aspects, or the first to third aspects. The communication interface in the chip can be an input / output interface, a pin, or a circuit, etc.

[0041] In one possible implementation, the chip or chip system described above in this application further includes at least one memory, in which instructions are stored. The memory may be a storage unit within the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).

[0042] It should be understood that the second to seventh aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] Figure 1 A schematic diagram of a scene to which the drawing method provided in the embodiment of the present application is applicable;

[0044] Figure 2 A schematic diagram of a stack;

[0045] Figure 3 A schematic diagram for drawing regional texture partitioning;

[0046] Figure 4 A schematic diagram for undoing handwriting;

[0047] Figure 5 A schematic diagram for saving texture data;

[0048] Figure 6 A schematic diagram for saving texture data and drawing data;

[0049] Figure 7 Another schematic diagram for saving texture data and drawing data;

[0050] Figure 8 A schematic diagram of a flow chart of an embodiment of a drawing method provided in an embodiment of the present application;

[0051] Figure 9A A schematic diagram of storing texture data and handwriting information in an embodiment of the present application;

[0052] Figure 9B Another schematic diagram of saving texture data and handwriting information in an embodiment of the present application;

[0053] Figure 10 A schematic diagram of a flow chart of another embodiment of the drawing method provided in an embodiment of the present application;

[0054] Figure 11 A schematic diagram of the undo handwriting provided in an embodiment of the present application;

[0055] Figure 12A A schematic diagram of a flow chart of another embodiment of the drawing method provided in an embodiment of the present application;

[0056] Figure 12B A schematic diagram of a flow chart of another embodiment of the drawing method provided in an embodiment of the present application;

[0057] Figure 12C A schematic diagram of a flow chart of another embodiment of the drawing method provided in an embodiment of the present application;

[0058] Figure 12D A schematic diagram of a flow chart of another embodiment of the drawing method provided in an embodiment of the present application;

[0059] Figure 13A A schematic diagram of texture data and stacks stored for electronic devices;

[0060] Figure 13B A schematic diagram of preloading texture data provided in an embodiment of the present application;

[0061] Figure 13C Another schematic diagram of preloading texture data provided in an embodiment of the present application;

[0062] Figure 14 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0063] Figure 15 Another structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0064] Figure 1 A schematic diagram of a scenario to which the drawing method provided in an embodiment of the present application is applicable. Figure 1 The undo and redo operations during the drawing process are introduced in Figure 1 The interface in does not restrict the interface of the drawing application (APP). Figure 1 The electronic device is taken as a tablet computer as an example for description.

[0065] Reference Figure 1 In a, the drawing interface 101 of the drawing APP may include: a menu area 11 and a drawing area 12. For example, the user can use a medium such as a finger, a joint, or a stylus to draw handwriting in the drawing area 12. The embodiment of the present application does not limit the medium used by the user to draw handwriting. The "user draws handwriting in the drawing area" or "user draws handwriting" described in the following embodiments can be understood as the user using a medium such as a finger, a joint, or a stylus to draw handwriting in the drawing area. In some embodiments, the stylus can be called a stylus.

[0066] The menu area 11 may include at least one identifier, each corresponding to a different function. The functions may include, but are not limited to, an eraser function, an undo function, a redo function, a brush function, a layer function, and a graphics function. The eraser function is used to erase the handwriting in the drawing area 12. The undo function is used to redo the handwriting that has been drawn. The redo function is used to redo the handwriting that has been redoed. The brush function is used to provide different types of brushes. For example, brushes may include, but are not limited to, pencils, writing brushes, oil brushes, crayons, etc. The layer function is used to create a new layer, delete a layer, insert a layer, etc. The graphics function is used to provide different shapes. For example, shapes may include, but are not limited to, squares, rectangles, circles, ellipses, triangles, etc.

[0067] It should be understood that Figure 1 In a, the menu area 11 is located above the drawing interface 101. For example, the menu area 11 may include an eraser function logo 111, an undo function logo 112, a redo function logo 113, a brush function logo 114, a layer function logo 115, and a graphic function logo 116.

[0068] In some embodiments, different functions in the menu area 11 may be arranged at different locations on the drawing interface 101. For example, the brush function may be arranged on the left side of the drawing interface 101, and the eraser function, undo function, redo function, layer function, etc. may be arranged above the drawing interface 101. The layout of the menu area 11 in the embodiment of the present application is not limited.

[0069] In some embodiments, the drawing interface 101 may also include other content, such as a close control, a save control, etc., which is not limited in this embodiment of the present application.

[0070] Reference Figure 1 In a, the user draws handwriting 1 and handwriting 2 in the drawing area 12, and handwriting 2 is drawn later than handwriting 1. The user operates the undo function mark 112, and the tablet computer can undo handwriting 2. The drawing area 12 displays the content before handwriting 2 is drawn, that is, the drawing area 12 displays handwriting 1, as shown in FIG. Figure 1 As shown in b in FIG. The user operates the recovery function mark 113, the tablet computer can recover the handwriting 2, and the drawing area 12 displays the handwriting 1 and the handwriting 2, as shown in FIG. Figure 1 As shown in c.

[0071] It should be understood that the handwriting drawn by the user in the drawing area 12 can constitute text, patterns, etc. In other words, the drawing method provided in the embodiment of the present application can be applied to scenes such as drawing text, patterns, etc. Specifically, the drawing method provided in the embodiment of the present application can be applied to scenes such as taking notes and drawing.

[0072] For ease of understanding, the following Figure 1 The following are the relevant terms and concepts involved in the embodiments of this application:

[0073] 1. Undo: In the drawing scene, Undo can cancel the handwriting drawn by the user, and the drawing area will display the content before the handwriting was drawn.

[0074] 2. Redo: In the drawing scene, redo can restore the undone handwriting to the drawing area, that is, the drawing area can redisplay the undone handwriting.

[0075] 3. Pixel: The unit of image display.

[0076] 4. Texture data: Contains color information for at least one pixel. In some embodiments, the color information may include three-channel red (R), green (G), and blue (B) information. In some embodiments, yellow may be used instead of green, and the color information may include red, yellow (Y), and blue information, referred to as RYB information. This embodiment of the present application focuses on the three-channel color of the pixel, and does not limit the number of channels; for example, the channels may be four or more. For example, a transparency channel may also be included.

[0077] by Figure 1For example, drawing area 12 in FIG. 1 is composed of multiple pixels. For example, drawing area 12 may be composed of m rows and n columns of pixels. Here, m is an integer greater than 1, and n is an integer greater than 1. The texture data for drawing area 12 may include the color information of each pixel in drawing area 12.

[0078] 5. Stack: A structure that stores linear data. Figure 2 The first end of a stack can be called the top, and the second end can be called the bottom. In some embodiments, the data stored at the top of the stack can be called the top element, and the data stored at the bottom of the stack can be called the bottom element. Inserting data into a stack can be called pushing, pushing, or pushing. The inserted data can be placed above the top of the stack, becoming the new top. Deleting data from a stack can be called popping or popping. Deleting data deletes the data at the top of the stack, and the data immediately below the top of the stack becomes the new top.

[0079] In the embodiments of the present application, the electronic device may use a stack to store data, and the details may refer to the description in the following embodiments.

[0080] 6. Stack element: Each element that makes up the stack. For example, Figure 2 The data in a box shown in can be regarded as a stack element. Figure 2 The stack in consists of 4 stack elements.

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

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

[0083] 8. Texture tile: refer to Figure 3 In a, the drawing area 12 displays handwriting. Currently, when an electronic device saves the texture data of the drawing area 12, it needs to save the full texture data, which includes the color information of each pixel in the drawing area 12. It should be understood that Figure 3 The menu area 11 is not shown.

[0084] In some embodiments, texture blocking may also be referred to as texture partitioning, texture slicing, etc.

[0085] Texture tiling is when an electronic device divides a drawing area into N sub-areas, each of which contains a number of pixels.

[0086] The handwriting-related sub-region can be understood as the sub-region containing the handwriting. Thus, 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-region, which can significantly reduce the amount of texture data and the memory occupied by the texture data. Here, N is an integer greater than or equal to 2.

[0087] It should be understood that the properties of the N sub-regions may be the same or different, including but not limited to size, shape, etc. In some embodiments, for example, each sub-region may be the same size and each sub-region may be rectangular. For example, the size of each sub-region may be 64 pixels × 64 pixels, or 32 pixels × 32 pixels, or 128 pixels × 128 pixels.

[0088] Take each sub-region as a rectangle as an example, refer to Figure 3 b in the figure can divide the drawing area 12 into 12 sub-areas, namely sub-area 1, sub-area 2, ..., sub-area 12. The sub-areas related to handwriting 1 include: sub-area 1, sub-area 2, sub-area 6, sub-area 7, sub-area 11, and sub-area 12. When the electronic device saves texture data, it can save the color information of each pixel in sub-area 1, sub-area 2, sub-area 6, sub-area 7, sub-area 11, and sub-area 12, but not save the color information of each pixel in the blank area (sub-area 3, sub-area 4, sub-area 5, sub-area 8, sub-area 9, and sub-area 10). In this way, texture tiling can avoid the electronic device from saving a large amount of blank data. Blank data can be understood as texture data of sub-areas that do not contain handwriting.

[0089] In some embodiments, when the electronic device performs texture tiling on the drawing area, the electronic device may generate an identifier for each sub-area, which is used to distinguish different sub-areas. In some embodiments, the identifier may also be called a number, ID, etc.

[0090] In some embodiments, from the perspective of an image or artwork, texture tiling can be achieved by dividing the image or artwork into multiple blocks, corresponding to the sub-regions in the above example. A block can include a portion of the image or artwork; or a portion of the background of the image or artwork; or a block can include a portion of the image or artwork and a portion of the background of the image or artwork.

[0091] In some embodiments, the background of the image or work may be a solid color background or other images or other works; the background may be a background preset by the software, or a background modified by the user.

[0092] 9. Stencil test: In response to the user's operation of drawing handwriting in the drawing area, the electronic device needs to perform operations such as drawing, rendering, layer synthesis, and display, so that the drawing area displays the handwriting. Stencil test means: before the electronic device draws handwriting, the target sub-area where the drawing is effective can be pre-set, so that the drawing is only effective in the target sub-area, and the drawing outside the target sub-area is not effective. In other words, the electronic device can draw handwriting in the target sub-area and not draw handwriting in other sub-areas, which can reduce the drawing workload of the electronic device. Accordingly, the target sub-area can display the handwriting of the drawing, and other sub-areas do not display the handwriting. Among them, the sub-areas can refer to the description in texture tiling.

[0093] 10. The electronic devices in the embodiments of the present application may be referred to as user equipment (UE), terminals, etc. The electronic devices in the embodiments of the present application may provide a drawing function, which may be provided by a system APP or a third-party APP in the electronic device. For example, the electronic device may 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. The embodiments of the present application do not specifically limit the form of the electronic device.

[0094] For an electronic device equipped with a stylus, the electronic device and the stylus can be interconnected via a communication network to enable 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.

[0095] More and more users are using electronic devices to draw and take notes. Undo and redo are two frequently used operations during the drawing process. However, electronic devices cannot easily handle undoing and redoing a drawing. This is because the user's drawing overwrites previous drawing, resulting in the loss of texture data for the overwritten drawing. When the user performs an undo operation, the electronic device cannot recover the overwritten portion.

[0096] For example, refer to Figure 4In a, the user draws handwriting 1 in the 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. Figure 4 In b, the user draws a rectangle in the drawing area 12. The drawing area 12 can display a rectangle that 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, only texture data 2 is saved in the electronic device, and texture data 2 does not include the texture data of the covered part of the handwriting 1. When the user performs an 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. Figure 4 As shown in c.

[0097] To ensure that electronic devices can undo and restore handwriting, the following three existing methods for saving texture data are introduced:

[0098] First, before introducing the method of saving texture data, let's introduce the stack used to save texture data:

[0099] During the drawing process, if all user operations are organized into a stack, the user's operation can trigger the electronic device to push the operation data as a stack element. The pushed operation data can include drawing data. In some embodiments, the drawing data can include information about the handwriting of the drawing. The handwriting information can include, but is not limited to, the coordinates of multiple track points in the handwriting and handwriting attributes. The handwriting attributes can include, but are not limited to, handwriting color, handwriting thickness, and handwriting line type.

[0100] In scenarios where a stack is used to store operational data, when a user performs an undo operation, it can be considered as popping the top element of the stack. When a user performs a redo operation, it can be considered as pushing the previously popped element back into the stack.

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

[0102] The following are three existing methods for saving texture data:

[0103] 1. Texture data saving method 1:

[0104] When the user performs a drawing operation, 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, when the user performs a drawing operation once, the electronic device can push the texture data of the current work into the stack.

[0105] For example, when the user does not perform any drawing operation, the stack may be empty. Figure 5 In a, the user draws handwriting 1 in the drawing area, and the texture data of the drawing area may be texture data 1. The electronic device pushes texture data 1 into the stack. Texture data 1 is the first stack element in the stack, and texture data 1 may also be called the top stack element. Figure 5 In b, the user draws handwriting 2 in the drawing area, and the texture data of the drawing area can be texture data 2. The electronic device pushes texture data 2 into the stack, and the top element of the stack is updated to texture data 2. Similarly, refer to Figure 5 In c, the user draws handwriting 3 in the drawing area, and the texture data of the drawing area can be texture data 3. The electronic device pushes texture data 3 into the stack, and the top element of the stack is updated to texture data 3. Similarly, refer to Figure 5 In d, the user draws circle 4 in the drawing area. The texture data of the drawing area may be texture data 4. The electronic device pushes texture data 4 into the stack, and updates the top element of the stack to texture data 4.

[0106] In this method, when the user performs an undo operation, the electronic device can pop the top element of the stack and restore the previously saved texture data to the drawing area, thus undoing the handwriting. When the user performs a redo operation, the electronic device can restore the popped element to the drawing area, thus restoring the handwriting.

[0107] For example, refer to Figure 5 In d, after the user draws circle 4 in the drawing area, the undo operation is performed. The electronic device can pop the top element "texture data 4" from the stack and restore the previous texture data "texture data 3" saved to the drawing area. The drawing area can display handwriting 1, handwriting 2 and handwriting 3, as shown in the following example. Figure 5 As shown in e. Figure 5 In the example e, 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 push "texture data 4" into the stack. In this way, the drawing area can display handwriting 1, handwriting 2, handwriting 3, and circle 4, as shown in FIG. Figure 5 As shown in f.

[0108] It should be understood that the electronic device restoring the texture data to the drawing area means that the electronic device sends the texture data for display so that the drawing area displays the corresponding handwriting.

[0109] In some embodiments, when saving texture data, the electronic device may store the texture data in a first memory space. Restoring the texture data to the drawing area by the electronic device involves copying the texture data in the first memory space, writing the copied texture data to a second memory space, and displaying the texture data in the second memory space so that the drawing area displays the corresponding handwriting. The second memory space is used to store the texture data to be displayed.

[0110] In some embodiments, when saving texture data, the electronic device may save the texture data in a first space of the memory. To avoid high memory usage, the texture data in the first space may be written to the hard disk. In this example, the electronic device restoring the texture data to the drawing area means: the electronic device writes the texture data in the hard disk to a third space of the memory, which may be the same as or different from the first space, and the electronic device copies the texture data in the third space, writes the copied texture data to the second space of the memory, and sends the texture data in the second space to the display so that the drawing area displays the corresponding handwriting.

[0111] However, in this method, every time the user performs a drawing operation, the electronic device needs to save the texture data of the drawing area, which takes up a lot of memory. In some embodiments, in order to reduce the memory occupied by texture data, the electronic device can write part or all of the texture data to the hard disk, but when the user performs an undo operation, the electronic device needs to first write the texture data in the hard disk to the memory. The reading and writing process will cause problems such as undo jams and long loading wait times. In addition, when the texture data of the work is large and the user needs to undo hundreds of drawing operations, each time the user performs an undo or redo operation, the texture data written from the hard disk to the memory may reach tens of GB, which is also a big challenge to the storage space of the hard disk.

[0112] 2. Texture data saving method 2:

[0113] To reduce the memory usage of texture data, in some embodiments, the electronic device can save the texture data of the drawing area when the drawing app is opened. When the drawing app is opened, the drawing area may or may not contain handwriting. In this method, when the user performs a drawing operation, the electronic device does not save the texture data of the drawing area, but instead saves the drawing data, i.e., pushes the drawing data into a stack.

[0114] Take the drawing area not containing handwriting when the drawing APP is opened as an example, for example, refer to Figure 6 In a, when the drawing APP is opened, the electronic device can save the texture data of the drawing area, such as texture data 0. Figure 6In b, the user draws handwriting 1 in the drawing area, and the electronic device pushes the handwriting 1 information into the stack. The handwriting 1 information may include the coordinates of multiple track points in the handwriting 1 and the attributes of the handwriting 1. The handwriting 1 information is the first stack element in the stack, and the handwriting 1 information can also be called the top stack element. Figure 6 In c, the user draws handwriting 2 in the drawing area, the electronic device pushes the information of handwriting 2 into the stack, and the top element of the stack is updated to the information of handwriting 2. Figure 6 In d, the user draws handwriting 3 in the drawing area, and the electronic device pushes the information of handwriting 3 into the stack, and updates the top element of the stack to the information of handwriting 3. The information of handwriting 2 and handwriting 3 can refer to the description of the information of handwriting 1. Figure 6 In the figure e, the user draws a circle 4 in the drawing area, and the electronic device can push information about circle 4 into a stack, and update the top element of the stack with the information about circle 4. The information about circle 4 may include attributes of the circle, which may include but are not limited to: line color, thickness, line type, fill color within the circle, and coordinates of the circle.

[0115] In this method, when the user wants to cancel the Mth handwriting, the electronic device can perform the following steps 1)-2). It can be understood that, in Figure 6 In the example, after the user draws circle 4 in the drawing area, the user draws 4 strokes, and M is equal to 4. Here, M is an integer greater than or equal to 1.

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

[0117] Step 2): Re-execute the drawing operation based on the first stack element to the (M-1)th stack element in the order from the bottom of the stack to the top of the stack. After the electronic device completes the drawing operation based on the (M-1)th stack element, the Mth stroke can be undone.

[0118] In this example, after the electronic device cancels the Mth stroke, the user performs a restore operation, and the electronic device can perform a drawing operation based on the Mth stack element to restore the Mth stroke.

[0119] Compared with saving method 1, in saving method 2, the electronic device only needs to save the texture data of the drawing area once when the drawing APP is opened. Each subsequent time the user performs a drawing operation, the electronic device only needs to save the drawing data of that time, and there is no need to save the full amount of texture data, thus reducing memory usage. However, when M is large, it takes a long time for the electronic device to re-execute the drawing operation based on the 1st stack element to the (M-1)th stack element, resulting in problems such as undo freezes and delays. In addition, for drawing scenarios such as painting with thousands or even tens of thousands of strokes, using the undo method in saving method 2, the time it takes to re-execute the drawing operation is in the order of seconds or even minutes, which results in a poor user experience.

[0120] 3. Texture data saving method 3:

[0121] Saving Method 3 combines the advantages of Saving Methods 1 and 2. When a drawing app is open, the electronic device can save the texture data of the drawing area and save the texture data of the drawing area again every X stack elements. In addition, each time the user performs a drawing operation, the electronic device can push the drawing data for that operation into the stack. Where X is an integer greater than or equal to 2.

[0122] Saving method 3 avoids the problem of saving the texture data of the drawing area after each drawing in saving method 1, which can reduce the memory occupied by texture data. In addition, the electronic device can save the texture data of the drawing area once every X stack elements. Compared with saving method 2, when the electronic device performs an undo operation, it does not need to roll back to the texture data saved when the drawing app was opened and execute the drawing operation in all stack elements. Instead, it rolls back to the last saved texture data and starts the drawing operation from the stack element corresponding to the texture data, reducing the drawing workload and improving drawing efficiency.

[0123] Take X as 2 as an example, for example, refer to Figure 7 In a, when the drawing APP is opened, the electronic device can save the texture data of the current work, such as texture data 0. Figure 7 In b, the user draws handwriting 1 in the drawing area, and the electronic device pushes the handwriting 1 information into the stack. Figure 7 In c, the user draws handwriting 2 in the drawing area, and the electronic device pushes the handwriting 2 information into the stack. At this point, two stack elements are added to the stack, and X reaches 2. The electronic device can save the texture data of the drawing area, such as texture data 2.

[0124] Reference Figure 7 In d, the user draws handwriting 3 in the drawing area, and the electronic device pushes the information of handwriting 3 into the stack. Figure 7 In e, the user draws circle 4 in the drawing area, and the electronic device pushes the information of circle 4 into the stack. At this time, two more stack elements are added to the stack, and X reaches 2. The electronic device can save the texture data of the drawing area, such as texture data 4.

[0125] In this method, when the user performs an undo operation, the electronic device can restore the last saved texture data to the drawing area and re-execute the drawing operation based on the stack elements from that point. For example, after the user draws a circle 4 in the drawing area, the user performs an undo operation. The electronic device can perform the following steps 1)-3):

[0126] 1) Get the last saved texture data, such as texture data 2.

[0127] 2) Texture data 2 is restored to the drawing area, and the drawing area displays the content before drawing handwriting 3.

[0128] 3) Based on the information of handwriting 3, the operation of drawing handwriting 3 is re-executed so that the drawing area displays the work before drawing handwriting 4, that is, the purpose of undoing circle 4 is achieved.

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

[0130] In scenarios where the texture data in the drawing area is large and the drawing load is heavy, if the X value is too large, the electronic device will need to redo multiple drawing operations when performing an undo operation, which increases the drawing workload. If X is too small, the electronic device still needs to save a large amount of texture data, resulting in a large memory usage. In short, with storage method 3, it is difficult for the electronic device to strike a balance between memory requirements and performance.

[0131] In response to the above problems, the embodiments of the present application provide a drawing method. Based on these methods, the electronic device can perform texture tiling on the drawing area. When the electronic device saves texture data, it does not save the full amount of texture data, but saves the texture data of the sub-area associated with the handwriting of the pen. The texture data of the sub-area can reduce memory usage compared to the full amount of texture data. In addition, when the electronic device re-executes the drawing operation according to the drawing data, it does not draw the complete handwriting. The electronic device can use a template testing method to pre-set the target sub-area where the drawing is effective, so that the drawing is only effective in the target sub-area, and the drawing is not effective 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 requirements and performance of the electronic device.

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

[0133] Figure 8 This is a flow chart of an embodiment of the drawing method provided in the present application. Figure 8 The drawing method provided in the embodiment of the present application may include:

[0134] S801: When a drawing APP is opened, the electronic device displays a drawing interface of the drawing APP, where the drawing interface includes a drawing area.

[0135] The desktop of the electronic device can display the icon of the drawing APP. The user operates the icon of the drawing APP to trigger the opening of the drawing APP. The drawing interface of the drawing APP can be as follows: Figure 1As shown, 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 and displaying drawing handwriting. Exemplarily, the drawing area can be a partial area or the entire area in the drawing interface.

[0136] When the drawing APP is opened, the drawing area may include handwriting, or may not include handwriting. In some embodiments, the content displayed in the drawing area may be called a work, and when the drawing APP is opened, the work is in a first work state or an initial work state.

[0137] The work status indicates the handwriting included in the current work. The first work status indicates the handwriting included in the work when the drawing app is opened. The handwriting included in the work can be different in different work states.

[0138] S802 : In response to the user drawing a first handwriting in the drawing area, the electronic device saves texture data 1 and pushes the information of the first handwriting into a stack.

[0139] In some examples, the texture data 1 may include texture data of a first sub-region in a first work state, where the first sub-region is a sub-region associated with a first stroke of handwriting.

[0140] In this embodiment of the present application, when a user draws the first handwriting in the drawing area, the electronic device may be triggered to save texture data, namely, texture data 1. Texture data 1 is the texture data of the first sub-area in the first artwork state, that is, the color information of each pixel in the first sub-area in the first artwork state. It can be understood that when the user draws the first handwriting in the drawing area, the drawing area is added with the first handwriting, and the artwork state in the drawing area is changed to the second artwork state.

[0141] In this embodiment of the present application, the electronic device can perform texture tiling on the drawing area, that is, the electronic device can divide the drawing area into N sub-areas. The first sub-area is the sub-area associated with the first handwriting. The sub-area associated with the first handwriting refers to the sub-area containing the first handwriting. In other words, texture data 1 is the texture data of the sub-area containing the first handwriting in the first work state.

[0142] In an embodiment of the present application, after the user draws the first handwriting in the drawing area, the electronic device does not save the full texture data, but saves the texture data of the sub-area associated with the first handwriting in the first work state, that is, the texture data of the sub-area associated with the first handwriting before the first handwriting is drawn is saved.

[0143] Compared to saving the entire amount of texture data, the electronic device saves the texture data of a sub-area of ​​the drawing area, which can reduce memory usage. In particular, when there are many handwritings in the first work state, saving the entire amount of texture data by the electronic device will occupy a large amount of memory. In the embodiment of the present application, the electronic device saves: before the first handwriting is drawn, that is, the texture data of the sub-area associated with the first handwriting in the first work state. When the electronic device performs an undo operation, the electronic device can restore the texture data of the sub-area associated with the first handwriting to the first work state, thereby realizing the undo operation, which is simple to operate.

[0144] In the embodiment of the present application, the information of the first handwriting includes not only the coordinates of multiple track points in the first handwriting and the attributes of the first handwriting, but also an identifier of the first sub-region. The first sub-region can be at least one sub-region.

[0145] For example, Figure 9A In the example of the first work state without handwriting, refer to Figure 9A In a, when the drawing APP is opened, the drawing interface does not include any handwriting, or in other words, the first work state does not include handwriting. It should be understood that the drawings of the embodiment of the present application take the example of the electronic device dividing the drawing area into 12 sub-areas, such as Figure 9A As shown in a. Figure 9A In b, the user draws handwriting 1 in the drawing area, and handwriting 1 can be called the first handwriting. For example, handwriting 1 is associated with three sub-areas, namely sub-area 5, sub-area 6, and sub-area 7. Figure 9A In b, the solid-line box represents the sub-region associated with handwriting 1.

[0146] In this embodiment of the present application, the electronic device can store the texture data of the three sub-regions associated with handwriting 1 in the first work state. Because the first work state does not include handwriting, the texture data of the three sub-regions associated with handwriting 1 can be blank data. In addition, the electronic device can push the information of handwriting 1 into a stack. The information of handwriting 1 can include: the identifiers of the three sub-regions associated with handwriting 1, the coordinates of multiple track points in handwriting 1, and the attributes of handwriting 1.

[0147] S803: In response to the user drawing a second handwriting in the drawing area, the electronic device detects whether the newly stacked elements reach a first threshold. If so, execute S804; if not, execute S805.

[0148] The newly pushed stack elements refer to the stack elements pushed starting from the stack element corresponding to texture data 1 (including the stack element corresponding to texture data 1). The stack element corresponding to texture data 1 is the information of the first handwriting. For example, in response to the user drawing a second handwriting in the drawing area, the electronic device detects that the number of newly pushed stack elements may be 1, and the newly pushed stack element is the information of the first handwriting.

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

[0150] S804: The electronic device saves texture data 2 and pushes the information of the second handwriting into a stack.

[0151] In some examples, the texture data 2 is: texture data of the second sub-region in the third work state, where the second sub-region is the sub-region associated with the second handwriting.

[0152] When the first threshold is 1, after the user draws a second stroke in the drawing area, the newly pushed stack element reaches the first threshold, and the electronic device can save texture data 2 and push the second stroke information onto the stack. In other words, after the user draws a second stroke in the drawing area, but before the second stroke information is pushed onto the stack, the electronic device can detect that the newly pushed stack element is 1, reaching the first threshold.

[0153] After the user draws the second handwriting in the drawing area, the second handwriting is added to the drawing area. At this time, the state of the work in the drawing area can be called the third work state.

[0154] Texture data 2 is the texture data for the second sub-region in the third artwork state. The second sub-region is the sub-region associated with the second handwriting, which refers to the sub-region containing the second handwriting. In other words, texture data 2 is the texture data for the sub-region containing the second handwriting in the third artwork state. Information about the second handwriting may include the identifier of the second sub-region, the coordinates of multiple track points within the second handwriting, and the attributes of the second handwriting.

[0155] It should be understood that the handwriting in different work states can be different, and therefore the handwriting contained in the same sub-area in different work states can also be different. In the embodiment of the present application, after the user draws the second handwriting in the drawing area, the electronic device can save the texture data of the second sub-area in the third work state when saving the texture data. This facilitates the electronic device to implement undo and redo operations based on texture data 2.

[0156] For example, referring to c in 9A, the user draws handwriting 2 in the drawing area, and the handwriting 2 can be called the second handwriting. The third work state includes handwriting 1 and handwriting 2. For example, handwriting 2 is associated with 2 sub-areas. Figure 9A In c, the two sub-areas associated with handwriting 2 are represented by dotted boxes, namely sub-area 8 and sub-area 12. After the user draws handwriting 2 in the drawing area, the electronic device detects that the newly stacked element is information about handwriting 1. If the newly stacked element reaches the first threshold 1, the electronic device can save texture data 2 and stack the information of handwriting 2. The texture data 2 includes: the texture data of the two sub-areas associated with handwriting 2 in the third work state. The information of handwriting 2 may include: the identifiers of the two sub-areas associated with handwriting 2, the coordinates of multiple track points in handwriting 2, and the attributes of handwriting 2.

[0157] After the electronic device pushes the information of handwriting 2 into the stack, the stack includes 2 stack elements.

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

[0159] When the first threshold is greater than or equal to 2, after the user draws a second stroke in the drawing area, the electronic device detects that the number of newly pushed stack elements is 1, which does not reach the first threshold. The electronic device may no longer save new texture data, but instead update the saved texture data 1. In this embodiment of the present application, the electronic device may update texture data 1 based on texture data 3.

[0160] Texture data 3 is texture data of the third sub-region in the first work state. The third sub-region is not directly associated with the second handwriting, but is a sub-region associated with the second handwriting and not included in the first sub-region.

[0161] Texture data 1 includes texture data of a first sub-area associated with a first handwriting. When a second handwriting covers the first handwriting, the sub-area associated with the second handwriting overlaps with the first sub-area. Texture data 1 already includes texture data of the overlapping sub-area in the first work state. When the electronic device updates the texture data, it does not need to store the texture data of the overlapping sub-area again. Instead, it only needs to store the texture data of the sub-area associated with the second handwriting and not included in the first sub-area. This avoids saving duplicate texture data and reduces memory usage.

[0162] The electronic device updating the texture data 1 according to the texture data 3 can be understood as: the electronic device adding and saving the texture data 3 on the basis of the texture data 1 to update the texture data 1. The updated texture data 1 includes: texture data 1 and texture data 3.

[0163] S806: The electronic device pushes the second handwriting information into the stack.

[0164] It should be understood that there is no order in which S805 and S806 may be executed simultaneously.

[0165] It should be understood that Figure 9A In the example above, the first threshold is 1, and the following example is explained with the first threshold being 2. Figure 9B For example, the first threshold value is 2. For example, the first work state includes handwriting, refer to Figure 9B In a, when the drawing APP is opened, the drawing interface of the drawing APP includes two handwritings, or in other words, the first work state includes two handwritings. Figure 9B In b, the user draws handwriting 1A in the drawing area, and the handwriting 1A can be called the first handwriting. For example, handwriting 1A is associated with four sub-areas, namely sub-area 5, sub-area 6, sub-area 7 and sub-area 8. Figure 9B The four sub-regions associated with handwriting 1A are represented by solid-line boxes in b. The electronic device can store the texture data of the three sub-regions associated with handwriting 1A in the first work state and push the information of handwriting 1A into a stack. The information of handwriting 1A can refer to the description of handwriting information in the above embodiment.

[0166] Reference Figure 9B In c, the user draws handwriting 2A in the drawing area, and the handwriting 2A can be called the second handwriting. For example, the handwriting 2A is associated with three sub-areas, namely sub-area 4, sub-area 8, and sub-area 12. Figure 9B In c, the three sub-regions associated with handwriting 2A are represented by dotted boxes. These three sub-regions overlap with the four sub-regions associated with handwriting 1A by one sub-region, which is sub-region 8. Figure 9B The overlapping sub-regions are shaded in grey in c.

[0167] After the user draws handwriting 2A in the drawing area, the electronic device detects that there is only one newly stacked element, namely the information of handwriting 1A, which does not reach the first threshold 2, and the electronic device can update the texture data 1. Figure 9B In step c, the electronic device can add and save texture data 3 based on texture data 1 and push the information of handwriting 2A into the stack. Texture data 3 includes texture data for two sub-regions associated with handwriting 2A in the first work state: sub-region 4 and sub-region 12. Information about handwriting 2A can include identifiers of the three sub-regions associated with handwriting 2A, coordinates of multiple track points in handwriting 2A, and attributes of handwriting 2A.

[0168] S807: In response to the user drawing the third handwriting in the drawing area, the electronic device detects whether the newly stacked elements reach the first threshold. If so, execute S808; if not, execute S809.

[0169] In some embodiments, when the electronic device executes S804 and then S807, the newly pushed stack elements are stack elements starting from the stack element corresponding to texture data 2. The stack element corresponding to texture data 2 may be information about the second handwriting, and the newly pushed stack elements are information about the second handwriting.

[0170] In some embodiments, when the electronic device executes S805-S806 and then executes S807, the newly pushed stack elements are: starting from the stack element corresponding to texture data 1, and the stack element corresponding to texture data 1 can be the information of the first handwriting, and the newly pushed stack elements include: the information of the first handwriting and the information of the second handwriting.

[0171] In summary, the newly pushed stack element refers to the stack element pushed starting 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 pushed when the last saved texture data was saved.

[0172] Exemplarily, when the electronic device executes S804 and then executes S807, and when the first threshold is 1, the newly pushed stack element reaches the first threshold 1. Exemplarily, when the electronic device executes S805-S806 and then executes S807, and when the first threshold is 2, the newly pushed stack element reaches the first threshold 2. Exemplarily, when the electronic device executes S805-S806 and then executes S807, and when the first threshold is greater than 2, the newly pushed stack element does not reach the first threshold.

[0173] S808: The electronic device saves the texture data 4 and pushes the information of the third handwriting into the stack.

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

[0175] In this embodiment of the present application, after the user draws a third stroke in the drawing area, if the newly pushed stack element reaches a first threshold, the electronic device can save texture data 4 and push the third stroke information into the stack. After the user draws a third stroke in the drawing area, the drawing area is newly added with the third stroke. At this time, the state of the artwork in the drawing area can be referred to as the fourth artwork state.

[0176] Texture data 4 is the texture data of the fourth sub-region in the fourth work state. The fourth sub-region is the sub-region associated with the third handwriting. In other words, texture data 4 is the texture data of the sub-region associated with the third handwriting in the fourth work state.

[0177] The information of the third handwriting may include: an identifier of the fourth sub-region, coordinates of multiple track points in the third handwriting, and attributes of the third handwriting.

[0178] For example, refer to Figure 9B In d, the user draws handwriting 3A in the drawing area, and the handwriting 3A can be called the third handwriting. For example, handwriting 3A is associated with 3 sub-areas. Figure 9B The dashed boxes in d represent the four sub-areas associated with handwriting 3. After the user draws handwriting 3A in the drawing area, the electronic device detects that two new stack elements have been added: information about handwriting 1A and information about handwriting 2A. If this reaches a first threshold 2, the electronic device can save texture data 4 and push the information about handwriting 3A onto the stack. Texture data 4 is the texture data for the four sub-areas associated with handwriting 3A in the fourth artwork state. The information about handwriting 3A can refer to the description of handwriting information in the above embodiment.

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

[0180] When the first threshold is greater than or equal to 3, after the user draws the third stroke in the drawing area, the electronic device detects that the number of newly pushed stack elements is 2, which does not reach the first threshold. The electronic device may no longer save new texture data and instead continue to update texture data 1. In this embodiment of the present application, the electronic device may update texture data 1 based on texture data 5.

[0181] Texture data 5 is the texture data for the fifth sub-region in the first artwork state. The fifth sub-region is not directly associated with the third stroke, but rather is a sub-region associated with the third stroke that is not included in the first or second sub-regions. In other words, the fifth sub-region is a sub-region associated with the third stroke that was not saved in the first artwork state.

[0182] In the embodiment of the present application, the electronic device updating texture data 1 based on texture data 5 can be understood as: adding and saving texture data 5 to the already saved texture data 1 (i.e., texture data 1 that has been updated once) to further update texture data 1. The saved texture data 1 may include texture data 1 and texture data 3. The updated texture data 1 includes texture data 1, texture data 3, and texture data 5.

[0183] S810, the electronic device pushes the information of the third handwriting into the stack.

[0184] It should be understood that there is no order in which S809 and S810 may be executed simultaneously.

[0185] It is understood that if the user continues to draw handwriting, the electronic device may iteratively execute the steps in the above embodiment. For example, if the user continues to draw handwriting, the electronic device may continue to detect whether the newly stacked stack element reaches the first threshold. If the newly stacked stack element reaches the first threshold, the electronic device may save new texture data and push the handwriting information onto the stack. If the newly stacked stack element does not reach the first threshold, the electronic device may update the texture data saved last time and push the handwriting information onto the stack.

[0186] In an embodiment of the present application, in a drawing scene, the electronic device can save texture data once every first threshold stack elements. 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 in the current work state, which can reduce the memory occupied by the texture data. In addition, each time the user draws handwriting, 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 previously saved based on the texture data saved last time, so as to update the texture data saved last time. This makes it easier for the electronic device to implement undo and restore operations. The undo and restore operations can refer to the description in the following embodiments.

[0187] The following describes the process of the electronic device undoing the second handwriting, taking the scenario where the electronic device executes S805-S806 as an example:

[0188] Reference Figure 10 The drawing method provided in the embodiment of the present application may include:

[0189] S1001: When a drawing APP is opened, the electronic device displays a drawing interface of the drawing APP, where the drawing interface includes a drawing area.

[0190] S1002 : In response to the user drawing a first handwriting in the drawing area, the electronic device saves texture data 1 and pushes information of the first handwriting into a stack.

[0191] S1003: In response to the user drawing a second handwriting in the drawing area, the electronic device detects whether the newly stacked elements reach a first threshold.

[0192] S1004: When the newly stacked 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 handwriting.

[0193] For S1001-S1004, refer to the descriptions in S801-S803 and S805-S806.

[0194] S1005, receiving a cancellation instruction.

[0195] For example, refer to Figure 1 On the drawing interface 101, the user can operate the undo function icon 112 to trigger the electronic device to receive the undo instruction. In the embodiment of the present application, the method of the user triggering the undo instruction is not limited. For example, the user can also use voice to say "undo handwriting" to trigger the electronic device to receive the undo instruction.

[0196] S1006: The electronic device restores the texture data of the second sub-region associated with the second handwriting in the first work state to the drawing area.

[0197] In response to the revocation instruction, the electronic device can search for the most recently saved texture data. In the embodiment of the present application, before the electronic device receives the revocation instruction, the electronic device has updated texture data 1 once, so the most recently saved texture data includes: texture data 1 and texture data 3.

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

[0199] In some embodiments, because the top element of the stack contains information about the second handwriting, and the second handwriting information includes the identifier of the second subregion associated with the second handwriting, the electronic device can obtain the identifier of the second subregion from the top element of the stack. It should be understood that texture data 1 and texture data 3 include texture data for subregions, and the subregions in texture data 1 and texture data 3 may overlap. Therefore, the electronic device can obtain the texture data associated with the second subregion from texture data 1 and texture data 3 based on the identifier of the second subregion.

[0200] Restoring the texture data of the second sub-area to the drawing area by the electronic device means: the electronic device displays the texture data of the second sub-area. In some embodiments, when saving the texture data of the second sub-area, the electronic device may store the texture data of the second sub-area in a first space of the memory. Restoring the texture data of the second sub-area to the drawing area by the electronic device means: the electronic device copies the texture data of the second sub-area in the first space, writes the copied texture data to the second space of the memory, and displays the texture data in the second space so that the drawing area displays the second stroke.

[0201] Because the texture data of the second sub-area is the texture data of the second sub-area in the first work state, and because the second sub-area in the first work state does not include the second stroke, the electronic device displays the texture data of the second sub-area, which can cause the drawing area to cancel the texture data of the second sub-area, that is, cancel the second stroke.

[0202] S1007: When the first sub-region associated with the first handwriting overlaps with the second sub-region associated with the second handwriting, the electronic device redraws the first handwriting.

[0203] It should be noted that when the first sub-region associated with the first handwriting and the second sub-region associated with the second handwriting do not overlap, the electronic device displays the texture data of the second sub-region in the first work state, and the drawing area may not display the second handwriting in the second sub-region, thus canceling the second handwriting. However, when the first sub-region associated with the first handwriting and the second sub-region associated with the second handwriting 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 handwriting in the second sub-region. It also does not display the first handwriting in the overlapping sub-region, indicating a shortage of the first handwriting. In this case, the electronic device needs to redraw the first handwriting to cancel only the second handwriting.

[0204] Because the information about the first handwriting in the stack includes the identifier of the first sub-region associated with the first handwriting, and the information about the second handwriting includes the identifier of the second sub-region associated with the second handwriting, in some embodiments, after restoring the texture data of the second sub-region associated with the second handwriting to the drawing area, the electronic device can query the stack elements. For example, the electronic device can query the information about the first handwriting and the second handwriting to detect whether the first sub-region associated with the first handwriting overlaps with the second sub-region associated with the second handwriting. If the first sub-region overlaps with the second sub-region, the electronic device can redraw the first handwriting based on the information about the first handwriting.

[0205] In some embodiments, to reduce the drawing workload of the electronic device, the electronic device can determine the identity of a sub-region where the first sub-region and the second sub-region overlap based on the information of the first and second handwriting. The electronic device can use a template test method to set the identity of the overlapping sub-region, so that the electronic device's operation of redrawing the first handwriting is only effective in the overlapping sub-region.

[0206] It will be appreciated that while this example uses a stack containing two stack elements as an example, when the stack contains multiple stack elements, the electronic device can determine whether the second sub-region overlaps with the sub-region associated with each handwriting based on the information about the second handwriting and the information about each handwriting. If there is overlap, the electronic device identifies the sub-region where the second sub-region overlaps with the sub-region associated with each handwriting. Thus, when redrawing handwriting of a different handwriting, the electronic device can employ a template test method, set the identifier of the overlapping sub-region, and redraw the handwriting of the different handwriting in the overlapping region corresponding to the handwriting of the different handwriting.

[0207] For example, after the user draws handwriting 1B, the electronic device saves texture data 1. The user draws handwriting 2B and handwriting 3B in sequence, and the electronic device can update the texture data 1. The method for the electronic device to save texture data 1 and update texture data 1 can refer to Figure 8 When the user performs an undo operation after drawing the handwriting 3B, the electronic device can first restore the texture data of the sub-region associated with the handwriting 3B in the first work state to the drawing area.

[0208] The electronic device detects whether the subregion associated with handwriting 1B overlaps with the subregion associated with handwriting 3B based on the information of handwriting 1B and handwriting 3B stored in the stack, and detects whether the subregion associated with handwriting 2B overlaps with the subregion associated with handwriting 3B based on the information of handwriting 2B and handwriting 3B stored in the stack. Assume that the subregion associated with handwriting 1B overlaps with the subregion associated with handwriting 3B by one subregion, which is subregion 1, and the subregion associated with handwriting 2B overlaps with the subregion associated with handwriting 3B by two subregions, which are subregions 2 and 3.

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

[0210] Here Figure 9B Take the example in as an example to introduce the process of electronic device performing revocation operation. Figure 11 In the drawing area, the drawing area includes the two existing handwriting strokes (handwriting 1A and handwriting 2A) when the drawing app is opened. A user's operation of the undo function indicator 112 triggers the electronic device to receive an undo instruction. In response to the undo instruction, the electronic device searches for the most recently saved texture data, which includes texture data 1 and texture data 3.

[0211] Among them, 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 handwriting 1A. 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 handwriting 2A and not included in the first sub-region. There are two third sub-regions. The first sub-region and the third sub-region overlap by one sub-region. In this embodiment of the present application, the electronic device can obtain the texture data of the three sub-regions associated with handwriting 2A in texture data 1 and texture data 3 based on the identifier of the second sub-region associated with the second handwriting at the top of the stack.

[0212] The electronic device restores the texture data of the three sub-areas associated with the handwriting 2A to the drawing area, and the content displayed in the drawing area is as follows: Figure 11 It is worth noting that because the four sub-areas associated with handwriting 1A overlap with the three sub-areas associated with handwriting 2A by sub-area 8, when the electronic device restores the texture data of the three sub-areas associated with handwriting 2A to the drawing area, it also restores the texture data of sub-area 8 associated with handwriting 1A in the first work state to the drawing area.

[0213] Because the first work state does not contain handwriting 1A and handwriting 2A, the texture data of the three sub-areas associated with handwriting 2A are restored to the drawing area, and the handwriting is not displayed in the three sub-areas associated with handwriting 2A. Figure 11 In b, the handwriting 1A lacks the handwriting in the sub-area 8. The electronic device needs to redraw the handwriting 1A to undo only the handwriting 2A.

[0214] In some embodiments, the electronic device can redraw the handwriting based on the stack elements stored in the stack. For example, the electronic device can redraw the handwriting 1A based on the first stack element "information of handwriting 1A" in the stack. After the electronic device re-executes the drawing operation, the drawing area can fully display the handwriting 1A, such as Figure 11 As shown in c.

[0215] Because the electronic device restores the texture data of the three sub-areas associated with handwriting 2A to the drawing area, it only affects part of the handwriting in the overlapping sub-area of ​​the first sub-area associated with handwriting 1A. 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-area among the four sub-areas associated with handwriting 1A and the three sub-areas associated with handwriting 2A based on the first stack element "information of handwriting 1A" and the second stack element "information of handwriting 2A". The electronic device can use a template test method to set the identifier of the overlapping sub-area, so that the operation of the electronic device to redraw handwriting 1A is only effective in the overlapping sub-area.

[0216] It is understandable that after the electronic device cancels the second handwriting, if the user performs a restore operation, the electronic device can redraw the second handwriting based on the information of the second handwriting in the stack, which is not described in detail in the embodiment of the present application.

[0217] It is conceivable that after the user performs a revocation operation once, if the user continues to perform the revocation operation, the electronic device may execute S1106 in response to the revocation instruction, and then continue to execute S1107 after S1106:

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

[0219] For S1107 , reference may be made to the relevant description in S1106 .

[0220] In an embodiment of the present application, in the scenario of undoing handwriting, the electronic device can query the texture data saved last time and restore the texture data of the sub-area associated with the handwriting of the pen in the first work state to the drawing area, thereby realizing the undo of the handwriting of the pen. In addition, when the sub-area associated with the handwriting of the pen overlaps with the sub-area associated with the previous handwriting, the electronic device can also use a template test method to redraw the handwriting of the overlapping area in the overlapping sub-area, which not only reduces the drawing workload but also allows the drawing area to fully display the previous handwriting, realizing the undo operation.

[0221] As described in the above embodiment, when the user performs the first few operations after opening the drawing APP, the electronic device saves the texture data, pushes it into the stack, and cancels the operation, etc. The method in the above embodiment can be applied to any drawing operation. In summary, the drawing method in the embodiment of this application is summarized as follows:

[0222] Reference Figure 12A The drawing method provided in the embodiment of the present application may include:

[0223] S1201: In response to a first drawing operation, display a first handwriting in a drawing area.

[0224] The first drawing operation can be considered as any drawing operation performed by the user in the drawing area. In response to the first drawing operation, the electronic device can display the first handwriting in the drawing area. For example, if the first drawing operation is the user drawing the first handwriting after opening the drawing app, the first handwriting can be the first handwriting. For example, if the first drawing operation is the user drawing the second handwriting, the first handwriting can be the second handwriting.

[0225] S1202: Save the first texture data and the first handwriting information.

[0226] In some examples, the first texture data includes: texture data of the 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 handwriting is displayed, and the first sub-area is: the sub-area associated with the first handwriting in the drawing area.

[0227] Exemplarily, for example, when the first handwriting is the first 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-area is the sub-area associated with the first handwriting in the drawing area. This example can refer to the description in S802.

[0228] For example, if the first handwriting is the second handwriting and the newly stacked element reaches a first threshold, the electronic device may include first texture data. The first texture data is texture data 2, the first artwork state is the artwork state before the second handwriting is drawn, and the first sub-area is the sub-area associated with the second handwriting within the drawing area. For this example, refer to the description in S804.

[0229] In some embodiments, the electronic device may store the first texture data and the first handwriting information in a memory. The first handwriting information may refer to the description in the above embodiments.

[0230] In some embodiments, the electronic device may store the first handwriting information in the form of a stack. For example, the electronic device may push the first handwriting information into a stack as a first stack element. In some embodiments, the stack may be stored in a memory of the electronic device.

[0231] S1203: In response to the second drawing operation, display a second handwriting in the drawing area.

[0232] S1203 may refer to the description in S1201.

[0233] In some embodiments, the second drawing operation may be an operation adjacent to the first drawing operation. For example, the first handwriting may be the first handwriting, and the second handwriting may be the second handwriting. For example, the first handwriting may be the second handwriting, and the second handwriting may be the third handwriting.

[0234] S1204: Add second texture data based on the first texture data and save information about the second handwriting.

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

[0236] In some embodiments, the second sub-region is a sub-region in the drawing area that is associated with the second handwriting, wherein the sub-region associated with the second handwriting can be understood as a sub-region in the drawing area that contains the second handwriting.

[0237] In some embodiments, the electronic device can save texture data once, such as the first texture data. In the subsequent user drawing process, the electronic device may no longer save new texture data, but continuously 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 handwriting in the drawing area, and adds the second texture data based on the first texture data, and saves the information of the second handwriting. It is understandable that in this example, in response to the user's undo operation, the electronic device can use Figure 10 Method to undo handwriting in , undo handwriting.

[0238] In some embodiments, in response to the second drawing operation, the electronic device may detect whether the number of saved handwriting information, starting from the first handwriting information, has reached a first threshold. When the electronic device detects whether the number of saved handwriting information has reached the first threshold, the first handwriting information needs to be included in the calculation.

[0239] In this example, when the number of saved handwriting data starting from the first handwriting data does not reach the first threshold, the electronic device does not save new texture data but updates the first texture data. In this embodiment of the present application, the electronic device can add the second texture data based on the first texture data to achieve the purpose of updating the first texture data.

[0240] In some embodiments, when the handwriting information is stored in a stack, the electronic device may push the second handwriting information into the stack as a second stack element, and the top element of the stack is the second handwriting information.

[0241] In this example, S1204 may be preceded by S1205:

[0242] S1205: Detect whether the number of handwritings that have been saved, starting from the first handwriting information, reaches a first threshold.

[0243] It should be understood that in some embodiments, S1205 is an optional step. Figure 12A S1205 is indicated by a dotted line.

[0244] Correspondingly, when it is determined that the number of handwritings with saved information starting from the first handwriting information does not reach the first threshold, the electronic device adds second texture data based on the first texture data and saves the second handwriting information.

[0245] In some embodiments, when handwriting information is stored in a stack, the electronic device may push the handwriting information as a stack element. For example, in S1202, the electronic device may push the first handwriting information as the first stack element. In this example, in response to the second drawing operation, the electronic device may detect whether the newly pushed stack elements, starting from the first stack element, have reached a first threshold.

[0246] When the number of newly added stack elements does not reach the first threshold starting from the first stack element, the electronic device can update the first texture data. In the embodiment of the present application, the electronic device can add the second texture data based on the first texture data to achieve the purpose of updating the first texture data.

[0247] Exemplarily, referring to the description in S805 and S806, when the first handwriting is the first pen handwriting, the second handwriting is the second pen handwriting, and the first threshold is greater than or equal to 2, the second texture data is texture data 3. This example can refer to the description in S805.

[0248] S1206 , in response to the undo instruction, restoring the texture data of the second sub-region to the drawing area, so that the drawing area does not display the second handwriting.

[0249] In some embodiments, when saving texture data, the electronic device may save the identifier of the sub-region corresponding to the texture data. Exemplarily, the electronic device saving the first texture data can be understood as: the electronic device saving the first texture data and the identifier of the first sub-region. Exemplarily, the electronic device adding the second texture data based on the first texture data can be understood as: the electronic device adding the second texture data and the identifier of the second sub-region based on the first texture data. In this embodiment, the electronic device can obtain the second texture data from the saved texture data based on the identifier of the second sub-region.

[0250] In some embodiments, the electronic device may obtain an identifier of the sub-region associated with the second handwriting from the information of the second handwriting (i.e., the second stack element). Based on the identifier of the sub-region associated with the second handwriting, the electronic device obtains texture data of the sub-region associated with the second handwriting from the previously saved texture data (the first texture data and the second texture data). After obtaining the texture data of the sub-region associated with the second handwriting, the electronic device may restore the texture data of the sub-region associated with the second handwriting to the drawing area.

[0251] The top element of the stack contains information about the second handwriting, including the identifier of the second subregion, the coordinates of multiple track points within the second handwriting, and attributes of the second handwriting. For example, the data about the second handwriting may include, but is not limited to, the color and thickness of the second handwriting. The electronic device can obtain the identifier of the subregion associated with the second handwriting from the top element of the stack, and based on the identifier of the second subregion, obtain the texture data of the second subregion from the first texture data and the second texture data.

[0252] Because the first texture data and the second texture data are both texture data for the sub-region in the first work state, if there is a third sub-region that overlaps the second sub-region and the first sub-region, the electronic device has already saved the texture data for the third sub-region when saving the first texture data. In some embodiments, the first sub-region may include the third sub-region, or the first sub-region may be the third sub-region.

[0253] In some embodiments, in order to reduce the amount of texture data stored by the electronic device and to reduce memory usage, the electronic device may add second texture data when updating the first texture data. The second texture data may include: texture data of sub-areas in the second sub-area except the third sub-area in the first work state.

[0254] In this embodiment, the first texture data includes texture data for a portion of the second sub-region (e.g., the third sub-region), and the second texture data includes texture data for a portion of the second sub-region. In response to the undo instruction, the electronic device can retrieve the identifier of the second sub-region associated with the second handwriting from the information about the second handwriting, and based on the identifier of the second sub-region, retrieve the texture data of the second sub-region from the first texture data and the second texture data. In this way, the electronic device can restore the texture data of the second sub-region to the drawing area, so that the second handwriting does not appear in the drawing area, thereby achieving the purpose of undoing the second handwriting.

[0255] In some embodiments, when the second handwriting overlaps with the first handwriting, and there is a third sub-area that overlaps between the first sub-area and the second sub-area, when the electronic device restores the texture data of the second sub-area associated with the second handwriting in the first state to the drawing area, the electronic device can also cancel the handwriting in the third sub-area, that is, causing the handwriting in the first sub-area to be canceled, that is, part of the handwriting in the first handwriting is also canceled, resulting in a shortage of the first handwriting. The electronic device can redraw the first handwriting so that when the second handwriting is canceled, the drawing area can fully display the first handwriting.

[0256] In this example, refer to Figure 12B After executing S1206, the electronic device may further execute the following steps:

[0257] S1207: Draw the handwriting of the first handwriting in the third sub-area.

[0258] The first stack element contains information about the first handwriting, including the identifier of the first subregion, the coordinates of multiple track points within the first handwriting, and the attributes of the first handwriting. The second stack element contains information about the second handwriting, including the identifier of the second subregion, the coordinates of multiple track points within the second handwriting, and the attributes of the second handwriting.

[0259] In some embodiments, when an electronic device stores 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 and the second sub-region based on 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.

[0260] In some embodiments, the electronic device may query the first stack element and the second stack element, and detect whether there is a third sub-region that overlaps the first sub-region and the second sub-region based on the identifier of the first sub-region and the identifier of the second sub-region. It should be understood that when the identifier of the first sub-region and the identifier of the second sub-region have the same identifier, the electronic device determines that the sub-region corresponding to the identifier is an overlapping sub-region.

[0261] In the embodiment of the present application, when there is a third sub-area overlapping between the first sub-area and the second sub-area, the electronic device can draw the first handwriting in the third sub-area so that the drawing area can completely display the first handwriting.

[0262] In some embodiments, the electronic device can use a template test method to set an identifier for the third sub-area. In this way, the electronic device can draw the handwriting based on the coordinates of multiple track points in the first handwriting and the attributes of the first handwriting, wherein the drawn handwriting is effective in the third sub-area. In other words, after the electronic device uses a template test method to set an identifier for the third sub-area, the electronic device can draw the handwriting of the first handwriting in the third sub-area.

[0263] It is conceivable that the user performing a restore operation may trigger the electronic device to restore the second handwriting. Accordingly, in response to the restore instruction, the electronic device may draw the second handwriting according to the information of the second handwriting, so that the drawing area displays the second handwriting.

[0264] It should be understood that the embodiments of the present application Figure 8 and Figure 10 The drawing method in the embodiment is summarized, and the embodiment of the present application has the same technical effect as the above embodiment, and the description in the above embodiment can be referred to.

[0265] 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 can be the first handwriting, and the second handwriting can be the third handwriting. In this example, the user can draw multiple handwritings in the drawing area, and the electronic device can perform the drawing method described in the following embodiments.

[0266] In one possible scenario, for example, in which a user draws a third handwriting between a first handwriting and a second handwriting, in response to the first drawing operation, the electronic device displays the first handwriting in the drawing area. The electronic device may save the first texture data and push the first stack element into the stack. In response to the third drawing operation, the electronic device displays the third handwriting in the drawing area.

[0267] In some embodiments, in response to the second drawing operation, the electronic device may add third texture data based on the first texture data and save information about the third handwriting.

[0268] In some embodiments, in response to the second drawing operation, the electronic device may detect whether the number of newly stacked elements, starting from the first stack element, reaches a first threshold. If the number of newly stacked elements does not reach the first threshold, the electronic device may add third texture data based on the first texture data and save information about the third handwriting.

[0269] In some embodiments, the third texture data includes texture data of a fourth sub-region in the first work state, wherein the fourth sub-region is a sub-region associated with the third handwriting in the drawing area.

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

[0271] In some embodiments, when storing handwriting information in a stack, the electronic device may push the third handwriting information as a third stack element. The third handwriting information may include an identifier of a fourth sub-region associated with the third handwriting, coordinates of multiple track points in the third handwriting, and attributes of the third handwriting.

[0272] In response to the second drawing operation, the electronic device displays the second handwriting in the drawing area, and the electronic device detects whether the newly stacked elements, starting from the first stack element, have reached a first threshold. If not, when the newly stacked elements have not reached the first threshold, the electronic device may add the second texture data based on the first texture data and the third texture data, and push the second stack element into the stack.

[0273] Exemplarily, for example, the first handwriting is the first handwriting, the third handwriting is the second handwriting, and the second handwriting is the third handwriting.

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

[0275] In some embodiments, the electronic device can detect whether there is an overlapping sixth sub-area between the second sub-area and the fourth sub-area based on the identifier of the second sub-area and the identifier of the fourth sub-area, and detect whether there is an overlapping third sub-area between the second sub-area and the first sub-area based on the identifier of the first sub-area and the identifier of the second sub-area. When there is an overlapping fourth sub-area between the second sub-area and the first sub-area, the electronic device can draw the handwriting of the first handwriting in the fourth sub-area. When there is an overlapping sixth sub-area between the second sub-area and the fourth sub-area, the electronic device can draw the handwriting of the third handwriting in the sixth sub-area. Please refer to the relevant description of "the electronic device draws the handwriting of the first handwriting in the third sub-area".

[0276] In an embodiment of the present application, in a scenario where a user draws multiple handwritings, after the electronic device restores the texture data of the second sub-region to the drawing area, the electronic device can determine whether the second sub-region overlaps with the sub-region associated with each handwriting based on the information of the second handwriting and the information of each handwriting. If overlap exists, the electronic device can use a template test method to set the identifier of the overlapping sub-region when redrawing the handwriting of different strokes, and redraw the handwriting of each stroke in the overlapping area corresponding to the different strokes, so that the electronic device only cancels the second handwriting.

[0277] The above embodiment describes a scenario where the electronic device detects that the number of newly added stack elements from the first stack element has not reached a first threshold. In some embodiments, after the electronic device adds the second stack element to the stack, in response to a fourth drawing operation, the electronic device displays a fourth handwriting in the drawing area. In this example, the electronic device can detect whether the number of newly added stack elements from the first stack element has reached the first threshold.

[0278] When the number of newly pushed stack elements reaches a first threshold, the electronic device may save the fourth texture data and push the fourth stack element onto the stack. The fourth texture data includes texture data of the fifth sub-area in the second artwork state, where the second artwork state is the state of the artwork in the drawing area before the fourth handwriting is displayed, the fifth sub-area is the sub-area associated with the fourth handwriting in the drawing area, and the fourth stack element is information about the fourth handwriting.

[0279] For this example, reference may be made to the descriptions in S804 and S808.

[0280] In summary, the drawing method provided in the embodiment of the present application is described below from the perspective of an image or a work. It should be understood that: Figure 12C The scenario where the second block of the second handwriting does not overlap with the first block of the first handwriting is introduced in [1]. Figure 12D , which introduces a scenario where the block for drawing the second handwriting overlaps the block for drawing the first handwriting. For example, the block for drawing the second handwriting and the block for drawing the first handwriting are both the first block.

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

[0282] Reference Figure 12C The drawing method provided in the embodiment of the present application may include:

[0283] S1201C, displaying a first image, where the first image includes a plurality of blocks.

[0284] The image can be understood as a work drawn by the user. The first image may include handwriting or not. For example, the first image may be the image displayed in the drawing area when the drawing app is opened, and the image may include or not include the handwriting drawn by the user. For example, the first image may be the image displayed in the drawing area after the user draws a few strokes after the drawing app is opened.

[0285] S1202C: In response to the first drawing operation on the first block, display a second image, where the second image includes the first image and a first handwriting corresponding to the first drawing operation.

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

[0287] The user can draw in the first area. In response to the first drawing operation on the first area, the electronic device can display a second image. The second image includes the first image and the first handwriting corresponding to the first drawing operation. In other words, compared to the first image, the second image has the first handwriting added, and the first handwriting occupies the first area.

[0288] S1203C: Save information of the first block and the first handwriting based on the first image.

[0289] The electronic device may store the first block based on the first image and information about the first handwriting, wherein the information about the first handwriting may include but is not limited to: an identifier of the first block, coordinates of multiple track points in the first handwriting, and attributes of the first handwriting.

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

[0291] S1204C: In response to the second drawing operation on the second block, display a third image, where the third image includes the second image and a second handwriting corresponding to the second drawing operation, and the first block and the second block do not overlap.

[0292] After the user draws the first handwriting in the first area, they can continue drawing. In response to a second drawing operation on the second area, the electronic device can display a third image. The third image includes the second image and the second handwriting corresponding to the second drawing operation. In other words, compared to the second image, the third image has the second handwriting added to it, and the second handwriting occupies the second area.

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

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

[0295] S1205C: Save information about the second block and the second handwriting based on the first image.

[0296] If the first block and the second block do not overlap, the electronic device may store information about the second block and the second handwriting based on the first image. The second handwriting information may include, but is not limited to, an identifier for the second block, coordinates of multiple track points within the second handwriting, and attributes of the second handwriting. In some embodiments, the electronic device may store the handwriting information in a stack, for example, by pushing the first handwriting information onto the stack.

[0297] The electronic device storing the second block based on the first image can be understood as: the electronic device storing the texture data of the second block based on the first image. In other words, the electronic device can store the texture data of the second block in the first image.

[0298] In this embodiment, after S1205C, the following steps may also be included:

[0299] S1206C: In response to the cancel instruction, process the third image based on the second block and display the second image.

[0300] After the user draws the second handwriting 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 to achieve the purpose of undoing the second handwriting in the third image.

[0301] In this embodiment of the present application, in response to the undo instruction, the electronic device can undo the second handwriting 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 handwriting in the third image based on the saved texture data of the second block.

[0302] It is understandable that the user can also perform a restore operation to restore the second handwriting. Accordingly, in response to the restore instruction, the electronic device can draw the second handwriting based on the information of the second handwriting, so that the electronic device can display the third image.

[0303] It should be understood that the embodiments of the present application have the same Figure 12A and Figure 12B For the same technical effects, reference can be made to the description in the above embodiments.

[0304] Reference Figure 12D The drawing method provided in the embodiment of the present application may include:

[0305] S1201D, displaying a first image, where the first image includes a plurality of blocks.

[0306] S1202D: In response to the first drawing operation on the first block, display a second image, where the second image includes the first image and information about the first handwriting corresponding to the first drawing operation.

[0307] S1203D: Save information about the first block and the first handwriting based on the first image.

[0308] For S1201D-S1203D, refer to the description in S1201C-S1203C.

[0309] S1204D: In response to the second drawing operation on the first block, display a third image, where the third image includes the second image and a second handwriting corresponding to the second drawing operation.

[0310] and Figure 12C The difference from the embodiment shown is that in the embodiment of the present application, when the user draws the second handwriting, he draws the second handwriting in the first block, and the first block is also the block where the user draws the first handwriting, that is, the block of the second handwriting overlaps with the block of the first handwriting.

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

[0312] S1205D, save the information of the second handwriting.

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

[0314] In some embodiments, the electronic device may store the handwriting information in the form of a stack. For example, the electronic device may push the second handwriting information into the stack.

[0315] In this embodiment, after S1205D, the following steps may also be included:

[0316] S1206D: In response to the undo instruction, the third image is processed based on the information of the first block and the first handwriting, and the second image is displayed.

[0317] After the user draws the second handwriting in the first block, the user can also perform an undo operation. In this example, because the block of the second handwriting overlaps with the block of the first handwriting and is both the first block, the electronic device can undo the second handwriting in the third image based on the first block. However, 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. The first and second handwriting do not exist in the first block of the first image. Therefore, when the electronic device undoes the second handwriting in the third image based on the first block, it also undoes the first handwriting in the third image.

[0318] In this embodiment, in order to cancel only the second handwriting without canceling the first handwriting, the electronic device may 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.

[0319] It is understandable that the user can also perform a restoration operation to restore the second handwriting. Accordingly, in response to the restoration instruction, the electronic device can draw the second handwriting based on the information of the second handwriting and display the third image.

[0320] It should be understood that the embodiments of the present application have the same Figure 12A and Figure 12B For the same technical effects, reference can be made to the description in the above embodiments.

[0321] As in the above embodiment, the electronic device can store texture data and a stack in the memory. For example, the electronic device can store the texture data and the stack in the first space of the memory. However, when the number of drawing operations is large, the electronic device stores a large amount of texture data, resulting in a reduction in the available memory of the electronic device. In some embodiments, to avoid the problem of texture data occupying 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.

[0322] Exemplarily, each time the electronic device saves texture data in the memory or updates texture data, the electronic device may write the texture data in the memory to the hard disk. Exemplarily, when the memory occupied by the texture data reaches a second threshold, the electronic device may write the texture data in the memory to the hard disk.

[0323] For example, the electronic device may store the most recent Z texture data in the memory and write the previously stored texture data to the hard disk. Alternatively, when the memory occupied by the texture data reaches a second threshold, the electronic device may store the most recent Z texture data in the memory and write the previously stored texture data to the hard disk, where Z is an integer greater than or equal to 2.

[0324] The embodiments of the present application do not limit the timing when the electronic device writes texture data in the memory to the hard disk, and the above examples are only for illustration.

[0325] Reference Figure 12A In the illustrated embodiment, in response to an undo command, the electronic device restores the texture data of the sub-area associated with the second handwriting to the drawing area. However, if the texture data of the sub-area associated with the second handwriting is written to the hard disk, the electronic device must first write the texture data of the sub-area associated with the second handwriting from the hard disk to the memory before restoring the texture data of the sub-area associated with the second handwriting to the drawing area. The process of reading data from the hard disk and writing data to the memory increases the latency of the undo operation, leading to issues such as undo lag and delay.

[0326] To address this issue, in an embodiment of the present application, the electronic device can pre-write the texture data of the sub-area associated with the second handwriting in the hard disk into the memory before using the texture data of the sub-area associated with the second handwriting. In this way, when the electronic device performs an undo operation, there is no need to perform a read operation. Instead, the texture data of the sub-area associated with the second handwriting in the memory is directly restored to the drawing area, reducing the time spent on the read operation. In other words, the electronic device can pre-load the texture data of the sub-area associated with the second handwriting to reduce the time spent on the read operation and avoid problems such as undo lag and delay.

[0327] The following embodiments describe a method for preloading texture data in an electronic device:

[0328] Method 1:

[0329] In some embodiments, when the number of undo commands received by the electronic device reaches a third threshold within a preset time period, the electronic device may preload the texture data. In other words, when a user performs multiple undo operations in a short period of time, the user is more likely to continue performing undo operations. Therefore, the electronic device may preload the texture data to reduce the delay of subsequent undo operations.

[0330] Figure 13A This diagram shows a schematic diagram of how electronic devices save texture data. Figure 13A Taking the first threshold of 3 as an example, after the user draws the first handwriting, the electronic device can save the texture data, such as texture data 1, and push the information of the first handwriting onto the stack. After the user draws the second handwriting, the electronic device can update texture data 1 and push the information of the second handwriting onto the stack. After the user draws the third handwriting, the electronic device can update texture data 1 and push the information of the third handwriting onto the stack. The method for the electronic device to save texture data 1 and update data 1 can refer to the description of the above embodiment.

[0331] After the user draws the fourth handwriting, the electronic device determines that the number of newly added stack elements has reached three. The electronic device can then save the texture data again, such as texture data 2, and push the fourth handwriting information onto the stack. After the user draws the fifth handwriting, the electronic device can update texture data 2 and push the fifth handwriting information onto the stack. After the user draws the sixth handwriting, the electronic device can update texture data 2 and push the sixth handwriting information onto the stack.

[0332] Similarly, after the user draws multiple times, the texture data saved by the electronic device and the stack can be Figure 13A shown.

[0333] Take the example of an electronic device writing all texture data to the hard disk, refer to Figure 13B Taking the information of the sixth handwriting as an example, the current top element of the stack is located between the information of the fourth handwriting and the information of the seventh handwriting in the stack. In some embodiments, the fourth handwriting can be regarded as the first stack element, and the seventh handwriting can be regarded as the fourth stack element.

[0334] Taking the third threshold of 2 as an example, if the electronic device receives two undo commands within a preset time period, meaning the user performs two undo operations consecutively within a short period of time, the electronic device will undo the sixth and fifth handwriting strokes. In this scenario, the electronic device determines that the user is likely to continue performing undo operations. The electronic device can preload texture data 2, meaning that before the user performs the undo operation again, the electronic device will pre-write texture data 2 from the hard disk to the memory. This way, when the user performs the undo operation again, the electronic device can directly restore texture data 2 to the drawing area, undoing the fourth handwriting stroke.

[0335] Similarly, in some embodiments, within a preset time, when the number of times the electronic device receives a recovery instruction reaches a third threshold, the electronic device can preload texture data. For example, taking the information that the current top element of the stack is the second handwriting as an example, and taking the third threshold as 2 as an example, when the number of times the electronic device receives a recovery instruction reaches 2 within the preset time length, that is, the user performs two recovery operations in a short period of time, the electronic device recovers the second handwriting and the third handwriting. 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 texture data 2, that is, before the user performs the recovery operation again, the texture data 2 in the hard disk is written into the memory in advance. In this way, when the user performs the recovery operation again, the electronic device can directly restore the texture data 2 to the drawing area to restore the fourth handwriting.

[0336] Method 2:

[0337] In some embodiments, if the distance between the current top stack 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 previously 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 pushed onto the stack when the texture data is saved.

[0338] For example, refer to Figure 13C Taking the current top element of the stack as the information of the sixth handwriting as an example, and taking the third threshold as 1 as an example, there is 1 stack element (i.e., the information of the fifth handwriting) between the current top element of the stack and the stack element corresponding to the previously saved texture data (i.e., the information of the fourth handwriting). In order to respond promptly to the user's undo operation at this time, 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 restore the texture data 2 to the drawing area to undo the sixth handwriting.

[0339] Similarly, the current top element of the stack is the information of the sixth handwriting, and the current top element of the stack is adjacent to the stack element corresponding to the next saved texture data (i.e., the information of the seventh handwriting). In order to respond promptly to the user's recovery operation at this time, 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 restore the texture data 3 to the drawing area to restore the seventh handwriting.

[0340] Method 3:

[0341] In some embodiments, the electronic device may also preload texture data based on the user's drawing habits. For example, the electronic device may continuously update the user's drawing habits based on the user's historical drawing data. The present application does not elaborate on how the electronic device acquires the user's drawing habits; for example, model training or statistical methods may be used.

[0342] For example, if a user performs multiple undo operations when using a specific function, the electronic device can preload texture data. For example, when using the eraser function, the user may make a mistake or erase too much, and the user may perform the undo operation multiple times. In this example, when the user uses the eraser function, the electronic device can preload one or more previous texture data based on the current top element in the stack.

[0343] For example, if a user is not proficient in using a certain type of brush, he or she may perform undo operations multiple times. In this example, when the user uses a certain type of brush function, the electronic device can preload one or more previous texture data based on the current top element of the stack.

[0344] It should be understood that in the embodiment of the present application, at least one logic of method 1, method 2, and method 3 can be pre-set in the electronic device so that the electronic device can preload texture data.

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

[0346] In an embodiment of the present application, before the user performs an undo operation or a 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 delay of the undo operation or the restore operation, and improve the user experience.

[0347] In some embodiments, the software system of the electronic device may adopt a layered architecture, an event-driven architecture, a microkernel architecture, a microservice architecture, or a cloud architecture. Figure 14A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The layered architecture divides the software system of an electronic device into several layers, each with a clear role and division of labor. Layers can communicate with each other through software interfaces.

[0348] In some embodiments, the software layer of the electronic device may include an application layer (applications) and an application framework layer (application framework). In addition, the electronic device may further include a hardware layer. It should be understood that the embodiments of the present application 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 embodiments of the present application. The modules included in each layer below do not constitute a limitation on the structure of the electronic device, and the level of module deployment (example description) does not constitute a limitation on the structure of the electronic device.

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

[0350] Reference Figure 14 The application layer includes a work management module, a layer management module, and an operation stack. The work management module manages works within the drawing app, such as user notes and drawings. The layer management module manages layers within the drawing app, such as creating, deleting, and inserting layers. It should be understood that these layers are visible to users within the drawing app.

[0351] The operation stack can be understood as the stack described in the above embodiment, and the handwriting information can be stored in the stack.

[0352] The application framework layer provides APIs and programming frameworks for applications in the application layer. The application framework layer includes some predefined functions.

[0353] Reference Figure 14 The application framework layer may include a rendering engine system. This rendering engine system may include modules such as brush drawing, layer composition, and a rendering pipeline. Brush drawing assists electronic devices in drawing handwriting. Layer composition assists electronic devices in compositing handwriting from different layers. It should be understood that these layers are layers within an image. The rendering pipeline assists electronic devices in rendering handwriting.

[0354] The rendering engine system provides APIs for brush drawing, layer composition, free drawing, and the rendering pipeline, preventing applications from interacting with underlying APIs. These include, but are not limited to, central processing unit (CPU) and graphics processing unit (GPU) interfaces.

[0355] Reference Figure 14 The hardware layer may include: CPU and GPU. Among them, the CPU can execute the above embodiment by calling the CPU interface. Figure 8 、 Figure 10 、 Figures 12A-12D The GPU can call the GPU interface to render the handwriting when drawing the handwriting so that the handwriting can be displayed in the drawing area.

[0356] In other words, the CPU is mainly responsible for processing and maintaining various data structures, such as the structure maintenance of the operation stack, popping and pushing stack elements, maintaining the current stack structure, maintaining texture data, etc. The GPU is mainly responsible for rendering the handwriting and outputting the handwriting to the drawing area.

[0357] It is understandable that Figure 14 The illustrated structure does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0358] It should be noted that the data involved in this application (including but not limited to data used for analysis, stored data, displayed data, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0359] In one embodiment, the present application also provides an electronic device. Figure 15 The electronic device may include: a processor 1501 (e.g., a CPU) and a memory 1502. The memory 1502 may include a high-speed random-access memory (RAM) and may also include a non-volatile memory (NVM), such as at least one disk storage. The memory 1502 may store various instructions for performing various processing functions and implementing the method steps of the present application.

[0360] Optionally, the electronic device involved in this application may further include: a power supply 1503, a communication bus 1504, and a communication port 1505. The communication port 1505 is used to enable communication between the electronic device and other peripheral devices. In the embodiment of the present application, the memory 1502 is used to store computer-executable program code, which includes instructions; when the processor 1501 executes the instructions, the instructions cause the processor 1501 of the electronic device to perform the actions in the above-mentioned method embodiment. The implementation principles and technical effects are similar and will not be repeated here.

[0361] Optionally, the electronic device involved in this application may further include: a display screen 1506. The display screen 1506 is used to display an interface of the electronic device.

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

[0363] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When software is used for implementation, it can be implemented in whole or in part 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, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive (SSD)).

[0364] The term "plurality" in this document refers to two or more. The term "and / or" in this document simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can represent: A alone, A and B together, or B alone. Furthermore, the character " / " in this document generally indicates an "or" relationship between the related objects; in a formula, the character " / " indicates a "division" relationship between the related objects.

[0365] It will be understood that the various numerical numbers involved in the embodiments of the present application are merely distinctions for the convenience of description and are not intended to limit the scope of the embodiments of the present application.

[0366] It can be understood that in the embodiments of the present application, the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

Claims

1. A drawing method, characterized in that: include: In response to the first drawing operation, displaying first handwriting in the drawing area; Saving first texture data and information about the first handwriting, wherein the first texture data includes texture data of a first sub-region in a first artwork state, wherein the first artwork state is the state of the artwork in the drawing area before the first handwriting is displayed, and the first sub-region is a sub-region in the drawing area associated with the first handwriting; In response to the second drawing operation, displaying second handwriting in the drawing area; Adding second texture data based on the first texture data and storing information about the second handwriting, wherein the second texture data includes texture data of a second sub-region in the first work state, the second sub-region being a sub-region associated with the second handwriting in the drawing area; In response to an undo instruction, the texture data of the second sub-area is restored to the drawing area, so that the drawing area does not display the second handwriting.

2. The method according to claim 1, characterized in that The adding of second texture data based on the first texture data and storing the second handwriting information includes: When it is determined that the number of handwritings with saved information starting from the first handwriting information does not reach a first threshold, the second texture data is added based on the first texture data, and the second handwriting information is saved.

3. The method according to claim 1 or 2, characterized in that There is a third sub-region overlapping between the first sub-region and the second sub-region, and the second texture data specifically includes: texture data of sub-regions in the second sub-region except the third sub-region in the first work state.

4. The method according to claim 3, characterized in that The method further comprises: Draw the first handwriting in the third sub-area.

5. The method according to claim 4, characterized in that The information of the first handwriting further includes: coordinates of a plurality of track points in the first handwriting, and attributes of the first handwriting; and drawing the first handwriting in the third sub-area includes: Using a template test method, setting an identifier of the third sub-area; The handwriting of the first handwriting in the third sub-area is drawn according to the coordinates of a plurality of track points in the first handwriting and the attributes of the first handwriting.

6. The method according to any one of claims 1 to 5, characterized in that The method further comprises: In response to the restoration instruction, drawing the second handwriting according to the information of the second handwriting; The second handwriting is displayed in the drawing area.

7. The method according to any one of claims 1 to 6, characterized in that In response to the second drawing operation, before displaying the second handwriting in the drawing area, the method further includes: In response to the third drawing operation, displaying third handwriting in the drawing area; Third texture data is added based on the first texture data, and information about the third handwriting is saved. The third texture data includes texture data of a fourth sub-region in the first work state. The fourth sub-region is a sub-region in the drawing area that is associated with the third handwriting and is not saved in the first work state.

8. The method according to claim 7, characterized in that The adding of third texture data based on the first texture data and storing information of the third handwriting includes: When it is determined that the number of handwritings with saved information starting from the first handwriting information does not reach a first threshold, third texture data is added based on the first texture data, and the third handwriting information is saved.

9. The method according to any one of claims 1 to 8, characterized in that The method further comprises: In response to a fourth drawing operation, displaying fourth handwriting in the drawing area; When it is determined that the number of handwritings for which information has been saved, starting from the information of the first handwriting, reaches a first threshold, fourth texture data and information of the fourth handwriting are saved, the fourth texture data including texture data of a fifth sub-region in a second artwork state, the second artwork state being the state of the artwork in the drawing area before the fourth handwriting is displayed, and the fifth sub-region being the sub-region associated with the fourth handwriting in the drawing area.

10. A drawing method, characterized in that: include: displaying a first image, wherein the first image includes a plurality of blocks; 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 handwriting corresponding to the first drawing operation; saving information of the first block and the first handwriting based on the first image; In response to a second drawing operation on the second block, displaying a third image, the third image including the second image and a second handwriting corresponding to the second drawing operation, wherein the first block and the second block do not overlap; The information of the second block and the second handwriting based on the first image is saved.

11. The method according to claim 10, characterized in that The method further comprises: In response to the undo instruction, the third image is processed based on the second block, and the second image is displayed.

12. The method according to claim 11, characterized in that The processing of the third image based on the second block includes: Based on the second block, the second handwriting in the third image is canceled.

13. The method according to claim 11 or 12, characterized in that The method further comprises: In response to the restoration instruction, the second handwriting is drawn based on the information of the second handwriting, and the third image is displayed.

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

15. A drawing method, characterized in that: include: displaying a first image, wherein the first image includes a plurality of blocks; In response to a first drawing operation on a first block, displaying a second image, wherein the second image includes the first image and information of a first handwriting corresponding to the first drawing operation; saving information of the first block and the first handwriting based on the first image; 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; The information of the second handwriting is saved.

16. The method according to claim 15, characterized in that The method further comprises: In response to an undo instruction, the third image is processed based on the information of the first block and the first handwriting, and the second image is displayed.

17. The method according to claim 16, characterized in that The processing of the third image based on the information of the first block and the first handwriting includes: based on the first block, canceling the second handwriting in the third image; Based on the information of the first handwriting, the first handwriting is drawn in the first block.

18. The method according to claim 16 or 17, characterized in that The method further comprises: In response to the restoration instruction, the second handwriting is drawn based on the information of the second handwriting, and the third image is displayed.

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

20. An electronic device, characterized in that: The electronic device includes: one or more processors and memory; The memory is coupled to the one or more processors, and is configured to store computer program codes, where the computer program codes include computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 1 to 19.

21. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1-19.

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

23. A computer program product, characterized in that The computer program product comprises a computer program code, and when the computer program code is run on an electronic device, the electronic device is caused to perform the method according to any one of claims 1 to 19.