Repository navigation
Draw circle tiles on the GPU - #44
Merged
Merged
Conversation
On a Pixel 5a and a Lenovo TB520FU, Skia drew polygon and polyline tiles as fast or faster than the GPU path, while circle tiles were twice as fast on the GPU. ShapeTileRenderer.gpuPolygonsAndLines turns their GPU path on; the comparison tests do.
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Circle tiles are drawn with OpenGL ES 3.0 off screen instead of on a Canvas. Polygon and polyline tiles stay on the Canvas by default (see Measurements). Without GLES 3, or when
ShapeTileRenderer.useGpuis false, everything is drawn on the Canvas as before.This is the Android counterpart of MapConductor/ios-sdk-core#41.
GlShapeSceneWhat a tile draws, as plain float arrays. It does not touch GL, so it can be built and checked on the JVM.
GL_LESS. A line's own overlapping triangles paint once, later lines pass over earlier ones, and the whole tile is a single draw call. GLES has no stencil export, so this replaces the stencil numbers iOS uses.GlShapeRasterizerglReadPixels. The pixels go straight to the Rust PNG encoder (TilePngEncoder.encode(buffer, premultiplied = true)).ShapeTileRendereris created.Circles from the geometry file
CircleTilePainter.recordAllreads a nationwide set's records straight fromCircleTileFileStorage(forEachRecord) instead of decoding aTileCircleper circle, which took about 3.5 µs each.Switches
ShapeTileRenderer.useGpu = false: everything on the Canvas.ShapeTileRenderer.gpuPolygonsAndLines = true: polygons and polylines on the GPU too. It is off by default.Measurements
Example app on MapLibre, the tiles of the first view, GPU vs Canvas. Times are median / max / total.
Pixel 5a
Lenovo TB520FU
Circles are about 2x faster, with the slowest tile 2.1 to 2.7x faster. Polylines are about even. Polygons are slower on the GPU, because neighbouring parcels' boxes overlap, so a big tile splits into thousands of small batches. That is why polygons and polylines stay on the Canvas for now.
Tests
New
ShapeTileGpuDeviceTest(8 tests) draws the same tile on the GPU and on the Canvas and compares the pixels. It turnsgpuPolygonsAndLineson, so all three paths are covered. The cases are:The existing shape tile device tests (
CircleTileRendererDeviceTest,CircleTileFileDeviceTest,PolygonTileRendererDeviceTest,PolylineTileRendererDeviceTest) now run circles on the GPU path.All 45 device tests pass on a Lenovo TB520FU, and the unit tests pass.