A method and system for optimizing primitive movement and sorting

By establishing a mapping table between graphic element identifiers and location indexes and designing differentiated sorting logic, the problem of inaccurate sorting of combined and non-combined graphic elements in existing technologies is solved, achieving accurate positioning of graphic elements and improving sorting efficiency.

CN122134542APending Publication Date: 2026-06-02BEIJING BOE ENERGY TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING BOE ENERGY TECH
Filing Date
2026-01-26
Publication Date
2026-06-02

Smart Images

  • Figure CN122134542A_ABST
    Figure CN122134542A_ABST
Patent Text Reader

Abstract

This invention provides a method and system for optimizing the movement and sorting of graphic elements, relating to the field of graphics processing technology. The method includes: acquiring target graphic elements and sorting instructions; using a list of all graphic elements in the current canvas as a reference list; establishing a mapping table between graphic element identifiers and position indices based on the reference list; determining the original position indices of the target graphic element and related sub-graphic elements in the reference list according to the mapping table; determining the target position of the target graphic element in the reference list according to the sorting instructions, the type of the target graphic element, and the original position index; updating the arrangement order of the target graphic element and related sub-graphic elements in the reference list according to the target position; and outputting a reference graphic element list after optimization of the target graphic element sorting based on the updated reference list.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of graphics processing technology, and in particular to a method and system for optimizing primitive movement and sorting. Background Technology

[0002] Primitive management is a crucial task in the graphics processor rendering pipeline. Primitive movement and sorting, as a fundamental step in graphics editing, is widely used in various canvas operation scenarios. This step relies on a reference list to control primitive positions. By establishing a relationship between primitive identifiers and position indices, it supports the orderly display of graphics and is a fundamental technical support for ensuring the smooth progress of the graphics processing workflow.

[0003] Current technologies can obtain target primitives and sorting instructions, establish a mapping table to determine the original position index of the primitives, and then update and output the primitive arrangement order. These technologies can fulfill basic primitive movement and sorting needs. By distinguishing primitive types and associating sub-primitive information, they provide core operational logic for graphic editing, effectively supporting primitive management in various canvas scenarios and ensuring the basic accuracy of graphic display.

[0004] However, existing technologies lack specific logic when processing combined and non-combined primitives, are prone to positional errors due to index offsets, and are not precise enough in handling the hierarchical relationships of nested combined primitives, affecting sorting efficiency and accuracy. Summary of the Invention

[0005] In view of the shortcomings of the prior art, the purpose of this invention is to provide a primitive movement and sorting optimization method, which can solve the technical problems of the prior art in that it lacks targeted logic when processing combined primitives and non-combined primitives, is prone to position errors due to index offset, and is not accurate enough in processing the hierarchical association of nested combined primitives, thus affecting sorting efficiency and accuracy.

[0006] A first aspect of this invention provides a method for optimizing primitive movement and sorting, comprising:

[0007] S1: Obtain the target primitive and sorting instructions; S2: Use the list of all primitives in the current canvas as a reference list; S3: Based on the reference list, establish a mapping table between the graphic element identifier and the position index of each graphic element; S4: Determine the original position index of the target graphic element and related sub-graphic elements in the reference list based on the mapping relationship table; S5: Determine the target position of the target graphic element in the reference list based on the sorting instruction, the type of the target graphic element, and the original position index; S6: Update the order of target primitives and related sub-primitives in the reference list based on the target location; S7: Based on the updated reference list, output the optimized reference primitive list after sorting the target primitives.

[0008] A second aspect of this invention provides a primitive movement and sorting optimization system, comprising: a processor and a memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the primitive movement and sorting optimization method as described in the first aspect.

[0009] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, a differentiated sorting logic is designed based on sorting instructions and target primitive types to address the lack of specificity in processing combined and non-combined primitives and avoid positional deviations. A positional compensation variable is introduced when updating the sorting order to compensate for index offsets, ensuring the accuracy of primitive positions after deletion and insertion. Relying on a mapping table and primitive identifier associations, the hierarchical relationships of nested combined primitives are accurately located, improving sorting efficiency. Simultaneously, associations are established using the original position indexes to ensure stable sorting results and improve the primitive movement and sorting technology logic. Attached Figure Description

[0010] The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Throughout the drawings, the same reference numerals denote the same parts. Obviously, the drawings described below are merely some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without any creative effort.

[0011] Figure 1 This is a flowchart illustrating a primitive movement and sorting optimization method provided in an embodiment of the present invention.

[0012] Figure 2 This is a schematic diagram of the structure of a primitive movement and sorting optimization system provided in an embodiment of the present invention. Detailed Implementation

[0013] To enable those skilled in the art to better understand the technical solutions in the embodiments of the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. It should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.

[0014] The primitive movement and sorting optimization method provided by the present invention will be described in detail below with reference to the accompanying drawings, through specific embodiments and application scenarios.

[0015] Reference manual attached Figure 1 The diagram shows a flowchart of a primitive movement and sorting optimization method provided by an embodiment of the present invention.

[0016] This invention provides a method for optimizing the movement and sorting of primitives, which may include the following steps: S1: Obtain the target primitive and sorting instructions.

[0017] The target graphic element refers to the graphic element to be moved and sorted, and the sorting instruction refers to the operation instruction used to control the graphic element to move up or down.

[0018] Optionally, sorting instructions include move-up instructions and move-down instructions.

[0019] Among them, the "move up" command refers to the command that controls the graphic element to move to a position earlier in the reference list, and the "move down" command refers to the command that controls the graphic element to move to a position later in the reference list.

[0020] For example, if a user needs to move a rectangle up in the canvas, the target element is that rectangle (the target element is the rectangle object), and the sorting command is the "move up" command (the sorting command value is the "move up" flag). If a user needs to move a group of circles down, the target element is the list of those circles, and the sorting command value is the "move down" flag.

[0021] It should be noted that this clause clarifies the specific types of sorting instructions, providing a clear basis for subsequent differentiated sorting logic, ensuring the accuracy of sorting operations, and avoiding operational deviations caused by ambiguous instructions.

[0022] In this embodiment of the invention, this step can accurately identify the operation object and operation direction, avoid operational redundancy caused by indiscriminate acquisition, provide a clear execution basis for the subsequent sorting process, and ensure the targeted nature of the operation.

[0023] S2: Use the list of all primitives in the current canvas as a reference list.

[0024] The canvas refers to the area on which graphics are edited, while the reference list is a collection that records all graphic element information within the current canvas, providing the basic data support for sorting.

[0025] For example, if there is a rectangle (identifier) ​​in the current canvas pen 1) Combined graphics (logos) pen 2. Contains two sub-circles), triangle (identifier) pen 3) For three graphic elements, refer to the list_ pens for[pen 1, pen 2, pen [3] Each element carries its own complete attribute information.

[0026] In this embodiment of the invention, this step can completely cover all primitives within the canvas, avoiding sorting misalignment caused by missing primitives, and providing a comprehensive data foundation for the subsequent establishment of a mapping relationship table.

[0027] S3: Based on the reference list, establish a mapping table between the graphic element identifier and the position index of each graphic element.

[0028] Among them, the graphic element identifier refers to the identification information used to uniquely distinguish each graphic element, the position index refers to the position number of the graphic element in the reference list, and the mapping table refers to the lookup table of associated graphic element identifiers and corresponding position indices.

[0029] Optionally, the mapping table includes element identifiers, location indexes, and association identifiers of related sub-elements.

[0030] Among them, the association identifier of related sub-elements refers to the identification information used to associate combined elements with their corresponding related sub-elements.

[0031] Specifically, the core function of the mapping table is to quickly look up the corresponding position index using the primitive identifier, without having to traverse the entire reference list.

[0032] For example, based on the above reference list_ pens [ pen 1, pen 2, pen 3], the established mapping table can be represented as { pen 1:0, pen 2:1, pen 3:2}, where the key is the primitive identifier and the value is the index of the corresponding position. If pen 2 is a composite graphic containing sub-elements. pen 2-1 pen 2-2, after supplementing the relevant sub-element association identifiers, the mapping relationship table can be expanded to { pen 1:0, pen 2:1 (Sub-identifier:) pen 2-1 pen 2-2), pen 3:2}.

[0033] It should be noted that this clause clarifies the core components of the mapping relationship table, enabling precise binding of graphic elements, locations, and sub-graphic element affiliations. This provides data support for quickly locating the positions of relevant sub-graphic elements and enhances the practicality and relevance of the mapping relationship table.

[0034] In one possible implementation, S3 specifically includes sub-steps S301 to S304: S301: Initialize an empty mapping table.

[0035] S302: Obtain a complete list of primitives containing the target primitive and related sub-primitives through recursive traversal operations.

[0036] Among them, the recursive traversal operation refers to the operation of traversing and combining primitives layer by layer to obtain all related sub-primitives, and the complete primitive list refers to the set that records the target primitive and all related sub-primitives.

[0037] S303: Traverse the reference list to identify whether the current element belongs to the complete element list.

[0038] Here, the current element refers to the element being validated while traversing the reference list.

[0039] For example, traversing a reference list_ pens [ pen 1, pen 2, pen 3], sequentially check whether the current graphic element is in the complete graphic element list [ pen 2, pen 2-1, pen In 2-2], only pen 2. If the conditions are met, subsequent data entry operations will only be performed on pen2.

[0040] S304: If the current graphic element belongs to the complete graphic element list, record the graphic element identifier and position index of the current graphic element, and store the current graphic element in the mapping table. Otherwise, continue to traverse the reference list until all graphic elements have been verified, and complete the establishment of the mapping table.

[0041] Furthermore, if the current graphic element is also in the complete graphic element list, the identifier and original position index information of the current graphic element are recorded in the mapping table to ensure that the mapping table only stores the associated data of the graphic elements to be adjusted, thereby improving query efficiency.

[0042] It should be noted that the above sub-steps accurately filter target graphic elements and related sub-graphic elements and enter them into the mapping relationship table through recursive traversal and list verification, avoiding irrelevant graphic elements from occupying storage resources, while ensuring the integrity of the mapping relationship table data, laying an accurate data foundation for subsequent location positioning.

[0043] In this embodiment of the invention, this step enables precise binding between graphic elements and locations, eliminating the need to repeatedly traverse the reference list to find locations, thus significantly improving the efficiency of subsequent location positioning.

[0044] S4: Based on the mapping relationship table, determine the original position index of the target primitive and related sub-primitives in the reference list.

[0045] Among them, related sub-elements refer to sub-graphic elements that have a hierarchical relationship with combined elements, and the original position index refers to the initial position number of the element in the reference list before the sorting operation is performed.

[0046] In one possible implementation, S4 specifically includes sub-steps S401 to S404: S401: Recursively traverse the target primitive to obtain all related sub-primitives contained in the target primitive.

[0047] S402: Integrate the target primitive with all related sub-primitives to obtain a complete primitive list.

[0048] For example, if the target primitive is a composite graphic... pen 2. After recursively traversing, obtain all its sub-elements. pen 2-1 pen 2-2, the complete list of primitives is obtained as [ pen 2, pen 2-1, pen 2-2].

[0049] S403: Based on the complete list of primitives, traverse the reference list to determine the target primitive and related sub-primitives.

[0050] For example, based on a complete list of primitives [ pen 2, pen 2-1, pen 2-2] Traversal Reference List_ pens The graphic elements to be adjusted were identified as follows: pen 2.

[0051] S404: Based on the mapping relationship table, extract the original position indices of the target primitive and related sub-primitives in the reference list.

[0052] Furthermore, the original position index serves as the basic benchmark data for subsequent sorting calculations and position adjustments, ensuring the accuracy of the sorting operation.

[0053] For example, according to the mapping table { pen 1:0, pen 2:1, pen 3:2}, extract target primitives pen The original location index of 2 is 1, and its related sub-primitives pen 2-1 pen The original position index of 2-2 can be obtained by recursively querying the mapping table.

[0054] It should be noted that the above sub-steps achieve accurate positioning of the original positions of the target primitive and related sub-primitives through hierarchical recognition and index extraction, avoiding misalignment caused by individual positioning. At the same time, the mapping relationship table is used to improve the efficiency of index extraction, providing a reliable basis for subsequent sorting position calculation.

[0055] Optionally, after S4 and before S5, the following are also included: Establish sorted lists between the target primitive and related sub-primitives and their original location indices.

[0056] The sorting list refers to a temporary list that associates the graphic elements with their original location indices and is used for subsequent sorting.

[0057] The sorting method of the sort list is determined according to the sorting instructions.

[0058] The sorting method refers to the index sorting rules set according to the needs of moving up or down.

[0059] Sort the sorted list based on the sorting method.

[0060] Based on the sorted list, the target primitive and each related sub-primitive are processed sequentially.

[0061] It should be noted that the above steps, by establishing a sorting list and specifying the sorting method, standardize the processing order of graphic elements, avoid sorting errors caused by chaotic processing order, and provide orderly guidance for batch processing of graphic elements, thereby improving the coherence and efficiency of the sorting process.

[0062] Specifically, the sorting method is determined by the sorting instruction: the move-up instruction corresponds to descending order, and the move-down instruction corresponds to ascending order.

[0063] For example, if the primitive to be adjusted is pen 2 (Original Index 1) pen 3 (Original index 2), the sorting instruction is a move-up instruction, so the initial sorted list is [{ pen 2:1},{ pen 3:2}], after being sorted in descending order by the original position index, becomes [{ pen 3:2},{ pen 2:1}], ensuring that processing starts from the primitive with the larger position index.

[0064] In this embodiment of the invention, this step can simultaneously locate the target graphic element and the associated sub-graphic element positions, avoiding misalignment caused by individual positioning, and providing an accurate positional reference for sorting combined graphic elements.

[0065] S5: Determine the target position of the target graphic element in the reference list based on the sorting instruction, the type of the target graphic element, and the original position index.

[0066] Among them, the target primitive type is divided into combined primitive (including related sub-primitives) and non-combined primitive (without related sub-primitives), and the target position refers to the final position number that the primitive should be in after the sorting operation is performed.

[0067] Optionally, when the sorting instruction is an up instruction, the target position of the target graphic element in the reference list is determined.

[0068] The methods for determining the target location specifically include: If the target graphic element is a composite graphic element, extract the original position indices of the related sub-graphic elements, and determine the next adjacent position index of the largest original position index as the target position. Otherwise, calculate the next adjacent position index based on the original position index of the target graphic element, and obtain the next adjacent graphic element from the reference list based on the next adjacent position index.

[0069] The next adjacent position index refers to the next index after the current position index, and the next adjacent graphic element refers to the graphic element in the reference list that is one position after the target graphic element.

[0070] If the next adjacent primitive is a combined primitive, recursively calculate the total number of the next adjacent primitive and related sub-primitives, and determine the target location by the next adjacent location index corresponding to the sum of the original location index of the target primitive and the total number. Otherwise, determine the target location by the location index of the next adjacent primitive.

[0071] Specifically, this step corresponds to the logic of the upward sorting function. When the target primitive is a non-combined primitive and the next adjacent primitive is a combined primitive, the target position needs to be calculated by formula. The core is to skip the entire combined primitive and its sub-elements to ensure that the upward position is accurate.

[0072] Furthermore, the specific formula for calculating the location involved in this step is: Target location = Original index of the target primitive + Total number of adjacent combined primitives and their sub-elements + 1.

[0073] For example, if the target primitive is a non-composite primitive pen 1 (Original index 0), the next adjacent primitive is a combined primitive. pen 2 (including 2 sub-primitives, total number) len If the value is 3, then substituting into the formula, the target position is calculated as: 0 + 3 + 1 = 4, i.e. pen 1 will be moved to position 4 in the reference list.

[0074] It should be noted that the above steps design differentiated target position calculation logic for combined and non-combined primitives, accurately avoid interference from adjacent combined primitives, ensure the accuracy of primitive positions after moving upwards, and improve sorting adaptability in nested scenarios.

[0075] Optionally, when the sorting instruction is a move-down instruction, the target position of the target element in the reference list is determined.

[0076] The methods for determining the target location specifically include: If the target graphic element is a composite graphic element, extract the original position indices of the related sub-graphic elements, and determine the smallest original position index as the target position. Otherwise, calculate the previous adjacent position index based on the original position index of the target graphic element, and obtain the previous adjacent graphic element from the reference list based on the previous adjacent position index.

[0077] The previous adjacent element refers to the element in the reference list that is one position before the target element.

[0078] If the preceding adjacent element is a composite element, recursively obtain the position index of the final-level parent composite element of the preceding adjacent element, and determine the position index of the final-level parent composite element as the target position. Otherwise, determine the position index of the preceding adjacent element as the target position.

[0079] Among them, the final parent composite primitive refers to the top-level composite primitive in nested composite primitives that has no higher-level parent.

[0080] Specifically, the logic of this step corresponds to the downward sorting function. The core is to ensure that the downward position fits the hierarchical relationship by recursively tracing back to the top-level parent in the case of nested composite primitives.

[0081] For example, if the target primitive is a non-composite primitive pen 3 (Original Index 2), the previous adjacent primitive is pen 2-1 (Child primitives, final parent composite primitives are) pen 2. If the location index is 1, then the target location is determined to be 1, that is... pen 3 will be moved to the position of reference list index 1.

[0082] It should be noted that the above steps accurately adapt to the differences in primitive types in the down-moving scenario. By locating the top-level parent composite primitive, the problem of inaccurate processing of nested composite primitive hierarchy is solved, ensuring that the primitive position after down-moving meets expectations.

[0083] In this embodiment of the invention, this step combines multi-dimensional parameters to determine the target position, avoiding positional deviations caused by a single parameter and ensuring that the position of the sorted elements meets expectations.

[0084] S6: Update the order of the target primitive and related sub-primitives in the reference list based on the target location.

[0085] Updating the sorting order refers to adjusting the position number of the graphic element in the reference list so that the graphic element is in the target position and the relative order of the associated sub-graphic elements is maintained.

[0086] In one possible implementation, S6 specifically includes: When the target primitive is a composite primitive, set a position compensation variable.

[0087] Among them, the position compensation variable refers to the variable used to offset the reference list index offset after the sub-element is deleted.

[0088] Traverse all related sub-primitives of the target primitive.

[0089] Based on the difference between the original location index and the location compensation variable of each related sub-element, the corresponding related sub-element is deleted from the reference list.

[0090] Based on the target location, the target primitive and each related sub-primitive are inserted into the reference list.

[0091] If the target element is a non-combined element, delete the target element directly from its original position and insert it into the target position.

[0092] Specifically, this step corresponds to the movement logic of combined primitives in the up and down sorting functions, and the position compensation variable corresponds to the parameters. offset Its core function is to offset the deviation caused by the change in the reference list index after the deletion of sub-elements, and to ensure the accuracy of the deletion position.

[0093] Furthermore, the specific formula for calculating the deletion position of the sub-element involved in this step is: Deletion Position = Original Position Index of Sub-element - Position Compensation Variable offset .

[0094] For example, if the composite primitives pen 2 containing sub-primitives pen 2-1 (Original Index 3) pen 2-2 (Original Index 4), Position Compensation Variable offset Initialize to 0, iterate and delete. pen When the value is 2-1, the deletion position is 3-0=3. After deletion... offset Increment to 1. Delete. pen At step 2-2, the deletion position is 4-1=3, ensuring that the deletion positions are accurate in both steps.

[0095] It should be noted that the above steps are designed with differentiated update logic for different primitive types. Position compensation variables are used to avoid position errors caused by index offsets, while maintaining the relative order stability of sub-primitives within the combined primitive. This balances sorting accuracy and efficiency, and improves the technical logic for updating the primitive arrangement order.

[0096] In this embodiment of the invention, this step can selectively update the positions of the target graphic element and its associated sub-graphic elements, avoiding efficiency loss caused by refreshing the entire list, while ensuring the stability of the internal structure of the combined graphic elements.

[0097] S7: Based on the updated reference list, output the optimized reference primitive list after sorting the target primitives.

[0098] The optimized reference element list refers to the final element list after position adjustment and sorting requirements, which can be directly used for graphic display and subsequent editing operations.

[0099] Specifically, the optimized reference element list is the reference list after its position has been adjusted. pens It can be directly synchronized to the canvas for display, or used for other subsequent editing operations.

[0100] For example, the above pen 1. After moving up, the optimized list of reference primitives_ pens for[ pen 2, pen 3, pen 2-1, pen 2-2, pen [1] The positions of each graphic element meet the sorting requirements and can be directly rendered and displayed on the canvas.

[0101] In this embodiment of the invention, this step outputs an optimized complete list, ensuring that the sorting results can be directly reused without secondary processing, thus improving the continuity of the graphic editing process.

[0102] Reference manual attached Figure 2 The diagram shows a schematic representation of a primitive movement and sorting optimization system provided in an embodiment of the present invention.

[0103] This invention provides a primitive movement and sorting optimization system 20, including: a processor 201 and a memory 202; The memory 202 stores programs or instructions that can run on the processor 201. When the program or instructions are executed by the processor 201, they implement the steps of the above-described primitive movement and sorting optimization method and achieve the same technical effect. To avoid repetition, the present invention will not elaborate further.

[0104] It should be understood that the processor 201 in this embodiment of the invention may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.

[0105] It should also be understood that the memory 202 in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct memory bus RAM (DR RAM).

[0106] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. 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. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. 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 sets of available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium. A semiconductor medium can be a solid-state drive.

[0107] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0108] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0109] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0110] In the several embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0111] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0112] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0113] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0114] This invention provides a readable storage medium comprising: storing a program or instructions on the readable storage medium, wherein when the program or instructions are executed by a processor, the program or instructions implement the steps of the above-described primitive movement and sorting optimization method and achieve the same technical effect. To avoid repetition, this invention will not elaborate further.

[0115] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present invention, and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the protection scope of the present invention.

Claims

1. A method for optimizing primitive movement and sorting, characterized in that, include: S1: Obtain the target primitive and sorting instructions; S2: Use the list of all primitives in the current canvas as a reference list; S3: Based on the reference list, establish a mapping table between the graphic element identifier and the position index of each graphic element; S4: Determine the original position index of the target graphic element and related sub-graphic elements in the reference list according to the mapping relationship table; S5: Determine the target position of the target graphic element in the reference list according to the sorting instruction, the type of the target graphic element, and the original position index; S6: Update the arrangement order of the target primitive and the related sub-primitives in the reference list according to the target location; S7: Based on the updated reference list, output the optimized reference primitive list after sorting the target primitives.

2. The primitive movement and sorting optimization method according to claim 1, characterized in that, The sorting instructions include move-up instructions and move-down instructions.

3. The primitive movement and sorting optimization method according to claim 1, characterized in that, The mapping table includes element identifiers, location indexes, and association identifiers of related sub-elements.

4. The primitive movement and sorting optimization method according to claim 1, characterized in that, S3 specifically includes: S301: Initialize an empty mapping table; S302: Obtain a complete list of graphic elements containing the target graphic element and the related sub-graphic elements through traversal recursion; S303: Traverse the reference list to identify whether the current graphic element belongs to the complete graphic element list; S304: If the current graphic element belongs to the complete graphic element list, then record the graphic element identifier and position index of the current graphic element, and store the current graphic element in the mapping relationship table; otherwise, continue to traverse the reference list until all graphic elements are verified and the mapping relationship table is fully established.

5. The primitive movement and sorting optimization method according to claim 1, characterized in that, S4 specifically includes: S401: Recursively traverse the target primitive to obtain all related sub-primitives contained in the target primitive; S402: Integrate the target graphic element with all related sub-graphic elements to obtain a complete graphic element list; S403: Based on the complete list of graphic elements, traverse the reference list to determine the target graphic element and the related sub-graphic elements; S404: Based on the mapping table, extract the original position indices of the target primitive and the related sub-primitives in the reference list.

6. The primitive movement and sorting optimization method according to claim 1, characterized in that, The process includes the following steps after S4 and before S5: Establish sorted lists between the target primitive and the related sub-primitives and their original location indices; The sorting method of the sorting list is determined according to the sorting instruction; Sort the sorted list according to the sorting method; Based on the sorted list, the target primitive and each of the related sub-primitives are processed sequentially.

7. The primitive movement and sorting optimization method according to claim 2, characterized in that, When the sorting instruction is an up instruction, the target position of the target graphic element in the reference list is determined; The specific methods for determining the target location include: If the target graphic element is a composite graphic element, extract the original position index of the related sub-graphic elements, and determine the next adjacent position index of the largest original position index in the original position index as the target position; otherwise, calculate the next adjacent position index based on the original position index of the target graphic element, and obtain the next adjacent graphic element in the reference list according to the next adjacent position index. If the next adjacent graphic element is a combined graphic element, the total number of the next adjacent graphic element and the related sub-graphic elements are recursively calculated respectively, and the next adjacent position index corresponding to the sum of the original position index of the target graphic element and the total number is determined as the target position; otherwise, the position index of the next adjacent graphic element is determined as the target position.

8. The primitive movement and sorting optimization method according to claim 2, characterized in that, When the sorting instruction is a move-down instruction, the target position of the target graphic element in the reference list is determined; The specific methods for determining the target location include: If the target graphic element is a composite graphic element, extract the original position index of the related sub-graphic elements and determine the smallest original position index as the target position; otherwise, calculate the previous adjacent position index based on the original position index of the target graphic element, and obtain the previous adjacent graphic element in the reference list according to the previous adjacent position index. If the previous adjacent graphic element is a composite graphic element, recursively obtain the position index of the final-level parent composite graphic element of the previous adjacent graphic element, and determine the position index of the final-level parent composite graphic element as the target position; otherwise, determine the position index of the previous adjacent graphic element as the target position.

9. The primitive movement and sorting optimization method according to claim 1, characterized in that, The specific inclusion of S6 is as follows: When the target graphic element is a composite graphic element, a position compensation variable is set; Traverse all related sub-elements of the target primitive; Based on the difference between the original position index of each related sub-element and the position compensation variable, the corresponding related sub-element is deleted from the reference list; Based on the target location, the target primitive and each of the related sub-primitives are inserted into the reference list; If the target element is a non-combined element, the target element is directly deleted from its original position and inserted into the target position.

10. A primitive movement and sorting optimization system, characterized in that, include: Processor and memory; The memory stores programs or instructions that can run on the processor, which, when executed by the processor, implement the steps of the primitive movement and sorting optimization method as described in any one of claims 1 to 9.