android4.4 WebView chromium for hardware rendering chromium kernel architecture

Source: Internet
Author: User

There are only a few classes that are different from native chromium.
I. Drawglfunctor
android4.4 WebView Chromium hardware rendering is an Android UI system and chromium core collaboration
Completed. The Android UI system is responsible for triggering web page rendering (calling Webview.ondraw ()), as well as providing
The final destination of the Web content (Hardwarecanvas); The chromium kernel provides specific rendering behavior.
This leads to the drawglfunctor structure.
Drawglfunctor.java/draw_gl_functor.cpp
Draw_gl_functor.cpp provides an interface for the Chromium kernel to register its own DRAWGL function.
Drawglfunctor is a function pointer, which is called by the system Webview.ondraw ()
is passed to the Android UI system and is called in the Android UI system,
The drawglfunctor operator () call is actually a DRAWGL function that is registered with the Chromium kernel.
Since Drawglfunctor's operator () is called by the Android UI system, it needs to be
After the drawglinfo structure of the Android UI system is converted into chromium awdrawglinfo,
Then call the DRAWGL function registered by the Chromium kernel and update the Android UI after the call is complete.
The DRAWGLINFO structure of the system.
First look at the process of registering the DRAWGL function of chromium to draw_gl_functor.cpp.

The global functions are defined in Draw_gl_functor.cpp:
void Setchromiumawdrawglfunction () {
G_aw_drawgl_function = reinterpret_cast<awdrawglfunction*> (draw_function);
}
The global variable that is set to Draw_gl_functor.cpp g_aw_drawgl_function is in Awcontents.java
Nativegetawdrawglfunction () returns the function ID.
What we see Awcontents.java::nativegetawdrawglfunction () is the specific function that is given.
aw_contents.cc
Static Jint getawdrawglfunction (jnienv* env, Jclass) {
Return reinterpret_cast<jint> (&drawglfunction);
}
The global function pointer variable drawglfunction is defined in aw_contents.cc:
extern "C" {
Static Awdrawglfunction drawglfunction;
static void drawglfunction (int view_context,
awdrawglinfo* Draw_info,
Void* spare) {
|view_context| Is the value of the was returned from the Java
AWCONTENTS.ONPREPAREDRAWGL; This cast must match the code there.
Reinterpret_cast<android_webview::browserviewrenderer*> (View_context)-&GT;DRAWGL (
Draw_info);
}
}
So the aw_contents.cc getawdrawglfunction () gets
Android_webview::inprocessviewrenderer: The function address of the:D RAWGL ().
The global variables that are set to Draw_gl_functor.cpp are G_aw_drawgl_function
Android_webview::inprocessviewrenderer::D rawgl ().
Then look at the process of Draw_gl_functor.cpp defined drawglfunctor () called by the Android UI system.

Draw_gl_functor.cpp
Virtual status_t operator () (int what, void* data) {
G_aw_drawgl_function (View_context_, &aw_info, NULL);
}
In the previous analysis, we know that the global variables defined by Draw_gl_functor.cpp g_aw_drawgl_function point to
Android_webview::inprocessviewrenderer::D rawgl ().
So the Drawglfunctor () call is Android_webview::inprocessviewrenderer::D rawgl ().
Two. Synchronouscompositorimpl
Structure diagram of Synchronouscompositorimpl:

Synchronouscompositorimpl the creation process:

Call Synchronouscompositorimpl::createforwebcontents ()
The actual invocation is:
Webcontentsuserdata::createforwebcontents () {
Dcheck (contents);
if (! Fromwebcontents (contents))
Contents->setuserdata (Userdatakey (), new T (contents));
}
Synchronouscompositorimpl is set to Webcontents's UserData after it is created.
The Synchronouscompositor interface of the Synchronouscompositorimpl is called in Inprocessviewrenderer.
The Synchronouscompositorimpl Synchronouscompositor interface implementation is transferred to the synchronouscompositoroutputsurface.
The Synchronouscompositorimpl Synchronouscompositoroutputsurfacedelegate interface is called in Synchronouscompositoroutputsurface. ;
The Synchronouscompositorimpl Synchronouscompositoroutputsurfacedelegate interface implementation is transferred to the
Synchronouscompositorclient is inprocessviewrenderer.
So Synchronouscompositorimpl just synchronouscompositoroutputsurface.
A brokered class that collaborates with Inprocessviewrenderer.
Three. Webgraphicscontext3dinprocesscommandbufferimpl and Glinprocesscontextimpl
The WEBGRAPHICSCONTEXT3DINPROCESSCOMMANDBUFFERIMPL structure diagram is as follows:

An instance of Webgraphicscontext3dinprocesscommandbufferimpl was created two times.
A scoped_ptr<webkit::webgraphicscontext3d> context3d_ variable that is stored in the Contextproviderinprocess instance,
Contextproviderinprocess instances are saved in Resourceprovider scoped_refptr<cc::contextprovider> Offscreen_context_ The Provider_ variable.
Another Webgraphicscontext3dinprocesscommandbufferimpl instance is saved in the Oututsurface Scoped_ptr<webkit::webgraphicscontext3d > Context3d_ variables.
The following is the creation process for the Webgraphicscontext3dinprocesscommandbufferimpl instance:

void Inprocessviewrenderer::D rawgl () is called first execution
BOOL Inprocessviewrenderer::initializehwdraw (). Initializes the class that is required to trigger hardware rendering.
Webkit::gpu::contextproviderinprocess::createoffscreen () creates a containing
Contextproviderinprocess instance of Webgraphicscontext3dinprocesscommandbufferimpl.
Synchronouscompositoroutputsurface::initializehwdraw () calls Createwebgraphicscontext3d () to create a
An instance of Webgraphicscontext3dinprocesscommandbufferimpl.
Contextproviderinprocess instances and instances of Webgraphicscontext3dinprocesscommandbufferimpl are passed as parameters to the
Outputsurface::initializeandsetcontext3d ().
The Webgraphicscontext3dinprocesscommandbufferimpl constructor requires Glinprocesscontext to do the argument.
Contextproviderinprocess instances through Outputsurface::initializeandsetcontext3d ()
Called Layertreehostimpl::D eferredinitialize () is eventually passed to the Resourceprovider::offscreen_context_provider_ variable.
Examples of Webgraphicscontext3dinprocesscommandbufferimpl through Outputsurface::initializeandsetcontext3d ()
The call Outputsurface::setcontext3d () is stored in the Oututsurface scoped_ptr<webkit::webgraphicscontext3d> context3d_ variable.
The webgraphicscontext3dinprocesscommandbufferimpl contained in the RESOURCEPROVIDER::OFFSCREEN_CONTEXT_PROVIDER_ variable contains the
Glinprocesscontext is null. In the WEBGRAPHICSCONTEXT3DINPROCESSCOMMANDBUFFERIMPL::MAYBEINITIALIZEGL () thing passed
Created by Glinprocesscontext::createcontext ().
Four. Inprocesscommandbuffer and Commandbufferservice

Glinprocesscontextimpl::initialize () Trigger process:

The global functions are defined in Synchronous_compositor_output_surface.cpp:
Scoped_ptr<webkit::webgraphicscontext3d> Createwebgraphicscontext3d ()
Glinprocesscontextimpl::initialize () created a
Inprocesscommandbuffer,gles2cmdhelper and Gles2implementation instances.
Inprocesscommandbuffer::initializeongputhread () created a
Commandbufferservice,gles2decoderimpl instance.
Unlike the GPU process architecture of a multi-process native chromium, there is no need to create a commandbufferproxy.
Gles2implementation still writes data through Gles2cmdhelper to Commandbuffer, which is directly to
Commandbufferservice indirectly included in the sharedmemory.
Gles2decoderimpl also reads the data from the Commandbuffer under the Gpuscheduler dispatch and invokes the GL operation in the command.
Finally, we summarize the rendering related chromium kernel structure.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.