UI map drawing method and device, mobile terminal and storage medium

By detecting and matching UI textures in mobile games and merging them into idle virtual textures, the performance issues caused by UI texture rendering are resolved, achieving memory optimization and performance improvement.

CN122115620APending Publication Date: 2026-05-29珠海剑心互动娱乐有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
珠海剑心互动娱乐有限公司
Filing Date
2026-01-21
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing UI texture drawing methods result in a large number of draw calls in mobile games, affecting game performance. In particular, the drawing methods based on single UI textures and UI atlases cannot effectively batch process, leading to performance bottlenecks.

Method used

By detecting whether the UI texture to be loaded matches the candidate texture, if the match is successful, the candidate texture is drawn; if the match fails, the UI texture is merged into a virtual texture with free area, thus optimizing graphics storage space and reducing the number of draw calls.

Benefits of technology

It effectively reduces memory usage, decreases the number of draw calls, improves game performance, avoids repeatedly loading the same UI textures, and improves graphics processing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122115620A_ABST
    Figure CN122115620A_ABST
Patent Text Reader

Abstract

The application discloses a UI map drawing method and device, a mobile terminal and a storage medium. The method comprises the following steps: when a first UI map corresponding to a target size to be loaded is received, it is detected whether any candidate map is matched; when the matching is successful, the matched candidate map is drawn; when the matching fails, the first UI map is drawn, a first target map is determined from all virtual maps, and the first UI map is merged into the first target map. The first target map is a virtual map having a free area matching the target size. If it is detected that the UI map does not match the existing virtual map, the UI map is merged into the free virtual map, the existing graphic storage space is reused, repeated loading is avoided, memory consumption is reduced, and simultaneously, since multiple UI maps can be merged into one virtual map, when there are multiple drawing requirements, the number of times of sending a drawing command to a GPU can be reduced, and game performance is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to, but is not limited to, the field of computer technology, and in particular to a method, apparatus, mobile terminal, and storage medium for drawing UI textures. Background Technology

[0002] In mobile game applications, existing methods for drawing UI textures fall into two categories: UI atlas-based drawing and single-texture-based drawing. Single-texture-based drawing generates a large number of draw calls to the GPU, impacting game performance. UI atlas-based drawing, when a new UI texture needs to be added, if the space in the pre-defined UI atlas is occupied by obsolete images, a new UI atlas is created. In this case, if multiple new UI textures arrive and are distributed across different UI atlases, batch processing of these textures becomes impossible. This results in at least one draw call for each UI texture's corresponding UI atlas, leading to multiple draw calls and further impacting game performance. In summary, existing UI texture drawing methods have drawbacks that negatively affect game performance. Summary of the Invention

[0003] This application provides a method, apparatus, mobile terminal, and storage medium for drawing UI textures, which can effectively reduce memory usage while improving game performance.

[0004] In a first aspect, embodiments of this application provide a method for drawing UI textures, applied to a mobile terminal. The mobile terminal has multiple preset virtual textures, each virtual texture being associated with multiple candidate textures. The method includes: When a first UI texture to be loaded is received, it is detected whether the first UI texture matches any of the candidate textures to obtain a matching result, wherein the first UI texture corresponds to a target size; When the matching result indicates a successful match, the candidate texture of the successful match is drawn; When the matching result indicates a matching failure, the first UI texture is drawn, the first target texture is determined from all the virtual textures, and the first UI texture is merged into the first target texture, wherein the first target texture is a virtual texture that has a free area that matches the target size.

[0005] In some embodiments, determining a first target texture from all of the virtual textures includes: Determine the candidate sizes for all free areas in any of the virtual textures; The virtual texture associated with the candidate size that is equal to the target size is determined as the first target texture.

[0006] In some embodiments, after determining the candidate sizes of all free areas in any of the virtual textures, the method further includes: When all of the candidate dimensions are not equal to the target dimension, a plurality of reference dimensions are selected from all the candidate dimensions, wherein all of the reference dimensions are larger than the target dimension; The virtual texture associated with the reference size that has the smallest difference from the target size is determined as the first target texture.

[0007] In some embodiments, when the first target texture is a virtual texture associated with the first reference size that has the smallest difference from the target size, merging the first UI texture into the first target texture includes: The target region is obtained by splitting the free area corresponding to the reference size with the smallest difference between the reference size and the target size, wherein the size of the target region is the target size; The first UI texture is merged into the target area of ​​the first target texture.

[0008] In some embodiments, after determining a first target texture from all the virtual textures and merging the first UI texture into the first target texture, the method further includes: Replace the first UI texture in the first target texture with the first target texture carrying the target coordinates, wherein the target coordinates are the coordinates of the first UI texture in the first target texture; Uninstall the first UI texture.

[0009] In some embodiments, after determining a first target texture from all the virtual textures and merging the UI texture into the first target texture, the method further includes: When an unload request for the second UI texture is received, a second target texture that matches the second UI texture is determined from all the candidate textures, and the reference area associated with the second target texture in the corresponding virtual texture is marked as free; When a third UI texture to be loaded is received, and the third UI texture fails to match any candidate texture, the size of the third UI texture matches the size of the second UI texture. The third UI texture is then drawn and merged into the reference area of ​​the second target texture to cover the second UI texture.

[0010] In some embodiments, before receiving a first UI texture to be loaded, detecting whether the first UI texture matches any of the candidate textures, and obtaining a matching result, the method further includes: The virtual texture is displayed at a preset size, wherein the virtual texture has an empty area; When all the virtual textures have no empty areas, a new virtual texture is automatically generated, and the new virtual texture is empty.

[0011] Secondly, embodiments of this application provide a control device, including at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform the UI texture drawing method as described in the first aspect.

[0012] Thirdly, embodiments of this application also provide a mobile terminal, including the control device of the second aspect.

[0013] Fourthly, embodiments of this application also provide a computer-readable storage medium storing computer-executable instructions for performing the UI texture drawing method as described in the first aspect.

[0014] This application provides a method, apparatus, mobile terminal, and storage medium for drawing UI textures. The method includes: upon receiving a first UI texture to be loaded, detecting whether the first UI texture matches any of the candidate textures to obtain a matching result, wherein the first UI texture corresponds to a target size; when the matching result indicates a successful match, drawing the successfully matched candidate texture; when the matching result indicates a failed match, drawing the first UI texture, determining a first target texture from all the virtual textures, and merging the first UI texture into the first target texture, wherein the first target texture is a virtual texture with a free area matching the target size. According to the solution provided by this application, if the UI texture to be loaded is not matched in the existing virtual textures, the UI texture will be merged into a free virtual texture, which can reuse existing graphics storage space, avoid repeatedly loading the same UI texture, reduce memory consumption, and since multiple UI textures can be merged into one virtual texture, when there are multiple drawing requirements, the number of times drawing commands are sent to the GPU can be reduced, improving game performance. Attached Figure Description

[0015] Figure 1 This is a flowchart of the steps of a UI texture drawing method provided in one embodiment of this application; Figure 2 This is a structural diagram of a control device provided in another embodiment of this application. Detailed Implementation

[0016] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0017] It is understandable that although functional modules are divided in the device schematic diagram and a logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first," "second," etc., in the specification, claims, or the aforementioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0018] In mobile game applications, existing methods for drawing UI textures fall into two categories: UI atlas-based drawing and single-texture-based drawing. Single-texture-based drawing generates a large number of draw calls to the GPU, impacting game performance. UI atlas-based drawing, when a new UI texture needs to be added, if the space in the pre-defined UI atlas is occupied by obsolete images, a new UI atlas is created. In this case, if multiple new UI textures arrive and are distributed across different UI atlases, batch processing of these textures becomes impossible. This results in at least one draw call for each UI texture's corresponding UI atlas, leading to multiple draw calls and further impacting game performance. In summary, existing UI texture drawing methods have drawbacks that negatively affect game performance.

[0019] To address the aforementioned problems, this application provides a method, apparatus, mobile terminal, and storage medium for drawing UI textures. The method includes: upon receiving a first UI texture to be loaded, detecting whether the first UI texture matches any of the candidate textures to obtain a matching result, wherein the first UI texture corresponds to a target size; when the matching result indicates a successful match, drawing the successfully matched candidate texture; when the matching result indicates a failed match, drawing the first UI texture, determining a first target texture from all the virtual textures, and merging the first UI texture into the first target texture, wherein the first target texture is a virtual texture with a free area matching the target size. According to the solution provided by this application, if the UI texture to be loaded is not matched in the existing virtual textures, the UI texture will be merged into a free virtual texture, which can reuse existing graphics storage space, avoid repeatedly loading the same UI texture, reduce memory consumption, and since multiple UI textures can be merged into one virtual texture, when there are multiple drawing requirements, the number of times drawing commands are sent to the GPU can be reduced, improving game performance.

[0020] The embodiments of this application will be further described below with reference to the accompanying drawings.

[0021] refer to Figure 1 , Figure 1 This is a flowchart illustrating the steps of a UI texture drawing method according to an embodiment of this application. This application provides a UI texture drawing method applied to a mobile terminal. The mobile terminal has multiple preset virtual textures, and each virtual texture is associated with multiple candidate textures. The method includes, but is not limited to, the following steps: Step S10: When the first UI texture to be loaded is received, it is detected whether the first UI texture matches any candidate texture to obtain the matching result, wherein the first UI texture corresponds to a target size.

[0022] Specifically, in some embodiments, during execution Figure 1 Before step S10 shown, the UI texture drawing method provided in this application embodiment also includes, but is not limited to, the following steps: Step S11: Display a virtual texture of a preset size, wherein the virtual texture has an empty area; Step S12: When there are no empty areas in all the virtual textures, a new virtual texture is automatically generated, and the new virtual texture is empty.

[0023] Specifically, this embodiment does not limit the displayed virtual texture to a preset size; it can be a virtual texture with a square length and width equal to the original size.

[0024] Understandably, upon receiving the first UI texture to be loaded, a virtual texture with available space will be displayed. If all existing virtual textures are used up, meaning there is no available space left in any of the virtual textures, a new virtual texture will be automatically generated, and this new virtual texture will be empty. This avoids creating virtual textures only when the first UI texture appears, preventing lag.

[0025] Understandably, when the first UI texture to be loaded is received, it is checked whether the first UI texture matches any candidate texture. The matching result can provide a valid data basis for determining the drawing method for the first UI texture.

[0026] Step S20: When the matching result indicates a successful match, draw the candidate texture of the successful match.

[0027] Step S30: When the matching result indicates that the matching has failed, draw the first UI texture, determine the first target texture from all the virtual textures, and merge the first UI texture into the first target texture. The first target texture is a virtual texture that has a free area that matches the target size.

[0028] Understandably, if a match is successful, it means that the candidate textures stored in any virtual texture are associated with the first UI texture. That is, the new first UI texture to be drawn is recorded in the virtual texture. This record, in addition to being mapped to the associated candidate texture, also carries the UV coordinates of the first UI texture on the successfully matched candidate texture. In other words, after confirming a successful match, this embodiment directly uses the UV coordinates corresponding to the successfully matched candidate texture and the first UI texture for drawing. In this way, existing graphics storage space can be reused, avoiding repeated loading of the same UI texture and reducing memory consumption. If the match fails, a draw needs to be generated first. The call causes the GPU to draw the first UI texture. Then, a virtual texture with a free area matching the target size is selected from the existing virtual textures (i.e., the first target texture). The first UI texture is then merged into the first target texture. If the UI texture to be loaded is not matched in the existing virtual textures, it will be merged into a free virtual texture. In this way, since multiple UI textures can be merged into one virtual texture, the number of times drawing commands are sent to the GPU can be reduced when there are multiple drawing requirements, thus improving game performance.

[0029] Specifically, in some embodiments, Figure 1 Step S30, which involves determining the first target texture from all virtual textures, includes, but is not limited to, the following steps: Step S31: Determine the candidate sizes for all free areas in any virtual texture; Step S32: The virtual texture associated with the candidate size that is equal to the target size is determined as the first target texture.

[0030] In addition, after performing step S31, the UI texture drawing method provided in this application embodiment also includes, but is not limited to, the following steps: Step S33: When all candidate dimensions are not equal to the target dimension, select multiple reference dimensions from all candidate dimensions, wherein all reference dimensions are larger than the target dimension. Step S34: The virtual texture associated with the reference size that has the smallest difference from the target size is determined as the first target texture.

[0031] Additionally, in some embodiments, when the first target texture is a virtual texture associated with a first reference size that has the smallest difference from the target size, Figure 1 Step S30, merging the first UI texture into the first target texture, includes, but is not limited to, the following steps: Step S35: Split the free area corresponding to the reference size with the smallest difference from the target size to obtain the target area, where the size of the target area is the target size; Step S36: Merge the first UI texture into the target area of ​​the first target texture.

[0032] It is understood that in this embodiment, based on the length and width (i.e., target size) of the first UI texture, a preset priority algorithm is used to allocate the corresponding virtual texture to the corresponding area position. The specific allocation method of the priority algorithm includes: determining the candidate sizes of all empty areas in any virtual texture, and determining the virtual texture associated with the candidate size that is equal to the target size as the first target texture. That is, based on the target size, a search is performed for an empty area that is equal to the target size and then allocated. If no such area is found, then multiple reference sizes larger than the target size are selected from all candidate sizes, and the virtual texture associated with the reference size with the smallest difference from the target size is determined as the first target texture. Then, the empty area of ​​the first target texture is split to obtain a target area with the target size, and the first UI texture is merged into the target area of ​​the first target texture, i.e., allocated to this target area.

[0033] Additionally, in some embodiments, during execution Figure 1 Following step S30, the UI texture drawing method provided in this application embodiment further includes, but is not limited to, the following steps: Step S41: Replace the first UI texture in the first target texture with a first target texture carrying target coordinates, wherein the target coordinates are the coordinates of the first UI texture in the first target texture; Step S42: Uninstall the first UI texture.

[0034] It is understood that in this embodiment, the first UI texture in the first target texture is replaced with a first target texture carrying target coordinates, where the target coordinates are the coordinates of the first UI texture in the first target texture, i.e., UV coordinates. The first UI texture is also unloaded. In this way, the drawing path of the next new UI texture to be loaded that is associated with the first UI texture can be changed. That is, for the new UI texture associated with the first UI texture, instead of drawing a single UI texture, it is now drawn based on the first target texture carrying the target coordinates. If multiple new UI textures are merged into the first target texture, batch drawing can be achieved, reducing draw calls and thus improving game performance.

[0035] Additionally, in some embodiments, during execution Figure 1 Following step S30, the UI texture drawing method provided in this application embodiment further includes, but is not limited to, the following steps: Step S43: When an unload request for the second UI texture is received, a second target texture that matches the second UI texture is determined from all candidate textures, and the reference area associated with the second target texture in the corresponding virtual texture is marked as free. Step S44: When the third UI texture to be loaded is received, and the third UI texture fails to match any candidate texture, the size of the third UI texture matches the size of the second UI texture, the third UI texture is drawn, and the third UI texture is merged into the reference area of ​​the second target texture to cover the second UI texture.

[0036] Understandably, in this embodiment, when an unload request for the second UI texture is received, a second target texture matching the second UI texture is determined from all candidate textures, and the reference area associated with the second UI texture in the second target texture is marked as free. When a third UI texture to be loaded is received, and the third UI texture fails to match any candidate texture, the size of the third UI texture matches the size of the second UI texture. The third UI texture is then drawn and merged into the reference area of ​​the second target texture to cover the second UI texture. That is, when an unload request for a new UI texture is received, the area where the UV coordinates of the second target texture matching that UI texture are located in the corresponding virtual texture (i.e., the reference area) is marked as free. When a new UI texture with the target size is received again, this new UI texture can be directly uploaded to the reference area to cover the original second UI texture. Thus, there is no need to create a separate cleanup instruction, reducing GPU bandwidth and computational overhead.

[0037] like Figure 2 As shown, Figure 2 This is a structural diagram of a control device provided in one embodiment of this application. The present invention also provides a control device 200, comprising: The processor 210 can be implemented using a general-purpose central processing unit (CPU), microprocessor, application specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this application. The memory 220 can be implemented as a read-only memory (ROM), static storage device, dynamic storage device, or random access memory (RAM). The memory 220 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 220 and called and executed by the processor 210 to execute the UI texture drawing method of the embodiments of this application. Input / output interface 230 is used to implement information input and output; The communication interface 240 is used to enable communication and interaction between this device and other devices. Communication can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.). Bus 250 transmits information between various components of the device (e.g., processor 210, memory 220, input / output interface 230, and communication interface 240); The processor 210, memory 220, input / output interface 230 and communication interface 240 are connected to each other within the device via bus 250.

[0038] In addition, this application also provides a mobile terminal, including the control device 200 of the above embodiments.

[0039] In addition, this application embodiment also provides a storage medium, which is a computer-readable storage medium, storing a computer program that, when executed by a processor, implements the above-described UI texture drawing method.

[0040] Memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs and non-transitory computer-executable programs. Furthermore, memory may include high-speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some embodiments, memory may optionally include memory remotely located relative to the processor, and these remote memories can be connected to the processor via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof. The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separate, and may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0041] It will be understood by those skilled in the art that all or some of the steps and systems in the methods disclosed above can be implemented as software, firmware, hardware, and suitable combinations thereof. Some or all of the physical components can be implemented as software executed by a processor, such as a central processing unit, digital signal processor, or microprocessor, or as hardware, or as an integrated circuit, such as an application-specific integrated circuit. Such software can be distributed on a computer-readable medium, which can include computer storage media (or non-transitory media) and communication media (or transient media). As is known to those skilled in the art, the term computer storage media includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technologies, CD-ROM, digital versatile disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tape, disk storage or other magnetic storage devices, or any other medium that can be used to store desired information and is accessible to a computer. Furthermore, as is known to those skilled in the art, communication media typically include computer-readable instructions, data structures, program modules, or other data in modulated data signals such as carrier waves or other transmission mechanisms, and may include any information delivery medium.

[0042] The above provides a detailed description of the preferred embodiments of the present invention. However, the present invention is not limited to the above embodiments. Those skilled in the art can make various equivalent modifications or substitutions without departing from the spirit of the present invention. All such equivalent modifications or substitutions are included within the scope defined by the claims of the present invention.

Claims

1. A method for drawing UI textures, characterized in that, Applied to a mobile terminal, wherein the mobile terminal has multiple preset virtual textures, and each virtual texture is associated with multiple candidate textures, the method includes: When a first UI texture to be loaded is received, it is detected whether the first UI texture matches any of the candidate textures to obtain a matching result, wherein the first UI texture corresponds to a target size; When the matching result indicates a successful match, the candidate texture of the successful match is drawn; When the matching result indicates a matching failure, the first UI texture is drawn, the first target texture is determined from all the virtual textures, and the first UI texture is merged into the first target texture, wherein the first target texture is a virtual texture that has a free area that matches the target size.

2. The method for drawing UI textures according to claim 1, characterized in that, Determining the first target texture from all the virtual textures includes: Determine the candidate sizes for all free areas in any of the virtual textures; The virtual texture associated with the candidate size that is equal to the target size is determined as the first target texture.

3. The method for drawing UI textures according to claim 2, characterized in that, After determining the candidate sizes of all free areas in any of the virtual textures, the method further includes: When all of the candidate dimensions are not equal to the target dimension, a plurality of reference dimensions are selected from all the candidate dimensions, wherein all of the reference dimensions are larger than the target dimension; The virtual texture associated with the reference size that has the smallest difference from the target size is determined as the first target texture.

4. The method for drawing UI textures according to claim 3, characterized in that, When the first target texture is a virtual texture associated with the first reference size that has the smallest difference between itself and the target size, merging the first UI texture into the first target texture includes: The target region is obtained by splitting the free area corresponding to the reference size with the smallest difference between the reference size and the target size, wherein the size of the target region is the target size; The first UI texture is merged into the target area of ​​the first target texture.

5. The method for drawing UI textures according to claim 1, characterized in that, After determining a first target texture from all the virtual textures and merging the first UI texture into the first target texture, the method further includes: Replace the first UI texture in the first target texture with the first target texture carrying the target coordinates, wherein the target coordinates are the coordinates of the first UI texture in the first target texture; Uninstall the first UI texture.

6. The method for drawing UI textures according to claim 1, characterized in that, After determining a first target texture from all the virtual textures and merging the UI texture into the first target texture, the method further includes: When an unload request for the second UI texture is received, a second target texture that matches the second UI texture is determined from all the candidate textures, and the reference area associated with the second target texture in the corresponding virtual texture is marked as free; When a third UI texture to be loaded is received, and the third UI texture fails to match any candidate texture, the size of the third UI texture matches the size of the second UI texture. The third UI texture is then drawn and merged into the reference area of ​​the second target texture to cover the second UI texture.

7. The method for drawing UI textures according to claim 1, characterized in that, Upon receiving the first UI texture to be loaded, before detecting whether the first UI texture matches any of the candidate textures and obtaining the matching result, the method further includes: The virtual texture is displayed at a preset size, wherein the virtual texture has an empty area; When all the virtual textures have no empty areas, a new virtual texture is automatically generated, and the new virtual texture is empty.

8. A control device, characterized in that, It includes at least one control processor and a memory for communicatively connecting to the at least one control processor; the memory stores instructions executable by the at least one control processor, which, when executed by the at least one control processor, enable the at least one control processor to perform the UI texture drawing method as described in any one of claims 1 to 7.

9. A mobile terminal, characterized in that, Includes the control device as described in claim 8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the UI texture drawing method as described in any one of claims 1 to 7.