Timestamp rendering method and device, computer equipment and readable storage medium
By separating the rendering of timestamps and test information in the test interface, and using preset image sets to render timestamps, the problem that timestamp rendering affects other tasks in traditional technology is solved, improving rendering efficiency and reducing memory jitter.
Patent Information
- Application Number
- CN202411560851.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-04
- Publication Date
- 2025-03-14
AI Technical Summary
When rendering timestamps, traditional technology will cause redrawing of the test interface and frequently create string objects, affecting other drawing tasks, and consume a lot of resources, reducing the rendering efficiency of timestamps.
By displaying a test interface including the first layer and the second layer, the first layer is used to display the timestamp and the second layer is used to display the test information. When the preset refresh cycle is satisfied, the system time is obtained, and the target image matching the character elements contained in the system time is obtained from the preset image set, and the target image matching the character elements contained in the system time is rendered to the first layer, avoiding formatting time into a string, and reducing the creation of string objects.
Improve the rendering efficiency of timestamps, avoid the rendering of timestamps that affect the rendering of test information, and reduce the high-frequency creation of string objects and system recycling objects, avoiding memory jitter.
Smart Images

Figure CN119621204A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a timestamp rendering method, apparatus, computer equipment, computer-readable storage medium, and computer program product. Background Art
[0002] During the development of application software, it is necessary to test the functions of the application software. During the testing process, information such as the operation steps, phenomena, logs, screen recordings, and the time when the problem occurred can be displayed in real time in the test interface. Developers can use the test interface to view the test information.
[0003] In order to display the test information in the test interface, the traditional technology mainly develops a floating window that displays the real-time time and displays the floating window on the screen. The test interface includes the operation steps in the test process and the time in the floating window. However, the traditional technology involves redrawing the test interface during rendering time, and the drawing time requires frequent creation of string objects, which will indirectly affect other drawing tasks, consume a lot of resources, and is not conducive to improving the rendering efficiency of timestamps. Summary of the invention
[0004] Based on this, it is necessary to provide a timestamp rendering method, apparatus, computer equipment, computer-readable storage medium and computer program product that can improve the rendering efficiency of timestamps in response to the above technical problems.
[0005] In a first aspect, the present application provides a timestamp rendering method, comprising:
[0006] Displaying a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information;
[0007] When the current moment satisfies a preset refresh cycle, the system time at the current moment is obtained, and a target image matching the character elements contained in the system time is obtained from a preset image set;
[0008] Rendering target images matching each of the character elements to the first layer to display a timestamp of the current moment in the first layer of the test interface.
[0009] In one embodiment, the character element includes a digital element and a symbol element, and acquiring a target image matching the character element included in the system time from a preset image set includes:
[0010] Determine, according to the display format of the system time, the digital elements corresponding to each time unit in the system time and the symbol elements contained in the system time;
[0011] According to a preset element-image mapping relationship, target images matching the digital elements and the symbolic elements corresponding to each of the timing units are respectively obtained from the preset image set; the element-image mapping relationship represents the matching relationship between the digital elements and the symbolic elements and each image in the image set.
[0012] In one embodiment, the step of acquiring target images matching the digital elements and the symbol elements corresponding to each of the time units from the preset image set according to the preset element-image mapping relationship includes:
[0013] Determine, according to the digital elements corresponding to the respective timing units, the digital elements corresponding to the respective counting units contained in the respective timing units;
[0014] According to the preset element-image mapping relationship, an image matching the digital element and the symbol element corresponding to each counting unit is searched from the preset image set as the target image.
[0015] In one of the embodiments, before acquiring the target image matching the character element included in the system time from the preset image set, the method further includes:
[0016] Obtaining a preset digital element and a preset symbol element;
[0017] Creating, according to a preset image format, a digital image corresponding to the preset digital element and a symbol image corresponding to the preset symbol element, and generating the preset image set according to the digital image and the symbol image;
[0018] A preset element-image mapping relationship is determined according to the digital image and the preset digital element, and the symbol image and the preset symbol element.
[0019] In one embodiment, before displaying the test interface including the first layer and the second layer, the method further includes:
[0020] Obtaining a layout file for the test interface and parsing the layout file to obtain an image rendering control; the image rendering control is used to render the first layer and the second layer;
[0021] Creating a renderer corresponding to the image rendering control and setting a refresh period of the renderer to a preset refresh period;
[0022] The refresh mode of the image rendering control is set, and the image rendering control is added to the window manager corresponding to the test interface; the window manager is used to manage the controls in the test interface.
[0023] In one embodiment, rendering the target image matching each of the character elements to the first layer includes:
[0024] Obtaining a starting rendering position of the target image in the first layer and size information of the target image in the first layer;
[0025] Starting from a starting rendering position in the first layer, the target image is drawn in the first layer according to the size information.
[0026] In one of the embodiments, obtaining the starting rendering position of the target image in the first layer includes:
[0027] Determine, according to the display format of the system time, each time unit in the system time and each counting unit contained in each time unit;
[0028] A starting rendering position of the target image in the first layer is determined according to each of the timing units and each of the counting units.
[0029] In a second aspect, the present application also provides a timestamp rendering device, including:
[0030] A display module, used to display a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information;
[0031] A matching module, used for obtaining the system time at the current moment when the current moment satisfies a preset refresh cycle, and obtaining a target image matching the character elements contained in the system time from a preset image set;
[0032] A rendering module is used to render the target image matching each of the character elements to the first layer, so as to display the timestamp of the current moment in the first layer of the test interface.
[0033] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the steps of the above method are implemented.
[0034] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.
[0035] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0036] The above-mentioned timestamp rendering method, device, computer equipment, computer-readable storage medium and computer program product display a test interface including a first layer and a second layer; the first layer is used to display the timestamp; the second layer is used to display the test information, so that the timestamp and the test information are respectively displayed in different layers in the test interface, avoiding the rendering of the timestamp to affect the rendering of the test information; when the current moment meets the preset refresh cycle, the system time at the current moment is obtained, and the target image matching the character elements contained in the system time is obtained from the preset image set; the target image matching each character element is rendered to the first layer to display the timestamp of the current moment in the first layer of the test interface, so that the timestamp is rendered in the first layer using the target image matching the character elements, without formatting the time as a string, avoiding frequent creation of string objects, and being able to render the timestamp with the target image matching each character element in the time in another layer different from the layer displaying the test information, avoiding the rendering of the timestamp to affect the rendering of the test information, and at the same time, it is also possible to avoid high-frequency creation of string objects and system recycling of objects to cause memory jitter, thereby improving the rendering efficiency of the timestamp. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0038] Figure 1 A schematic diagram of a flow chart of a timestamp rendering method in an embodiment;
[0039] Figure 2 A schematic diagram of a test interface in an embodiment
[0040] Figure 3 A schematic diagram of configuring a window manager in one embodiment;
[0041] Figure 4 is a schematic diagram of a renderer life cycle in one embodiment;
[0042] Figure 5 A schematic diagram of determining an element image mapping relationship in an embodiment;
[0043] Figure 6 A schematic diagram of drawing a timestamp in one embodiment;
[0044] Figure 7is a structural block diagram of a timestamp rendering device in one embodiment;
[0045] Figure 8 The figure is a diagram of the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0047] In an exemplary embodiment, Figure 1 As shown, a timestamp rendering method is provided, and the method is applied to a terminal for example. It can be understood that the method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server. In this embodiment, the method includes the following steps S102 to S106. Among them:
[0048] Step S102, displaying a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information.
[0049] Among them, the first layer can refer to an image layer used to display a timestamp. In actual applications, the layer can be used to place images, text or graphic content, etc. In a specific implementation, the position management between the first layer and the second layer may include but is not limited to the first layer being located above the second layer.
[0050] Among them, the second layer can refer to an image layer used to display test information. In actual applications, test information can refer to information generated when testing application software during the process of developing application software. In specific implementations, test information can include but is not limited to operating steps, phenomena, etc., and the expression form of test information can include but is not limited to images, videos, etc.
[0051] The test interface may refer to an interface used to display test information and timestamps to the user. In actual applications, the timestamp in the test interface may represent the time point when the test information appears.
[0052] As an example, when developing application software, the development engineer will test the software after the function is implemented. During the testing process, the test engineer will feedback the operating steps, phenomena, logs, screen recordings, the time when the problem occurred and other information to the developer for analysis. The test interface can be used to display information such as operating steps, phenomena, logs, screen recordings, the time when the problem occurred and other information. The terminal can first display a test interface including a first layer and a second layer in the display area of the terminal, wherein the first layer can be used to display a timestamp, and the second image can be used to display test information such as operating steps and phenomena of the problem found during the testing process.
[0053] Step S104, when the current moment meets the preset refresh cycle, the system time at the current moment is obtained, and a target image matching the character elements included in the system time is obtained from a preset image set.
[0054] The current moment may refer to a time point representing the current time.
[0055] Among them, the preset refresh cycle may refer to pre-set information representing the refresh interval of the timestamp in the first layer. In actual applications, the preset refresh cycle may include the length of time between two adjacent rendering time points of the timestamp in the first layer. In a specific implementation, the preset refresh cycle may include a preset rendering frame rate.
[0056] The system time may refer to the time maintained internally by the computer operating system.
[0057] The preset image set may refer to a pre-set set including a number of images.
[0058] The character elements included in the system time may refer to numbers and / or characters included in the time information representing the system time.
[0059] The target image may refer to an image obtained from a preset image set and matching the character elements included in the system time.
[0060] As an example, the terminal can calculate the time difference or image frame difference between the current moment and the moment of the last rendering of the timestamp in the first layer, and compare the time difference or image frame difference with the preset refresh cycle. If the time difference or image frame difference is greater than or equal to the preset refresh cycle, the terminal can determine that the current moment meets the preset refresh cycle, the terminal can obtain the system time at the current moment, and then the terminal can analyze the character elements contained in the system time at the current moment, and obtain a target image that matches the character elements contained in the system time from a preset image set, so as to render the timestamp in the first layer based on the target image.
[0061] Step S106, rendering the target image matching each character element to the first layer, so as to display the timestamp of the current moment in the first layer of the test interface.
[0062] As an example, the terminal can first determine the position of the target image matching each character element in the first layer, and render the target image matching each character element to the first layer through the image rendering control corresponding to the first layer, so as to display the timestamp of the current moment in the first layer of the test interface. The terminal can also determine the position of the test information in the second layer, and render each test information to the second layer through the image rendering control corresponding to the second layer, so as to display the test information of the current moment in the second layer of the test interface.
[0063] In the above timestamp rendering method, a test interface including a first layer and a second layer is displayed; the first layer is used to display the timestamp; the second layer is used to display the test information, so that the timestamp and the test information are respectively displayed in different layers in the test interface, so as to avoid that the rendering of the timestamp affects the rendering of the test information; when the current moment meets the preset refresh cycle, the system time at the current moment is obtained, and a target image matching the character elements contained in the system time is obtained from a preset image set; the target image matching each character element is rendered to the first layer to display the timestamp of the current moment in the first layer of the test interface, so as to render the timestamp in the first layer using the target image matching the character elements, without formatting the time as a string, avoiding frequent creation of string objects, and being able to render the timestamp with the target image matching each character element in the time in another layer different from the layer displaying the test information, avoiding that the rendering of the timestamp affects the rendering of the test information, and at the same time, it is also possible to avoid memory jitter caused by high-frequency creation of string objects and system recycling of objects, thereby improving the rendering efficiency of the timestamp.
[0064] In an exemplary embodiment, character elements include digital elements and symbol elements, and target images matching the character elements contained in the system time are respectively obtained from a preset image set, including: determining the digital elements corresponding to each timing unit in the system time and the symbol elements contained in the system time according to the display format of the system time; according to a preset element-image mapping relationship, respectively obtaining target images matching the digital elements and symbol elements corresponding to each timing unit from a preset image set; the element-image mapping relationship represents the matching relationship between the digital elements and symbol elements and each image in the image set.
[0065] The display format may refer to information representing the combination of character elements in the system time. In practical applications, the display format of the system time may be flexibly adjusted. For example, the display format of the system time may be expressed as "2000-01-01 08:00:00.599".
[0066] Among them, the timing units may include year, month, day, hour, minute, second, millisecond, etc.
[0067] The preset element-image mapping relationship may refer to information representing the matching relationship between digital elements and symbolic elements and each image in the image set.
[0068] As an example, the terminal may first determine the display format of the system time, then analyze each timing unit in the system time in combination with the display format, and then determine the digital element corresponding to each timing unit in the system time. The terminal may also analyze the symbolic elements contained in the system time in combination with the display format. The terminal may then obtain a preset element image mapping relationship, and based on the preset element image mapping relationship, search in a preset image set for images that match the digital elements corresponding to each timing unit and images that match the symbolic elements as target images. In actual applications, each digital element and / or each symbolic element in the system time may have a matching image in a preset image set, and the images in the image set may represent the corresponding digital elements / symbolic elements through specific textures.
[0069] In this embodiment, the digital elements corresponding to each timing unit in the system time and the symbolic elements contained in the system time are determined according to the display format of the system time; according to the preset element-image mapping relationship, target images matching the digital elements and symbolic elements corresponding to each timing unit are respectively obtained from the preset image set; the element-image mapping relationship represents the matching relationship between the digital elements and symbolic elements and each image in the image set, and can analyze the digital elements corresponding to each timing unit in the system time and the symbolic elements contained in the system time one by one, and filter out the accurate target image from the image combination, thereby improving the accuracy of the target image, avoiding rendering errors caused by using wrong images for timestamp rendering, and thus improving the accuracy of timestamp rendering.
[0070] In some embodiments, according to a preset element-image mapping relationship, a target image matching the digital elements and symbolic elements corresponding to each timing unit is obtained from a preset image set, including: determining the digital elements corresponding to each counting unit contained in each timing unit according to the digital elements corresponding to each timing unit; and according to the preset element-image mapping relationship, querying from the preset image set an image matching the digital elements and symbolic elements corresponding to each counting unit as the target image.
[0071] Among them, counting units may include ones, tens, hundreds, thousands, etc.
[0072] As an example, for each time unit, the terminal can determine the digital elements corresponding to each counting unit contained in each time unit according to the digital elements corresponding to the time unit, such as the system time "2000-01-01 Take "08:00:00.599" as an example to illustrate. When the time unit is year, the digital element corresponding to the time unit is 2000. The terminal can analyze the digital elements corresponding to each counting unit contained in the time unit. The digital element corresponding to the time unit of year is "2000", in which the digital element of the counting unit of thousands is 2, the digital element of the counting unit of hundreds is 0, the digital element of the counting unit of tens is 0, and the digital element of the counting unit of individuals is 0. Similarly, when the time unit is month, the digital element corresponding to the time unit is 01. The terminal can determine that the digital element corresponding to the time unit of month is "01", in which the digital element of the counting unit of tens is 0, and the digital element of the counting unit of individuals is 1; when the time unit is day, the digital element corresponding to the time unit is 01. The terminal can determine that the digital element corresponding to the time unit of day is "01", in which the digital element of the counting unit of tens is 0, and the digital element of the counting unit of individuals is 1; when the time unit is hour, the time unit The corresponding digital element is 08. The terminal can determine that the digital element corresponding to the time unit is hours is "08", the digital element of the counting unit is 0, and the digital element of the counting unit is 8; when the time unit is minutes, the digital element corresponding to the time unit is 00. The terminal can determine that the digital element corresponding to the time unit is minutes is "00", the digital element of the counting unit is 0, and the digital element of the counting unit is 0; when the time unit is seconds, the digital element corresponding to the time unit is 00. The terminal can determine that the digital element corresponding to the time unit is seconds is "00", the digital element of the counting unit is 0, and the digital element of the counting unit is 0; when the time unit is milliseconds, the digital element corresponding to the time unit is 599. The terminal can determine that the digital element corresponding to the time unit is milliseconds is "599", the digital element of the counting unit is 5, the digital element of the counting unit is 9, and the digital element of the counting unit is 9. The terminal can also determine that the symbol elements contained in the system time are "-", ":", ".", and then the terminal can query the image matching the digital elements and symbol elements corresponding to each counting unit from the preset image set according to the preset element image mapping relationship as the target image.
[0073] In this embodiment, the digital elements corresponding to each counting unit contained in each timing unit are determined according to the digital elements corresponding to each timing unit; according to the preset element-image mapping relationship, an image matching the digital elements and symbol elements corresponding to each counting unit is queried from a preset image set as a target image, and the digital elements corresponding to each counting unit contained in each timing unit in the system time and the symbol elements contained in the system time can be analyzed one by one, and an accurate target image can be screened out from the image combination, thereby improving the accuracy of the target image, avoiding rendering errors caused by using an incorrect image for timestamp rendering, and thereby improving the accuracy of timestamp rendering.
[0074] In some embodiments, before obtaining a target image that matches the character elements contained in the system time from a preset image set, the method further includes: obtaining a preset digital element and a preset symbol element; creating a digital image corresponding to the preset digital element and a symbol image corresponding to the preset symbol element according to a preset image format, and generating a preset image set based on the digital image and the symbol image; determining a preset element-image mapping relationship based on the digital image and the preset digital element, and the symbol image and the preset symbol element.
[0075] Among them, the preset digital elements may include 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9.
[0076] The preset symbol elements may include but are not limited to “-”, “:”, “.”, etc.
[0077] The preset image format may include a Bitmap format.
[0078] The digital image may refer to an image of a preset digital element represented by texture.
[0079] The symbol image may refer to an image that represents a preset symbol element through texture.
[0080] As an example, the terminal can use 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 as preset digital elements, and the terminal can use "-", ":", "." as preset symbol elements. Then the terminal can create digital images corresponding to the preset digital elements and symbol images corresponding to the preset symbol elements according to the preset image format. After that, the terminal can use the set consisting of each digital image and each symbol image as a preset image set. The terminal can also bind the preset digital elements and the digital images corresponding to the preset digital elements and bind the preset symbol elements and the symbol images corresponding to the preset symbol elements, so as to determine the preset element-image mapping relationship. In actual applications, the preset digital elements and the preset symbol elements can be used as keys, and the terminal can obtain the corresponding image in the preset image set according to the key.
[0081] In this embodiment, by obtaining preset digital elements and preset symbolic elements; creating digital images corresponding to the preset digital elements and symbolic images corresponding to the preset symbolic elements according to a preset image format, and generating a preset image set based on the digital images and the symbolic images; determining the preset element-image mapping relationship based on the digital images and the preset digital elements, and the symbolic images and the preset symbolic elements, it is possible to create images corresponding to the preset digital elements and the preset symbolic elements, and construct a preset element-image mapping relationship, so as to obtain an accurate target image based on the preset element-image mapping relationship, improve the accuracy of the target image, avoid rendering errors caused by using an erroneous image for timestamp rendering, and thereby improve the accuracy of timestamp rendering.
[0082] In some embodiments, before displaying the test interface including the first layer and the second layer, the above method also includes: obtaining a layout file for the test interface and parsing the layout file to obtain an image rendering control; the image rendering control is used to render the first layer and the second layer; creating a renderer corresponding to the image rendering control and setting the refresh period of the renderer to a preset refresh period; setting the refresh mode of the image rendering control, and adding the image rendering control to the window manager corresponding to the test interface; the window manager is used to manage the controls in the test interface.
[0083] The layout file may refer to information used to describe the layout of elements in the test interface.
[0084] The image rendering control may refer to a component used to render the first layer and the second layer.
[0085] Here, the renderer may refer to a component for rendering text / images, etc.
[0086] Among them, the refresh mode can refer to information that characterizes the triggering method of each rendering operation of the renderer. In actual applications, the refresh mode may include but is not limited to continuous refresh. When the refresh mode is continuous refresh, the renderer can automatically trigger the next rendering operation after the previous rendering operation is completed.
[0087] The window manager may refer to a control used to manage the test interface.
[0088] As an example, in order to render a timestamp in the first layer of the test interface and render test information in the second layer of the test interface, the terminal can first obtain the layout file for the test interface and parse the layout file to obtain at least one image rendering control. The terminal can then create a renderer corresponding to each image rendering control and set the refresh period of the renderer to a preset refresh period. The terminal can also set the refresh mode of the image rendering control and add the image rendering control to the window manager corresponding to the test interface. The terminal can control the image rendering control through the window manager to render the corresponding content in the first layer and / or the second layer.
[0089] In this embodiment, an image rendering control is obtained by obtaining a layout file for a test interface and parsing the layout file; the image rendering control is used to render a first layer and a second layer; a renderer corresponding to the image rendering control is created and a refresh period of the renderer is set to a preset refresh period; a refresh mode of the image rendering control is set, and the image rendering control is added to a window manager corresponding to the test interface; the window manager is used to manage controls in the test interface, and can pre-set the working modes of image rendering controls and renderers corresponding to each layer in the test interface, so as to accurately render the contents of different layers in the test interface through the window manager, thereby improving the rendering accuracy.
[0090] In some embodiments, rendering a target image matching each character element to a first layer includes: obtaining a starting rendering position of the target image in the first layer and size information of the target image in the first layer; starting from the starting rendering position in the first layer, drawing the target image in the first layer according to the size information.
[0091] The starting rendering position may refer to information representing the position of the starting point of rendering the target image in the first layer. In practical applications, the starting rendering position may include position coordinates.
[0092] The size information may refer to information representing the length, width, etc. of the target image in the first layer. In practical applications, the starting rendering position and size information of the target image may be flexibly adjusted and set based on actual needs.
[0093] As an example, in order to render the target images matching each character element to the first layer, the terminal can first determine the starting rendering position of the target image in the first layer, and the size information of the target image in the first layer. For each target image, the terminal can start from the starting rendering position corresponding to the target image in the first layer, and draw the target image in the first layer according to the size information of the target image. When each target image is drawn in the first layer, the terminal can determine that the timestamp rendering in the first layer is completed.
[0094] In this embodiment, by obtaining the starting rendering position of the target image in the first layer and the size information of the target image in the first layer; starting from the starting rendering position in the first layer, the target image is drawn in the first layer according to the size information, so that the target image can be accurately rendered into the first layer according to the corresponding size, thereby improving the accuracy of timestamp rendering.
[0095] In some embodiments, obtaining the starting rendering position of the target image in the first layer includes: determining each timing unit in the system time and each counting unit contained in each timing unit according to the display format of the system time; and determining the starting rendering position of the target image in the first layer according to each timing unit and each counting unit.
[0096] As an example, in order to determine the starting rendering position of the target image in the first layer, the terminal can first determine the timing units in the system time and the counting units contained in each timing unit according to the display format of the system time, and then the terminal can analyze the arrangement relationship between the timing units and the arrangement relationship between the counting units in each timing unit to determine the starting rendering position of the target image in the first layer. In actual applications, the terminal can also determine the symbol elements contained in the system time according to the display format of the system time, and then the terminal can analyze the arrangement relationship between the timing units, the arrangement relationship between the counting units in each timing unit, and the arrangement relationship between the timing units and the symbol elements to determine the starting rendering position of the target image in the first layer.
[0097] In this embodiment, by determining each timing unit in the system time and each counting unit contained in each timing unit according to the display format of the system time; determining the starting rendering position of the target image in the first layer according to each timing unit and each counting unit, the starting rendering position of the target image in the first layer can be accurately analyzed based on the display format of the system time, thereby ensuring the accuracy of rendering of the target image in the first layer, thereby improving the accuracy of timestamp rendering.
[0098] In some embodiments, Figure 2As shown, a schematic diagram of a test interface is provided. In order to display the timestamp on the first layer of the test interface and the test information on the second layer of the test interface, the terminal can create the characters "0-9", colon ":", hyphen "-", dot "." and other characters required for displaying the system time in advance as static images, and use the image rendering control to display the system time in the form of a texture. Specifically, the terminal can set the image rendering control (such as GLSurfaceView) on the layout to display the system time, and set the renderer, rendering mode and refresh cycle for the image rendering control. In the initialization logic of the renderer, the terminal can create a static image corresponding to the character, and bind the static image to the texture. In each refresh cycle, the current system timestamp is read. The terminal can calculate the value of the year, month, day, hour, minute, second, and millisecond (such as 0-9), and select the corresponding texture according to the calculated value, and draw it on the window, so as to realize the timestamp drawing. Before drawing the timestamp, the terminal can define the control to be used in the layout file. Specifically, the terminal can define the root layout control for the test interface as the first image rendering control (such as ConstraintLayout), and specify the width of the layout as 200 pixels and the height of the layout as 72 pixels. The terminal can also define a second image rendering control (such as GLSurfaceView) and specify the identifier (such as id) of the second image rendering control as glSurfaceView, which can be used to find the second image rendering control. The terminal can set the width and height of the layout corresponding to the second image rendering control to fill the parent layout, that is, the width of the layout corresponding to the second image rendering control is 200 pixels, and the height of the layout corresponding to the second image rendering control is 72 pixels, thereby using GLSurfaceView in the layout file to display the system time.
[0099] like Figure 3As shown, a schematic diagram of configuring a window manager is provided. The terminal can set a renderer, a rendering mode, and a refresh cycle for a GLSurfaceView. Specifically, the terminal can first obtain the window manager WindowManger, and then obtain the layout inflater LayoutInflater. The layout inflater can be used to load a layout file in XML format into a displayable Android control object. After that, the terminal can parse the layout file into a control layout, thereby loading the layout file as a control object, and find the second image rendering control in the layout through the identifier. Since the second image rendering control encapsulates and manages OpenGLES (Open Graphics Library for Embedded Systems, Open Image Library for Embedded Operating Systems), the terminal can set the version of OpenGLES and create a timestamp renderer, then the terminal can set the rendering frame rate / refresh cycle of the renderer (such as 30 frames, a rendering frame rate of 30 frames means 30 renderings per second, about 33 milliseconds per rendering), then the terminal can set the renderer to the second image rendering control, and the terminal can also set the refresh mode of the second image rendering control to continuous refresh. In the continuous refresh mode, the rendering thread of the second image rendering control will automatically trigger the next drawing after the first frame is rendered, without external manual triggering, and then the terminal can add the loaded control to the window manager, thereby setting the renderer, rendering mode and refresh cycle for GLSurfaceView.
[0100] like Figure 4 As shown, a schematic diagram of the renderer life cycle is provided. The renderer of the open image library of the embedded operating system has four life cycles: initialization, window validation, drawing and resource release. In the initialization phase, the renderer will set the OpenGL environment, create and compile the shader program. When the rendering surface (such as the layout corresponding to the second image rendering control) is created or recreated, it will enter the window validation phase. In the drawing phase, each time a frame of image is drawn, the terminal will execute operations such as activating the shader program, so the drawing phase can be repeatedly executed. When the image is no longer needed, it enters the resource release phase. In the resource release phase, the terminal will release all allocated resources, such as releasing OpenGES textures and shader objects, program objects, etc., to avoid memory leaks.
[0101] like Figure 5As shown, a schematic diagram for determining the element-image mapping relationship is provided. The element-image mapping relationship is required to draw the timestamp. Since the timestamp involves the digital elements 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and the symbol elements "-", ":", ".", the terminal can create a static image of 13 character elements (such as creating 13 texture objects). The terminal can set a class, which can be used to save the texture information corresponding to the texture (such as static image information). The class can include a texture identifier (such as a texture ID). The terminal can also set the width and height of the static image. The terminal can also set an array for saving the created texture information (such as static image information), which can be used as an element Image mapping relationship, this array can be used to query the texture / static image corresponding to the digital element / symbol element when drawing, and then the terminal can create a digital image (such as a Bitmap image) corresponding to the preset digital element and a symbol image (such as a Bitmap image) corresponding to the preset symbol element according to the preset image format. The terminal can use the set of digital images and symbol images as a preset image set. The terminal can bind the preset digital elements with the digital images corresponding to the preset digital elements one by one, and bind the preset symbol elements with the symbol images corresponding to the preset symbol elements one by one, and record the binding relationship in the array, so as to determine the preset element image mapping relationship. Specifically, the terminal can traverse the digital image and the symbol image, bind the texture of the digital element / the texture of the symbol element with the corresponding image, and set the texture wrapping and texture filtering parameters. The terminal can also use the digital element / symbol element as a key to cache the image bound with the corresponding texture into the preset image set.
[0102] like Figure 6As shown, a schematic diagram of drawing timestamp is provided. In the process of drawing timestamp, the terminal can first obtain the time difference between the current moment and the moment corresponding to the last timestamp drawing operation. If the time difference is greater than or equal to the preset refresh cycle, the terminal needs to draw the timestamp corresponding to the current moment. If the time difference is less than the preset refresh cycle, the terminal can control the second image rendering control to sleep until the time difference between the current moment and the moment corresponding to the last timestamp drawing operation is greater than or equal to the preset refresh cycle. When drawing timestamp, the terminal first enables the OpenGLES program object, clears the drawing buffer, and activates the handle in the OpenGLES program. The handle can be used to pass the position coordinates to the graphics processing unit (GPU), thereby informing the GPU of the shape of the image to be drawn. After that, the terminal passes the position coordinates representing the rectangle to the shader handle and sets the drawing shape. Then the terminal can obtain the system time at the current moment, and read the year, month, day, hour, minute, second, and millisecond of the system time. After that, the terminal can calculate the digital elements of the counting units (such as individuals / tens / hundreds / thousands) contained in each time unit in the system time. Specifically, when drawing the time unit "year" in the timestamp, since the time unit "year" occupies 4 digits, the terminal can calculate the value of each digit separately, and then pass the coordinate value (x, y) of the starting point to be drawn, that is, the starting rendering position. The terminal can start from the starting rendering position in the first layer, query the target image corresponding to the digital element / symbol element in the image set, and control the GPU to draw each target image in the first layer in sequence by calling the drawing function according to the target image corresponding to the digital element in each time unit and the size information of the target image corresponding to the symbol element in the system time.
[0103] In this embodiment, since GLSurfaceView is drawn based on a separate layer, drawing on it will not trigger the redrawing of the parent layout and sibling controls, and it does not need to remeasure and layout itself. There is a rendering thread inside GLSurfaceView that can actively trigger the drawing of each cycle, and there is no need to implement a timer externally to manually trigger the drawing. GLSurfaceView encapsulates the drawing environment and interface of OpenGLES. OpenGLES is based on GPU drawing and can use the powerful performance of GPU for rendering without taking up too many CPU resources. The characters to be displayed in the timestamp itself are fixed, so each character is created as a static picture, and the system time is read each time it is drawn, and its year, month, day, hour, minute, second, and millisecond are calculated. Then, each character to be displayed is calculated and drawn in the form of a texture; avoid Tex The tView solution needs to format the time into a string each time it is drawn before displaying it, which causes the problem of high-frequency creation of string objects - system recycling of objects - memory jitter. It can not trigger the redrawing of the parent layout and sibling controls during rendering, and it does not need to measure and layout itself. Moreover, since it is a separate layer, the drawing efficiency is much higher than that of the Android native control TextView. Since the characters to be drawn are created as static images in advance and then drawn, they do not need to be formatted into a time string each time they are rendered, which also avoids the memory jitter caused by the creation of a large number of string objects. GLSurfaceView itself also has a separate rendering thread, and there is no need to start a timer to manually trigger rendering. Finally, image rendering is based on the GPU, so the powerful performance of the GPU can be used, which effectively reduces the CPU load and improves the performance and stability of timestamp rendering.
[0104] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0105] Based on the same inventive concept, the embodiment of the present application also provides a timestamp rendering device for implementing the timestamp rendering method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more timestamp rendering device embodiments provided below can refer to the limitations of the timestamp rendering method above, and will not be repeated here.
[0106] In an exemplary embodiment, Figure 7 As shown, a timestamp rendering device is provided, including: a display module 702, a matching module 704 and a rendering module 706, wherein:
[0107] The display module 702 is used to display a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information.
[0108] The matching module 704 is used to obtain the system time at the current moment when the current moment meets the preset refresh cycle, and obtain a target image that matches the character elements included in the system time from a preset image set.
[0109] The rendering module 706 is used to render the target image matching each of the character elements to the first layer, so as to display the timestamp of the current moment in the first layer of the test interface.
[0110] In one of the exemplary embodiments, the character elements include digital elements and symbol elements, and the matching module 704 is further specifically used to determine the digital elements corresponding to each timing unit in the system time and the symbol elements contained in the system time according to the display format of the system time; according to a preset element image mapping relationship, obtain target images matching the digital elements corresponding to each timing unit and the symbol elements from the preset image set; the element image mapping relationship represents the matching relationship between the digital elements and the symbol elements and each image in the image set.
[0111] In one of the exemplary embodiments, the matching module 704 is further specifically used to determine the digital elements corresponding to each counting unit contained in each of the timing units based on the digital elements corresponding to each of the timing units; and according to the preset element-image mapping relationship, query the image that matches the digital elements corresponding to each of the counting units and the symbol elements from the preset image set as the target image.
[0112] In one of the exemplary embodiments, the above-mentioned device also includes a mapping module, which is specifically used to obtain preset digital elements and preset symbolic elements; create digital images corresponding to the preset digital elements and symbolic images corresponding to the preset symbolic elements according to a preset image format, and generate the preset image set based on the digital images and the symbolic images; determine the preset element-image mapping relationship based on the digital images and the preset digital elements, and the symbolic images and the preset symbolic elements.
[0113] In one of the exemplary embodiments, the above-mentioned device also includes a control module, which is specifically used to obtain a layout file for the test interface and parse the layout file to obtain an image rendering control; the image rendering control is used to render the first layer and the second layer; create a renderer corresponding to the image rendering control and set the refresh period of the renderer to a preset refresh period; set the refresh mode of the image rendering control, and add the image rendering control to the window manager corresponding to the test interface; the window manager is used to manage the controls in the test interface.
[0114] In one of the exemplary embodiments, the rendering module 706 is further specifically used to obtain the starting rendering position of the target image in the first layer and the size information of the target image in the first layer; starting from the starting rendering position in the first layer, the target image is drawn in the first layer according to the size information.
[0115] In one of the exemplary embodiments, the rendering module 706 is further specifically used to determine, according to the display format of the system time, each timing unit in the system time and each counting unit contained in each timing unit; and to determine, according to each timing unit and each counting unit, the starting rendering position of the target image in the first layer.
[0116] Each module in the above-mentioned timestamp rendering device can be implemented in whole or in part by software, hardware or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0117] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a timestamp rendering method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.
[0118] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0119] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.
[0120] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.
[0121] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.
[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application 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 relevant regulations.
[0123] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.
[0124] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0125] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be construed as limiting the scope of the present application. It should be noted that, for a person of ordinary skill in the art, several modifications and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A timestamp rendering method, characterized in that: The method comprises: Displaying a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information; When the current moment satisfies a preset refresh cycle, the system time at the current moment is obtained, and a target image matching the character elements contained in the system time is obtained from a preset image set; Rendering target images matching each of the character elements to the first layer to display a timestamp of the current moment in the first layer of the test interface.
2. The method according to claim 1, characterized in that The character elements include digital elements and symbol elements, and the step of acquiring a target image matching the character elements included in the system time from a preset image set includes: Determine, according to the display format of the system time, the digital elements corresponding to each time unit in the system time and the symbol elements contained in the system time; According to a preset element-image mapping relationship, target images matching the digital elements and the symbolic elements corresponding to each of the timing units are respectively obtained from the preset image set; the element-image mapping relationship represents the matching relationship between the digital elements and the symbolic elements and each image in the image set.
3. The method according to claim 2, characterized in that The step of acquiring target images matching the digital elements and the symbol elements corresponding to each of the time units from the preset image set according to the preset element-image mapping relationship comprises: Determine, according to the digital elements corresponding to the respective timing units, the digital elements corresponding to the respective counting units contained in the respective timing units; According to the preset element-image mapping relationship, an image matching the digital element and the symbol element corresponding to each counting unit is searched from the preset image set as the target image.
4. The method according to claim 1, characterized in that: Before acquiring the target image matching the character element contained in the system time from the preset image set, the method further includes: Obtaining a preset digital element and a preset symbol element; Creating, according to a preset image format, a digital image corresponding to the preset digital element and a symbol image corresponding to the preset symbol element, and generating the preset image set according to the digital image and the symbol image; A preset element-image mapping relationship is determined according to the digital image and the preset digital element, and the symbol image and the preset symbol element.
5. The method according to claim 1, characterized in that Before displaying the test interface including the first layer and the second layer, the method further includes: Obtaining a layout file for the test interface and parsing the layout file to obtain an image rendering control; the image rendering control is used to render the first layer and the second layer; Creating a renderer corresponding to the image rendering control and setting a refresh period of the renderer to a preset refresh period; The refresh mode of the image rendering control is set, and the image rendering control is added to the window manager corresponding to the test interface; the window manager is used to manage the controls in the test interface.
6. The method according to claim 1, characterized in that The step of rendering the target image matching each of the character elements to the first layer includes: Obtaining a starting rendering position of the target image in the first layer and size information of the target image in the first layer; Starting from a starting rendering position in the first layer, the target image is drawn in the first layer according to the size information.
7. The method according to claim 6, characterized in that The obtaining the starting rendering position of the target image in the first layer includes: Determine, according to the display format of the system time, each time unit in the system time and each counting unit contained in each time unit; A starting rendering position of the target image in the first layer is determined according to each of the timing units and each of the counting units.
8. A timestamp rendering device, characterized in that: The device comprises: A display module, used to display a test interface including a first layer and a second layer; the first layer is used to display a timestamp; the second layer is used to display test information; A matching module, used for obtaining the system time at the current moment when the current moment satisfies a preset refresh cycle, and obtaining a target image matching the character elements contained in the system time from a preset image set; A rendering module is used to render the target image matching each of the character elements to the first layer, so as to display the timestamp of the current moment in the first layer of the test interface.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Real-time rendering display system and method for UI interface layout information based on swan gap system
CN120234083A
A real-time rendering and display system and method for UI interface layout information based on Hongmeng system
CN120234083B
