chromium for android 硬體渲染流程總結

來源:互聯網
上載者:User

標籤:des   android   blog   c   tar   ext   

render進程中

一.webkit模組
webkit引擎會為網頁內容同時建立Dom tree, Render tree和RenderLayer tree.
這三棵樹之間的關係參見chrome硬體渲染

每一個Render Object都關聯著一個RenderLayer.Render Object與RenderLayer是多對一的關係。
RenderLayer代表了網頁某一層的內容。正是由於RenderLayer的存在,網頁上的元素才可以按照
正確的順序合成,從而恰當的顯示有交疊的內容,和半透明元素等效果。
觸發RenderLayer建立的條件如下:
1.網頁的root節點;
2.有明確的CSS position屬性(relative,absolute,transform)
3.元素是透明的
4.overflow, alpha mask,或者reflection
5.有css filter(濾鏡) 屬性
6.有2D加速Context或者3D(webGL)context的 canvas 元素對應的RenderObject.
7.video元素對應的RenderObject。
RenderLayerCompositor負責管理所有RenderLayer的合成,並決定可以作為合成層的Layer.
只有滿足以下條件的RenderLayer才可以成為合成層(composited layer).
RenderLayer.h中定義了31個reasons:
    CompositingReason3DTransform                            
    CompositingReasonVideo                                 
    CompositingReasonCanvas                               
    CompositingReasonPlugin                                
    CompositingReasonIFrame                                 
    CompositingReasonBackfaceVisibilityHidden              
    CompositingReasonAnimation                              
    CompositingReasonFilters                               
    CompositingReasonPositionFixed                          
    CompositingReasonPositionSticky                      
    CompositingReasonOverflowScrollingTouch                
    CompositingReasonBlending                              
    CompositingReasonAssumedOverlap                        
    CompositingReasonOverlap                               
    CompositingReasonNegativeZIndexChildren                
    CompositingReasonTransformWithCompositedDescendants    
    CompositingReasonOpacityWithCompositedDescendants     
    CompositingReasonMaskWithCompositedDescendants          
    CompositingReasonReflectionWithCompositedDescendants    
    CompositingReasonFilterWithCompositedDescendants       
    CompositingReasonBlendingWithCompositedDescendants    
    CompositingReasonClipsCompositingDescendants           
    CompositingReasonPerspective                          
    CompositingReasonPreserve3D                             
    CompositingReasonReflectionOfCompositedParent         
    CompositingReasonRoot                             
    CompositingReasonLayerForClip                          
    CompositingReasonLayerForScrollbar                      
    CompositingReasonLayerForScrollingContainer           
    CompositingReasonLayerForForeground                     
    CompositingReasonLayerForBackground                    
    CompositingReasonLayerForMask                         
被認為是合成層的RenderLayer會建立RenderLayerBacking,RenderLayerBacking
與composited layer是一一對應的關係。RenderLayerBacking控制composited layer
的合成行為,並包含了多個GraphicsLayers。
GraphicsLayer是後端儲存的抽象表示。不同平台負責提供具體的後端儲存類給GraphicsLayer.
對於chromium for android平台提供的是cc模組的PictureLayer類。
是webkit::GraphicsLayer到cc::PictureLayer之間的關係:

當chromium for android硬體渲染流程全解析(render進程)中的流程一完成後,

webkit::RenderLayer tree表示的網頁內容就以網頁繪製命令的形式轉移到cc模組中。
簡單的說就是RenderLayer tree中的每個RenderLayer包含的網頁資訊都以繪製命令的形式儲存在了
LayerTreeHostImpl包含的LayerTreeImpl代表的cc::PictureLayer tree中了。
二.cc模組
1.網頁內容的光柵化,這個過程是在cpu上執行的,完成後,網頁內容以像素形式儲存在一塊SharedMemory上.
這塊SharedMemory可以跨進程使用。是由Render進程向Browser進程發送訊息,由Browser進程建立的,
並將sharedMemory的handle傳回給Render進程使用。這塊SharedMemory還會在GPU進程中使用。
2.網頁各層的混合過程。光柵化後,儲存網頁內容的SharedMemory在GPU進程中作為紋理資料的源上傳給gpu,
實現紋理貼圖(glTexImage2D)。chromium是分塊渲染的策略,TileManager管理的每個Tile最終都對應著一塊
texture(ResourceProvider負責分配的),SharedMemory中的網頁內容通過glTexImage2D最終渲染到了Tile
對應的texture上。
3.LayerTreeHostImpl::CalculateRenderPasses()記錄已經上傳了資料來源的需要渲染的Tile的資訊。
為LayerTreeHostImpl::DrawLayers()做準備.
4.LayerTreeHostImpl::DrawLayers()觸發的實際的繪製過程。(glDrawElements).
這個過程會先調用glFramebufferTexture2DEXT,將texture attach到render進程建立的off-screen surface對應的
framebuffer object上,再接著對每個Tile對應的texture調用glDrawElements,這個過程完成後,
網頁內容就被渲染到了attach到framebuffer上的textures上了,這些texture會被傳遞給browser進程。

Browser進程
Browser進程的主要工作是將render進程中包含網頁內容的texture合成到on-screen surface。
Browser進程建立的是on-screen surface,網頁內容最終要渲染到on-screen surface的back buffer上。
Browser進程調用eglswapbuffer後onscreen surface對應的back buffer和front buffer會互換,
下次螢幕重新整理時,front buffer的內容會顯示到螢幕上。具體流程參見chromium for android硬體渲染流程全解析(browser進程)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.