webview渲染流程 – 人间奇迹 – 博客园

webview渲染流程

复制代码

<span style="color: #000000;">文档标记说明</p><p>#################  消息边界</p><p></span>+++++++++++++++++<span style="color: #000000;">  区域分隔  </p><p>$$$$$$$$$$$$$$$$$  线程边界</p><p></span>~~~~~~~~~~~~~~~~~<span style="color: #000000;">  进程边界</p><p></span>-----------------<span style="color: #000000;">  代码块功能模块分隔</p><p></span>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>创建GLES20Canvas Render</p><p>GLES20Canvas()  [GLES20Canvas.java]</p><p>    </span>|--&gt;<span style="color: #000000;"> android_view_GLES20Canvas_createLayerRenderer() [android_view_GLES20Canvas.cpp]</p><p>        </span>|--&gt; OpenGLRenderer* renderer = <span style="color: #0000ff;">new</span><span style="color: #000000;"> LayerRenderer(layer);</p><p></span>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>Fragment </p><p>        </span>|--&gt;LocalActivityManager.startActivity()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">LocalActivityManager.java]</p><p>            </span>|--&gt;LocalActivityManager.moveToState()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">LocalActivityManager.java]</p><p>                </span>|--&gt;ActivityThread.startActivityNow()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">ActivityThread.java]</p><p></span>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++</p><p>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>Launcher 启动 Activity 流程</p><p></span>|--&gt;<span style="color: #000000;">Activity.startActivity()</p><p>    </span>|--&gt;<span style="color: #000000;">mInstrumentation.execStartActivity()</p><p>        </span>|--&gt;<span style="color: #000000;">ActivityManagerProxy.startActivity() </p><p>~~~~~~~~~~~~~~~~~~~~~~</span>|   |<span style="color: #000000;">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Process.ActivityManagerService </p><p>        </span>|--&gt;<span style="color: #000000;">ActivityManagerService.startActivityAsUser</p><p>            </span>|--&gt;<span style="color: #000000;"> ...</p><p>                </span>|--&gt;ActivityManagerService.startProcessLocked() [frameworks/<span style="color: #0000ff;">base</span>/services/java/com/android/server/am/<span style="color: #000000;">ActivityManagerService.java]</p><p>~~~~~~~~~~~~~~~~~~~~~~</span>|   |<span style="color: #000000;">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Process.Activity</p><p>    </span>|--&gt;<span style="color: #000000;">ActivityThread.main()</p><p>        </span>|--&gt;ActivityThread.attach(<span style="color: #0000ff;">false</span><span style="color: #000000;">)</p><p>            </span>|--&gt;ActivityManagerProxy.attachApplication() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">ActivityManagerNative.java]</p><p>~~~~~~~~~~~~~~~~~~~~~~</span>|   |<span style="color: #000000;">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Process.ActivityManagerService </p><p>            </span>|--&gt;<span style="color: #000000;">ActivityManagerService.attachApplication()</p><p>                </span>|--&gt;<span style="color: #000000;">ActivityManagerService.attachApplicationLocked() </p><p>                    </span>|--&gt;mMainStack.topRunningActivityLocked()   [frameworks/<span style="color: #0000ff;">base</span>/services/java/com/android/server/am/<span style="color: #000000;">ActivityStack.java]</p><p>                    </span>|--&gt;<span style="color: #000000;">mMainStack.realStartActivityLocked()</p><p>                        </span>|--&gt;ApplicationThreadProxy.scheduleLaunchActivity() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">ApplicationThreadNative.java]</p><p>~~~~~~~~~~~~~~~~~~~~~~</span>|   |<span style="color: #000000;">~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</p><p>Process.Activity                    </p><p>                        </span>|--&gt;<span style="color: #000000;">ApplicationThread.scheduleLaunchActivity()     </p><p>                            </span>|--&gt;ApplicationThread.queueOrSendMessage()     <span style="color: #008000;">//</span><span style="color: #008000;"> Binder</span></p><p>#########################| sendMessage |<span style="color: #000000;">###################################################################                               </p><p>                             H mH                ActivityThread.mLooper                                                    </p><p>########################</span>| handleMessage|<span style="color: #000000;"> ##################################################################                                </p><p>                    </span>|--&gt;<span style="color: #000000;">ActivityThread.handleMessage                </p><p>                        </span>|--&gt;<span style="color: #000000;">ActivityThread.handleLaunchActivity()  </p><p>                        .    </span>|--&gt;<span style="color: #000000;">ActivityThread.performLaunchActivity()  </p><p>                        .        </span>|--&gt;mInstrumentation.newActivity()     [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Instrumentation.java]</p><p>                        .        </span>|--&gt;LoadedApk.makeApplication()        [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">LoadedApk.java]</p><p>                        .        </span>|--&gt;<span style="color: #000000;">ActivityThread.createBaseContextForActivity() </p><p>                        .        </span>|--&gt;activity.attach()    [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Activity.java]</p><p>                        .            </span>|--&gt;PolicyManager.makeNewWindow(<span style="color: #0000ff;">this)</span>[frameworks/<span style="color: #0000ff;">base</span>/core/j×/com/android/<span style="color: #0000ff;">inter</span>/policy/<span style="color: #000000;">PolicyManager.java]</p><p>                        .            </span>|--&gt;<span style="color: #000000;">PhoneWindow.setWindowManager()</p><p>                        .                </span>|--&gt;<span style="color: #000000;">getSystemService(Context.WINDOW_SERVICE)</p><p>                        .                    </span>|--&gt;<span style="color: #000000;">WindowManagerImpl.createLocalWindowManager();       创建窗口mWindowManager</p><p>                        .        </span>|--&gt;<span style="color: #000000;">mInstrumentation.callActivityOnCreate()     </p><p>                        .           </span>|--&gt;activity.performCreate()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Activity.java]</p><p>                        .                 </span>|--&gt;<span style="color: #000000;">Activity.onCreate()</p><p>                        .                   </span>|--&gt;<span style="color: #000000;">Activity.setContentView()</p><p>                        .                       </span>|--&gt;PhoneWindow.setContentView() [*/policy/impl/<span style="color: #000000;">PhoneWindow.java]</p><p>                        .                          </span>|--&gt;<span style="color: #000000;">PhoneWindow.installDecor()</p><p>                        .                             </span>|--&gt;mContentParent =<span style="color: #000000;"> PhoneWindow.generateLayout(mDecor)</p><p>                        .        </span>|--&gt;activity.performStart()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Activity.java]</p><p>                        .        </span>|--&gt;<span style="color: #000000;">mInstrumentation.callActivityOnRestoreInstanceState() </p><p>                        .            </span>|--&gt;activity.performRestoreInstanceState()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Activity.java]</p><p>                        .        </span>|--&gt;mInstrumentation.callActivityOnPostCreate()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Instrumentation.java]</p><p>                        .           </span>|--&gt;activity.onPostCreate()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/app/<span style="color: #000000;">Activity.java]</p><p>                        </span>|--&gt;<span style="color: #000000;">ActivityThread.handleResumeActivity()             激活 Activity</p><p>                            </span>|--&gt;<span style="color: #000000;">ActivityThread.performResumeActivity()</p><p>                                </span>|--&gt;<span style="color: #000000;">Activity.performResume()</p><p>                                    </span>|--&gt;<span style="color: #000000;">Activity.performRestart()</p><p>                                    .    </span>|--&gt;<span style="color: #000000;">Instrumentation.callActivityOnRestart()</p><p>                                    .        </span>|--&gt;<span style="color: #000000;">Activity.onRestart()</p><p>                                    </span>|--&gt;<span style="color: #000000;">Activity.performStart() </p><p>                                    .    </span>|--&gt;<span style="color: #000000;">Instrumentation.callActivityOnStart()</p><p>                                    .        </span>|--&gt;<span style="color: #000000;">Activity.onStart()</p><p>                                    </span>|--&gt;<span style="color: #000000;">Instrumentation.callActivityOnResume()</p><p>                                    .    </span>|--&gt;<span style="color: #000000;">Activity.onResume()</p><p>                                    </span>|--&gt;<span style="color: #000000;">Activity.onPostResume()</p><p>                            </span>|--&gt;WindowManagerImpl.addView()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">WindowManagerImpl.java]</p><p>                                </span>|--&gt;WindowManagerGlobal.addView() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">WindowManagerGlobal.java]</p><p>                                    </span>|--&gt;root = <span style="color: #0000ff;">new</span><span style="color: #000000;"> ViewRootImpl()                 创建root 绑定窗口系统</p><p>                                    </span>|--&gt;<span style="color: #000000;">ViewRootImpl.setView(PhoneWindow.getDecorView()) </p><p>                                        </span>|--&gt;mAttachInfo.mRootView =<span style="color: #000000;"> DecorView;</p><p>                 </span>/&lt;----------------------|--&gt;<span style="color: #000000;">ViewRootImpl.requestLayout()           第一次布局调度</p><p>                 </span>|                        |--&gt;<span style="color: #000000;">(DecorView)view.assignParent(ViewRootImpl)        </p><p>                 </span>|                 </p><p>                 |</p><p>                 |</p><p>                 |                 </p><p>                 |</p><p>                 |</p><p>                 |</p><p>+++++++++++++++++|+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>sw 渲染流程       </span>|<span style="color: #000000;"></p><p>                 \</span>/</p><p>|--&gt;<span style="color: #000000;">ViewRootImpl.requestLayout()                                                                                                </p><p></span>|--&gt;<span style="color: #000000;">ViewRootImpl.invalidate()                                                                                                        </p><p>    </span>|--&gt;ViewRootImpl.scheduleTraversals [frameroks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewRootImpl.java]                               </p><p>                                                                                                                                </p><p>#########################</span>| postCallback |<span style="color: #000000;">#############################################################                               </p><p>                 ViewRootImple.ViewRootHandler mHandler                                                                             </p><p>########################</span>| Callback|<span style="color: #000000;"> ##################################################################                          </p><p></span>&lt;@@MessageHandler name=Travdersalrunnable &gt;                                                                                       </p><p>|--&gt;ViewRootImpl.TraversalRunnable.run() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewRootImpl.java]                                   </p><p>    </span>|--&gt;ViewRootImpl.doTraversal()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewRootImpl.java]                                 </p><p>        </span>|--&gt;ViewRootImpl.performTraversals()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewRootImpl.java]                       </p><p>            </span>|--&gt;<span style="color: #000000;">ViewRootImpl.performMeasure()  or  ViewRootImpl.measureHierarchy(view host)  计算subtree</p><p>            </span>|--&gt;<span style="color: #000000;">ViewRootImpl.performLayout()</p><p>                </span>|--&gt;<span style="color: #000000;">ViewRootImpl.measureHierarchy()</p><p>                </span>|--&gt;<span style="color: #000000;">DecorView.layout()</p><p>            </span>|--&gt;<span style="color: #000000;">ViewRootImpl.performDraw()                           </p><p>                </span>|--&gt;<span style="color: #000000;">ViewRootImpl.draw()     </p><p>            </span>/-----&gt;|--&gt;<span style="color: #000000;">ViewGroup.drawChild()   </p><p>            </span>|           |--&gt;<span style="color: #000000;">View.draw(Canvas,ViewGroup) </p><p>            </span>|              |--&gt;{ <span style="color: #0000ff;">if</span><span style="color: #000000;">( hasDisplayList) } </p><p>            </span>|              .      |((HardwareCanvas) canvas).drawDisplayList() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">HardwareCanvas.java]</p><p>sw          </span>|              .      |--&gt;GLES20Canvas.drawDisplayList()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">GLES20Canvas.java]</p><p>            </span>|              .          |--&gt;android_view_GLES20Canvas_drawDisplayList() [frameworks/<span style="color: #0000ff;">base</span>/core/jni/<span style="color: #000000;">android_view_GLES20Canvas.cpp]</p><p>            </span>|              .            |--&gt;<span style="color: #000000;">OpenGLRenderer::drawDisplayList()</p><p>            </span>|<span style="color: #000000;">              .</p><p>            </span>|              |--&gt;view.draw(Canvas) [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">view.java]</p><p>            </span>|                   |--&gt;background.draw(canvas)   <span style="color: #800080;">1</span><span style="color: #000000;">. Draw the background</p><p>            </span>|                   |--&gt;canvas.saveLayer()          <span style="color: #800080;">2</span>. save the canvas<span style="color: #800000;">'</span><span style="color: #800000;"> layers</span></p><p>            |                   |--&gt;ViewGroup.dispatchDraw(canvas)      <span style="color: #800080;">4</span>. Draw children [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewGroup.java]</p><p>            \</span>&lt;--------------------|--&gt;<span style="color: #000000;">ViewGroup.drawChild()</p><p>                                </span>|--&gt;canvas.drawRect             <span style="color: #800080;">5</span><span style="color: #000000;">. draw the fading edges and restore layers</p><p>                                </span>|--&gt;View.onDrawScrollBars     <span style="color: #800080;">6</span>. Draw decorations  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/<span style="color: #000000;">ViewGroup.java]</p><p>                                </span>|--&gt;View.onDraw(canvas)       <span style="color: #800080;">3</span>. Draw view<span style="color: #800000;">'</span><span style="color: #800000;">s content</span></p><p>                                || </p><p>--------------------------------||----------------------------------------------------------------------------------------------------------<span style="color: #000000;"></p><p>                    webview     \</span>/</p><p>                                 |--&gt;<span style="color: #000000;">onDraw(Canvas canvas)  [WebViewClassic.java]</p><p>                                   </span>|--&gt;<span style="color: #000000;">drawContent(Canvas canvas)  [WebViewClassic.java]</p><p>                            </span>----------------------------------------------------------------------------------------------------------------</p><p>                                      |--&gt;nativeDraw(canvas, mVisibleContentRect, mBackgroundColor) [webkit/android/nav/<span style="color: #000000;">WebView.cpp]</p><p>                                 sw   .   </span>|--&gt;draw()     [webkit/android/nav/<span style="color: #000000;">WebView.cpp]</p><p>                                      .         { m_baseLayer</span>-&gt;<span style="color: #000000;">draw() } </p><p>                                      .         </span>|--&gt; Layer::draw()    [frameworks/native/services/surfaceflinger/<span style="color: #000000;">layer.cpp]</p><p>                                      .            </span>|--&gt; Layer::onDraw()  [frameworks/native/services/surfaceflinger/<span style="color: #000000;">layer.cpp]</p><p>                                      .</p><p>                            </span>---------------------------------------------------------------------------------------------------------------- </p><p>                                      |--&gt;functor = nativeCreateDrawGLFunction() [webkit/android/nav/<span style="color: #000000;">WebView.cpp]</p><p>                                      </span>|--&gt;((HardwareCanvas) canvas).callDrawGLFunction(functor)  [*/android/webkit/<span style="color: #000000;">WebViewClassic.java]   </p><p>                                         </span>|--&gt;<span style="color: #000000;">callDrawGLFunction()  [GLES20Canvas.java]</p><p>                                 hw          </span>|--&gt;<span style="color: #000000;"> android_view_GLES20Canvas_callDrawGLFunction() [android_view_GLES20Canvas.cpp] </p><p>                                             </span>|--&gt;OpenGLRenderer::callDrawGLFunction() [frameworks/<span style="color: #0000ff;">base</span>/libs/hwui/<span style="color: #000000;">OpenGLRenderer.cpp]</p><p>                                                  </span>|--&gt; mFunctors.add(functor);                                         -------&gt;<span style="color: #000000;">\            </p><p>                            ###################################</span>| add |#########################################################|<span style="color: #000000;">#########          </p><p>                                                 SortedVector</span>&lt;Functor*&gt; mFunctors  异步                                         |<span style="color: #000000;"></p><p>                            ##################################</span>| invoke| #######################################################|<span style="color: #000000;">#########                                                                                                                                         </span>|                                                                                                                                                   |</p><p>                                                                                                                                |</p><p>                                                                                                                                |</p><p>-------------------------------------------------------------------------------------------------------------------------------|----------<span style="color: #000000;">        </p><p>hw  渲染流程                                                                                                                     </span>|</p><p>                                                                                                                                |</p><p>|--&gt;ViewRootImpl.requestLayout()                                                                                               |</p><p>|--&gt;ViewRootImpl.invalidate()                                                                                                   |    </p><p>    |--&gt;ViewRootImpl.scheduleTraversals [frameroks/<span style="color: #0000ff;">base</span>/core/java/android/view/ViewRootImpl.java]                              |</p><p>                                                                                                                                |<span style="color: #000000;"></p><p>#########################</span>| postCallback |#############################################################                           |<span style="color: #000000;">    </p><p>                 ViewRootImple.ViewRootHandler mHandler                                                                         </span>|<span style="color: #000000;">    </p><p>########################</span>| Callback| ##################################################################                           |</p><p>&lt;@@MessageHandler name=Travdersalrunnable &gt;                                                                                       |</p><p>|--&gt;ViewRootImpl.TraversalRunnable.run() [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/ViewRootImpl.java]                               |    </p><p>    |--&gt;ViewRootImpl.doTraversal()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/ViewRootImpl.java]                                 |</p><p>        |--&gt;ViewRootImpl.performTraversals()  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/ViewRootImpl.java]                       |</p><p>            |--&gt;ViewRootImpl.performMeasure()  or  ViewRootImpl.measureHierarchy(view host)  计算subtree                       |</p><p>            |--&gt;ViewRootImpl.performLayout()                                                                                   |</p><p>                |--&gt;ViewRootImpl.measureHierarchy()                                                                               |</p><p>                |--&gt;DecorView.layout()                                                                                           |<span style="color: #000000;"></p><p>hw            </span>|--&gt;ViewRootImpl.performDraw()                                                                                        |</p><p>                |--&gt;ViewRootImpl.draw()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/ViewRootImpl.java]                           |<span style="color: #000000;"></p><p>                   { attachInfo.mHardwareRenderer.draw }                                                                       </span>|</p><p>                   |--&gt;hardwareRenderer.draw()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/hardwareRenderer.java]                | </p><p>                      |--&gt;hardwareRenderer.drawDisplayList()   [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/hardwareRenderer.java]  |</p><p>                         |--&gt;handleFunctorStatus()    [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/HardwareRenderer.java]           |</p><p>                               |--&gt;mHandler.postDelayed()    [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/HardwareRenderer.java]       |</p><p>                                                                                                                                |</p><p>&lt;@@/MessageHandler&gt;                                                                                                                |<span style="color: #000000;"></p><p>###################################</span>| post  |######################################################################               |<span style="color: #000000;"></p><p>                           View.Handler mHandler </span>= ViewRootImple.ViewRootHandler mHandler                                         |<span style="color: #000000;"></p><p>#################################</span>|  CallBack |######################################################################           |    </p><p>     |--&gt;HardwareRenderer.HardwareFunctorsRunnable.run [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/HardwareRenderer.java]           |<span style="color: #000000;"></p><p>         { mCanvas.invokeFunctors(mRedrawClip) }                                                                                 </span>|</p><p>         |--&gt;GLES20Canvas.invokeFunctors  [frameworks/<span style="color: #0000ff;">base</span>/core/java/android/view/GLES20Canvas.java]                           |</p><p>            |--&gt; android_view_GLES20Canvas_invokeFunctors  [framework/<span style="color: #0000ff;">base</span>/core/jni/android_view_GLES20Canvas.cpp]               |</p><p>               |--&gt;OpenGLRenderer::invokeFunctors [frameworks/<span style="color: #0000ff;">base</span>/libs/hwui/OpenGLRenderer.cpp]   &lt;---------------------------/<span style="color: #000000;"></p><p>                   { Functor</span>* f = functors.itemAt(i); result |= (*f)(DrawGlInfo::kModeProcess, &amp;<span style="color: #000000;">info) }</p><p>                   </span>|--&gt;GLDrawFunctor() &lt;-- (*wvInstance.*funcPtr)()  [webkit/android/nav/<span style="color: #000000;">WebView.cpp:GLDrawFunctor]</p><p>                       </span>|--&gt;drawGL()        [webkit/android/nav/<span style="color: #000000;">WebView.cpp]</p><p>                              </span>|--&gt;m_glWebViewState = <span style="color: #0000ff;">new</span><span style="color: #000000;"> GLWebViewState()</p><p>                              </span>|--&gt;(GLWebViewState)m_glWebViewState-&gt;drawGL()  [webkit/android/nav/<span style="color: #000000;">GLWebViewState.cpp]</p><p>                                    </span>|--&gt;tilesManager = TilesManager::instance()  [webcore/platform/graphics/android/rendering/<span style="color: #000000;">TilesManager.cpp]</p><p>                                    </span>|--&gt;tilesManager-&gt;updateTilesIfContextVerified()         <span style="color: #008000;">//</span><span style="color: #008000;"> 创建/更新 Tile纹理</span></p><p>                              .     |--&gt;<span style="color: #000000;">TransferQueue::updateDirtyTiles()   </p><p>                              .     .    </span>|--&gt;<span style="color: #000000;">TransferQueue.updatePureColorTiles()</p><p>                              .     .    #################################################</span>| TexturesGenerator.add |<span style="color: #000000;">#######</p><p>                              .  .                          TileManager</span>-&gt;<span style="color: #000000;">m_transferQueue</p><p>                              .     .    ######################</span>|      |<span style="color: #000000;">###################################################</p><p>                              .     .  { </span><span style="color: #0000ff;">for</span> each Item <span style="color: #0000ff;">in</span><span style="color: #000000;"> m_transferQueueSize }</p><p>            </span>---------------------.--------------------------------------------------------------------------------------------------------<span style="color: #000000;"></p><p>            GpuUpload          .     .  </span>|--&gt;(GLConsumer)m_sharedSurfaceTexture-&gt;updateTexImage()  [frameworks/native/libs/gui/<span style="color: #000000;">GLConsumer.cpp]</p><p>                              .     .  .    </span>|--&gt;GLConsumer.acquireBufferLocked(&amp;<span style="color: #000000;">item) </p><p>                              .     .  .        </span>|--&gt;ConsumerBase::acquireBufferLocked(item)   [frameworks/native/libs/gui/<span style="color: #000000;">ConsumerBase.cpp]</p><p>                              .     .  .            </span>|--&gt;mBufferQueue-&gt;acquireBuffer(item)     [frameworks/native/libs/gui/<span style="color: #000000;">BufferQueue.cpp]</p><p>                              .     .  .</p><p>                              .     .  .            </span>-------------|  <span style="color: #0000ff;">set</span> mbuf(slotindex)|------------------------------------------------<span style="color: #000000;"></p><p>                              .     .  .                             Slot mSlots[]</p><p>                              .     .  .            </span>---------------| mCurrentTexture |--------------------------------------------------<span style="color: #000000;">    </p><p>                              .     .  .        </p><p>                              .     .  .    </span>|--&gt;GLConsumer.releaseAndUpdateLocked(item)     <span style="color: #800080;">1</span>. item.mgraphicBuffer-&gt;<span style="color: #000000;">EGLImage Tile</p><p>                              .     .  .</p><p>                              .     .  .    </span>---------------------------|  <span style="color: #0000ff;">set</span> |--------------------------------------------------------<span style="color: #000000;"></p><p>                              .     .  .                        mEglSlots[buf].mEglImage</p><p>                              .     .  .    </span>----------------------| mCurrentTexture |--------------------------------------------------<span style="color: #000000;"></p><p>                              .     .  .</p><p>                              .     .  .    </span>|--&gt;<span style="color: #000000;">GLConsumer.bindTextureImageLocked()         </p><p>                              .     .  .        </span>|--&gt;glEGLImageTargetTexture2DOES()          <span style="color: #800080;">2</span>. EGLImage -&gt;<span style="color: #000000;"> texture m_sharedSurfaceTextureId</p><p>                              .     .    .        </span>|--&gt;GLConsumer::doGLFenceWaitLocked()    <span style="color: #008000;">//</span><span style="color: #008000;"> Wait for the new buffer to be ready.</span></p><p>            ---------------------.-------------------------------------------------------------------------------------------------------<span style="color: #000000;">                </p><p>                              .     .    </span>|--&gt;destTexture-&gt;<span style="color: #000000;">requireGLTexture()</p><p>            </span>---------------------.-------------------------------------------------------------------------------------------------------<span style="color: #000000;"></p><p>            CpuUpload          .     .    </span>|--&gt;<span style="color: #000000;">GLUtils::updateTextureWithBitmap(TileTexture.m_ownTextureId,m_transferQueue[index].bitmap)</p><p>            </span>---------------------.-------------------------------------------------------------------------------------------------------<span style="color: #000000;"></p><p>            GpuUpload         .  .  </span>|--&gt;TransferQueue::blitTileFromQueue()  m_sharedSurfaceTextureId-&gt;m_fboID-&gt;<span style="color: #000000;">TileTexture.m_ownTextureId</p><p>            </span>---------------------.-------------------------------------------------------------------------------------------------------<span style="color: #000000;"></p><p>                              .     .    </span>|--&gt;m_transferQueueItemCond.signal()  --------------------------------------------------------------&gt;<span style="color: #000000;">\</p><p>                                                                                                                                           </span>|</p><p>                                 |--&gt;tilesManager-&gt;gatherTextures()                                                                         |</p><p>                                 |--&gt;ImagesManager::instance()-&gt;prepareTextures[webcore/platform/graphics<span style="color: #008000;">/*</span><span style="color: #008000;">/rendering/ImagesManager.cpp]    |</p><p>                              |--&gt;GLWebViewState::setupDrawing()    [webkit/android/nav/GLWebViewState.cpp]                                 |</p><p>                              .      |--&gt;tilesManager-&gt;shader()-&gt;initGLResources()[webcore/plat/gfx/</span><span style="color: #008000;">*/</span>rendering/ShaderProgram.cpp]             |<span style="color: #000000;"></p><p>                              .      </span>|--&gt;tilesManager-&gt;transferQueue()-&gt;initGLResources() init fbo,bufferQueue,GLConsumer sharedSurface     |<span style="color: #000000;"></p><p>    painting                  .      </span>|--&gt;shader-&gt;setupDrawing()                                                                             |<span style="color: #000000;"></p><p>                              .                                                                                                             </span>|</p><p>                              |--&gt;SurfaceCollectionManager::drawGL() [webcore/plat*/gfx/rendering/SurfaceCollectionManager.cpp]             |</p><p>           ------------------------------------------------------------------------------------------------------------------------------|-----<span style="color: #000000;"></p><p>             m_paintingCollection </span>|--&gt;m_paintingCollection-&gt;prepareGL() [webcore/plat*/gfx/rendering/SurfaceCollection.cpp]                 |<span style="color: #000000;"></p><p>                                    .  { m_paintingCollection</span>-&gt;isReady() }                                                                 |<span style="color: #000000;"></p><p>                                    .  </span>|--&gt;SurfaceCollectionManager.swap()                                                                 |<span style="color: #000000;"></p><p>                                    .        </span>|--&gt;m_drawingCollection  = m_paintingCollection; paintingcollection-&gt;drawingcollection         |<span style="color: #000000;"></p><p>                                  .          </span>|--&gt;m_paintingCollection = m_queuedCollection;  drawingcollection-&gt;m_paintingCollection         |<span style="color: #000000;"></p><p>                                  .          </span>|--&gt;m_queuedCollection   = <span style="color: #800080;">0</span> ;                                                                 |</p><p>           ----or------------------------------------------------------------------------------------------------------------------------|-----<span style="color: #000000;"></p><p>             m_drawingCollection  </span>|--&gt;m_paintingCollection-&gt;prepareGL()    [webcore/plat*/gfx/rendering/SurfaceCollection.cpp]                  |</p><p>           ------------------------------------------------------------------------------------------------------------------------------|-----<span style="color: #000000;"></p><p>                                     {either a swap just occurred, or there </span><span style="color: #0000ff;">is</span> no more work to be done: <span style="color: #0000ff;">do</span> a full draw}                     |</p><p>                                     |--&gt;m_drawingCollection-&gt;swapTiles()                                                                     |<span style="color: #000000;"></p><p>                                     {(didCollectionSwap </span>&amp;&amp; m_paintingCollection)}                                                             |</p><p>                                     |--&gt;m_paintingCollection-&gt;prepareGL()                                                                     |</p><p>           ------------------------------------------------------------------------------------------------------------------------------|-----</p><p>                                     |--&gt;SurfaceCollection::prepareGL()                                                                     |<span style="color: #000000;"></p><p>                                  .      { </span><span style="color: #0000ff;">for</span> each surface <span style="color: #0000ff;">in</span> WTF::Vector&lt;Surface*&gt; m_surfaces }                                             |<span style="color: #000000;"></p><p>                                  .   </span>|--&gt;m_surfaces[i]-&gt;prepareGL() [webcore/plat*/gfx/rendering/Surface.cpp]                             |<span style="color: #000000;"></p><p>                                  .        </span>|--&gt;m_surfaceBacking-&gt;prepareGL()                                                               |</p><p>                                ---------------------------------------------------------------------------------------------------------|------<span style="color: #000000;"></p><p>                                  .              </span>|--&gt;m_backTileGrid-&gt;prepareGL()                                                             |<span style="color: #000000;"></p><p>                                  .              </span>|--&gt;SurfaceBacking.swapTileGrids()  [webcore/plat*/gfx/rendering/SurfaceBacking.cpp]          |<span style="color: #000000;"></p><p>                                  .              </span>|--&gt;m_frontTileGrid-&gt;swapTiles()                                                             |</p><p>                                ---------------------------------------------------------------------------------------------------------|------<span style="color: #000000;"></p><p>                                  .              </span>|--&gt;m_frontTileGrid-&gt;prepareGL()                                                             |</p><p>                                ---------------------------------------------------------------------------------------------------------|------<span style="color: #000000;"></p><p>                                  .                 </span>|--&gt;TileGrid::prepareGL()  m_backTileGrid m_frontTileGrid m_lowResTileGrid             |<span style="color: #000000;"></p><p>                                  .                     </span>|--&gt;TileGrid.computeTilesArea() [webcore/plat*/gfx/rendering/TileGrid.cpp]             |<span style="color: #000000;"></p><p>                                  .                     {  </span><span style="color: #0000ff;">for</span> each (x,y) <span style="color: #0000ff;">in</span> m_area  }                                                          |<span style="color: #000000;"></p><p>                                  .                        </span>|--&gt;TileGrid.prepareTile(x,y)                                                      |<span style="color: #000000;"></p><p>                                  .                            </span>|--&gt;Tile* tile = getTile(x, y)                                                     |<span style="color: #000000;"></p><p>                                  .                            </span>|--&gt;tile-&gt;setContents()                                                           |<span style="color: #000000;"></p><p>                                  .                            </span>|--&gt;operation = <span style="color: #0000ff;">new</span> PaintTileOperation[*/PaintTileOperation.cpp]             |<span style="color: #000000;"></p><p>                                  .                            </span>|--&gt;tilesManager-&gt;scheduleOperation(operation)                                  |<span style="color: #000000;"></p><p>                                  .                                </span>|--&gt;m_textureGenerators[m_scheduleThread]-&gt;scheduleOperation()           |<span style="color: #000000;"></p><p>                                   .                                </span>|--&gt;TexturesGenerator::scheduleOperation ()                                 |<span style="color: #000000;"></p><p>                                   .                                    </span>|--&gt;mRequestedOperations.append(operation)                             |<span style="color: #000000;"></p><p>                                   .                             ##############################</span>|          |#######################         |<span style="color: #000000;"></p><p>                                    .  .                                  WTF::Vector</span>&lt;QueuedOperation*&gt; mRequestedOperations                 |<span style="color: #000000;"></p><p>                                    .     .                            #################################################################          </span>|</p><p>                         /&lt;--------------------------------------    |--&gt;mRequestedOperationsCond.signal()                                 |</p><p>   ----------------------|--------.------------------------------------------------------------------------------------------------------|------- </p><p>                         |          |--&gt;m_drawingCollection-&gt;drawGL()        [webcore/plat*/gfx/rendering/SurfaceCollection.cpp]                 |</p><p>                         |             |--&gt;(BaseLayerAndroid*)m_compositedRoot-&gt;drawTreeSurfacesGL()                                         |</p><p>                         |        /-----&gt;    |--&gt;LayerAndroid::drawTreeSurfacesGL()                                                             |</p><p>                         |        |              |--&gt;LayerAndroid.drawSurfaceAndChildrenGL [webcore/plat*/gfx/android/LayerAndroid.cpp]         |</p><p>                         |        |                 ( { <span style="color: #0000ff;">this</span>.surface()-&gt;getFirstLayer() == <span style="color: #0000ff;">this</span> } )                                             |</p><p>                         |  /&lt;--|---------------|--&gt;surface()-&gt;drawGL()                                                                     |</p><p>                         |    |    |                |--&gt;Layer::getChild()                                                                     |</p><p>                         |    |    |                |--&gt;sublayers.append(SkTDArray&lt;Layer*&gt; m_children)                                       |</p><p>                         |    |    |                 { <span style="color: #0000ff;">for</span> each layer <span style="color: #0000ff;">in</span>  sublayers }                                                         |</p><p>                         |    |    \---loop--------|--&gt;sublayers[i]-&gt;drawTreeSurfacesGL()                                                     |</p><p>                         |    |                                                                                                             |</p><p>                         |  \------------------&gt;|--&gt;Surface::drawGL()            [webcore/plat*/gfx/rendering/SurfaceCollection.cpp]      |</p><p>                         |                           |--&gt;m_surfaceBacking-&gt;drawGL                                                          |</p><p>                         |                           .  { draw low res prefetch page <span style="color: #0000ff;">if</span> zooming or front texture missing content }         |</p><p>                         |                           .  |--&gt;m_lowResTileGrid-&gt;drawGL() aggressiveRendering &amp;&amp; isMissingContent()             |</p><p>                         |                           .  |--&gt;m_frontTileGrid-&gt;drawGL()                                                         |</p><p>                         |                           .      |--&gt;m_area=TileGrid.computeTilesArea()                                          |</p><p>                         |                           .      |{ <span style="color: #0000ff;">for</span> each tile <span style="color: #0000ff;">in</span> TileGrid.m_tiles}                                             |</p><p>                         |                           .      |--&gt;Tile* tile = m_tiles[i]                                                     |</p><p>                         |                           .      |--&gt;tile-&gt;isTileVisible(m_area)  <span style="color: #0000ff;">if</span>(tile <span style="color: #0000ff;">in</span> m_area)                             |<span style="color: #000000;"></p><p>        Compositing        </span>|                           .          |--&gt;tile-&gt;drawGL()                                                           |</p><p>                         |                           .               |--&gt;m_frontTexture-&gt;drawGL()                                             |</p><p>                         |                            .                  |--&gt;TilesManager::instance()-&gt;shader()-&gt;drawQuad()                     |</p><p>                         |                           .                    |--&gt;matrix = getTileProjectionMatrix(data)  drawGl Position         |</p><p>                         |                           .                    |--&gt;ShaderProgram.drawQuadInternal()                             |</p><p>                         |                           .{ <span style="color: #008000;">//</span><span style="color: #008000;"> draw member layers (draws image textures, glextras) }                              |</span></p><p>                         |                           .{ <span style="color: #0000ff;">for</span> each layer <span style="color: #0000ff;">in</span> Vector&lt;LayerAndroid*&gt; m_layers }                                 |</p><p>                         |                           |--&gt;m_layers[i]-&gt;drawGL()                                                              |</p><p>                         |                                                                                                                  |</p><p>                         |                                                                                                                     |</p><p>                         |                                                                                                                 |</p><p>    ---------------------|---------------------------------------------------------------------------------------------------------------|------- </p><p>                         |                                                                              <span style="color: #800080;">1</span>                                     |<span style="color: #000000;"></p><p>$$$$$$$$$$$$$$$$$$$$$$$$$</span>|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$|<span style="color: #000000;">$$$$$$$$$</p><p>TexturesGenerator 线程</span>+++|++++++++++                                                               线程边界                              |                $$$$$$$$$$$$$$$$$$$$$$$$$|$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$|<span style="color: #000000;">$$$$$$$$$</p><p>    </span>|--&gt;TexturesGenerator::th|readLoop()                                                      NUM_TEXTURES_GENERATORS                         |            </p><p>       |--&gt;mRequestedOperati|onsCond.wait(mRequestedOperationsLock)                                                                            |<span style="color: #000000;"></p><p>       .                 </span>|                           +++++++++++++                                                                           |<span style="color: #000000;"></p><p>       .#################</span>|###########################| wait |###########################                                                   |<span style="color: #000000;">       </p><p>       .                 </span>|                    mRequestedOperationsCond                                                                       |<span style="color: #000000;"></p><p>       .###############</span>| |signal |######################################################                                                  |<span style="color: #000000;">  </p><p>       .              </span>+++++++++++++                                                                                                          |<span style="color: #000000;"></p><p>       .##############################################################                                                                     </span>|<span style="color: #000000;"></p><p>       .          WTF::Vector</span>&lt;QueuedOperation*&gt; mRequestedOperations                                                                      |<span style="color: #000000;"></p><p>       .#####################</span>|         |##############################                                                                   |</p><p>       |--&gt;currentOperation = popNext();                                                                                                 |</p><p>       |--&gt;BaseRenderer::swapRendererIfNeeded(m_renderer)                                                                                  |</p><p>       |--&gt;currentOperation-&gt;run(m_renderer)     [webcore/plat*/gfx/rendering/PaintTileOperation.cpp]                                     |</p><p>             |--&gt;m_tile-&gt;paintBitmap(m_painter, renderer)    [webcore/plat*/gfx/rendering/Tile.cpp]                                         |</p><p>                    |--&gt;TextureInfo* textureInfo = texture-&gt;getTextureInfo()        [webcore/plat*/gfx/rendering/TileTexture.h]                     |</p><p>                    |--&gt;(BaseRenderer)renderer-&gt;renderTiledContent(renderInfo)    [webcore/plat*/gfx/rendering/BaseRenderer.cpp]                 |</p><p>                     |--&gt;InstrumentedPlatformCanvas canvas()  [webcore/plat*/gfx/rendering/InstrumentedPlatformCanvas.cpp]                     |</p><p>---------------------------------------------------------------------------------------------------------------------------------------     |<span style="color: #000000;"></p><p>RasterRenderer      </span>|--&gt;RasterRenderer::setupCanvas    子类override      [webcore/plat*/gfx/rendering/RasterRenderer.cpp]                      |<span style="color: #000000;"></p><p>                  .   </span>|--&gt;SkDevice* device = <span style="color: #0000ff;">new</span> SkDevice(m_bitmap)                                                                          |<span style="color: #000000;"></p><p>                  .      </span>|--&gt;canvas-&gt;setDevice(device)                                                                                            |</p><p>                  |--&gt;renderInfo.tilePainter-&gt;paint(&amp;canvas);    TilePainter子类override                                                  |</p><p>                  |--&gt;BaseRenderer.checkForPureColor(renderInfo, canvas)    子类override [webcore/plat*/gfx/rendering/BaseRenderer.cpp]     |<span style="color: #000000;"></p><p>                  .      </span>|--&gt;RasterRenderer::deviceCheckForPureColor(renderInfo, &amp;canvas)                                                       |</p><p>                  |--&gt;RasterRenderer::renderingComplete(RasterRenderer.cpp)                                                                   |<span style="color: #000000;"></p><p>                  .  </span>|--&gt;GLUtils::paintTextureWithBitmap()                     [webcore/plat*/gfx/rendering/GLUtils.cpp]                     |</p><p>            ------------------------------------------------------------------------------------------------------------------             |<span style="color: #000000;"></p><p>                  .         </span>|--&gt;GLUtils::skipTransferForPureColor(renderInfo, bitmap)                                                          |<span style="color: #000000;"></p><p>                  .         .    </span>|--&gt;TilesManager::instance()-&gt;transferQueue()-&gt;addItemInPureColorQueue(renderInfo)                             |<span style="color: #000000;"></p><p>                  .         .        </span>|--&gt;TransferQueue.addItemCommon(renderInfo, GpuUpload, (TileTransferData)&amp;data)                             |</p><p>            -------------.----------------------------------------------------------------------------------------------------             |<span style="color: #000000;"></p><p>                  .      </span>|--&gt;GLUtils::updateQueueWithBitmap()                                                                               |<span style="color: #000000;"></p><p>                  .          </span>|--&gt;TilesManager::instance()-&gt;transferQueue()-&gt;updateQueueWithBitmap(renderInfo, bitmap)                     |<span style="color: #000000;"></p><p>                  .                </span>|--&gt;TransferQueue::updateQueueWithBitmap                                                                   |<span style="color: #000000;"></p><p>                  .                 .     </span>|--&gt;TransferQueue.tryUpdateQueueWithBitmap(renderInfo, bitmap)                   /&lt;--------------&lt;--+<span style="color: #000000;"></p><p>                  .                 .         </span>|--&gt;readyForUpdate()                                                         |                  |<span style="color: #000000;"></p><p>                  .                 .         .########################</span>|  wait  |##########################################|#######           |<span style="color: #000000;"></p><p>                  .                 .         .    m_transferQueueItemCond.wait(m_transferQueueItemLocks)sferQueueItemCond </span>|                  |<span style="color: #000000;"></p><p>                  .                 .         .######################################################################</span>| signal |###            |<span style="color: #000000;"></p><p>                  .                 .         .                                                                        </span>++++++++++             |</p><p>          --------.--------------.-------.----------------------------------------------------------------------------------------            |<span style="color: #000000;"></p><p>                   .                 .         </span>|--&gt;GLUtils::updateSharedSurfaceTextureWithBitmap(m_ANW.<span style="color: #0000ff;">get</span>(), bitmap)                         |<span style="color: #000000;"></p><p>                   .                 .         .    </span>|--&gt;ANativeWindow_Buffer buffer    [frameworks/native/include/android/Native_window.h]    |<span style="color: #000000;"></p><p>                  .                 .         .    </span>|--&gt;ANativeWindow_lock(anw, &amp;buffer, <span style="color: #800080;">0</span>)                                                    |<span style="color: #000000;"></p><p>         GpuUpload .                 .         .    </span>|--&gt;bitmap.lockPixels()                                                                   |<span style="color: #000000;"></p><p>                   .                 .         .    </span>|--&gt;buffer.bits &lt;-- bitmap.getPixels()                                                    |<span style="color: #000000;"></p><p>                   .                 .         .    </span>|--&gt;bitmap.unlockPixels()                                                                 |<span style="color: #000000;"></p><p>                   .                 .         .    </span>|--&gt;ANativeWindow_unlockAndPost()                                                         |</p><p>          --------.--------------.-------.----------------------------------------------------------------------------------------            |<span style="color: #000000;"></p><p>                    .                 .         </span>|--&gt;TransferQueue.addItemInTransferQueue(renderInfo, currentUploadType, bitmap)               |<span style="color: #000000;"></p><p>                    .                 .         .    </span>|--&gt;m_transferQueueIndex = (m_transferQueueIndex + <span style="color: #800080;">1</span>) % m_transferQueueSize              |<span style="color: #000000;"></p><p>                    .                 .         .    </span>|--&gt;TileTransferData* data = &amp;m_transferQueue[index]                                     |<span style="color: #000000;"></p><p>                    .                 .         .    </span>|--&gt;TransferQueue.addItemCommon(renderInfo, type, data)                                  |</p><p>          --------.--------------.-------.----------------------------------------------------------------------------------------            |<span style="color: #000000;"></p><p>        CpuUpload .                 .         .  </span>|--&gt;(*m_transferQueue[index].bitmap) = bitmap                                                |</p><p>          --------.--------------.------------------------------------------------------------------------------------------------            |<span style="color: #000000;"></p><p>                  .                 </span>|--&gt;tile-&gt;backTextureTransferFail()   mark to be retransferred                                            |</p><p>------------------.-----------------------------------------------------------------------------------------------------------------          |<span style="color: #000000;">    GaneshRenderer    </span>|--&gt;GaneshRenderer::setupCanvas()     [webcore/plat*/gfx/rendering/GaneshRenderer.cpp]                                      |<span style="color: #000000;"></p><p>                  .      </span>|--&gt;GaneshContext* ganesh = GaneshContext::instance()                                                                |<span style="color: #000000;"></p><p>                  .      </span>|--&gt;TransferQueue* tileQueue = TilesManager::instance()-&gt;transferQueue()                                             |</p><p>                  |   |--&gt;tileQueue-&gt;readyForUpdate()                                       /&lt;----------------------------&lt;-------------/<span style="color: #000000;">     </p><p>                  .   .   </span>+++++++++++++                                                      |<span style="color: #000000;">                    </p><p>                  .###.####</span>|  wait  |########################################################|<span style="color: #000000;">################</p><p>not available now .      .    Condition m_transferQueueItemCond                                     </span>|<span style="color: #000000;"></p><p>                  .###.##################################################################</span>| signal |<span style="color: #000000;">#########</p><p>                  .   .                                                                    </span>+++++++++++++<span style="color: #000000;"></p><p>                  .      </span>|--&gt;device = ganesh-&gt;getDeviceForTile(renderInfo)      <span style="color: #0000ff;">get</span> device <span style="color: #0000ff;">for</span> SkCanvas and <span style="color: #0000ff;">set</span><span style="color: #000000;"> EGLContext</p><p>                  .      .     </span>|--&gt;display =<span style="color: #000000;"> eglGetDisplay(EGL_DEFAULT_DISPLAY)</p><p>                  .      .     </span>|--&gt;eglInitialize(display, &amp;majorVersion, &amp;<span style="color: #000000;">minorVersion)</p><p>                  .      .     </span>|--&gt;eglChooseConfig(display, configAttribs, &amp;m_surfaceConfig, <span style="color: #800080;">1</span>, &amp;<span style="color: #000000;">numConfigs)</p><p>                  .      .     </span>|--&gt;m_surfaceContext =<span style="color: #000000;"> eglCreateContext(display, m_surfaceConfig, NULL, contextAttribs)</p><p>                  .      .     </span>|--&gt;TransferQueue* tileQueue = TilesManager::instance()-&gt;<span style="color: #000000;">transferQueue()</p><p>                  .      .     </span>|--&gt;ANativeWindow* anw = tileQueue-&gt;m_ANW.<span style="color: #0000ff;">get</span><span style="color: #000000;">(); </p><p>                  .      .     </span>|--&gt;<span style="color: #000000;">ANativeWindow_setBuffersGeometry()</p><p>                  .      .     </span>|--&gt;tileQueue-&gt;m_eglSurface =<span style="color: #000000;"> eglCreateWindowSurface(display, m_surfaceConfig, anw, NULL);</p><p>                  .      .     </span>|--&gt;eglMakeCurrent(display, tileQueue-&gt;m_eglSurface, tileQueue-&gt;<span style="color: #000000;">m_eglSurface, m_surfaceContext)</p><p>                  .      .     </p><p>                  .      .     </span>|--&gt;GrContext* grContext =<span style="color: #000000;"> getGrContext()</p><p>                  .      .     </span>|--&gt;GrRenderTarget* renderTarget = grContext-&gt;<span style="color: #000000;">createPlatformRenderTarget(renderTargetDesc)</p><p>                  .      .     </span>|--&gt;m_tileDeviceSurface = <span style="color: #0000ff;">new</span><span style="color: #000000;"> SkGpuDevice(grContext, renderTarget)</p><p>                  .      </span>|--&gt;canvas-&gt;<span style="color: #000000;">setDevice(m_tileDeviceSurface)</p><p>                  </span>|--&gt;renderInfo.tilePainter-&gt;paint(&amp;<span style="color: #000000;">canvas);</p><p>                  </span>|--&gt;<span style="color: #000000;">BaseRenderer.checkForPureColor(renderInfo, canvas)</p><p>                  .      </span>|--&gt;<span style="color: #000000;">GaneshRenderer::deviceCheckForPureColor(){}</p><p>                  </span>| --&gt;<span style="color: #000000;">GaneshRenderer::renderingComplete(GaneshRenderer.cpp)</p><p>                  .      </span>|--&gt;GaneshContext::instance()-&gt;<span style="color: #000000;">flush()</p><p>                  .      </span>|--&gt;TransferQueue* tileQueue = TilesManager::instance()-&gt;<span style="color: #000000;">transferQueue()</p><p>                  .      </span>|--&gt;eglSwapBuffers(eglGetCurrentDisplay(), tileQueue-&gt;<span style="color: #000000;">m_eglSurface)</p><p>                  .      </span>|--&gt;tileQueue-&gt;addItemInTransferQueue(&amp;<span style="color: #000000;">renderInfo, GpuUpload, dummyBitmap)</p><p>                     .          </span>|--&gt;m_transferQueueIndex = (m_transferQueueIndex + <span style="color: #800080;">1</span>) %<span style="color: #000000;"> m_transferQueueSize                     </p><p>                    .          </span>|--&gt;TileTransferData* data = &amp;<span style="color: #000000;">m_transferQueue[index]                                            </p><p>                    .          </span>|--&gt;<span style="color: #000000;">TransferQueue.addItemCommon(renderInfo, type, data)                                          </p><p>          </span>--------.--------------.-------.----------------------------------------------------------------------------------------<span style="color: #000000;">         </p><p>        CpuUpload .          </span>|--&gt;(*m_transferQueue[index].bitmap) =<span style="color: #000000;"> bitmap                                                    </p><p>          </span>--------.--------------.------------------------------------------------------------------------------------------------</p><p>------------------.------------------|---------------------------------------------------<span style="color: #000000;"></p><p>                     .                     </span>|<span style="color: #000000;"></p><p>                     .                     </span>|<span style="color: #000000;"></p><p>                                        \</span>/<span style="color: #000000;"></p><p>                    TransferQueue.addItemInTransferQueue(renderInfo, currentUploadType, bitmap)</p><p>#################################</span>|          |<span style="color: #000000;">################################################################                </p><p>                           TileManager</span>-&gt;m_transferQueue  --&gt;<span style="color: #000000;">  QueueBuffer (GraphicBuffer)                                          </p><p>#################################</span>|          |<span style="color: #000000;">######################################################################                </p><p>                 TilesManager::updateTilesIfContextVerified(TilesManager.cpp)</p><p></span>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>android 线程启动   </span><span style="color: #0000ff;">new</span> xxthread()-&gt;run   ---&gt; _threadLoop()---&gt;<span style="color: #000000;"> readyToRun() </p><p>                                                                   threadLoop</p><p>                                </p><p></span>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<span style="color: #000000;"></p><p>关键代码</p><p>TileManager</p><p>TransferQueue.cpp</p><p>GLComsumer.cpp (SurfaceTexture)</p><p>Tile.h</span>/.cpp

复制代码

分类: Android

来源URL:http://www.cnblogs.com/yaozhongxiao/p/3864868.html