Mobile Development 13 min read

Understanding Android HWUI, Skia, and OpenGL Rendering Pipeline

The article explains Android’s graphics pipeline by detailing how HWUI and Skia translate view operations into OpenGL ES commands, describing RenderThread stages such as synchronization, dirty‑region calculation, buffer handling, and drawing, and comparing mobile GPU architectures like TBR, TBDR, and IMR.

OPPO Kernel Craftsman
OPPO Kernel Craftsman
OPPO Kernel Craftsman
Understanding Android HWUI, Skia, and OpenGL Rendering Pipeline

Background

In Android, the graphics rendering subsystem consists mainly of HWUI and RenderEngine. Every pixel displayed on the screen passes through these modules. A simplified rendering flow starts with view operations being converted into a RenderNode DisplayList, which stores drawing commands and their hierarchy.

1. HWUI and Skia Overview

HWUI has evolved significantly across Android versions (1.0, 3.0, 4.0, Q) and now drives hardware‑accelerated drawing. Skia acts as the middleware that translates HWUI commands into OpenGL ES calls, which finally drive the GPU.

2. RenderThread Rendering Stages

The RenderThread pipeline is divided into several stages:

2.1 Synchronize View Tree – Configures the rendering environment, uploads textures (checking a texture cache keyed by size and format), and builds the View tree by recursively traversing child nodes and syncing their DisplayLists to RenderNodes.

2.2 Calculate Layout Dirty Region – Recursively computes the intersection of child and parent RenderNodes to determine the minimal region that needs to be redrawn, reducing power consumption.

2.3 dequeueBuffer – Calls eglQuerySurface via queryBufferAge to obtain a buffer from the GPU.

2.4 Calculate Frame‑to‑Previous‑Frame Dirty Region – Performs a union of the current frame’s dirty area with the previously recorded dirty region in the BufferQueue, enabling partial updates.

2.5 Draw Process – Creates a BackendRenderTarget for the current Surface, iterates the DisplayList via renderFrame , and uses renderLayersImpl to draw off‑screen buffers for views with damage regions. The final RenderNode tree is then rendered directly.

2.6 queueBuffer – Calls Surface::setSurfaceDamage and eglSwapBuffersWithDamageKHR to submit the rendered buffer and trigger the onFrameAvailable callback.

3. OpenGL Basics

The programmable stages of the OpenGL pipeline include Vertex Shader, Tessellation Shader, Geometry Shader, and Fragment Shader. These stages enable complex model rendering, with each shader handling specific tasks such as vertex transformation, triangle generation, and pixel coloring.

4. GPU Hardware Architectures

Three major GPU rendering architectures are described:

4.1 IMR (Immediate Mode Rendering) – A linear, sequential pipeline used mainly on PCs. Commands are executed immediately, and the framebuffer resides in system memory. Advantages: simple flow; Disadvantages: high bandwidth consumption.

4.2 TBR (Tile‑Based Rendering) – Optimized for mobile devices by dividing the framebuffer into tiles. After vertex processing, a binning pass assigns triangles to tiles, which are then rasterized and shaded tile‑by‑tile, reducing bandwidth by using on‑chip memory.

4.3 TBDR (Tile‑Based Deferred Rendering) – Similar to TBR but defers pixel shading until all tiles have been rasterized, further improving bandwidth at the cost of some latency.

4.4 EarlyZ & HSR (Hierarchical Z‑Buffer) – EarlyZ performs a fast depth test to cull fragments, while HSR postpones shading until after all fragments are generated, completely eliminating overdraw for opaque geometry.

5. Demonstrations

The article includes simple demos that illustrate how to draw a triangle using Skia and OpenGL, reinforcing the theoretical concepts with practical code snippets (not reproduced here).

Conclusion

The article provides a concise overview of Android’s graphics stack—from HWUI and Skia to OpenGL and GPU architectures—enabling readers to grasp the fundamentals of rendering pipelines and to explore AOSP source code for deeper investigation.

RenderingAndroidGPUOpenGLSkiaHWUI
OPPO Kernel Craftsman
Written by

OPPO Kernel Craftsman

Sharing Linux kernel-related cutting-edge technology, technical articles, technical news, and curated tutorials

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.