[GUI] Remove CPU scanline polygon rasterizer (RecordedCoarseGeometry) and 4x4 CPU supersampling (RecordedGeometryCoverage) from Skia GPU path

Open
#227 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
32/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
performance

Research direction

Start with sources/Cairo/wrapper/RecordedCoarseGeometry.cs and sources/Cairo/wrapper/RecordedGeometryCoverage.cs, then inspect the Skia GUI drawing path and pixel-diff tests. Compare the current CPU mask generation with drawing paths and dashed strokes through SKCanvas, and identify which tests need tolerance changes. Done means both CPU rasterizers are removed, GPU drawing uses Skia anti-aliasing and dash effects, and pixel-diff tests pass with appropriate tolerances.

Written by the indexing model from the issue text.

Description

complexity: medium performance rendering

Problem

To match libcairo-2 fixed-point scanline rounding pixel-for-pixel in synthetic diff tests, the Skia GUI pipeline rasterizes paths on the CPU using per-pixel GetPixel / SetPixel loops and uploads the resulting alpha masks as textures:

  1. RecordedCoarseGeometry.Fast (sources/Cairo/wrapper/RecordedCoarseGeometry.cs:112-151):
    • Implements a software scanline polygon rasterizer in C# using Int128 fixed-point edge division (FixedX), per-scanline List<Edge> allocations and active.Sort(...) calls across 4 sub-rows per pixel row, followed by bitmap.SetPixel(x - left, y - top, ...) and SKImage.FromBitmap(bitmap).
  2. RecordedCoarseGeometry.Aliased (sources/Cairo/wrapper/RecordedCoarseGeometry.cs:76-110):
    • Converts aliased paths into thousands of 1-pixel-tall SKRect spans on the CPU by sorting active edges at y + 127.0 / 256 on every row.
  3. RecordedGeometryCoverage.Capture (sources/Cairo/wrapper/RecordedGeometryCoverage.cs:22-50):
    • Allocates 4x-scaled SKBitmap tiles on the CPU, averages alpha coverage in a quadruple nested loop calling tile.GetPixel(x * scale + sx, y * scale + sy) and mask.SetPixel(...), and uploads the CPU mask via SKImage.FromBitmap(mask).

Running software scanline rasterization and GetPixel/SetPixel supersampling on the CPU inside the GPU rendering path defeats hardware acceleration and adds substantial CPU and GC overhead.

Proposed Fix

  • Delete RecordedCoarseGeometry and RecordedGeometryCoverage.
  • Draw paths and dashed strokes directly on the GPU SKCanvas using standard SKPaint anti-aliasing (IsAntialias = antialias != Antialias.None) and native SKPathEffect.CreateDash.
  • Relax pixel-diff test tolerances where needed to allow standard Skia GPU anti-aliasing rather than emulating Cairo 24.8 fixed-point scanline quantization on the CPU.
Dominant language
C#
Stars
22
Forks
4
Avg merge
1h 11m
Merged PRs (30d)
40

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from StratumServer/Optimum

All issues in StratumServer/Optimum

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.