CN115729655A - Data rendering method and device, electronic equipment and medium - Google Patents

Data rendering method and device, electronic equipment and medium Download PDF

Info

Publication number
CN115729655A
CN115729655A CN202110999945.9A CN202110999945A CN115729655A CN 115729655 A CN115729655 A CN 115729655A CN 202110999945 A CN202110999945 A CN 202110999945A CN 115729655 A CN115729655 A CN 115729655A
Authority
CN
China
Prior art keywords
page
control
node
tree structure
sub
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110999945.9A
Other languages
Chinese (zh)
Inventor
苟亚明
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110999945.9A priority Critical patent/CN115729655A/en
Publication of CN115729655A publication Critical patent/CN115729655A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application discloses a data rendering method, a data rendering device, electronic equipment and a data rendering medium, which can be applied to various scenes such as cloud technology, AI, intelligent transportation, vehicle-mounted and the like. The method comprises the following steps: the method comprises the steps of obtaining a page display request in an application client, calling a page main thread to obtain page data requested to be displayed by the page display request, calling page sub threads to create object nodes corresponding to each control node in a control tree structure included in the page data, correspondingly establishing a mapping relation between each object node and display attribute information corresponding to each control node on the basis of the page sub threads to obtain an object tree structure, traversing each object node in sequence on the basis of the page sub threads, and rendering and displaying a page control corresponding to each object node according to the display attribute information having the mapping relation with the traversed object node. By adopting the embodiment of the application, the efficiency of rendering the page data is promoted.

Description

Data rendering method and device, electronic equipment and medium
Technical Field
The present application relates to the field of page processing technologies, and in particular, to a data rendering method and apparatus, an electronic device, and a medium.
Background
After the client acquires the page data, the page data needs to be rendered and then can be displayed in the page of the client. At present, a rendering method for page data generally performs rendering in a page main thread, however, the inventor finds in practice that the page main thread is generally required to detect an interactive operation of a user in a client page, and if the page main thread is also required to perform rendering of the page data, this not only hinders the page main thread from performing the interactive operation of the user in the client page, but also causes inefficiency in rendering of the page data.
Disclosure of Invention
The embodiment of the application provides a data rendering method, a data rendering device, electronic equipment and a medium, and the method and the device are beneficial to improving the efficiency of rendering page data.
In one aspect, an embodiment of the present application provides a data rendering method, where the method includes:
if a page display request in an application client is acquired, calling a page main thread to acquire page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
calling page sub-threads to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node on the basis of the page sub thread to obtain an object tree structure;
and traversing each object node in the object tree structure in sequence based on the page sub thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
In one aspect, an embodiment of the present application provides a data rendering apparatus, where the apparatus includes:
the obtaining unit is used for calling a page main thread to obtain page data requested to be displayed by the page display request if the page display request in the application client is obtained; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
the processing unit is used for calling the page sub thread to create an object node corresponding to each control node in the control tree structure and constructing an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
the processing unit is also used for correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node based on the page sub thread to obtain an object tree structure;
and the processing unit is also used for sequentially traversing each object node in the object tree structure based on the page sub thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information having a mapping relation with the traversed object node.
In one aspect, an embodiment of the present application provides an electronic device, where the electronic device includes a processor and a memory, where the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to perform the following steps:
if a page display request in an application client is obtained, calling a page main thread to obtain page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
calling page sub-threads to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node on the basis of the page sub thread to obtain an object tree structure;
and traversing each object node in the object tree structure in sequence based on the page sub thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
In one aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer program instructions are stored, and when the computer program instructions are executed by a processor, the computer program instructions are configured to perform the following steps:
if a page display request in an application client is obtained, calling a page main thread to obtain page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency relations, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
calling page sub-threads to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node on the basis of the page sub thread to obtain an object tree structure;
and traversing each object node in the object tree structure in sequence based on the page sub thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
In one aspect, embodiments of the present application disclose a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer readable storage medium. A processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the data rendering method described above.
According to the method and the device, the page display request in the application client can be obtained, the page data requested to be displayed by the page display request is obtained by calling the page main thread, then the page sub thread is called to create the object node corresponding to each control node in the control tree structure included in the page data, the initial object tree structure identical to the structure frame of the control tree structure is built based on each created object node, then the mapping relation between the display attribute information corresponding to each object node and each control node in the initial object tree structure is correspondingly created based on the page sub thread, the object tree structure is obtained, then each object node in the object tree structure can be traversed sequentially based on the page sub thread, and the page control corresponding to each object node is rendered and displayed on the client page of the application client according to the display attribute information with the mapping relation with the traversed object node. The page data are rendered and displayed by calling the page sub-threads except the page main thread, so that the efficiency of rendering the page data is improved, and in addition, the control tree structure is mapped into the object tree structure, so that the page sub-threads are prevented from being crashed due to the fact that the page sub-threads are directly rendered and displayed on the basis of the page data when the page sub-threads are called, and the stability of rendering the page data on the page sub-threads is ensured.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the description of the embodiments are briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present application, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram illustrating an effect of a data rendering system according to an embodiment of the present application;
fig. 2 is a schematic flowchart of a data rendering method according to an embodiment of the present application;
FIG. 3 is a schematic diagram illustrating an effect of a page provided in an embodiment of the present application;
fig. 4 is a schematic diagram illustrating an effect of a control tree structure according to an embodiment of the present application;
FIG. 5 is a schematic diagram illustrating an effect of an initial object tree structure according to an embodiment of the present application;
fig. 6 is a schematic flowchart of a data rendering method according to an embodiment of the present application;
fig. 7 is a schematic flowchart of a data rendering method according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a data rendering apparatus according to an embodiment of the present application;
fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
The embodiment of the application provides a data rendering scheme, which can be used for calling a sub thread to construct an object tree structure according to a control tree structure with a plurality of control nodes contained in page data after the page data is acquired, and then rendering and displaying the page control drunk by each object node through the object tree structure and display attribute information corresponding to each object node in the object tree structure, so that the data rendering efficiency can be improved.
The technical scheme of the application can be applied to electronic equipment, which may be a terminal, a server, or other equipment for data rendering, and the application is not limited. Optionally, the server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a network service, cloud communication, a middleware service, a domain name service, a security service, a CDN, a big data and artificial intelligence platform, and the like. The terminal may be, but is not limited to, a smart phone, a tablet computer, a laptop computer, a vehicle-mounted terminal, a desktop computer, a smart speaker, a smart watch, and the like. The terminal and the server may be directly or indirectly connected through wired or wireless communication, and the application is not limited herein.
In a possible implementation manner, the embodiment of the present application may be applied to a data rendering system, please refer to fig. 1, and fig. 1 is a schematic effect diagram of the data rendering system provided in the embodiment of the present application. The data rendering system may include an electronic device and a page data source. The electronic equipment can obtain a page display request in an application client, call a page main thread to obtain page data requested to be displayed by the page display request, and further call a page sub thread to process the page data so as to render and display a plurality of page controls in the page data. The page data source may be a data source of page data that can be obtained by the electronic device, for example, the page data source may be a server corresponding to an application client in the electronic device, and may also be a database storing the page data, which is not limited herein. And when the application client acquires the page display request, the application client can acquire the page data requested to be displayed by the page display request from the page data source.
The technical scheme of the application can be applied to the field of block chains, and the block chains are novel application modes of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. The Blockchain (Blockchain), which is essentially a decentralized database, is a string of data blocks associated by using a cryptographic method, each data block contains information of a batch of network transactions for verifying the validity (anti-counterfeiting) of the information and generating a next block, and the Blockchain may include a Blockchain underlying platform, a platform product service layer and an application service layer. For example, an application client in the electronic device may invoke a page main thread to acquire page data from a block chain, and then process the acquired page data.
The technical scheme of the application can be applied to the technical field of cloud storage, cloud storage (cloud storage) is a new concept which is extended and developed on the cloud computing concept, and a distributed cloud storage system (hereinafter referred to as a storage system) refers to a storage system which integrates a large number of storage devices (storage devices are also referred to as storage nodes) of various different types in a network through application software or application interfaces to cooperatively work through functions of cluster application, grid technology, distributed storage file systems and the like and provides data storage and service access functions to the outside. For example, an application client in the electronic device may call a page main thread to acquire page data from the cloud storage device, and then process the acquired page data.
It is to be understood that the foregoing scenarios are only examples, and do not constitute a limitation on application scenarios of the technical solutions provided in the embodiments of the present application, and the technical solutions of the present application may also be applied to other scenarios. For example, as a person having ordinary skill in the art can know, with the evolution of the system architecture and the emergence of new service scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.
Based on the above description, the embodiments of the present application provide a data rendering method. Referring to fig. 2, fig. 2 is a schematic flowchart of a data rendering method according to an embodiment of the present disclosure. The method may be performed by the electronic device described above. The data rendering method may include the following steps.
S201, if the page display request in the application client is obtained, calling a page main thread to obtain page data requested to be displayed by the page display request.
The application client may be any application client having a client page, and the page display request may be a request for instructing to display a specified page in the client page of the application client, which is acquired based on the application client.
Alternatively, the page display request may be generated based on a page display operation of the application client. The page display operation may be a touch operation (such as a click, a long press, a slide, a pinch, and the like) performed based on a control in the application client, or may be a voice instruction for instructing to display a page in a client page of the application client, which is not limited herein. For example, when detecting an operation of clicking a control for instructing to enter a page b based on a page a in the application client, a page display request for acquiring page data corresponding to the page b is generated. For another example, when a voice instruction for instructing to enter a control of a page b is detected based on a page a of the application client, a page display request for acquiring page data corresponding to the page b is generated.
The page main thread may be a thread that is automatically started after the application client is started, and the page main thread is generally used for receiving and responding to an interaction operation between a user and the application client, such as a click operation, a long-time press operation, a slide operation, a pinch operation, and the like. It can be understood that, generally, when the page main thread performs an operation that needs to consume time, interaction between a user and an electronic device is blocked, for example, response time is long, and the like.
The page data may be data for displaying a page acquired based on a page display request. The page data comprises a control tree structure, the control tree structure is formed by control nodes corresponding to N page controls with display dependency relations, the page data further comprises display attribute information corresponding to each control node of the N control nodes, and N is a positive integer.
The page control can be a whole displayed during page display, and pictures, characters, buttons and the like in the page can be regarded as the page control. For example, referring to fig. 3, fig. 3 is a schematic view illustrating an effect of a page provided by an embodiment of the present application, and as shown in 3101, 3102, and 3103 in (1) in fig. 3, each of them can be regarded as a page control whose content is an image, and as shown in 3104 and 3105 in fig. 3, each of them can be a page control whose content is a text, and as shown in 3106 in fig. 3, a region including a plurality of page controls, or can be regarded as a page control including a plurality of sub-page controls. As shown in 3201, 3202, and 3203 in (2) in fig. 3, each of the page controls may be regarded as a page control whose content is an image, as shown in 3204, a page control whose content is text, as shown in 3205 in fig. 3, an area including a plurality of page controls, or as a page control including a plurality of sub-page controls.
It can be understood that the control tree structure included in the page data may be composed of control nodes corresponding to a plurality of page controls, that is, each page control may be abstracted as a control node, one control tree structure may include one control root node, one or more control sub-nodes are provided below the control root node, and optionally, one or more control sub-nodes may also be provided below the control root node. It is understood that the structural framework of the control tree structure is subject to the actual page data. For example, referring to fig. 4, fig. 4 is an effect schematic diagram of a control tree structure provided in this embodiment, where (1) in fig. 4 is a page display effect corresponding to page data, it can be seen that, page controls corresponding to 4102 and 4103 may be included under the page control corresponding to 4101 (that is, parent page controls of the page controls 4102 and 4103 are the page control 4101, and child page controls of the page control 4101 are the page controls 4102 and 4103), page controls corresponding to 4103 may include page controls corresponding to 4104 (that is, a parent page control of the page control 4104 is the page control 4103, and child page controls of the page control 4103 are the page control 4104, so that it can be obtained that corresponding control tree structures included in the page data may be referred to (2) in fig. 4, nodes of the page control 4101 may be root nodes (labeled as node controls) in the control node structure of the control 4101, nodes (labeled as root nodes 4202 and 4203) corresponding to nodes of the page control 4101, and nodes of the page control 4204 may also be referred to nodes of the root node control 4203, and nodes of the node control 4204 may also be referred to nodes of the root node control 4203, and node control 4204.
The page data further includes display attribute information corresponding to each control node in the N control nodes, where the display attribute information may be information for describing an attribute when the page control corresponding to each control node is displayed, and for example, the display attribute information may be information describing a region size, a space, coordinate information, a font, a color, a stroke width, an underline, and the like of the corresponding page control.
Optionally, the page data may be page data constructed based on some front end frameworks, such as page data based on UIKIt framework (a lightweight, modular front end framework), which uses UIView and its subclasses (UIImageView, UIButton, UILabel) to render and display a plurality of page controls contained in the page data. The display attribute information of the page control corresponding to each control node in the page data may be represented by some fields, for example, the font of the page control may be described by a field with an attribute name of NSFontAttributeName, the word space of the page control may be described by a field with an attribute name of NSKernAttributeName, and the like, which are not described herein again.
In a possible implementation manner, the client page includes a plurality of sub-view pages, the number of the control tree structures is multiple, one control tree structure corresponds to one sub-view page, N page controls corresponding to one control tree structure belong to page controls in one sub-view page, and the display dependency relationship among the N page controls includes a display dependency relationship or a parallel display dependency relationship.
The sub-view page may be a view page displayed by one control tree structure correspondingly, that is, the obtained page data may include a plurality of control tree structures, each control tree structure may correspond to one sub-view page in a client page of the application client, and N page controls included in the corresponding control tree structure may be displayed in each sub-view page.
The display dependency relationship between the N page controls in the page data includes an inclusion display dependency relationship or a parallel display dependency relationship. The display dependency relationship may indicate that one page control is a parent page control (or a child page control) of another page control, and if the page control a is a parent page control of the page control B, the display dependency relationship between the page control a and the page control B is the display dependency relationship, or if the page control a is a child page control of the page control B, the display dependency relationship between the page control a and the page control B is the display dependency relationship. The parallel display dependency may indicate that one page control and another page control belong to the same parent page control, and if the page control C and the page control D belong to the same child page control of the page control E, the display dependency between the page control C and the page control D is the parallel display dependency.
S202, calling page sub threads to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node.
The page sub-thread can be a thread created based on a page main thread, and the execution logic of the page sub-thread does not affect the execution logic of the page main thread, so that the page sub-thread is called to process a control tree structure in page data, the influence of the processing logic of the page data on the execution logic of the page main thread can be avoided, the problem that the task of the main thread is too busy and the blocking of the page main thread is reduced is avoided, and particularly when the data in the page data is more and very complex, the page main thread needs to respond to some user operations and further performs a lot of data processing, so that the task of the page main thread is very busy, and further the pause of a low-end machine card (such as a machine model below iPhone7 and equipment smaller than an iOS10 system in the market) is obvious, therefore, the scheme can utilize multithreading to transfer a rendering process to the sub-thread for processing, the data rendering efficiency can be improved, and the pause of electronic equipment can be reduced.
In one possible implementation, the page sub-thread may be opened based on the page main thread before the page sub-thread is invoked. For example, a pagechild thread may be opened by an asynchronous execution task creation method (Dispatch _ async) of Grand Central Dispatch (GCD, a newer solution to multi-core programming). GCD is a concurrent task that is executed on the basis of a thread pool pattern, primarily for optimizing applications to support multi-core processors and other symmetric multiprocessing systems. Optionally, after the page sub thread is opened, the context data of the page sub thread may be obtained and stored, where the context data may be environment data used for indicating the page sub thread, for example, the context data may be used for indicating a current scheduling state of the CPU for the page sub thread, a data state of program operation (such as a data initialization state), and the like, which are not limited herein.
The object node may be obtained by mapping each control node in the control tree structure, that is, each control node in the control tree structure may be mapped as one object node, that is, N control nodes in the control tree structure may be mapped as N object nodes, respectively.
The initial object tree structure has a structural framework of a control tree structure. That is, the object dependency relationship between the object nodes in the initial object tree structure corresponds to the display dependency relationship of the control tree structure.
The object dependency relationships among the N object nodes in the initial object tree structure include inclusion object dependency relationships or parallel object dependency relationships.
If the two control nodes in the control tree structure are in the dependency relationship of the inclusion display, the object dependency relationship between the object nodes corresponding to the two control nodes is the dependency relationship of the inclusion object, that is, the dependency relationship of the inclusion object may indicate that one object node is an object parent node (or an object child node) of another object, and if the object node a is an object parent node of the object node B, the object dependency relationship between the object node a and the object node B is the dependency relationship of the inclusion object, or if the object node a is a child page control of the object node B, the object dependency relationship between the object node a and the object node B is the dependency relationship of the inclusion object.
If the two control nodes in the control tree structure are in a parallel display dependency relationship, the object dependency relationship between the object nodes corresponding to the two control nodes is a parallel object dependency relationship, that is, or, the parallel object dependency relationship may indicate that one object node and another object node belong to the same object parent node, and if the object node C and the object node D belong to the same object child node of the object node E, the object dependency relationship between the object node C and the object node D is a parallel object dependency relationship.
For example, please refer to fig. 5, fig. 5 is a schematic diagram illustrating an effect of an initial object tree structure provided in an embodiment of the present application. Fig. 5 (1) is an effect schematic diagram of a control tree structure, in the control tree structure, a control root node is a control node indicated by 5101, 2 control sub-nodes may be included below the control root node 5101, that is, control nodes indicated by 5102 and 5103, and 1 control sub-node may be included below the control node 5103, that is, a control node indicated by 5104. Correspondingly, an initial object tree structure that can be constructed according to the control tree structure shown in (1) in fig. 5 may be as shown in (2) in fig. 5, a control root node 5101 may correspond to an object root node 5201, and similarly, the control nodes 5102, 5103, and 5104 may respectively correspond to object nodes 5202, 5203, and 5204, and an object dependency relationship between each object node in the initial object tree structure may also correspond to the control tree structure, that is, an object sub-node 5201, 5203 may be included below the object root node 5201, and an object node 5204 may be included below the object node 5203, so as to obtain an initial object tree structure that is the same as the structural frame of the object tree structure.
S203, correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node based on the page sub thread to obtain the object tree structure.
The mapping relationship may be a relationship between the object node and the display attribute information of the control node corresponding to the object node, that is, the display attribute information for the control node may be mapped to the display attribute information for the object node corresponding to the control node. Alternatively, the display attribute information having a mapping relationship with the object node may be referred to as object attribute information.
The object tree structure may be a tree structure in which display attribute information having a mapping relationship with each object node in the initial object tree structure is assigned to each object node.
It will be appreciated that the structural framework of the object tree structure is the same as the structural framework of the initial object tree structure, i.e., the structural framework of the object tree structure is the same as the structural framework of the control tree structure.
In a possible implementation manner, when a mapping relationship between an object node and display attribute information corresponding to a control node is established, display attribute information of the control node corresponding to the object node may be determined, and the display attribute information of the control node is converted to obtain attribute information adapted to the object node in the object tree structure, for example, an attribute name in the display attribute information of the control node may be converted to obtain an attribute name adapted to the object node in the object tree structure, or information of a target field of the object node is determined according to the display attribute information of the control node to obtain attribute information adapted to the object node in the object tree structure, for example, the target field may be a field such as a space (margin), an object child node (subnode), an object parent node (superNode), a region size (size), a node type (type), and the like. Optionally, a node name (NodeID) of each object node may also be determined, for example, a plurality of object nodes in the object tree structure may be encoded according to a certain encoding rule, and the encoding result is used as the NodeID of the object node.
It can be understood that the mapping of the control tree structure to the object tree structure is that when the data form of the front-end frame (such as UIKit frame) based on the page data is subjected to page rendering display in the page sub-thread, the page sub-thread may be crashed, and the acquired page data needs to be converted, so that the page data is rendered and displayed by other advanced drawing engines, and the page sub-thread is prevented from crashing. For example, calling a page child thread renders and displays a plurality of page controls contained in the page data based on the Core Graphics (an advanced drawing engine of Quartz 2D) framework. Core Graphics is commonly developed with Graphics rendering applications to iOS, tvOS, macOS. Core Graphics is a simple encapsulation of the underlying C language, where a large number of low-level, lightweight 2D rendering APIs are provided. And when the mapping relation between the object nodes and the display attribute information corresponding to the control nodes is established, converting the attribute names in the display attribute information of the control nodes to obtain the attribute names of the object nodes in the object tree structure of the Core Graphics framework, or determining the information of the target fields of the object nodes in the object tree structure of the Core Graphics framework according to the display attribute information of the control nodes to obtain the attribute information of the object nodes in the object tree structure of the Core Graphics framework.
It can be understood that the display attribute information in the page data is data constructed based on the UIKit frame, that is, the attribute name provided by the page developer is the attribute name in the UIKit, and then the page developer can still adopt some common front-end frames to construct the page data, and only when processing the page data for rendering and displaying, the tree control structure of the page data can be converted, and the object tree structure corresponding to the Core Graphics frame converted can also be called as a corresponding BaseNodeModel basic data object. When the corresponding object tree structure is generated according to the control tree structure, the object tree structure can be the same as a structural frame of the control tree structure, so that data of the UIkit frame can be better reused when the object tree structure based on the CoreGraphic frame is constructed, the data mapping cost is reduced, and the rendering efficiency is improved.
For example, as shown in table 1, table 1 may represent an attribute name of the Core Graphics frame converted from an attribute name of the UIkit frame. The first column in table 1 may represent an attribute name based on the UIKit frame, the second column in table 1 may represent a Core Graphics attribute name corresponding to the attribute name of the UIKit frame, the third column in table 1 may represent a description for each attribute, such as the attribute name of the attribute for describing font under the UIKit frame is NSFontAttributeName, the attribute name of the attribute under the Core Graphics frame is kctfontatttributename, and the like, the attribute name of the attribute for describing word space under the UIKit frame is NSKernAttributeName, the attribute name of the attribute under the Core Graphics frame is kctkkernattributename, and the like, which are not limited herein.
TABLE 1
Figure BDA0003233829740000121
It is to be understood that the attribute names in table 1 are only used as examples here, and in some scenarios, a conversion for other attribute names may also be included, and are not limited here.
And moreover, some fields of the corresponding object nodes can be obtained through conversion according to the display attribute information corresponding to the control nodes in the UIKit framework. For example, referring to table 2, table 2 may be field names converted according to display attribute information of the UIkit frame. The first column in table 2 may represent field names of target fields converted according to display attribute information of the UIkit frame, and the second column may represent a description for each field. For example, referring to the row in which serial number 1 of table 2 is located, a field NodeID for indicating a node name (ID) of an object node may be determined according to a control node in the UIkit frame; referring to the row of sequence number 2 in table 2, a field margin for indicating the distance between the object node and another object node may be extracted, and the field may take values corresponding to the upper distance, the left distance, the lower distance, and the right distance, respectively; referring to row number 3 of table 2, a field marginNode for indicating the distance of an object node with reference to another object node may be extracted, and values of the field may be left. Referring to the row where the sequence number 4 in table 2 is located, a field subNodes for indicating an object sub-node of an object node may be extracted, that is, a value of the field may be a node name of the object sub-node, and if there is an object node without an object sub-node, a value of the subNodes field of the object node may be NULL (NULL); referring to the row of sequence number 5 in table 2, a field superNode for indicating an object parent node of an object node may be extracted, that is, a value of the field may be a node name of the object parent node, and if the object root node does not have the object parent node, a value of the superNode field of the object root node may be NULL (NULL); referring to the row of the serial number 6 in table 2, a field size for indicating the size of the region corresponding to the object node may be extracted, and the value of the field may be a value corresponding to each of the width and the height; referring to the row of the serial number 7 in table 2, a field type for indicating the node type of the object node may be extracted, and the field may take a value of 0 or 1, and is respectively used for indicating that the object node is an image node or a text node.
TABLE 2
Figure BDA0003233829740000131
It is to be understood that the field names in table 2 are only used as examples here, and in some scenarios, conversion for other field names may also be included, and are not limited here.
And S204, sequentially traversing each object node in the object tree structure based on the page sub-thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
The traversing of each object node in the object tree structure may be sequentially traversing the object sub-nodes of each object node in the object tree structure from the object root node until the object node has no object sub-node, and optionally, the object node having no object sub-node may also be referred to as a leaf object node. For example, please refer to the object tree structure shown in (2) in fig. 5, sequentially traversing each object node in the object tree structure may be to traverse to the object root node 5201 first, and then traverse to the object sub-nodes 5202 and 5203 of the object root node, where since the object node 5202 has no object sub-node, and the object node 5203 has an object sub-node 5204, the object node 5204 may be traversed to the object node 5204, and since the object node 5204 has no object sub-node, the traversal for each object node of the object tree structure is ended. Moreover, when each object node is traversed, display attribute information (i.e., object attribute information) having a mapping relationship with the traversed object node needs to be acquired, and then the page control corresponding to the object node is rendered and displayed.
In a possible implementation manner, rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information having the mapping relationship with the traversed object node may specifically include the following steps: determining the page position of the page control corresponding to each object node according to the display attribute information which has a mapping relation with the traversed object nodes; respectively acquiring the control content of the page control corresponding to each object node according to the display attribute information which has a mapping relation with each object node; and rendering and displaying the page control corresponding to each object node in the application client according to the page position, the control content and the display attribute information of the page control corresponding to each object node.
The page position of the page control can be determined according to the attribute information which is used for indicating the page position of the page control in the display attribute information. For example, the attribute information indicating the page position of the page control may include attribute information indicating a region size (size) of the page control, may also include attribute information indicating coordinate information of the page control, and the like, which are not limited herein.
In one embodiment, the N object nodes in the object tree structure include an object root node and an object child node, the object child node having an object parent node among the N object nodes; then, determining the page position of the page control corresponding to each object node according to the display attribute information having the mapping relationship with the traversed object node may specifically include the following steps: if the object root node in the object tree structure is traversed, determining the page position of the page control corresponding to the object root node according to the display attribute information which has a mapping relation with the object root node; and if the object child nodes in the object tree structure are traversed, acquiring object parent nodes of the traversed object child nodes, and determining the page positions of the page controls corresponding to the traversed object child nodes according to the display attribute information which has a mapping relation with the traversed object child nodes and the display attribute information which has a mapping relation with the object parent nodes of the traversed object child nodes.
The page position of the corresponding page control is determined according to the object root node, the size of the area when the page control corresponding to the object root node is displayed can be determined according to the attribute information used for indicating the size (size) of the area of the page control, and the relative position relationship between the object root node and the object root nodes of other object tree structures is determined according to the attribute information used for indicating the space and the space reference control of the page control. For example, the page position of the page control corresponding to the object root node may be determined according to the attribute information describing the size of the space between the upper, lower, left, and right page controls of the page control corresponding to the object root node when the client page is displayed.
Determining the page position of the page control corresponding to the traversed object child node according to the display attribute information having a mapping relationship with the traversed object child node and the display attribute information having a mapping relationship with the object parent node of the traversed object child node, determining the page position of the page control corresponding to the traversed object child node for the object attribute information based on the object parent node, and determining the coordinate origin based on the page position of the object parent node, for example, establishing the coordinate origin with the top left vertex of the object parent node, further determining the position of the object child node according to the attribute information of the coordinate information for indicating the object child node to refer to the coordinate origin of the object parent node in the object attribute information of the object child node, and determining the area size of the object child node according to the attribute information for indicating the area size of the object node in the object attribute information of the object child node, thereby determining the page position of the object child node. By analogy, the page position of each object node in the object tree structure can be determined.
The control content of the page control can be content displayed when the page control is displayed, and can be determined according to attribute information which is used for indicating the control content of the page control in the display attribute information. For example, the content of the control may be text information, and the display attribute information of the page control may include attribute information for indicating the text information of the page control; for another example, the control content may be image information, and the display attribute information of the page control may include an image address or an image name indicating the image information of the page control.
In one possible implementation, any one of the N object nodes of the object tree structure is represented as the ith object node, and i is a positive integer less than or equal to N. Then, respectively obtaining the control content of the page control corresponding to each object node according to the display attribute information having the mapping relationship with each object node, which may specifically include the following steps: if the control content of the page control corresponding to the ith object node belongs to the local control content, acquiring a local content identifier from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a local database according to the local content identifier; if the control content corresponding to the page control corresponding to the ith object node belongs to the cloud control content, acquiring a cloud content address from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a cloud database according to the cloud content address.
The local control content may be control content stored in the electronic device where the application client is located. The local control content may be stored in a local database. The local content identifier may be an identifier corresponding to the local control content when the local control content is stored in the local database, such as a local content name (i.e., a name corresponding to the local control content when the local control content is stored in the local database, or a local content address (i.e., an address corresponding to the local control content when the local control content is stored in the local database).
The cloud control content may be control content stored in a server (e.g., a cloud server, a physical server, a distributed system) different from the electronic device in which the application client is located. The cloud control content may be stored in a cloud database. The cloud content address can be an address corresponding to the cloud control content when the cloud control content is stored in the cloud database.
That is, if the control content corresponding to the page control belongs to the local control content, the local content identifier (such as the local content name or the local content address) of the local control content may be determined according to the attribute information indicating the local content identifier of the local control content in the display attribute information, and the local control content may be obtained from the local database storing the local control content according to the local content identifier. If the control content corresponding to the page control belongs to the cloud control content, determining the cloud content address of the cloud control content according to the attribute information of the cloud content address used for indicating the cloud control content in the display attribute information, and acquiring the cloud control content from a cloud database storing the cloud control content according to the cloud content address.
Optionally, if the control content corresponding to the page control belongs to the cloud control content, the local site content may be loaded first, and the node name of the object node corresponding to the page control loaded with the local site content is recorded, then the object node corresponding to the node name may correspond to a download operation, the cloud control content of the page control is obtained from a cloud database according to the cloud control content address corresponding to the page control, after the cloud control content is obtained, the local site content corresponding to the page control may be replaced with the cloud control content, and then the page control is rendered and displayed through the page position, the cloud control content and the display attribute information. Therefore, the problem that the tree structure of the control where the page control is located is rendered and displayed slowly due to the fact that the content of the cloud control is downloaded from the cloud database slowly can be avoided.
According to the page position, the control content and the display attribute information of the page control corresponding to each object node, rendering display is carried out on the page control corresponding to each object node in the application client, the corresponding control content can be imported into the page position of the page control, the display effect of the control content is adjusted according to the display attribute information, and then rendering display of the page control is achieved.
In a possible implementation manner, when rendering and displaying the page controls corresponding to the N object nodes in the object tree structure, the corresponding N page controls may be drawn according to the page positions and the control contents of the page controls corresponding to the N object nodes, and then the N object nodes are rendered and displayed as a whole (i.e., the object tree structure). The rendering of the page control may be to render a basic graphic element of the page control, for example, determine a page position corresponding to the page control, and import control content corresponding to the page control at the corresponding page position. Rendering and displaying the N object nodes as a whole (i.e., the object tree structure) may render and display the page controls corresponding to the N object nodes according to the content drawn by each page control, so that each page control can have the display effect (such as a background color, a stroke width, a stroke color, and the like) of the page control indicated by the display attribute information. Optionally, in some scenarios, the rendering and rendering of the page control may be performed simultaneously, or collectively referred to as rendering and displaying the page control, which is not limited herein.
Optionally, when the page control corresponding to the object node is obtained for drawing, the node type of the object node may be determined according to attribute information used for indicating the node type (type) of the object node in the object attribute information of the object node, and then different drawing manners may be adopted according to different node types. For example, if the object node is a text node, the text content corresponding to the object node may be determined according to the attribute information of the text content indicating the object node in the object attribute information of the object node, and the text content may be imported into the page position of the object node for drawing. If the image content is the local image content, the local image content may be obtained according to the above manner of obtaining the local control content, and the local image content is imported to the page position of the image node, and if the image content is the cloud image content, the local station content (i.e., the local station image) may be loaded first, the cloud image content may be obtained according to the above manner of obtaining the cloud control content, and the local station image may be replaced by the cloud image content. Other drawing manners may also be adopted for different node types, and are not limited herein.
Optionally, when the N object nodes are rendered and displayed as a whole (that is, the object tree structure), the size of the area of the object root node may be determined according to attribute information used for indicating the size of the display area in the display attribute information of the object root node of the object tree structure, so that the size (such as the width or the height) of the area corresponding to the object tree structure may be obtained, and the distance between the object tree structure and another object tree structure may also be determined according to attribute information used for indicating the distance between the tree control structure corresponding to another object tree structure in the display attribute information of the object root node of the object tree structure, so that the final size of the area corresponding to the object tree structure is determined according to the size and the distance of the area corresponding to the object tree structure, for example, the final height of the object tree structure is obtained by adding the height and the distance in the size of the area. And then, the page controls corresponding to the N object nodes in the object tree structure can be rendered and displayed according to the final area size of the object tree structure.
It can be understood that, when the N page controls corresponding to the object tree structure are displayed in the client page of the application client, the page controls corresponding to the object tree structure may be displayed in the corresponding sub-view page.
In a possible implementation manner, the page data may include a plurality of control tree structures, the plurality of control tree structures of the page data may be processed based on one page sub-thread, or one page sub-thread may be constructed based on each control tree structure, and the corresponding control tree structures are processed based on each page sub-thread, and each page sub-thread may be sequentially invoked according to a certain sequence, or each page sub-thread may be invoked simultaneously, which is not limited herein.
Optionally, the number of the page sub-threads may be multiple, and one sub-view page may correspond to one page sub-thread, and then the embodiment of the present application may further include the following steps: acquiring a view display sequence of a plurality of sub-view pages in a client page; and constructing a thread queue of a plurality of page sub threads according to the view display sequence of the plurality of sub view pages. Then, each object node in the object tree structure is sequentially traversed based on the page sub-thread, and the corresponding object node in the object tree structure may be traversed for sequentially calling the page sub-thread in the thread queue. For specific relevant description, reference may be made to the relevant description of the embodiment shown in fig. 6, which is not described herein again.
In a possible implementation manner, after a client page of an application client renders and displays a page control corresponding to each object node, a page main thread may be called to receive a trigger operation based on the page control corresponding to the object node in the client page. The trigger operation may be of multiple trigger types, such as clicking, long-pressing, sliding, and kneading, and the trigger operation of each trigger type may be used to trigger a corresponding service event, such as clicking a certain page control to obtain new page data for display, long-pressing a certain page control to display a corresponding operation option, sliding a certain page control to display different content, and the like, which is not limited herein.
Optionally, the trigger operation based on the page control corresponding to the object node in the client page is received, and may be to receive a touch operation (such as a touch operation of clicking, long-pressing, sliding, kneading, and the like) for the client page, detect coordinate information (which may be referred to as Point coordinates) corresponding to the touch operation, calculate an object node corresponding to the coordinate information of the touch operation, determine the corresponding page control according to the object node corresponding to the coordinate information, and determine that the trigger operation based on the page control is received.
In a possible implementation manner, the N object nodes of the object tree structure include a jth object node and a kth object node, j and k are positive integers less than or equal to N, page controls corresponding to the jth object node and the kth object node both have at least one control trigger operation, and the kth object node is an object parent node of the jth object node. When detecting the trigger operation of the page control corresponding to the object node in the client page based on the page main thread, the following steps may be specifically executed: if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, and the triggering operation of at least one control corresponding to the jth object node comprises the triggering operation, executing a business event triggered by the triggering operation on the page control corresponding to the jth object node in the client page; and if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, the triggering operation of at least one control corresponding to the jth object node does not comprise the triggering operation, and the triggering operation of at least one control corresponding to the kth object node comprises the triggering operation, executing the business event triggered by the triggering operation on the page control corresponding to the kth object node in the client page. The control triggering operation may be a triggering operation that is corresponding to the page control and can trigger a corresponding service event, for example, the control triggering operation of the page control may be a triggering operation that triggers a corresponding service event through a click operation.
That is to say, after receiving the trigger operation for the page control corresponding to the object node, the control trigger operation that is possessed by the object node may be detected, and if the control trigger operation that is possessed by the object node includes the trigger operation, the business event that is triggered by the trigger operation may be executed for the page control corresponding to the object node.
After receiving the trigger operation of the page control for the object node, the trigger operation of the control for the object node may be detected, if the trigger operation of the control for the object node does not include the trigger operation, the object parent node for the object node may be determined, and the trigger operation of the control for the object parent node may be further detected, and if the trigger operation of the control for the object parent node includes the trigger operation, the service event triggered by the trigger operation may be executed on the page control corresponding to the object parent node (i.e., the parent page control of the page control corresponding to the object node).
For example, as shown in (1) in fig. 4, if the triggering operation of the page control 4104 corresponding to the object node that is detected to be clicked by the client side page is based on the triggering operation of the page control 4104, it is detected whether the page control shown by 4104 has a clicked control triggering operation, and if yes, a business event corresponding to the triggering operation of the page control 4104 is executed; if not, determining a parent page control (namely the page control 4103) of the page control shown by 4104, detecting whether the page control shown by 4103 has a clicked control triggering operation, if so, executing a business event corresponding to the triggering operation of the page control shown by 4103, if not, acquiring the parent page control of the page control 4103, and so on, if the triggering operation of the control contained in the page control corresponding to the object root node does not have the triggering operation until the object root node in the object tree structure corresponding to the clicked object node is acquired, indicating that the triggering operation triggering business event fails. Therefore, the triggerable range of the trigger operation on the business event can be enlarged, and the situation that the response cannot be obtained due to the fact that the trigger operation is not accurately executed on the corresponding page control is reduced.
According to the method and the device, the page display request in the application client can be acquired, the page data requested to be displayed by the page display request is acquired by calling the page main thread, the page sub thread is called to create the object node corresponding to each control node in the control tree structure included in the page data, the initial object tree structure identical to the structure frame of the control tree structure is constructed based on each created object node, the mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node is correspondingly established based on the page sub thread, the object tree structure is obtained, then each object node in the object tree structure can be sequentially traversed based on the page sub thread, and the page control corresponding to each object node is rendered and displayed on the client page of the application client according to the display attribute information with the mapping relation with the traversed object node. The page data are rendered and displayed by calling the page sub-threads except the page main thread, so that the efficiency of rendering the page data is improved, and in addition, the control tree structure is mapped into the object tree structure, so that the page sub-threads are prevented from being crashed due to the fact that the page sub-threads are directly rendered and displayed on the basis of the page data when the page sub-threads are called, and the stability of rendering the page data on the page sub-threads is ensured.
Referring to fig. 6, fig. 6 is a schematic flowchart of a data rendering method according to an embodiment of the present disclosure, where the method is executable by the electronic device. The method may include the following steps.
S601, if the page display request in the application client is obtained, calling a page main thread to obtain the page data requested to be displayed by the page display request.
For the description of step S601, reference may be made to step S201, which is not described herein again.
S602, obtaining the view display sequence of a plurality of sub-view pages in the client page.
The view display sequence may be a display sequence corresponding to each sub-view page in the client page. When the control tree structures corresponding to the sub-view pages are processed and rendered for display, the rendering and display sequence is performed for each control tree structure.
In one possible implementation, the view display order may be determined according to the position of the sub-view pages in the client page. For example, the view display order may be that a plurality of sub-view pages in the client page are displayed in sequence from top to bottom.
The view display sequence can also be determined according to the node type of each object node in the object tree structure corresponding to the sub-view page. For example, the view display sequence may be that a sub-view page not including an image node in the corresponding object tree structure is displayed first, a sub-view page not including a video node in the corresponding object tree structure is displayed, and then a sub-view page including a video node in the corresponding object tree structure is displayed.
It is understood that the view display order may also be determined in other ways, and is not limited herein.
S603, constructing a thread queue of a plurality of page sub threads according to the view display sequence of the plurality of sub view pages.
The thread queue may be a queue including page sub-threads constructed for each sub-view page, and the thread queue may have an order of invocation of each page sub-thread therein. That is to say, for each control tree structure in the page data, a corresponding child thread may be constructed for processing the corresponding control tree structure and performing rendering display. And then sequentially calling the page sub threads to process the corresponding control tree structure according to the sequence of each page sub thread in the thread queue.
S604, sequentially calling page sub-threads in the thread queue to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node.
S605, sequentially calling page sub threads in the thread queue to correspondingly establish a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node to obtain the object tree structure.
And S606, sequentially calling page sub-threads in the thread queue to traverse the object nodes in the corresponding object tree structures, and rendering and displaying the page control corresponding to each object node on the client page of the application client according to the display attribute information which has a mapping relation with the traversed object nodes.
The steps S604 to S606 can refer to the related descriptions of the steps S202 to S204, that is, the steps S202 to S204 can be executed for each page sub-thread. Therefore, multiple sub threads can be called to process and render and display multiple control tree structures in the page data, and the efficiency of processing the page data is improved. And the view display sequence can be used for determining the sequence in which the corresponding content of each sub-view page is displayed when the page data is rendered and displayed, so as to avoid that a large amount of data is processed at the same time, which causes the processor load of the electronic equipment to be overhigh.
For example, in one possible scenario, application of the present solution is described herein as applying the present solution to rendering of information stream (feed stream) data. Referring to fig. 7, fig. 7 is a schematic flowchart of a data rendering method according to an embodiment of the present disclosure. The electronic device may call a page main thread to obtain information page data (i.e., S701), open a page sub-thread (i.e., S702), open a sub-thread through dispatch _ async of the GCD, further call a page sub-thread to obtain and analyze information stream page data (i.e., S703), construct an object tree structure according to a control tree structure in the information stream page data (i.e., S704), then obtain and store a context in the page sub-thread, and call a page sub-thread to draw an object node in the object tree structure corresponding to the information stream page data (i.e., S705), for example, call uigraphics getcurrentcontext (a function for obtaining a context) to obtain a current context, and call cgcontextsavstate (a function for storing a context) to store a context. When the object node is drawn, the node type of the object node may be determined first (i.e., S706), if the object node is an image node, it may be determined whether the control content of the page control corresponding to the image node is local image content (i.e., S707), if the control content is local image content, the corresponding local image content may be obtained directly according to the local image name of the local image content, and the page position corresponding to the page control is imported to display the image (i.e., S708), e.g., the name (imagename) of the local image content is obtained by a static method of a user interface image class (UIImage class), a uiim object is created, and then drawtpoint (a function of a user drawn object node) is called, and the coordinate information imported to the object node may be drawn. If the node is not the local image content, the local station image can be loaded, the node name is recorded, the image is downloaded according to the content address (namely S709) to display the image, for example, the local station image is loaded first, a system method of expanding a user interface image (UIImage) is adopted, the capability of a station control (palceHolder) is increased, the current node name (NodeID) is recorded, downloading is carried out through the image address (such as a cloud end image address), an object node corresponding to each NodeID can correspond to one downloading operation, and the local station image is replaced after the downloading is finished, so that the drawing can be finished. If the node type is a text node, the text content may be determined according to the object attribute information of the text node, and the text content is imported (i.e., S710), and the page control corresponding to the text node may be rendered to display the text (i.e., S711), for example, the text is obtained first, then an nsmustaparagraphistyle (attribute field of the text used to represent the node object) object is created, the nsmustaparagraphistyle object is an attribute field representing the text, the value of the attribute field is analyzed, and finally, the rendering is performed by a drawInRect (a method for a user to render an object node). By analogy, the drawing of the page controls in the information flow page data can be completed, and then the rendering display can be performed on the multiple page controls corresponding to the object tree structure (i.e., S712), so that the service event can be triggered according to the triggering operation in the following (i.e., S713), for example, after the user generates the click, long press, and sliding behaviors, the service event is captured by rewriting touchend (a method for capturing the service event), the object node corresponding to the touch operation is calculated for the transmitted point coordinate, and the triggering service event is determined according to the object node support type and the corresponding object parent node.
The method and the device for rendering the page control in the application client side can acquire a page display request in the application client side, call a page main thread to acquire page data requested to be displayed by the page display request, acquire a view display sequence of a plurality of sub-view pages in a client side page, construct a thread queue of a plurality of page sub-threads according to the view display sequence of the plurality of sub-view pages, further call page sub-threads in the thread queue in sequence to create object nodes corresponding to each control node in a control tree structure, construct an initial object tree structure identical to a structural frame of the control tree structure based on each created object node, call page sub-threads in the thread queue in sequence to create a mapping relation between display attribute information of each object node in the initial object tree structure and each control node in the initial object tree structure in sequence to obtain the object tree structure, then call page sub-threads in the thread queue in sequence to traverse each object node in the object tree structure, and render and display the page control corresponding to each object node in the application client side page in the application client side. The page data are rendered and displayed by calling the page sub-threads except the page main thread, so that the efficiency of rendering the page data is improved, and in addition, the control tree structure is mapped into the object tree structure, so that the page sub-threads are prevented from being crashed due to the fact that the page sub-threads are directly rendered and displayed on the basis of the page data when the page sub-threads are called, and the stability of rendering the page data on the page sub-threads is ensured.
Referring to fig. 8, fig. 8 is a schematic structural diagram of a data rendering apparatus according to an embodiment of the present disclosure. Alternatively, the apparatus may be provided in the electronic device. As shown in fig. 8, the data rendering apparatus described in the present embodiment may include:
an obtaining unit 801, configured to, if a page display request in an application client is obtained, invoke a page main thread to obtain page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
a processing unit 802, configured to invoke a page child thread to create an object node corresponding to each control node in the control tree structure, and construct an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
the processing unit 802 is further configured to correspondingly establish a mapping relationship between each object node in the initial object tree structure and the display attribute information corresponding to each control node based on the page sub thread, so as to obtain an object tree structure;
the processing unit 802 is further configured to sequentially traverse each object node in the object tree structure based on the page sub thread, and render and display the page control corresponding to each object node on a client page of the application client according to the display attribute information having a mapping relationship with the traversed object node.
In one embodiment, the processing unit 802 is specifically configured to:
determining the page position of the page control corresponding to each object node according to the display attribute information which has a mapping relation with the traversed object nodes;
respectively acquiring the control content of the page control corresponding to each object node according to the display attribute information which has a mapping relation with each object node;
and rendering and displaying the page control corresponding to each object node in the application client according to the page position, the control content and the display attribute information of the page control corresponding to each object node.
In one embodiment, the N object nodes in the object tree structure include an object root node and an object child node, the object child node having an object parent node among the N object nodes;
the processing unit 802 is specifically configured to:
if the object root node in the object tree structure is traversed, determining the page position of the page control corresponding to the object root node according to the display attribute information which has a mapping relation with the object root node;
and if the object child nodes in the object tree structure are traversed, acquiring object parent nodes of the traversed object child nodes, and determining the page positions of the page controls corresponding to the traversed object child nodes according to the display attribute information which has a mapping relation with the traversed object child nodes and the display attribute information which has a mapping relation with the object parent nodes of the traversed object child nodes.
In one embodiment, any one of N object nodes of the object tree structure is represented as the ith object node, where i is a positive integer less than or equal to N;
the processing unit 802 is specifically configured to:
if the control content of the page control corresponding to the ith object node belongs to the local control content, acquiring a local content identifier from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a local database according to the local content identifier;
if the control content corresponding to the page control corresponding to the ith object node belongs to the cloud control content, acquiring a cloud content address from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a cloud database according to the cloud content address.
In one implementation, a client page includes multiple sub-view pages, the number of control tree structures is multiple, one control tree structure corresponds to one sub-view page, N page controls corresponding to one control tree structure belong to page controls in one sub-view page, and display dependencies among the N page controls include display dependencies or parallel display dependencies.
In an embodiment, the number of page sub-threads is multiple, and one sub-view page corresponds to one page sub-thread, and the processing unit 802 is further configured to:
acquiring a view display sequence of a plurality of sub-view pages in a client page;
constructing a thread queue of a plurality of page sub threads according to the view display sequence of a plurality of sub view pages;
sequentially traversing each object node in the object tree structure based on the page child thread, comprising:
and sequentially calling page sub threads in the thread queue to traverse the object nodes in the corresponding object tree structure.
In one embodiment, the N object nodes of the object tree structure include a jth object node and a kth object node, j and k are positive integers less than or equal to N, page controls corresponding to the jth object node and the kth object node both have at least one control trigger operation, and the kth object node is an object parent node of the jth object node;
the processing unit 802 is further configured to:
if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, and the triggering operation of at least one control corresponding to the jth object node comprises the triggering operation, executing a business event triggered by the triggering operation on the page control corresponding to the jth object node in the client page;
and if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, the triggering operation of at least one control corresponding to the jth object node does not comprise the triggering operation, and the triggering operation of at least one control corresponding to the kth object node comprises the triggering operation, executing the business event triggered by the triggering operation on the page control corresponding to the kth object node in the client page.
According to the method and the device, the page display request in the application client can be acquired, the page data requested to be displayed by the page display request is acquired by calling the page main thread, the page sub thread is called to create the object node corresponding to each control node in the control tree structure included in the page data, the initial object tree structure identical to the structure frame of the control tree structure is constructed based on each created object node, the mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node is correspondingly established based on the page sub thread, the object tree structure is obtained, then each object node in the object tree structure can be sequentially traversed based on the page sub thread, and the page control corresponding to each object node is rendered and displayed on the client page of the application client according to the display attribute information with the mapping relation with the traversed object node. The page data are rendered and displayed by calling the page sub-threads except the page main thread, so that the efficiency of rendering the page data is improved, and in addition, the control tree structure is mapped into the object tree structure, so that the page sub-threads are prevented from being crashed due to the fact that the page sub-threads are directly rendered and displayed on the basis of the page data when the page sub-threads are called, and the stability of rendering the page data on the page sub-threads is ensured.
Referring to fig. 9, fig. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. The electronic device described in this embodiment includes: a processor 901, a memory 902. Optionally, the electronic device may further include a network interface 903 or a power supply module. Data may be exchanged between the processor 901, the memory 902, and the network interface 903.
The Processor 901 may be a Central Processing Unit (CPU), and may also be other general-purpose processors, digital Signal Processors (DSPs), application Specific Integrated Circuits (ASICs), field-Programmable Gate arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components, and the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The network interface 903 may include an input device such as a control panel, a microphone, a receiver, etc., and/or an output device such as a display screen, a transmitter, etc., to name but a few. For example, in an application embodiment, the network interface may include a receiver and a transmitter.
The memory 902 may include a read-only memory and a random access memory, and provides program instructions and data to the processor 901. A portion of the memory 902 may also include non-volatile random access memory. When the processor 901 calls the program instruction, it is configured to:
if a page display request in an application client is acquired, calling a page main thread to acquire page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
calling page sub threads to create object nodes corresponding to each control node in the control tree structure, and constructing an initial object tree structure based on each created object node; the initial object tree structure is provided with a structure frame of a control tree structure;
correspondingly establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node on the basis of the page sub thread to obtain an object tree structure;
and traversing each object node in the object tree structure in sequence based on the page sub thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
In one embodiment, the processor 901 is specifically configured to:
determining the page position of the page control corresponding to each object node according to the display attribute information which has a mapping relation with the traversed object nodes;
respectively acquiring the control content of the page control corresponding to each object node according to the display attribute information which has a mapping relation with each object node;
and rendering and displaying the page control corresponding to each object node in the application client according to the page position, the control content and the display attribute information of the page control corresponding to each object node.
In one embodiment, the N object nodes in the object tree structure include an object root node and an object child node, the object child node having an object parent node among the N object nodes;
the processor 901 is specifically configured to:
if the object root node in the object tree structure is traversed, determining the page position of the page control corresponding to the object root node according to the display attribute information which has a mapping relation with the object root node;
and if the object child nodes in the object tree structure are traversed, acquiring the object parent nodes of the traversed object child nodes, and determining the page positions of the page controls corresponding to the traversed object child nodes according to the display attribute information which has a mapping relation with the traversed object child nodes and the display attribute information which has a mapping relation with the object parent nodes of the traversed object child nodes.
In one embodiment, any one of the N object nodes of the object tree structure is represented as the ith object node, and i is a positive integer less than or equal to N;
the processor 901 is specifically configured to:
if the control content of the page control corresponding to the ith object node belongs to the local control content, acquiring a local content identifier from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a local database according to the local content identifier;
if the control content corresponding to the page control corresponding to the ith object node belongs to the cloud control content, acquiring a cloud content address from the display attribute information which has a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a cloud database according to the cloud content address.
In one implementation, a client page includes multiple sub-view pages, the number of control tree structures is multiple, one control tree structure corresponds to one sub-view page, N page controls corresponding to one control tree structure belong to page controls in one sub-view page, and display dependencies among the N page controls include display dependencies or parallel display dependencies.
In one embodiment, the number of page sub-threads is multiple, and one sub-view page corresponds to one page sub-thread, and the processor 901 is further configured to:
acquiring a view display sequence of a plurality of sub-view pages in a client page;
constructing a thread queue of a plurality of page sub threads according to the view display sequence of the plurality of sub view pages;
sequentially traversing each object node in the object tree structure based on the page child thread, comprising:
and sequentially calling page sub threads in the thread queue to traverse the object nodes in the corresponding object tree structure.
In one embodiment, the N object nodes of the object tree structure include a jth object node and a kth object node, j and k are positive integers less than or equal to N, page controls corresponding to the jth object node and the kth object node both have at least one control trigger operation, and the kth object node is an object parent node of the jth object node;
the processor 901 is further configured to:
if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, and the triggering operation of at least one control corresponding to the jth object node comprises the triggering operation, executing a business event triggered by the triggering operation on the page control corresponding to the jth object node in the client page;
and if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, the triggering operation of at least one control corresponding to the jth object node does not comprise the triggering operation, and the triggering operation of at least one control corresponding to the kth object node comprises the triggering operation, executing the business event triggered by the triggering operation on the page control corresponding to the kth object node in the client page.
Optionally, when executed by the processor, the program instructions may also implement other steps of the method in the foregoing embodiments, which are not described herein again.
The present application further provides a computer-readable storage medium, in which a computer program is stored, where the computer program includes program instructions, and the program instructions, when executed by a processor, cause the processor to execute the above method, such as executing the method executed by the electronic device, which is not described herein in detail.
Optionally, the storage medium, such as a computer-readable storage medium, referred to herein may be non-volatile or volatile.
Alternatively, the computer-readable storage medium may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to the use of the blockchain node, and the like. The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm. A block chain (Blockchain), which is essentially a decentralized database, is a series of data blocks associated by using a cryptographic method, and each data block contains information of a batch of network transactions, so as to verify the validity (anti-counterfeiting) of the information and generate a next block. The blockchain may include a blockchain underlying platform, a platform product service layer, an application service layer, and the like.
It should be noted that, for simplicity of description, the above-mentioned embodiments of the method are described as a series of acts, but those skilled in the art should understand that the present application is not limited by the described order of acts, as some steps may be performed in other orders or simultaneously according to the present application. Further, those skilled in the art should also appreciate that the embodiments described in the specification are preferred embodiments and that the acts and modules referred to are not necessarily required in this application.
Those skilled in the art will appreciate that all or part of the steps in the methods of the above embodiments may be implemented by associated hardware instructed by a program, which may be stored in a computer-readable storage medium, and the storage medium may include: flash disks, read-Only memories (ROMs), random Access Memories (RAMs), magnetic or optical disks, and the like.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. The computer instructions are read by a processor of the computer device from a computer-readable storage medium, and the computer instructions are executed by the processor to cause the computer device to perform the steps performed in the embodiments of the methods described above. For example, the computer device may be a terminal, or may be a server.
The data rendering method, the data rendering device, the electronic device, and the storage medium provided in the embodiments of the present application are described in detail above, and a specific example is applied in the description to explain the principles and the embodiments of the present application, and the description of the embodiments is only used to help understand the method and the core ideas of the present application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (10)

1. A method of data rendering, the method comprising:
if a page display request in an application client is acquired, calling a page main thread to acquire page data requested to be displayed by the page display request; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
calling page sub threads to create object nodes corresponding to each control node in the control tree structure respectively, and constructing an initial object tree structure based on each created object node; the initial object tree structure has a structural framework of the control tree structure;
establishing a mapping relation between each object node in the initial object tree structure and the display attribute information corresponding to each control node respectively on the basis of the page sub thread to obtain an object tree structure;
and traversing each object node in the object tree structure in sequence based on the page sub-thread, and rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information which has a mapping relation with the traversed object node.
2. The method according to claim 1, wherein rendering and displaying the page control corresponding to each object node on a client page of the application client according to the display attribute information having a mapping relationship with the traversed object node comprises:
determining the page position of the page control corresponding to each object node according to the display attribute information having the mapping relation with the traversed object nodes;
respectively acquiring the control content of the page control corresponding to each object node according to the display attribute information which has a mapping relation with each object node;
and rendering and displaying the page control corresponding to each object node in the application client according to the page position, the control content and the display attribute information of the page control corresponding to each object node.
3. The method of claim 2, wherein the N object nodes in the object tree structure include an object root node and an object child node having an object parent node among the N object nodes;
the determining the page position of the page control corresponding to each object node according to the display attribute information having the mapping relationship with the traversed object node includes:
if the object tree structure is traversed to the object root node, determining the page position of the page control corresponding to the object root node according to the display attribute information which has a mapping relation with the object root node;
and if the object child nodes in the object tree structure are traversed, acquiring the object father nodes of the traversed object child nodes, and determining the page positions of the page controls corresponding to the traversed object child nodes according to the display attribute information which has a mapping relation with the traversed object child nodes and the display attribute information which has a mapping relation with the object father nodes of the traversed object child nodes.
4. The method according to claim 2, wherein any one of the N object nodes of the object tree structure is represented as the ith object node, i being a positive integer less than or equal to N;
the obtaining the control content of the page control corresponding to each object node according to the display attribute information having the mapping relationship with each object node includes:
if the control content of the page control corresponding to the ith object node belongs to local control content, acquiring a local content identifier from display attribute information having a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a local database according to the local content identifier;
if the control content corresponding to the page control corresponding to the ith object node belongs to the cloud control content, acquiring a cloud content address from display attribute information having a mapping relation with the ith object node, and acquiring the control content of the page control corresponding to the ith object node from a cloud database according to the cloud content address.
5. The method according to claim 1, wherein the client page includes a plurality of sub-view pages, the number of the control tree structures is plural, one control tree structure corresponds to one sub-view page, the N page controls corresponding to one control tree structure belong to page controls in one sub-view page, and the display dependencies between the N page controls include display dependencies or parallel display dependencies.
6. The method of claim 5, wherein the number of the page sub threads is multiple, and one sub-view page corresponds to one page sub thread, and the method further comprises:
acquiring a view display sequence of the multiple sub-view pages in the client page;
constructing a thread queue of the multiple page sub-threads according to the view display sequence of the multiple sub-view pages;
the sequentially traversing each object node in the object tree structure based on the page child thread comprises:
and sequentially calling page sub threads in the thread queue to traverse the object nodes in the corresponding object tree structure.
7. The method according to claim 1, wherein the N object nodes of the object tree structure include a jth object node and a kth object node, j and k are positive integers less than or equal to N, the page controls corresponding to the jth object node and the kth object node each have at least one control trigger operation, and the kth object node is an object parent node of the jth object node;
the method further comprises the following steps:
if the triggering operation of the page control corresponding to the jth object node in the client page is detected based on the page main thread, and at least one control triggering operation corresponding to the jth object node comprises the triggering operation, executing a service event triggered by the triggering operation on the page control corresponding to the jth object node in the client page;
and if the triggering operation aiming at the page control corresponding to the jth object node in the client page is detected based on the page main thread, the triggering operation of at least one control corresponding to the jth object node does not comprise the triggering operation, and the triggering operation of at least one control corresponding to the kth object node comprises the triggering operation, executing the business event triggered by the triggering operation on the page control corresponding to the kth object node in the client page.
8. An apparatus for data rendering, the apparatus comprising:
the acquiring unit is used for calling a page main thread to acquire page data requested to be displayed by a page display request if the page display request in an application client is acquired; the page data comprises a control tree structure, the control tree structure is formed by control nodes respectively corresponding to N page controls with display dependency, the page data also comprises display attribute information respectively corresponding to each control node in the N control nodes, and N is a positive integer;
the processing unit is used for calling page sub threads to create object nodes corresponding to each control node in the control tree structure respectively and constructing an initial object tree structure based on each created object node; the initial object tree structure has a structural framework of the control tree structure;
the processing unit is further configured to correspondingly establish a mapping relationship between each object node in the initial object tree structure and the display attribute information corresponding to each control node based on the page sub thread to obtain an object tree structure;
the processing unit is further configured to sequentially traverse each object node in the object tree structure based on the page sub-thread, and render and display the page control corresponding to each object node on a client page of the application client according to display attribute information having a mapping relationship with the traversed object node.
9. An electronic device comprising a processor, a memory, wherein the memory is configured to store a computer program comprising program instructions, and wherein the processor is configured to invoke the program instructions to perform the method of any of claims 1-7.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer program comprising program instructions that, when executed by a processor, cause the processor to carry out the method according to any one of claims 1-7.
CN202110999945.9A 2021-08-27 2021-08-27 Data rendering method and device, electronic equipment and medium Pending CN115729655A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110999945.9A CN115729655A (en) 2021-08-27 2021-08-27 Data rendering method and device, electronic equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110999945.9A CN115729655A (en) 2021-08-27 2021-08-27 Data rendering method and device, electronic equipment and medium

Publications (1)

Publication Number Publication Date
CN115729655A true CN115729655A (en) 2023-03-03

Family

ID=85290595

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110999945.9A Pending CN115729655A (en) 2021-08-27 2021-08-27 Data rendering method and device, electronic equipment and medium

Country Status (1)

Country Link
CN (1) CN115729655A (en)

Similar Documents

Publication Publication Date Title
CN107239318B (en) Using conversion method, device and equipment
US11797273B2 (en) System and method for enhancing component based development models with auto-wiring
CN110908712A (en) Data processing method and equipment for cross-platform mobile terminal
EP3279816A1 (en) Data analysis processing method, apparatus, computer device, and storage medium
CN112860247B (en) Custom generation method, device, equipment and medium of model component
CN114996619A (en) Page display method and device, computer equipment and storage medium
WO2023082654A1 (en) Method, apparatus and device for generating service interaction diagram, and storage medium
CN113360139A (en) Integration method and device of front-end frame, electronic equipment and storage medium
CN115809056B (en) Component multiplexing implementation method and device, terminal equipment and readable storage medium
CN112486807A (en) Pressure testing method and device, electronic equipment and readable storage medium
CN112035113A (en) Navigation bar loading method, device, equipment and medium of H5 page
CN107506597A (en) Medical files acquisition methods, terminal and server
CN114237398B (en) Method and device for generating room small map based on illusion engine and storage medium
CN115729655A (en) Data rendering method and device, electronic equipment and medium
CN113535151B (en) Code generation method and device
CN116775174A (en) Processing method, device, equipment and medium based on user interface frame
CN115705465A (en) Data analysis result presentation method, device, equipment and storage medium
CN113778412A (en) Data resource arranging method and device, computer equipment and readable storage medium
CN113761416A (en) Request processing method, device, server and storage medium
CN113779483B (en) Page component generation method and device, storage medium and computer equipment
CN116595284B (en) Webpage system operation method, device, equipment, storage medium and program
CN113986850B (en) Storage method, device, equipment and computer readable storage medium of electronic volume
US10672157B2 (en) Bar chart optimization
KR20240090928A (en) Artificial intelligence-based integration framework
CN116739845A (en) Contract generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination