Semantics for 2D Rasterization

📅 2026-03-24
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This work addresses the inefficiencies in 2D graphics rasterization caused by the semantic complexity and opaque execution model of existing libraries such as Skia, which often lead applications to emit suboptimal drawing commands. We present μSkia, the first formal semantics for Skia, mechanized in Lean and structured in three layers to precisely model canvas state, layer stacks, blending, and color filters, thereby achieving separation of concerns and extensibility. Building upon this semantics, we develop a high-performance optimizer that guarantees semantic correctness of transformations through pattern matching and translation validation, while uncovering several implicit side-effect conditions. Evaluated on 99 real-world Skia programs extracted from the Top 100 websites, the optimizer achieves an average speedup of 18.7% on modern GPU backends, with each optimization taking less than 32 microseconds and demonstrating consistent performance gains across multiple platforms.

Technology Category

Application Category

📝 Abstract
Rasterization is the process of determining the color of every pixel drawn by an application. Powerful rasterization libraries like Skia, CoreGraphics, and Direct2D put exceptional effort into drawing, blending, and rendering efficiently. Yet applications are still hindered by the inefficient sequences of operations that they ask these libraries to perform. Even Google Chrome, a highly optimized program co-developed with the Skia rasterization library, still produces inefficient instruction sequences even on the top 100 most visited websites. The underlying reason for this inefficiency is that rasterization libraries have complex semantics and opaque and non-obvious execution models. To address this issue, we introduce $μ$Skia, a formal semantics for the Skia 2D graphics library, and mechanize this semantics in Lean. $μ$Skia covers language and graphics features like canvas state, the layer stack, blending, and color filters, and the semantics itself is split into three strata to separate concerns and enable extensibility. We then identify four patterns of sub-optimal Skia code produced by Google Chrome, and then write replacements for each pattern. $μ$Skia allows us to verify the replacements are correct, including identifying numerous tricky side conditions. We then develop a high-performance Skia optimizer that applies these patterns to speed up rasterization. On 99 Skia programs gathered from the top 100 websites, this optimizer yields a speedup of 18.7% over Skia's most modern GPU backend, while taking at most 32 $μ$s for optimization. The speedups persist across a variety of websites, Skia backends, and GPUs. To provide true, end-to-end verification, optimization traces produced by the optimizer are loaded back into the $μ$Skia semantics and translation validated in Lean.
Problem

Research questions and friction points this paper is trying to address.

rasterization
semantics
graphics library
performance inefficiency
execution model
Innovation

Methods, ideas, or system contributions that make the work stand out.

formal semantics
rasterization optimization
Skia
Lean
translation validation
🔎 Similar Papers
No similar papers found.
B
Bhargav Kulkarni
University of Utah, USA
H
Henry Whiting
University of Utah, USA
Pavel Panchekha
Pavel Panchekha
University of Utah, Kahlert School of Computing
Web BrowsersNumerical AnalysisProgramming Languages