String display processing method, device, terminal and storage medium
By performing different rendering processing on the preset type characters of the character string to be displayed in the terminal user interface, the problems of high power consumption and lag in the prior art are solved, and more efficient string display is achieved.
Patent Information
- Application Number
- CN202210495910.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-28
- Publication Date
- 2024-12-10
- Estimated Expiration
- 2039-08-28
AI Technical Summary
The prior art consumes a lot of power when floating display of character strings to be displayed in the terminal user interface, especially when the number of character strings to be displayed is too large, and there is a lack of effective rendering processing methods.
By receiving character display instructions, we can determine whether the preset type characters are included in the string to be displayed. If not, the target character rendering is preprocessed to generate the rendering data set to render the character image. If included, the string rendering is preprocessed to generate the rendering data. Sets to render string images, implement rendering processing for different types of characters.
It effectively reduces terminal power consumption and overhead, improves the efficiency of string display, avoids the occurrence of lag, and achieves a smoother user interface display.
Smart Images

Figure CN114885202B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device, terminal and storage medium for displaying and processing a character string. Background Art
[0002] With the development of technology, various applications are constantly developing new functions to improve user experience. For example, many applications can display some content floating on the user interface to attract users' attention. For example, the barrage function is developed in video applications so that users can view other users' comments on the video while watching the video; for another example, the content that users need to pay attention to on a website is displayed floating on the page of a website, such as advertising content, website usage instructions, etc.
[0003] A commonly used method for floating content on a user interface can be: a server collects content that needs to be displayed within a period of time, which can also be called a string to be displayed; then the string to be displayed is sent to a terminal that displays the string to be displayed, and the terminal generates a character image corresponding to each character to be displayed in the string to be displayed, and then renders each character image to display the string to be displayed in the user interface of the terminal. However, practice has shown that this method consumes more terminal power consumption in actual applications, and is prone to jamming when there are a large number of strings to be displayed. Therefore, how to more effectively display the string to be displayed in the user interface of the terminal has become a hot research issue. Summary of the invention
[0004] The embodiments of the present invention provide a method, device, terminal and storage medium for displaying and processing a character string, which can specifically render a target character string including characters of different types, and better realize floating display of the target character string in the user interface of the terminal.
[0005] On the one hand, an embodiment of the present invention provides a method for displaying a character string, comprising:
[0006] Receiving a character display instruction, wherein the character display instruction is used to instruct to render a character string to be displayed;
[0007] If the target character string in the character string to be displayed does not include a character of a preset type, performing a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, the first rendering data set including a target character image corresponding to the target character, and generating a rendering instruction for the character string set to be displayed according to the first rendering data set to instruct image rendering to be performed on the target character image;
[0008] If the target string in the string to be displayed includes characters of a preset type, a second rendering preprocessing is performed on the target string to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and a rendering instruction for the string set to be displayed is generated based on the second rendering data set to instruct image rendering of the string image.
[0009] On the other hand, an embodiment of the present invention provides a string display processing device, including:
[0010] A receiving unit, used for receiving a character display instruction, wherein the character display instruction is used for instructing to render a character string to be displayed;
[0011] a processing unit, configured to, if the target character string in the character string to be displayed does not include a character of a preset type, perform a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, wherein the first rendering data set includes a target character image corresponding to the target character, and generate a rendering instruction for the character string set to be displayed according to the first rendering data set, so as to instruct image rendering to be performed on the target character image;
[0012] The processing unit is further configured to, if a target character string in the character string to be displayed includes characters of a preset type, perform a second rendering preprocessing on the target character string to obtain a second rendering data set, wherein the second rendering data set includes a character string image corresponding to the target character string, and generate a rendering instruction for the character string set to be displayed based on the second rendering data set to instruct image rendering to be performed on the character string image.
[0013] In another aspect, an embodiment of the present invention provides a terminal, the terminal comprising:
[0014] a processor adapted to implement one or more instructions; and,
[0015] A computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by the processor and executing the following steps:
[0016] Receiving a character display instruction, wherein the character display instruction is used to instruct to render a character string to be displayed;
[0017] If the target character string in the character string to be displayed does not include a character of a preset type, performing a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, the first rendering data set including a target character image corresponding to the target character, and generating a rendering instruction for the character string set to be displayed according to the first rendering data set to instruct image rendering to be performed on the target character image;
[0018] If the target string in the string to be displayed includes characters of a preset type, a second rendering preprocessing is performed on the target string to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and a rendering instruction for the string set to be displayed is generated based on the second rendering data set to perform image rendering on the string image with the instruction.
[0019] In the embodiment of the present invention, different rendering preprocessing methods are adopted to obtain a first rendering data set and a second rendering data set according to whether the target character string includes characters of a preset type, and then a rendering instruction for a character string set to be displayed is generated according to the first rendering data set or the second rendering data, thereby realizing different rendering processing according to the types of characters included in the target character string. Compared with the prior art that adopts a unified processing method for all target character strings, the target character string can be displayed more effectively. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying any creative work.
[0021] Figure 1a It is a structural schematic diagram of a string display processing solution provided by an embodiment of the present invention;
[0022] Figure 1b is a schematic diagram of a user interface of a terminal provided by an embodiment of the present invention;
[0023] Figure 1c is a schematic diagram of another user interface of a terminal provided by an embodiment of the present invention;
[0024] Figure 1d is a schematic diagram of a user interface of another terminal provided by an embodiment of the present invention;
[0025] Figure 1e is a schematic diagram of a user interface of another terminal provided by an embodiment of the present invention;
[0026] Figure 1f is a schematic diagram of displaying a character string on a user interface provided by an embodiment of the present invention;
[0027] Figure 2 is a flow chart of a method for displaying and processing a character string provided by an embodiment of the present invention;
[0028] Figure 3ais a schematic diagram of a character rendering texture set provided by an embodiment of the present invention;
[0029] Figure 3b is a schematic diagram of another character rendering texture set provided by an embodiment of the present invention;
[0030] Figure 3c is a schematic diagram of character rendering provided by an embodiment of the present invention;
[0031] Figure 3d is a schematic diagram of another character rendering provided by an embodiment of the present invention;
[0032] Figure 3e is a schematic diagram of storing a character image provided by an embodiment of the present invention;
[0033] Figure 4 is a flowchart of another character string display processing method provided by an embodiment of the present invention;
[0034] Figure 5a is a schematic diagram of a target character typesetting provided by an embodiment of the present invention;
[0035] Figure 5b is a schematic diagram of a target character provided by an embodiment of the present invention;
[0036] Figure 5c is a schematic diagram of another target character typesetting provided by an embodiment of the present invention;
[0037] Figure 5d is a schematic diagram of another target character typesetting provided by an embodiment of the present invention;
[0038] Figure 5e is a schematic diagram of another target character typesetting provided by an embodiment of the present invention;
[0039] Figure 6 is a structural schematic diagram of a string display processing device provided by an embodiment of the present invention;
[0040] Figure 7 It is a schematic diagram of the structure of a terminal provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0041] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0042] The embodiment of the present invention provides a string display processing scheme, which can be applied to an application scenario where a string needs to be displayed floatingly in a user interface of a terminal, wherein floating display refers to displaying certain strings in a manner of floating above the content displayed in the user interface, and these strings can be commentary texts, such as bullet screens, or advertising graphics and texts in a website, etc. The string display processing scheme may include: receiving a character display instruction, the character display instruction is used to instruct the terminal to render the string to be displayed so as to realize floating display of the string to be displayed on the user interface of the terminal; if the target string in the string to be displayed does not include a preset type of character, performing a first rendering preprocessing on the target character included in the target string to obtain a first rendering data set, the first rendering data set includes a target character image corresponding to the target character, and generating and sending a rendering instruction for the string set to be displayed according to the first rendering data set, the rendering instruction instructing to render the target character image; if the target string in the string to be displayed includes a preset type of character, performing a second rendering preprocessing on the target string to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and generating and sending a rendering instruction for the string set to be displayed according to the second rendering data set, the rendering instruction instructing to render the string image.
[0043] The string display processing scheme provided by the embodiment of the present invention can realize different rendering preprocessing methods for target strings including different types of characters, and then generate rendering instructions for the set of strings to be displayed for rendering according to different rendering preprocessing results. Compared with the prior art that uses a unified rendering processing method for any string, the target string can be displayed more effectively.
[0044] Taking the application of the string display processing solution in adding bullet screen to a video as an example, an embodiment of the present invention provides a structural schematic diagram of a string display processing solution, as shown in FIG. Figure 1a shown. Figure 1a The structural diagram shown may include a server 101 and at least one terminal 102. The terminal 102 may be a mobile phone, a tablet computer, a laptop computer, a wearable device, etc. The server 101 may refer to a cloud server or a local server. The terminal 102 is connected to the server 101, and the two can exchange information.
[0045] In one embodiment, the terminal 102 can be used to play videos. Optionally, a video player for playing videos can be installed in the terminal 102, and the user can watch the video through the video player; or the user can also watch the video on a web page through the terminal 102. The server 101 can store data that provides service support for the video service in the terminal 102.
[0046] In one embodiment, when playing a video, the terminal 102 may display a bullet screen option for adding bullet screens on the user interface. The user may trigger the bullet screen option and input the bullet screen content, i.e., a character string, through a keyboard or microphone. The terminal 102 sends the character string set to the server 101. For example, user A watches a video through a terminal 102. Figure 1b and Figure 1c A user interface for playing a video on a terminal provided in an embodiment of the present invention is provided. Assume that the video being played is a game video. The user interface may include a bullet screen button 103. If the bullet screen button 103 is Figure 1b , it means that user A has turned off the bullet screen function, that is, the bullet screen added by other users who watch the video for the video is not displayed in the user interface, and user A cannot add bullet screen in the user interface; if the bullet screen button 103 is Figure 1c The status shown indicates that user A has turned on the barrage function, that is, the barrage added to the video by any user watching the video is displayed in the user interface, and user A can add barrage in the user interface.
[0047] Assume that Figure 1c In the user interface shown, when user A turns on the barrage function, the user interface also includes a barrage input box 104 and a barrage setting button 105. If user A clicks the barrage setting button 105, the terminal displays the barrage setting interface, wherein the barrage setting interface may include the barrage font size, the number of barrages, and the barrage color, etc. If user A performs a barrage input operation in the barrage box 104, the terminal will display a keyboard to facilitate the user to enter the barrage content in the barrage input box through the keyboard. Optionally, the terminal may also include a confirmation button 106 in the interface displaying the keyboard. When the confirmation button 106 is clicked, the terminal 102 sends the character string in the barrage input box 104 to the server 101. Assuming that user A clicks on the barrage input box 104, the terminal displays the keyboard as shown in the figure. Figure 1d As shown, user A Figure 1d The user enters “So-and-so is awesome, thumbs up, thumbs up” in the barrage input box 104 , and clicks the confirmation button 106 .
[0048] In one embodiment, since multiple users can watch the same video through multiple different terminals 102, if multiple users input character strings through their respective terminals 102, the server 101 will receive multiple character strings. For example, assuming that user B watches the above video through a terminal 102 different from user A, refer to Figure 1e A user interface for adding bullet comments to the terminal 102 corresponding to user B. Figure 1e The bullet screen input box 107 and the confirmation button 108 are also included. Assume that user B Figure 1e The user enters “The defender’s shooting skills are good. I admire you” in the bullet comment input box 107 and clicks the confirmation button 108.
[0049] At this time, the terminal 102 corresponding to user A and the terminal 102 corresponding to user B send the character strings in their respective bullet screen input boxes to the server 101 .
[0050] In one embodiment, the server 101 can set a preset time range according to the video content, collect the strings within the preset time range, and form the strings into a set of strings to be displayed, and carry the strings in the character display instruction to send to each terminal 102 that is currently watching the same video. Then the server 101 continues to collect multiple strings within the next preset time range. That is, the set of strings to be displayed received by the terminal 102 corresponding to user A includes the string input by user A through the bullet screen input box 104, and also includes the string input by user B through the bullet screen input box 107.
[0051] After receiving the character display instruction sent by the server 101, the terminal 102 executes the above-mentioned string display processing scheme to display each string in the string set to be displayed collected by each terminal 102 on the user interface of the terminal. For example, after the terminal 102 corresponding to user A executes the above-mentioned string display processing scheme, the string set to be displayed on the user interface can be displayed as follows: Figure 1f As shown. Figure 1f As can be seen, it includes both the words “So-and-so is awesome, thumbs up, thumbs up” input by user A in the barrage input box 104 , and the words “The defender’s shooting skills are good, I admire you” input by user B in the barrage input box 106 .
[0052] Based on the above description, an embodiment of the present invention provides a flow chart of a method for displaying and processing a string. Figure 2 shown. Figure 2 The character string display processing method may be executed by a terminal, and specifically may be executed by a processor of the terminal. Figure 2 The character string display processing method shown may include the following steps:
[0053] Step S201: receiving a character display instruction, wherein the character display instruction instructs rendering of a character string set to be displayed.
[0054] In one embodiment, the character display instruction received by the terminal may be sent by the server. For example, in an application scenario of adding bullet screen to a video, each terminal playing the video may detect the adding bullet screen operation input by the corresponding user. Figure 1d and Figure 1fAs shown, the collected barrage content, i.e., character strings, are sent to the server. The server obtains a set of strings to be displayed based on the characters sent by each terminal, generates a character display instruction carrying the set of strings to be displayed, and sends the character display instruction to each terminal so that the terminal can render and display the set of strings to be displayed.
[0055] The set of strings to be displayed may include one or more strings, and it is assumed that the target string is any string in the set of strings to be displayed. For the convenience of description, the string display processing method described in this embodiment is specifically introduced by taking the target string in the set of strings to be displayed as an example. For other strings in the set of strings to be displayed except the target string, the same processing method as the target string is also adopted.
[0056] Step S202: If the target character string in the to-be-displayed character string set does not include characters of a preset type, a first rendering preprocessing is performed on the target characters included in the target character string to obtain a first rendering data set, the first rendering data set including a target character image corresponding to the target character, and a rendering instruction for the to-be-displayed character string set is generated and sent according to the first rendering data set.
[0057] Among them, the rendering instruction is used to indicate the rendering instruction for image rendering of the target character image. Optionally, after the terminal generates the rendering instruction about the character string set to be displayed according to the first rendering data set, it sends the rendering instruction to the rendering engine, and the rendering engine performs image rendering on the target character image to realize the display of the target character string on the user interface of the terminal. It should be understood that the character types included in each character string in the character string set to be displayed are generally different, and the processing methods and processes for different types of characters are also different. If a unified method is adopted to render each character string in the character string set to be displayed, there may be a slower rendering process for the character string including special or more complex characters, which affects the efficiency of the character string display. Among them, the character type may include text type, image type and other types. The characters of the text type are displayed as text on the user interface, and the characters of the image type are displayed as images on the user interface. Other types of characters are generally more special or more complex texts or images.
[0058] Based on this, in order to better display the character string and improve the efficiency of character string display, the embodiment of the present invention pre-sets some preset types of characters, and performs targeted rendering processing on the character string including the preset type of characters and the character string not including the preset type of characters. Optionally, the preset type of characters may be characters with a relatively low reuse rate, and the reuse rate may be understood as the character having a low probability of appearing in the barrage next time. For example, some characters that can only be sent by users who have registered as super members, or characters that can only be sent by users whose continuous viewing time exceeds the preset time, are characters with a low reuse rate. The preset type of characters described in the embodiment of the present invention may belong to other types of characters.
[0059] In one embodiment, the terminal can determine the preset type based on the history of the string display processing. For example, if it is found during several string display processing processes that a string including a certain character is displayed, it takes a long time to process the character, and the probability of the character appearing in the next string display processing process is low, then the character type corresponding to the character can be set to the preset type.
[0060] In other embodiments, the preset type of characters may also be set by the developer. The developer determines which type of characters meets the characteristics of low reuse rate based on the historical records of the character strings input by each user, and sets the character type with low reuse rate as the preset type. The characters that match the preset type are the characters of the preset type.
[0061] Based on the above description, before rendering each character string in the character string to be displayed, the embodiment of the present invention can first determine whether each character string includes a preset type of character, and then adopt a corresponding rendering method to render it according to the determination result. In the following description of the embodiment of the present invention, taking the target character string included in the character string set to be displayed as an example, it is introduced how to adopt a corresponding rendering method to render it according to the determination result.
[0062] In one embodiment, if it is detected that the target string does not include characters of a preset type, a first rendering process is performed on the target string included in the target string to obtain a first rendering data set, the first rendering data set includes a target character image corresponding to the target character, and then a rendering instruction about the string set to be displayed is generated and sent according to the first rendering data set, and the rendering instruction is used to indicate a rendering instruction for image rendering of the target character image. Among them, the target string does not include characters of a preset type, which may mean that: the character types of all target characters in the target string are not of the preset type; or, the target string does not include characters of the preset type, which may also mean that: the number of characters whose character types are equal to the preset type in the target characters is less than a quantity threshold, and the quantity threshold may be 1, 2 or other values. The method for determining whether the target string includes characters of a preset type is not specifically limited in the embodiment of the present invention, and may be determined by actual application requirements and terminal rendering performance.
[0063] In one embodiment, the first rendering preprocessing may refer to determining the first display parameters required to display the target character on the user interface and the processing of the first rendering parameters corresponding to the target character. Specifically, the first rendering preprocessing of the target character string included in the target character string to obtain the first rendering data set may include: obtaining the first display parameter for floating display of the target character on the user interface based on the character type of the target character; obtaining the first rendering parameter corresponding to the target character based on a preset character rendering texture set, the preset character rendering texture set including a character image corresponding to at least one character; obtaining the first rendering data set according to the first display parameter and the first rendering parameter.
[0064] Among them, the first display parameter may include a display position, and the display position may be expressed in the form of coordinates, or in the form of a distance and angle from a preset point in the user interface. For example, a coordinate system is established with the upper left corner vertex of the user interface as the origin, and any position in the user interface can be expressed in the form of coordinates. For example, the first display parameter of the target character includes (5,5) units of centimeters. For another example, the upper left corner vertex in the user interface is set as the preset point, and the first display parameter of the target character may include the position of the target character in the user interface relative to the preset point, which can be expressed as 4 centimeters, 30 degrees north-east.
[0065] In one embodiment, the implementation method of determining the first display parameter may be determined based on the configuration information corresponding to the floating display pre-set by the terminal and the typesetting processing of the target character. The configuration information may include information such as the character size, the distance from the top position of the user interface to start displaying the string, the color of the string, and the font of the string. The typesetting processing of the target character may refer to typesetting the target characters included in the target string according to a preset typesetting rule. How to determine the first display parameter corresponding to the target character will be described in detail later.
[0066] In one embodiment, the first rendering parameters may include a target character image corresponding to the target character and position information of the target character image. Obtaining the first rendering parameters corresponding to the target character based on a preset character rendering texture set may refer to: searching for the target character image from the character rendering texture set and determining the position information of the target character image; or, obtaining the first rendering parameters corresponding to the target character based on the preset character rendering texture set may also refer to: generating a target character image corresponding to the target character, updating the preset character image texture set according to the target character image, and then obtaining the position information of the target character image in the updated character image texture set.
[0067] The preset character image texture set includes at least one character corresponding to a character, and the preset character texture set is pre-set. Optionally, when the terminal is idle or the number of services processed is small, commonly used characters are obtained, and character images corresponding to each character are generated according to the character image generation rule, and each character image constitutes a character image texture set. The preset character image texture set may include a text type texture set such as Figure 3a As shown and the image type texture set is as Figure 3b shown.
[0068] It should be understood that the character image texture set stored in the terminal is to convert each character image into its corresponding encoding form for storage. Optionally, for a character, when the terminal uses the character generation rule to generate the character image corresponding to the character, the character encoding corresponding to the character and the encoding corresponding to the character image are associated and stored. When it is necessary to obtain the character image corresponding to the character, the character image corresponding to the character is found according to the character encoding and the associated storage relationship. For example, suppose a character string included in the character string to be displayed is Figure 3c As shown, the terminal detects the character code corresponding to each character in the string. Assuming that the crown image 301 corresponds to 660, the terminal replaces the crown image in the string with the character code. Figure 3d As shown in 302, other characters in the string are also replaced with their corresponding character codes (in Figure 3d not shown); in the Figure 3d After the display parameters and rendering parameters of each character in the text are obtained, the corresponding character image is found according to the non-character encoding of each character for rendering, and the character string displayed on the user interface is obtained, such as Figure 3c shown.
[0069] It should be understood that the character codes corresponding to characters of different character types may be different. For example, the character code corresponding to the character of the crown image may be 660, and the character code corresponding to the emoticon Emoji character type may be as follows: Figure 3e As shown. In the first column, CN, JP and KR represent the text characters corresponding to the corresponding Emoji. The text characters represent the meaning of the Emoji. CN represents the Chinese image, JP represents the Japanese image, and KR represents the Korean image. The middle column represents the Emoji image corresponding to each text character, and the last column represents the character encoding range corresponding to the corresponding Emoji in the terminal.
[0070] In one embodiment, after determining the first rendering data set, the terminal can generate a rendering instruction carrying the first rendering data set, and send the rendering instruction to the rendering engine so that the rendering engine renders the target characters according to the first rendering data set, thereby displaying the target character string on the user interface.
[0071] Step S203: if the target string of the string to be displayed includes characters of a preset type, a second rendering preprocessing is performed on the target string to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and a rendering instruction for the string set to be displayed is generated according to the second rendering data set.
[0072] Among them, the rendering instruction is used to instruct the image rendering of the string image. Optionally, after the terminal generates the rendering instruction about the string set to be displayed according to the second rendering data set, the rendering instruction can be sent to the rendering engine, and the rendering engine performs image rendering on the string image corresponding to the target string to realize the display of the target string on the user interface of the terminal. In one embodiment, the second rendering preprocessing can refer to the processing of determining the second rendering parameters and the second display parameters corresponding to the target string. Specifically, the second rendering preprocessing of the target string to obtain the second rendering data set may include: obtaining the second display parameters of the target string based on the configuration information corresponding to the floating display; generating the string image corresponding to the target string using the string image generation rule; adding the string image corresponding to the target string to the preset character rendering texture set to update the preset character rendering texture set, and determining the position information of the string image corresponding to the target string in the updated character rendering texture set; determining the second rendering parameter according to the string image and the position information of the string image in the updated character rendering texture set, and obtaining the second rendering data set according to the second rendering parameter and the second display parameter.
[0073] The configuration information corresponding to the floating display is as described above, and the configuration information may include information such as character size, the distance from the top of the user interface at which the string is to be displayed, the color of the string, and the font of the string. The second display parameter of the target string may include a display position, which may be expressed in the form of coordinates or in the form of distance plus angle, which will not be described in detail here.
[0074] In one embodiment, the second rendering parameter may include a string image corresponding to the target string and the location information of the string image. In this way, in subsequent rendering, the string image can be quickly found for rendering based on the location information of the string, which can save rendering time. From the above, it can be seen that the character image texture set preset by the terminal only includes character images corresponding to some commonly used characters, and does not include string images corresponding to strings. The terminal needs to generate a string image corresponding to the target string according to the string image generation rules. In order to uniformly manage the character images, the string image can be added to the preset character image texture set for storage to update the preset character image texture set, and then the location information of the string image in the character image texture set is obtained.
[0075] The character string image and the position information of the character string image in the updated character rendering texture set constitute the second rendering parameter, and the second rendering parameter and the second display parameter can be combined to obtain a second rendering data set. Then, a rendering instruction carrying the second rendering data set is generated, and the rendering instruction is sent to the rendering engine. The rendering engine performs image rendering according to the second rendering data set to display the character string to be displayed on the user interface of the terminal.
[0076] In one embodiment, for any character string in the set of character strings to be displayed, the following can be used when performing character string display processing: Figure 2 The string display processing method shown performs rendering processing to display each string in the string set to be displayed in the user interface of the terminal.
[0077] In one embodiment, if the character string to be displayed includes other character strings in addition to the target character string, and if the other character strings do not include characters of the preset type, the rendering instruction is also used to instruct image rendering of character images corresponding to the characters included in the other character strings; if the other character strings include characters of the preset type, the rendering instruction is also used to instruct image rendering of string images corresponding to the other character strings.
[0078] Specifically, according to Figure 2 The string display processing method shown processes other strings: if other strings include characters of a preset type, the first rendering preprocessing is performed on the other strings to obtain a third rendering data set, wherein the third rendering data set includes string images corresponding to other strings. If the target string includes characters of a preset type, a rendering instruction for the string to be displayed is generated based on the third rendering data set and the second rendering data set, and the rendering instruction at this time instructs the rendering engine to render the string images corresponding to other strings and the string images corresponding to the target string; if the target string does not include characters of a preset type, a rendering instruction for the string set to be displayed is generated based on the third rendering data set and the first rendering data set, and the rendering instruction at this time is used to instruct the rendering engine to render the target character images corresponding to the target characters in the target string and the string images corresponding to other strings.
[0079] In other embodiments, if the other character strings do not include characters of a preset type, a first rendering preprocessing is performed on the other character strings to obtain a fourth rendering data set, and the fourth rendering data set includes character images corresponding to other characters included in the other character strings; at this time, if the target character string does not include characters of a preset type, a rendering instruction for the character string set to be displayed is generated based on the fourth rendering data set and the first rendering data set, and the rendering instruction is sent to the rendering engine, and the rendering instruction in this case is used to instruct image rendering of the target character image corresponding to the target character in the target character string and the character image corresponding to other characters; if the target character string includes characters of a preset type, a rendering instruction for the character string set to be displayed is generated based on the fourth rendering data set and the second rendering data set, and the rendering instruction is sent to the rendering engine, and the rendering instruction at this time is used to instruct rendering of character images corresponding to other characters, as well as rendering of the character string image corresponding to the target character string.
[0080] Based on this description, it can be known that when the string to be displayed includes multiple strings, the terminal will obtain a rendering data set corresponding to each string, and then send rendering instructions about the string to be displayed to the rendering engine based on the rendering data set corresponding to each string. Compared with the prior art, each time a rendering data set of a string is obtained, a rendering instruction about the string is sent to the rendering engine. This can effectively reduce the number of times rendering instructions are sent to the rendering engine, reduce the interaction with the rendering engine, and save the power consumption overhead of the terminal.
[0081] In the embodiment of the present invention, after receiving a character display instruction carrying a character string set to be displayed, it is detected whether the target character string in the character string set to be displayed includes a preset type of character: if not, the target character string included in the target character string is processed to obtain a first rendering data set, and a rendering instruction about the character string set to be displayed is generated based on the first rendering data set to instruct the rendering of the target character image; if included, the target character string is processed as a whole to obtain a second rendering data set, and a rendering instruction about the character string to be displayed is generated based on the second rendering data set to instruct the rendering of the character string image corresponding to the target character string. In other words, for a target character string that does not include a preset type of character, rendering is performed with the character as the smallest unit, and for a character string that includes a preset type of character, rendering is performed with the target character string as a whole as a unit. Different rendering processing is implemented according to the different types of characters included in the target character string, and compared with the prior art that adopts a unified processing method for all target character strings, the target character string can be displayed more effectively.
[0082] In order to specifically introduce how to use the string display processing method provided by the embodiment of the present invention to render when the string set to be displayed includes multiple strings, it is assumed that the string set to be displayed includes a target string and other strings different from the target string, and the target string includes a target character, and the other strings include other characters, and the number of the target character and the other characters is at least one. In addition, a business call thread, a parsing thread, and a rendering thread are running in the terminal. By performing string display processing on the string to be displayed through different threads, each processing process can be independent of each other and does not affect each other, thereby improving the efficiency of string display.
[0083] Based on the above assumptions, the embodiment of the present invention also provides a flowchart of another string display processing method. Figure 4 As shown, Figure 4 The string display processing method shown can be applied to a terminal, in which a calling thread, a parsing thread, and a rendering thread are running. Figure 4 The string display processing method shown is actually executed by the terminal calling the above three threads. Figure 4 The steps in the figure that use a specific color to fill are executed by the thread corresponding to the color. Specifically, Figure 4 The character string display processing method shown may include the following steps:
[0084] Step S401: receiving a character display instruction, where the character display instruction is used to instruct rendering of a character string set to be displayed.
[0085] The set of character strings to be displayed may include a target character string and other character strings, the target character string includes a target character, and the other character strings include other characters. The target character string and the other character strings may not include characters of a preset type; or both include characters of a preset type; or, one of the target character string and the other character string includes characters of a preset type, and the other does not include characters of a preset type. Below, an example is taken to assume that the target character string does not include characters of a preset type, and the other character strings include characters of a preset type.
[0086] In one embodiment, step S401 may be performed by the terminal calling a calling thread. Optionally, the calling thread may be used to receive some services to be executed, such as rendering and displaying tasks of a string to be displayed, or opening or closing a bullet screen service.
[0087] Step S402: Detect whether the target character string and other character strings include characters of a preset type.
[0088] In one embodiment, the terminal may call a calling thread to detect target characters included in a target string and other characters included in other strings to determine whether the target string and other strings include characters of preset types, and may send the detection result to a parsing thread, which processes the target string and other strings respectively according to the detection result.
[0089] In one embodiment, if the terminal detects that the target string does not include characters of a preset type, a first rendering preprocessing may be performed on the target characters in the target string through steps S403-S407 to obtain a first rendering data set corresponding to the target string, wherein steps S403-S404, and steps S406-S407 may be executed by the terminal calling a parsing thread, and step S405 may be executed by the terminal calling a rendering thread; if the terminal detects that the target string includes characters of a preset type, a second rendering preprocessing may be performed on other strings through steps S408-S4011 to obtain a third rendering data set corresponding to other strings, wherein steps S408, S4010 and S4011 may be executed by the terminal calling a parsing thread, and step S409 may be executed by the terminal calling a rendering thread.
[0090] Step S403: If the target character string does not include a character string of a preset type, then detecting whether a preset character rendering texture set includes a character image that matches a target character included in the target character string.
[0091] In one embodiment, by Figure 2 As can be seen from the description of the illustrated embodiment, performing the first rendering process on the target in the target character string may refer to determining the first display parameter and the first rendering parameter corresponding to the target character. The first rendering parameter corresponding to the target character may be determined through steps S403 to S405, which are described in detail below; and the first display parameter corresponding to the target character may be determined through step S406.
[0092] In one embodiment, the first rendering parameter of the target character includes a target character image corresponding to the target character and the position of the target character image. Optionally, the terminal is pre-set with a character rendering texture set, which stores some pre-set character images corresponding to commonly used characters. When obtaining the target character image corresponding to the target character, the terminal can first detect whether the target character image corresponding to the target character has been preset in the character rendering texture set; if not, the terminal needs to generate the target character image according to the character image generation rule, and then determine the position information of the target character image; if so, the target character image and its position information can be directly obtained from the character rendering texture set, eliminating the step of generating the target character image, which can save part of the power consumption of the terminal and improve the speed of the terminal in displaying the character string.
[0093] Step S404: If the character rendering texture set includes a character image that matches the target character, the matched character image is determined as the target character image corresponding to the target character, and the position information of the target character image is determined according to the position of the matched character image in the character rendering texture set.
[0094] In one embodiment, the character rendering texture set preset by the terminal stores a character image corresponding to at least one character, and these character images are stored in a certain storage order. For example, the terminal presets a storage space of N rows and M columns, N and M are positive integers greater than 1, and the storage order can be stored based on columns, that is, the first character image is stored in the first row and first column, and the second character image is placed in the second row and first column, and so on, until the first column is full, and the character image is stored in the next column. Alternatively, the storage order can also be stored on a row basis, or can also include other storage orders, which are not specifically limited in the embodiments of the present invention. Based on this, the terminal can record the position corresponding to each character image in the character rendering texture set.
[0095] In one embodiment, when storing a preset character image, the terminal may store the character code in association with the character image. When detecting whether the character rendering texture set includes a character image matching the target character, the terminal may first parse the target character to obtain the character code corresponding to the target character; then detect whether the character rendering texture set includes a character image corresponding to the character code, and if so, determine that the character rendering texture set includes a character image matching the target character, otherwise, determine that the character rendering texture set does not include a character image matching the target character. The terminal may determine the position of the matching character image as the position information of the target character image.
[0096] Step S405: If the character rendering texture set does not include a character rendering image that matches the target character, a target character image corresponding to the target character is generated using a character rendering image generation rule, and the target character image is added to a preset character rendering texture set according to a preset storage rule to update the character rendering texture set, and position information of the target character image in the updated character rendering texture set is obtained according to the preset storage rule.
[0097] In one embodiment, if the character rendering texture set does not include a character rendering image that matches the target character, the terminal may generate a target character image corresponding to the target character according to a character rendering image generation rule, and in order to enrich the preset character rendering texture set, the generated target character image may be added to the preset character rendering texture set. Since the terminal stores character images in the character texture image set in accordance with a preset storage order, the terminal may obtain the position information of the target character image in the character rendering texture set according to the storage order.
[0098] In other embodiments, when the terminal pre-sets the character rendering texture set, the text-type character image and the image-type character image can be stored in one character rendering texture set; or, the terminal can also be provided with two different character rendering texture sets to store the preset displayed text-type character images and image-type character images. If the terminal sets the character rendering texture set for the text-type character image and the character rendering texture set for the image-type character image, before executing step S404, the target character can also be parsed to determine the character type to which the target character belongs; then, the corresponding character rendering texture set is found according to the character type of the target character to search for the target character image. In this way, the time for the terminal to check whether there is a character image that matches the target character can be saved, and searching in different character rendering texture sets can also improve the accuracy of the search.
[0099] Step S406: acquiring a first display parameter for floating display of the target character on the user interface based on the character type of the target character.
[0100] From the above, it can be seen that the character type in step S406 may include text type and image type, and each character type corresponds to a typesetting rule. The specific implementation method of step S406 can be: typeset the target character according to the typesetting rule corresponding to the character type of the target character; determine the first display parameter corresponding to the target character according to the typeset target character and the configuration information corresponding to the floating display.
[0101] In one embodiment, the typesetting rules also include alignment rules. When a character string is typeset according to a certain alignment rule, the characters included in the character string in the typeset result are relatively neat. The typesetting rules may include baseline alignment, vertical center alignment, etc. In one embodiment, typesetting the target characters of the book search according to the typesetting rules corresponding to the character type of the target characters may actually refer to typesetting the target characters according to the alignment rules indicated in the typesetting rules corresponding to the character type of the target characters. Optionally, in an embodiment of the present invention, the alignment rules indicated in the typesetting rules corresponding to the text type characters refer to baseline alignment, and the alignment rules corresponding to the image type characters may refer to vertical center alignment. In other embodiments, the typesetting rules also include information such as the spacing between characters, the size of characters, and the shape of characters.
[0102] In one embodiment, since the typesetting rules corresponding to different character types may be different, and the number of target characters is at least one, if the number of target characters is multiple (assuming that the target characters include a first character and a second character), when typeset the target characters according to the alignment rules indicated by the typesetting rules corresponding to the target character type, it is also necessary to consider whether the character types of the various target characters are the same, and then adopt different methods for typeset.
[0103] Specifically, if the target characters include a first character and a second character, typeset the target characters according to the typesetting rules corresponding to the character types of the target characters, including: if the first character type corresponding to the first character and the second character type corresponding to the second character are the same, typeset the first character and the second character according to the alignment rules indicated in the typesetting rules corresponding to the first character type or the second character type; if the first character type and the second character type are different, typeset the first character and the second character according to the size of the first character, the size of the second character, the alignment rules corresponding to the first character type, and the alignment rules corresponding to the second character type.
[0104] In one embodiment, the first character type and the second character type being the same may mean that both are text types; or both are image types, assuming that the alignment rule indicated in the typesetting rules corresponding to the text type is baseline alignment, and the alignment rule indicated in the typesetting rules corresponding to the image type is vertical center alignment.
[0105] In one embodiment, when the first character type and the second character type are both text types, the implementation method of typeset the first character and the second character according to the alignment rule indicated in the typesetting rule corresponding to the first character type or the second character type can be: typeset the first character and the second character on the default baseline according to the character spacing and other information indicated by the typesetting rule; find the parts of the first character and the second character below the baseline after typeset (for the convenience of the following description, the parts of the first character and the second character below the baseline are referred to as below-baseline glyphs, and the parts of the first character and the second character above the baseline are referred to as above-baseline glyphs), and obtain the height of each below-baseline glyph, and use the baseline corresponding to the below-baseline glyph with the largest height as the baseline of the target string, which can also be understood as the starting position of the bottom of the target string; obtain the height of the above-baseline glyph, and use the sum of the height of the above-baseline glyph with the largest height and the height of the below-baseline glyph with the largest height as the height of the target string.
[0106] For example, assuming that the target characters include "O", "p", "e", "n", "g", and "l", each character is typeset on the default baseline according to the character spacing and other information indicated by the typesetting rules. The typesetting result can be as follows: Figure 5a As shown, Figure 5a 501 represents the default baseline; then the length of the glyphs below the baseline of each character is obtained. For the characters "O", "l", "e" and "n", the glyphs below the baseline are not included, and the characters "p" and "g" include the glyphs below the baseline. The heights of the two glyphs below the baseline are obtained. Assuming that the length of the glyph below the baseline of the character "p" is the highest, the baseline of the character "p" is used as the baseline of the target string as shown in 502. Further, the height of the glyphs above the baseline of each character is obtained. Assuming that the heights of the glyphs above the baseline of the characters "O" and "l" are the highest, the height of the target string can be: the sum of the height of the glyph above the baseline with the largest height and the height of the glyph below the baseline with the largest height is used as the height of the target string. In 5a, the glyph above the baseline with the largest height is the character "O" or the character "l". Figure 5a As shown in 51, the baseline-below glyph with the largest height is the baseline-below glyph corresponding to the character "p". Figure 5a In 52, the sum of the height of 51 and the height of 52 is determined as the height of the target character string.
[0107] In other embodiments, when both the first character type and the second character type are image types, the implementation method of typeset the first character and the second character according to the alignment rule indicated in the typesetting rule corresponding to the first character type or the second character type can be: first typeset the first character and the second character with the largest size according to the typesetting rule; then calculate the coordinates of the upper left corner vertex of the other character according to the height of the larger character, and typeset according to the calculated coordinates of the upper left corner vertex; determine the height of the largest character of the two as the height of the target character. Among them, the calculation of the coordinates of the upper left corner vertex of the other character according to the height of the larger character can be achieved by the following formula: upper left corner vertex coordinates = (height of the largest character - height of the character) / 2 + height of the character.
[0108] For example, suppose the target character string includes three image-type characters, namely, "crying expression", "shield image" and "laughing expression". Figure 5b As shown in the figure, it is assumed that among the three characters, the size of the "shield image" is the largest, and the other two characters are the same. The layout of the three characters can be as follows Figure 5c As shown: first, the "shield image" is typeset according to the typesetting rules; then, the upper left vertex coordinates of the "crying expression" and the "laughing expression" are determined according to the height of the "shield image" and the heights of the "crying expression" and the "laughing expression" respectively; they are typeset according to their respective vertex coordinates; then the height of the "shield image" is determined as the height of the target character string.
[0109] In one embodiment, if the first character type and the second character type are different, the first character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and the second character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the second character type. Specifically, it may include: comparing the size of the first character and the size of the second character; if the size of the first character is larger than the size of the second character, the first character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and the height of the target string is determined according to the typesetting result; the second character is typeset based on the height of the target string and the alignment rule indicated in the typesetting rule corresponding to the second character type. Similarly, if the size of the second character is larger than the size of the first character, the second character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the second character type, and the height of the target string is determined according to the typesetting result; the first character is typeset according to the height of the target string and the alignment rule indicated in the typesetting rule corresponding to the first character type. That is, the larger size of the first character and the second character is typeset first, and then the smaller size is typeset.
[0110] In one embodiment, the first character type and the second character type are different may include the first character type being a text type and the second character type being an image type; or the first character type being an image type and the second character type being a text type. Figure 5d A schematic diagram of a target character typesetting provided by an embodiment of the present invention. Assume that the target character string includes text type characters "O", "p", "e", "n", "g", "l", and image type characters such as Figure 5b The "shield image" and "crying expression" shown. If the size of the "shield image" is the largest, the "crying expression" is the smallest. When typeset, first typeset the "shield image", then typeset the above-mentioned text type characters, and finally typeset the "crying expression". The specific typesetting implementation method can be: the height of the "shield image" is the height of the target string; based on the vertical centering rule, the height occupied by the text type character part during typeset is determined, including the bottom position 503 and the top position 504 of the text type character; the longest character "O" in the text type character is typeset according to the top position B, and then the position 505 at the bottom of "O" is used as the baseline for typesetting the text type characters, and the other characters are typeset between 503 and 504 according to the above-mentioned baseline alignment rule. After the typeset results of each text type character are obtained, the "crying expression" is typeset according to the above-mentioned vertical centering rule.
[0111] For example, in Figure 5d If the size of the text characters is larger than that of the image characters, the characters are first typeset according to the baseline alignment rule to determine the height of the target string. Figure 5e As shown, 506 represents the baseline, and the distance between 507 and 508 represents the height of the target character string; based on the height of the target character string and the vertical alignment rule, the coordinates of the upper left corner vertex of the largest character in the image type characters are determined, and the largest image type character is typeset and stored according to the coordinates. For other image type characters, they can be typeset according to the image type character typesetting process described above, which will not be repeated here.
[0112] Step S407 : determining a first rendering parameter corresponding to the target character according to the target character image and the position information of the target character image, and determining a first rendering data set according to the first rendering parameter and the first display parameter.
[0113] In one embodiment, the target character image and the position information of the character image are combined to obtain a first rendering parameter corresponding to the target character, and then the first rendering parameter and the first display parameter are combined to obtain a first rendering data set.
[0114] Step S408: if the other character string includes characters of a preset type, a character string image generation rule is used to generate a character string image corresponding to the other character string.
[0115] Step S409: Add the character string images corresponding to the other character strings to the preset character rendering texture set to update the character rendering texture set, and determine the position information of the character string images corresponding to the other character strings in the updated character rendering texture set.
[0116] Step S4010: Obtain third display parameters of other character strings based on configuration information corresponding to the floating display.
[0117] Step S4011, determining third rendering parameters corresponding to other strings according to string images corresponding to other strings and position information of the string images in the updated character rendering texture set, and obtaining a third rendering data set according to the third rendering parameters and the third display parameters.
[0118] Steps S408 to S4011 mainly introduce how to perform second rendering preprocessing to obtain a third rendering data set for other strings that do not include the preset type. Some feasible implementation methods included in the steps can be found in Figure 2 The description of step S203 in the illustrated embodiment will not be repeated here.
[0119] Step S4012: Generate rendering instructions for the to-be-displayed character string set according to the first rendering data set and the third rendering data set, and send the rendering instructions to the rendering engine so that the rendering engine performs image rendering based on the second rendering data set and the third rendering data set.
[0120] In one embodiment, the first rendering data set and the third rendering data set are carried in one rendering instruction. Compared with the method in the prior art where each rendering instruction carries one rendering data set, this can reduce the number of rendering instructions and save power consumption of the terminal.
[0121] It should be understood that Figure 4 It only shows how to display the character string when the target character string does not include the characters of the preset type, but other character strings include the characters of the preset type. In actual applications, it may happen that the target character string includes the characters of the preset type, but other character strings do not include the characters of the preset type; or the target character string and other character strings do not include the characters of the preset type; or the target character string and other character strings both include the characters of the preset type. For these cases, please refer to the specific character string display processing process. Figure 4 The description of the corresponding steps in will not be repeated here.
[0122] In an embodiment of the present invention, if a character display instruction includes two to-be-displayed strings, namely a target string and other strings, the target string does not include characters of a preset type, and the other strings include characters of a preset type, processing the target string includes: detecting whether a preset character rendering texture set includes a character image that matches a target character included in the target string; if the character rendering texture set includes a character image that matches the target character, determining the matched character image as a target character image corresponding to the target character, and determining position information of the target character image according to the position of the matched character image in the character rendering texture set; if the character rendering texture set does not include a character rendering image that matches the target character, generating a target character image corresponding to the target character using a character rendering image generation rule, adding the target character image to the preset character rendering texture set according to a preset storage rule to update the character rendering texture set, and obtaining position information of the target character image in the updated character rendering texture set according to the preset storage rule; obtaining a first display parameter for floatingly displaying the target character on a user interface based on the character type of the target character; determining a first rendering parameter corresponding to the target character according to the target character image and the position information of the target character image, and determining a first rendering data set according to the first rendering parameter and the first display parameter.
[0123] The processing of other strings may include: generating string images corresponding to other strings using string image generation rules; adding string images corresponding to other strings to a preset character rendering texture set to update the character rendering texture set, and determining position information of string images corresponding to other strings in the updated character rendering texture set; acquiring third display parameters of other strings based on configuration information corresponding to the floating display; determining third rendering parameters corresponding to other strings based on string images corresponding to other strings and position information of the string images in the updated character rendering texture set, and obtaining a third rendering data set based on the third rendering parameters and the third display parameters.
[0124] Finally, a rendering instruction about the string set to be displayed is generated according to the first rendering data set and the third rendering data set, and the rendering instruction is sent to the rendering engine, so that the rendering engine performs image rendering based on the second rendering data set and the third rendering data set.
[0125] In the above-mentioned string display processing process, different rendering processing is implemented according to different types of characters included in the target string, and compared with the prior art that adopts a unified processing method for all target strings, the target string can be displayed more effectively. In addition, the first rendering data set and the third rendering data set are carried in a rendering instruction and sent to the rendering engine, which can reduce the interaction between the terminal and the rendering engine and save the power consumption of the terminal.
[0126] In addition, when performing the first rendering preprocessing on the target character in the target character string, a preset character rendering texture set is introduced. First, it is detected whether the preset character rendering texture set includes a character image matching the target character. If it is included, the target character image corresponding to the target character is directly obtained; if it is not included, the target string image corresponding to the target character is generated, which effectively reduces the number of generated character images, saves terminal power consumption and improves rendering efficiency.
[0127] In order to verify the efficiency of the embodiment of the present invention in string display processing, taking adding barrage to video as an example, the string display processing method shown in the embodiment of the present invention is compared with the method of adding barrage in the prior art. It is assumed that the following comparison results are obtained under the assumption that the terminal displays 100 barrages per second. The comparison results are shown in Table 1 below.
[0128] Table 1
[0129]
[0130] As can be seen from Table 1, compared with the prior art, the embodiments of the present invention have the following advantages:
[0131] On the one hand, in the prior art, rendering is performed in units of the entire barrage under any circumstances, so that the number of generated string images is proportional to the number of barrages; while in the string display processing method of the embodiment of the present invention, a character rendering texture set is pre-set, and whether the target string includes characters of a preset type determines whether to render in units of the characters included in the barrage or in units of the entire barrage, and only when the character rendering texture set does not include a character image or a string image matching the barrage, a character image or a string image is generated, thereby reducing the number of generated character images or string images and saving terminal power consumption overhead.
[0132] Secondly, in the prior art, for a bullet screen, after the terminal generates a rendering data set corresponding to the bullet screen, it sends a rendering instruction to the rendering engine, so that the number of rendering instructions is proportional to the number of bullet screens, resulting in frequent interactions between the terminal and the rendering engine, affecting the rendering speed. In the embodiment of the present invention, the rendering data sets of multiple bullet screens are carried in the same rendering instruction and sent to the rendering engine for rendering, which effectively reduces the interaction between the terminal and the rendering engine, thereby improving the rendering speed.
[0133] Thirdly, in the prior art, the parsing, rendering and display of bullet comments are all performed in the same thread, and when there are too many bullet comments, the string display may become stuck. In the embodiment of the present invention, the parsing and rendering of bullet comments are performed by the service call thread, the parsing thread and the rendering thread respectively, which does not affect the display of bullet comments, and the bullet comments can still be displayed smoothly when there are a large number of strings.
[0134] Fourthly, the string display processing method of the embodiment of the present invention can make the refresh rate of the video screen greater than the refresh rate in the prior art; and the memory occupied in the process of the string display processing method described in the embodiment of the present invention is much smaller than the memory occupied in the prior art; and the processor occupancy rate during the processing of the string display processing method in the embodiment of the present invention is much lower than that in the prior art.
[0135] Based on the above-mentioned string display processing method, the embodiment of the present invention also discloses a string display processing device, which can execute Figure 2 and Figure 4 The string display processing method shown in the figure can be configured in a terminal. Figure 6 , the string display processing device can run the following units:
[0136] A receiving unit 601 is used to receive a character display instruction, where the character display instruction is used to instruct to render a character string to be displayed;
[0137] The processing unit 602 is configured to, if the target character string in the character string to be displayed does not include a character of a preset type, perform a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, wherein the first rendering data set includes a target character image corresponding to the target character, and generate a rendering instruction for the character string set to be displayed according to the first rendering data set to instruct image rendering to be performed on the target character image;
[0138] The processing unit 602 is further configured to, if a target character string in the character string to be displayed includes characters of a preset type, perform a second rendering preprocessing on the target character string to obtain a second rendering data set, wherein the second rendering data set includes a character string image corresponding to the target character string and generates a rendering instruction for the character string set to be displayed based on the second rendering data set to instruct image rendering of the character string image.
[0139] In one embodiment, the set of strings to be displayed also includes other strings besides the target string: if the other strings do not include characters of the preset type, the rendering instruction is also used to instruct image rendering of character images corresponding to the characters included in the other strings; if the other strings include characters of the preset type, the rendering instruction is also used to instruct image rendering of string images corresponding to the other strings.
[0140] In one embodiment, the processing unit 602 performs the following operations after performing a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set: obtaining a first display parameter for floating display of the target character on the user interface based on the character type of the target character; obtaining a first rendering parameter corresponding to the target character based on a preset character rendering texture set, wherein the preset character rendering texture set includes a character image corresponding to at least one character; and obtaining a first rendering data set according to the first display parameter and the first rendering parameter.
[0141] In one embodiment, the first rendering parameters include a target character image corresponding to the target character and position information of the target character image. When the processing unit 702 obtains the first rendering parameters corresponding to the target character based on a preset character rendering texture set, it performs the following operations: if the character rendering texture set includes a character image that matches the target character, the matching character rendering image is determined as the target character image corresponding to the target character, and the position information of the target character image is determined according to the position of the matching character rendering image in the character rendering texture set.
[0142] In one embodiment, when the processing unit 702 obtains the first rendering parameter corresponding to the target character based on a preset character rendering texture set, it performs the following operations: if the character rendering texture set does not include a character rendering image matching the target character, a character rendering image generation rule is used to generate a target character image corresponding to the target character, and the target character image is added to the character rendering texture set according to a preset storage rule to update the character rendering texture set; and the position information of the target character image in the updated character rendering texture set is obtained according to the preset storage rule.
[0143] In one embodiment, when the processing unit 702 obtains the first display parameter for displaying the target character on the user interface based on the character type of the target character, it performs the following operations: typeset the target character according to the typesetting rule corresponding to the character type of the target character; and determines the first display parameter corresponding to the target character based on the typeset target character and the configuration information corresponding to the floating display.
[0144] In one embodiment, the target characters include a first character and a second character, and the processing unit 702 performs the following operations when typeset the target characters according to the typesetting rules corresponding to the character types of the target characters: if the first character type corresponding to the first character and the second character type corresponding to the second character are the same, the first character and the second character are typeset according to the alignment rules indicated in the typesetting rules corresponding to the first character type or the second character type; if the first character type and the second character type are different, the first character is typeset according to the alignment rules indicated in the typesetting rules corresponding to the first character type, and the second character is typeset according to the alignment rules indicated in the typesetting rules corresponding to the second character type.
[0145] In one embodiment, when the processing unit 702 typesets the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and typesets the second character according to the alignment rule indicated in the typesetting rule corresponding to the second character type, the processing unit 702 performs the following operations: compares the size of the first character with the size of the second character; if the size of the first character is larger than the size of the second character, typeset the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and determines the height of the target character string according to the typesetting result; typesets the second character based on the height of the target character string and the alignment rule indicated in the typesetting rule corresponding to the second character type.
[0146] In one embodiment, the second rendering parameters include a string image corresponding to the target string and position information of the string image. When the processing unit 702 performs a second rendering preprocessing on the target string to obtain a second rendering data set, the processing unit 702 performs the following operations: obtaining a second display parameter of the target string based on the configuration information corresponding to the floating display; generating a string image corresponding to the target string using a string image generation rule; adding the string image corresponding to the target string to a preset character rendering texture set to update the preset character rendering texture set, and determining the position information of the string image corresponding to the target string in the updated character rendering texture set; determining the second rendering parameters based on the string image and the position information of the string image in the updated character rendering texture set, and obtaining the second rendering data set based on the second rendering parameters and the second display parameters.
[0147] In one embodiment, the terminal runs a calling thread, a parsing thread and a rendering thread: the terminal calls the calling thread to execute: receiving a character display instruction and detecting a target character included in the target character string; the terminal calls the parsing thread to execute a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, and a second rendering preprocessing on the target character string to obtain a second rendering data set; the terminal calls the rendering thread to execute: generating a rendering instruction according to the first rendering data set, and generating a rendering instruction according to the second rendering data set.
[0148] According to one embodiment of the present invention, Figure 2 and Figure 4 The various steps involved in the method shown can be performed by Figure 6 The character strings shown are executed by each unit in the display processing device. For example, Figure 2 Step S201 shown can be performed by Figure 6 Step S202 and step S203 may be performed by the processing unit 602 in the string display processing device described in the figure; for example, Figure 4 The step S401 shown in FIG. 4 can be performed by Figure 6 The receiving unit 601 in the string display processing device shown in FIG. 6 may be executed, and steps S402 to S4012 may be executed by the processing unit 602 in the string display processing device shown in FIG. 6 .
[0149] According to another embodiment of the present invention, Figure 6 The various units in the string display processing device shown can be individually or completely combined into one or several other units to form, or one (some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the functions of multiple units can be realized by one unit. In other embodiments of the present invention, the string display processing device can also include other units. In practical applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.
[0150] According to another embodiment of the present invention, the program can be executed by running a program on a general computing device such as a computer including a central processing unit (CPU), a random access memory medium (RAM), a read-only memory medium (ROM), and other processing elements and storage elements. Figure 2 or Figure 4 A computer program (including program code) for each step involved in the corresponding method shown in Figure 6The string display processing device shown in the embodiment of the present invention is used to implement the string display processing method of the embodiment of the present invention. The computer program can be recorded on a computer-readable storage medium, for example, and loaded into the above-mentioned computing device through the computer-readable storage medium and run therein.
[0151] In the embodiment of the present invention, after receiving a character display instruction carrying a character string set to be displayed, it is detected whether the target character string in the character string set to be displayed includes a preset type of character: if not, the target character string included in the target character string is processed to obtain a first rendering data set, and a rendering instruction about the character string set to be displayed is generated based on the first rendering data set to instruct the rendering of the target character image; if included, the target character string is processed as a whole to obtain a second rendering data set, and a rendering instruction about the character string to be displayed is generated based on the second rendering data set to instruct the rendering of the character string image corresponding to the target character string. In other words, for a target character string that does not include a preset type of character, rendering is performed with the character as the smallest unit, and for a character string that includes a preset type of character, rendering is performed with the target character string as a whole as a unit. Different rendering processing is implemented according to the different types of characters included in the target character string, and compared with the prior art that adopts a unified processing method for all target character strings, the target character string can be displayed more effectively.
[0152] Based on the description of the above method embodiment and the device embodiment, the embodiment of the present invention further provides a terminal, referring to Figure 7 A schematic diagram of the structure of a terminal provided by an embodiment of the present invention. Figure 7 As shown, the terminal may include a processor 701 and a computer storage medium 702 .
[0153] The computer storage medium 702 may be stored in a memory of a server. The computer storage medium 902 is used to store a computer program. The computer program includes program instructions. The processor 701 is used to execute the program instructions stored in the computer storage medium 702 . The processor 701 or CPU (Central Processing Unit) is the computing core and control core of the server, which is suitable for implementing one or more instructions, and is specifically suitable for loading and executing one or more instructions to implement the corresponding method flow or corresponding function; in one embodiment, if the electronic device corresponds to the aforementioned server, the processor 701 described in the embodiment of the present invention can be used to execute: receiving a character display instruction, the character display instruction is used to instruct the rendering of the string to be displayed; if the target string in the string to be displayed does not include a preset type of character, the target character included in the target string is subjected to a first rendering preprocessing to obtain a first rendering data set, the first rendering data set includes a target character image corresponding to the target character, and a rendering instruction for the string set to be displayed is generated according to the first rendering data set to instruct the image rendering of the target character image; if the target string in the string to be displayed includes a preset type of character, the target string is subjected to a second rendering preprocessing to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and a rendering instruction for the string set to be displayed is generated according to the second rendering data set to instruct the image rendering of the string image.
[0154] The embodiment of the present invention also provides a computer storage medium (Memory), which is a memory device in an electronic device for storing programs and data. It is understandable that the computer storage medium here can include both built-in storage media in the electronic device and, of course, extended storage media supported by the electronic device. The computer storage medium provides a storage space in which one or more instructions suitable for being loaded and executed by the processor 701 are stored. These instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage; optionally, it can also be at least one computer storage medium located away from the aforementioned processor.
[0155] In one embodiment, the set of strings to be displayed also includes other strings besides the target string, and the processor 701 is further used for: if the other strings do not include the preset type of characters, the rendering instruction is also used to instruct image rendering of character images corresponding to the characters included in the other strings; if the other strings include the preset type of characters, the rendering instruction is also used to instruct image rendering of string images corresponding to the other strings.
[0156] In one embodiment, when the processor 701 performs a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, the processor 701 performs the following operations: based on the character type of the target character, obtaining a first display parameter for floating display of the target character on the user interface; based on a preset character rendering texture set, obtaining a first rendering parameter corresponding to the target character, wherein the preset character rendering texture set includes a character image corresponding to at least one character; and obtaining a first rendering data set according to the first display parameter and the first rendering parameter.
[0157] In one embodiment, the first rendering parameter includes a target character image corresponding to the target character and position information of the target character image. When the processor 701 obtains the first rendering parameter corresponding to the target character based on a preset character rendering texture set, it performs the following operations: if the character rendering texture set includes a character image that matches the target character, the matching character rendering image is determined as the target character image corresponding to the target character, and the position information of the target character image is determined according to the position of the matching character rendering image in the character rendering texture set.
[0158] In one embodiment, when the processor 701 obtains the first rendering parameter corresponding to the target character based on a preset character rendering texture set, the processor 701 performs the following operations: if the character rendering texture set does not include a character rendering image matching the target character, a character rendering image generation rule is used to generate a target character image corresponding to the target character, and the target character image is added to the character rendering texture set according to a preset storage rule to update the character rendering texture set; and the position information of the target character image in the updated character rendering texture set is obtained according to the preset storage rule.
[0159] In one embodiment, when the processor 701 obtains the first display parameter for displaying the target character on the user interface based on the character type of the target character, it performs the following operations: typeset the target character according to the typesetting rule corresponding to the character type of the target character; and determines the first display parameter corresponding to the target character based on the typeset target character and the configuration information corresponding to the floating display.
[0160] In one embodiment, the target characters include a first character and a second character, and the processor 701 performs the following operations when typeset the target characters according to the typesetting rules corresponding to the character types of the target characters: if the first character type corresponding to the first character and the second character type corresponding to the second character are the same, the first character and the second character are typeset according to the alignment rules indicated in the typesetting rules corresponding to the first character type or the second character type; if the first character type and the second character type are different, the first character is typeset according to the alignment rules indicated in the typesetting rules corresponding to the first character type, and the second character is typeset according to the alignment rules indicated in the typesetting rules corresponding to the second character type.
[0161] In one embodiment, when the processor 701 typesets the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and typesets the second character according to the alignment rule indicated in the typesetting rule corresponding to the second character type, the processor 701 performs the following operations: compares the size of the first character with the size of the second character; if the size of the first character is larger than the size of the second character, typeset the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and determines the height of the target character string according to the typesetting result; typesets the second character based on the height of the target character string and the alignment rule indicated in the typesetting rule corresponding to the second character type.
[0162] In one embodiment, the second rendering parameters include a string image corresponding to the target string and position information of the string image. When the processor 701 performs a second rendering preprocessing on the target string to obtain a second rendering data set, the following operations are performed: obtaining a second display parameter of the target string based on the configuration information corresponding to the floating display; generating a string image corresponding to the target string using a string image generation rule; adding the string image corresponding to the target string to a preset character rendering texture set to update the preset character rendering texture set, and determining the position information of the string image corresponding to the target string in the updated character rendering texture set; determining the second rendering parameters based on the string image and the position information of the string image in the updated character rendering texture set, and obtaining the second rendering data set based on the second rendering parameters and the second display parameters.
[0163] In one embodiment, the terminal runs a calling thread, a parsing thread and a rendering thread: the terminal calls the calling thread to execute: receiving a character display instruction and detecting a target character included in the target character string; the terminal calls the parsing thread to execute a first rendering preprocessing on the target characters included in the target character string to obtain a first rendering data set, and a second rendering preprocessing on the target character string to obtain a second rendering data set; the terminal calls the rendering thread to execute: generating a rendering instruction according to the first rendering data set, and generating a rendering instruction according to the second rendering data set.
[0164] A person skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0165] The above disclosure is only part of the embodiments of the present invention, which certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A method for displaying and processing a character string, characterized in that: include: receiving a character display instruction, wherein the character display instruction instructs rendering of a character string set to be displayed; Obtaining characters of a preset type; the reuse rate of the characters of the preset type is lower than the reuse rate of characters of a non-preset type; the reuse rate refers to the probability of a character appearing in the next bullet screen; If the target character string in the to-be-displayed character string set does not include a character of a preset type, typeset the target character according to a typesetting rule corresponding to the character type of the target character; the target character belongs to the target character string; the character type of the target character is a text type or an image type; Determining a first display parameter corresponding to the target character according to the typeset target character and the configuration information corresponding to the floating display; Acquire a first rendering parameter corresponding to the target character based on a preset character rendering texture set, wherein the preset character rendering texture set includes a character image corresponding to at least one character; Obtain a first rendering data set according to the first display parameter and the first rendering parameter; The first rendering data set includes a target character image corresponding to the target character, and a rendering instruction about the character string set to be displayed is generated according to the first rendering data set to instruct image rendering of the target character image, the first rendering preprocessing refers to determining a first display parameter required for displaying the target character on the user interface and a first rendering parameter corresponding to the target character, the first display parameter includes a display position, and the first rendering parameter includes a target character image corresponding to the target character and position information of the target character image; If the target string in the set of strings to be displayed includes characters of a preset type, a second rendering preprocessing is performed on the target string to obtain a second rendering data set, the second rendering data set includes a string image corresponding to the target string, and a rendering instruction for the set of strings to be displayed is generated based on the second rendering data set to instruct image rendering of the string image, the second rendering preprocessing refers to determining a second rendering parameter corresponding to the target string and a processing of a second display parameter, the second display parameter includes a display position, and the second rendering parameter includes a string image corresponding to the target string and position information of the string image.
2. The method according to claim 1, characterized in that The set of character strings to be displayed also includes other character strings except the target character string, and the method further includes: If the other character string does not include the characters of the preset type, the rendering instruction is further used to instruct to perform image rendering on the character images corresponding to the characters included in the other character string; If the other character string includes the preset type of characters, the rendering instruction is further used to instruct to perform image rendering on the character string image corresponding to the other character string.
3. The method according to claim 1, characterized in that The obtaining a first rendering parameter corresponding to the target character based on a preset character rendering texture set includes: If the character rendering texture set includes a character image that matches the target character, the matching character rendering image is determined as the target character image corresponding to the target character, and the position information of the target character image is determined according to the position of the matching character rendering image in the character rendering texture set.
4. The method according to claim 3, characterized in that The obtaining a first rendering parameter corresponding to the target character based on a preset character rendering texture set includes: If the character rendering texture set does not include a character rendering image matching the target character, generating a target character image corresponding to the target character using a character rendering image generation rule, and adding the target character image to the character rendering texture set according to a preset storage rule to update the character rendering texture set; The position information of the target character image in the updated character rendering texture set is obtained according to the preset storage rule.
5. The method according to claim 1, characterized in that The target characters include a first character and a second character, and typeset the target characters according to a typesetting rule corresponding to a character type of the target characters, including: If a first character type corresponding to the first character and a second character type corresponding to the second character are the same, typeset the first character and the second character according to an alignment rule indicated in a typesetting rule corresponding to the first character type or the second character type; If the first character type and the second character type are different, the first character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and the second character is typeset according to the alignment rule indicated in the typesetting rule corresponding to the second character type.
6. The method according to claim 5, characterized in that The typesetting of the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and the typesetting of the second character according to the alignment rule indicated in the typesetting rule corresponding to the second character type, include: comparing a size of the first character and a size of the second character; If the size of the first character is larger than the size of the second character, typeset the first character according to the alignment rule indicated in the typesetting rule corresponding to the first character type, and determine the height of the target character string according to the typesetting result; The second character is typeset based on the height of the target character string and an alignment rule indicated in a typesetting rule corresponding to the second character type.
7. The method according to claim 1, characterized in that The performing second rendering preprocessing on the target character string to obtain a second rendering data set includes: Acquire a second display parameter of the target character string based on configuration information corresponding to the floating display; Generate a character string image corresponding to the target character string using a character string image generation rule; Adding the character string image corresponding to the target character string to a preset character rendering texture set to update the preset character rendering texture set, and determining position information of the character string image corresponding to the target character string in the updated character rendering texture set; A second rendering parameter is determined according to the character string image and the position information of the character string image in the updated character rendering texture set, and the second rendering data set is obtained according to the second rendering parameter and the second display parameter.
8. The method according to claim 1, characterized in that The string display processing method is applied in a terminal, and the terminal runs a calling thread, a parsing thread, and a rendering thread, wherein: The terminal calls the calling thread to execute: receiving a character display instruction and detecting a target character included in the target character string; The terminal calls the parsing thread to execute: performing a first rendering preprocessing on target characters included in the target character string to obtain the first rendering data set; The terminal calls a rendering thread to execute: generating a rendering instruction according to the first rendering data set.
9. A character string display processing device, characterized in that: include: A receiving unit, used for receiving a character display instruction, wherein the character display instruction is used for instructing to render a character string set to be displayed; The receiving unit is further used to obtain characters of a preset type; the reuse rate of the characters of the preset type is lower than the reuse rate of characters of a non-preset type; the reuse rate refers to the probability of a character appearing in the next bullet screen; a processing unit, configured to typeset the target character according to a typesetting rule corresponding to the character type of the target character if the target character string in the to-be-displayed character string set does not include a character of a preset type; the target character belongs to the target character string; the character type of the target character is a text type or an image type; The processing unit is further used to determine the first display parameter corresponding to the target character according to the typeset target character and the configuration information corresponding to the floating display; The processing unit is further used to obtain a first rendering parameter corresponding to the target character based on a preset character rendering texture set, wherein the preset character rendering texture set includes a character image corresponding to at least one character; The processing unit is further used to obtain a first rendering data set according to the first display parameter and the first rendering parameter; the first rendering data set includes a target character image corresponding to the target character, and generates and sends a rendering instruction about the character string set to be displayed according to the first rendering data set, the rendering instruction is used to instruct to perform image rendering on the target character image, the first rendering preprocessing refers to determining the first display parameter required to display the target character on the user interface and the processing of the first rendering parameter corresponding to the target character, the first display parameter includes a display position, and the first rendering parameter includes a target character image corresponding to the target character and position information of the target character image; The processing unit is further configured to, if a target string in the set of strings to be displayed includes characters of a preset type, perform a second rendering preprocessing on the target string to obtain a second rendering data set, the second rendering data set including a string image corresponding to the target string, and generate and send a rendering instruction about the set of strings to be displayed based on the second rendering data set, the rendering instruction being used to instruct image rendering of the string image, the second rendering preprocessing referring to determining a second rendering parameter corresponding to the target string and a processing of a second display parameter, the second display parameter including a display position, and the second rendering parameter including a string image corresponding to the target string and position information of the string image.
10. A terminal, characterized in that: Also includes: a processor adapted to implement one or more instructions; as well as, A computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by the processor and executing the character string display processing method according to any one of claims 1 to 8.
11. A computer storage medium, characterized in that: The computer storage medium stores computer program instructions, and when the computer program instructions are executed by a processor, they are used to execute the character string display processing method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Glyph management in texture atlases
CA2969778A1
Page generation method and device
CN105512318A
TrueType font rendering method
CN106294291A
Method and device for drawing bullet screens through utilization of canvas
CN107172474A
Graph-text mixed typesetting method and device, computer readable storage medium and terminal
CN108805960A
