Android View 绘制和渲染

Drawing and Rendering

Posted by LXG on April 1, 2020

一文彻底搞懂Android View的绘制流程

深入Android渲染机制

Android基于Choreographer的渲染机制详解

App Launch Systrace

systrace_app_launch

View Drawing Rendering

view_drawing_rendering

performTraversals


//ViewRootImpl.java

private void performTraversals() {

    int childWidthMeasureSpec = getRootMeasureSpec(mWidth, lp.width);
    int childHeightMeasureSpec = getRootMeasureSpec(mHeight, lp.height);

    //执行测量流程
    performMeasure(childWidthMeasureSpec, childHeightMeasureSpec);

    //执行布局流程
    performLayout(lp, desiredWindowWidth, desiredWindowHeight);

    //执行绘制流程
    performDraw();
}

perform_traversals

View Rendering

UI对象—->CPU处理为多维图形,纹理—–通过OpeGL ES接口调用GPU—->GPU对图进行光栅化(Frame Rate)—->硬件时钟(Refresh Rate)—-垂直同步—->投射到屏幕

view_rendering