DOCX

UI Chromium hardware accelerated rendering synthesis process analysis

By Bernard Stephens,2015-11-15 05:59
47 views 0
UI Chromium hardware accelerated rendering synthesis process analysis

    UI Chromium hardware accelerated rendering

    synthesis process analysis

    In Chromium in, Render end and WebGL end drawn out through the Browser UI ultimate end is displayed on the screen. In other words, it is responsible for the synthesis Render Browser end end end and WebGL UI. This involves transfer of resources between different OpenGL context and synchronization issues. Among hem, the resource transfer mechanisms to resolve issues through Mailbox t

    synchronization mechanism to solve the problem by Sync Point. This paper will analyze the following synthesis Render Browser end end end and WebGL UI process.

    Render end is responsible for drawing the web UI. In Chromium, the web UI is abstracted into a tree Layer Tree, each Layer have to use a Layer object description, the leftmost in Figure 1 below:

    1 Layer Diagram Tree, Pending Layer Tree and the Active Layer Tree

    WebGL side is responsible for drawing a webpage canvas tag. In Chromium, the webpage canvas tag is abstracted as a TextureLayer object appears as a Layer is used to describe a web UI of the Layer Tree.

    Render end of the three in-house maintenance Tree. In addition to the Layer Tree,

    the other two are Pending Layer Tree Tree and Active Layer Tree. In Pending Layer Tree and Active Layer Tree, each Layer is described by a LayerImpl object. Accordingly, the webpage canvas tag in Pending Layer Tree and Active Layer Tree is abstracted as a TextureLayerImpl object.

    Layer Tree maintained by Render Render thread ends, and Pending Layer Tree and Active Layer Tree maintained by Render end Compositor thread. Render Layer Tree thread obtained by parsing the page content. Pending Layer Tree equivalent of a copy of Layer Tree. Whenever Layer Tree changes, Compositor thread will have its sync (Synchronize) Pending Layer Tree to go.Pending Layer Tree after a rasterized (Rasterize) process, it becomes Active Layer Tree. Active Layer Tree represents a synthesis of the end can be Browser UI.

    Pending Layer Tree Layer Tree and presence makes Render Compositor thread and the thread can concurrently draw web UI, shown in Figure 2:

    Figure 2 a schematic drawing of concurrent web UI

    This is equivalent to a frame on the page UI is drawn into two parts. Render the first half of the thread, the second half of the Compositor thread. Wherein the first N + the first half and second half of the N-th frame 1 can be processed concurrently. This is similar to the Android 5.0 UI application hardware accelerated rendering mechanism, specific reference Android application UI hardware accelerated rendering technology brief introduction and learning programs This series of articles. Among them, Render here Compositor thread and the thread is equivalent to Android 5.0 application process in the Main Thread and Render thread.

    From the front Process Analysis Chromium hardware accelerated OpenGL rendering command execution A text may know, Render end GPU command execution draw web UI, but is written to the GPU to perform a GPU command buffer, and then read by the GPU process from the GPU command buffer out of GPU command, and calls the appropriate OpenGL functions execute them. This process is actually increasing the page rendering process parallelism, which is in the Render end GPU GPU command buffer write commands simultaneously, GPU process from GPU GPU command buffer read command processing. So it can make good use of multi-core characteristics of the device. It is also hardware accelerated rendering Chromium and Android hardware accelerated rendering of one important difference.

    Pending Layer Tree and Active Layer Tree Use Browser-side existence of both web UI can be synthesized at any time. Active Layer Tree describes the page content

    changes occur before a UI frame. Pending Layer Tree to be rasterized is a lengthy process. If there is no presence of Active Layer Tree, it will result in the Pending Layer Tree during rasterization, Browser-side web UI can not be displayed on the screen.

    Early, Render end first through a process called GL Renderer renderer in the Active Layer Tree draw a texture, and then passed to draw a good texture synthesis Browser side, shown in Figure 3:

    Figure 3 GL Renderer

    Active Layer Tree Layer Each corresponds to a Render Pass, these Render Pass up a Render Pass List. Wherein each Render Pass also contains a Quad List. Quad

    List consists of a series of Draw Quad composition. Draw Quad is a description of a texture mapping command, the texture mapping command specifies the texture object and texture coordinates and other information.

    Mentioned earlier, WebGL side of the page is responsible for drawing canvas tag. This content canvas tag is drawn in a texture. This texture is generated in the WebGL end OpenGL context, and then passed to the Render end by Mailbox.

    As mentioned earlier, web page canvas tag is abstracted as a TextureLayer object. This TextureLayer object corresponds to the Render Pass List in a Render Pass. The Render Pass the Quad List contains a Texture Draw Quad. The Texture Draw Quad specified texture object description tag is the canvas UI. In other words, the canvas tag WebGL end UI drawing on a texture. Note that this texture object is created in the WebGL end OpenGL context, Render end OpenGL context can not access it directly. To make Render client can access the texture object, WebGL Mailbox will end by this texture object to Render end, Render end so you can access it.

    Render end finally by GL Renderer Render Pass List all Render Pass, including the canvas tag corresponding Render Pass, we are drawn in a texture. The texture which is then passed to the Browser side through the Mailbox. Browser end like Render end, just as they have to draw the UI (including the transfer from Render end came texture object) abstract into Layer Tree, Pending Layer Tree and Active Layer

    Tree three Tree. Browser-side Active Layer Tree also corresponds to a Render Pass List. The Render Pass List ultimately be drawn by a GL Renderer. However, this Render Pass List will be drawn on the screen, instead of being drawn in a texture.

    From the above analysis we can know, by GL Renderer, Render end first draw their Render Pass List in a texture. After this texture is passed to Broswer end, again drawing on the screen.This means that the end of Render UI is drawn twice. The first draw OpenGL context Render end, the second end is drawn Browser OpenGL context. In fact, we can end the Render Render Pass List passed to Browser-side rendering. This can reduce a draw, thereby improving efficiency.

    The end of Render Render Pass List passed to the Browser client is through a process called Delegated Renderer renderer implementation, shown in Figure 4:

    Figure 4 Delegated Renderer

    Render end Render Pass List Delegated Renderer after treatment to form a Compositor Frame. After this Compositor Frame Browser passed to end, it will form a Browser ends an Active Layer Tree Layer, so as to be drawn on the screen. Render texture object side Render Pass List, including, WebGL side generated texture objects are passed to the Browser side by Mailbox access.

    In the above description of the process, we mentioned the Layer Tree, Pending Layer Tree, Active Layer Tree, Render Thread, Compositor Thread, Render Pass, Draw Quad, GL Renderer, Delegated Renderer and Compositor Frame concepts, they belong in Chromium Compositor module concept. Chromium in the Compositor module referred to as the CC module, which is responsible for the synthesis of Render end and Browser UI, in the following analysis, we simply relate to its content. After the analysis page rendering article, we will analyze in detail principle CC module.

    In the above description of the process, we have repeatedly mentioned the Mailbox Chromium mechanism, which play a role in transferring resources at the end of the synthesis Browser Render end and WebGL side UI process, so create an OpenGL context can be accessed in another OpenGL context resources. So, then we first analyze the Mailbox mechanism Chromium.

    Defined Mailbox is very simple, it is a name, as follows:

     struct GPU_EXPORT Mailbox {

     Mailbox ();

     bool IsZero () const;

     void SetZero ();

     void SetName (const int8_t * name);

     // Generate a unique unguessable mailbox name.

     static Mailbox Generate ();

     ......

     int8_t name [GL_MAILBOX_SIZE_CHROMIUM];

     ......

     };

    This structure is defined in the file external / chromium_org / gpu / command_buffer / common /

    mailbox.h in.

    You can see from here, Mailbox name using an array name int8_t description. Mailbox name of a valid non-zero, an array name is not all zero.

    When creating a Mailbox, its name is set to 0 by default, as follows:

     Mailbox :: Mailbox () {

     memset (name, 0, sizeof (name));

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / common / mailbox.cc in.

    After the member functions we can structure SetName set a Mailbox Mailbox name, as follows:

     void Mailbox :: SetName (const int8 * n) {

     DCHECK (IsZero () || memcmp (name, n, sizeof (name))!);

     memcpy (name, n, sizeof (name));

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / common / mailbox.cc in.

    It can also function by member Mailbox structure SetZero a Mailbox name is set to 0, as follows:

     void Mailbox :: SetZero () {

     memset (name, 0, sizeof (name));

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / common / mailbox.cc in.

    Mailbox structure also provides the member function IsZero determine whether a Mailbox name to 0, as follows:

     bool Mailbox :: IsZero () const {

     for (size_t i = 0; i

     if (name [i])

     return false;

     }

     return true;

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / common / mailbox.cc in.

    We can generate by Mailbox Generate a static member function name is not Mailbox 0, as follows:

     Mailbox Mailbox :: Generate () {Mailbox result; // Generates

    cryptographically-secure bytes base :: RandBytes (result.name, sizeof

    (result.name));. ...... Return result;}

    This function is defined in the file external / chromium_org / gpu / command_buffer / common / mailbox.cc in.

    In general, we do not directly call the Mailbox class static member function Generate to generate a Mailbox, but by OpenGL interface class member functions GenMailboxCHROMIUM GLES2Implementation generated as follows:

     void GLES2Implementation :: GenMailboxCHROMIUM (

     GLbyte * mailbox) {

     ......

     gpu :: Mailbox result = gpu :: Mailbox :: Generate ();

     memcpy (mailbox, result.name, sizeof (result.name));

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / client / gles2_implementation.cc in.

    Generated Mailbox mailbox via the output parameters returned to the caller. After the caller get generated Mailbox, continue to call the member function roduceTextureCHROMIUM GLES2Implementation the Mailbox object associated P

    with a texture, as follows:

     void GLES2Implementation :: ProduceTextureCHROMIUM (GLenum target,

     const GLbyte * data) {

     ......

     helper _-> ProduceTextureCHROMIUMImmediate (target, data);

     CheckGLError ();

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / client / gles2_implementation.cc in.

    Parameter data describes a Mailbox, another parameter target describes the texture object to be associated with.

    From the front Process Analysis Chromium hardware accelerated OpenGL rendering command execution One article can know, the class member variables GLES2Implementation helper_ points to a GLES2CmdHelper object here call its member function ProduceTextureCHROMIUMImmediate GPU command buffer to write a gles2 :: cmds :: ProduceTextureCHROMIUMImmediate order for delivery to the GPU process handling.

    GPU process will gles2 :: cmds :: ProduceTextureCHROMIUMImmediate command DoProduceTextureCHROMIUM distributed processing

    GLES2DecoderImpl class member function, the process is as follows:

     void GLES2DecoderImpl :: DoProduceTextureCHROMIUM (GLenum target,

     const GLbyte * data) {

     ......

     TextureRef * texture_ref = texture_manager () -> GetTextureInfoForTarget (

     & State_, target);

     ProduceTextureRef ("glProduceTextureCHROMIUM", texture_ref, target, data);

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / service / gles2_cmd_decoder.cc in.

    DoProduceTextureCHROMIUM GLES2DecoderImpl class member function first calls the member function texture_manager get a TextureManager object. This object is responsible for managing OpenGL TextureManager currently being used in the context where the texture object sharing group. With this TextureManager after the object, you can call its member function GetTextureInfoForTarget target texture parameters obtained as described in the referenced object. With this texture reference

    ect after the member function DoProduceTextureCHROMIUM obj

    GLES2DecoderImpl next class member function calls another ProduceTextureRef the next step.

    GLES2DecoderImpl class member functions ProduceTextureRef implementation is as follows:

     void GLES2DecoderImpl :: ProduceTextureRef (std :: string func_name,

     TextureRef * texture_ref, GLenum target, const GLbyte * data) {

     const Mailbox & mailbox = * reinterpret_cast (data);

     .......

     Texture * produced = texture_manager () -> Produce (texture_ref);

     ......

     group _-> mailbox_manager () -> ProduceTexture (target, mailbox, produced);

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / service / gles2_cmd_decoder.cc in.

    GLES2DecoderImpl class member functions ProduceTextureRef first mandatory parameter data structure into a Mailbox, and then they call the objects described above TextureManager member function Produce acquisition parameters described texture_ref texture texture object reference object reference, as follows:

     Texture * TextureManager :: Produce (TextureRef * ref) {

     DCHECK (ref);

     return ref-> texture ();

     }

    This function is defined in the file external / chromium_org / gpu / command_buffer / service / texture_manager.cc in.

    Member function texture TextureManager Produce class member function call parameters described TextureRef ref object can be obtained texture object references. The texture of objects using a Texture object description.

    Back ProduceTextureRef GLES2DecoderImpl class member function, which calls the member function next mailbox_manager member variable points to a ContextGroup group_ object to get a MailboxManager object. With this MailboxManager after the object, call its member function ProduceTexture the next step.

    GLES2DecoderImpl class member variables group_ point ContextGroup object is a resource-sharing group described, MailboxManager object calls this member function mailbox_manager ContextGroup objects obtained for managing OpenGL OpenGL context sharing group is currently using a context belongs to those who have been Mailbox referenced texture object. This means that in a different context the

Report this document

For any questions or suggestions please email
cust-service@docsford.com