[GUI] Replace dual Cairo+Recorder command stream architecture with direct SKSurface/SKCanvas backing in Cairo wrapper

Open
#230 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
25/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp

Research direction

Start by reading the Cairo wrapper in sources/Cairo/wrapper/, especially the Cairo.ImageSurface and Cairo.Context implementations, along with the existing SurfaceRecorder and managed graphics state code. Trace how drawing calls reach the native Cairo surface and the recorder, then compare that flow with the proposed SKSurface and SKCanvas backing. Done means drawing is forwarded through SkiaSharp and the recorder, managed state, and pixel-emulation layers are removed.

Written by the indexing model from the issue text.

Description

complexity: hard enhancement performance rendering

Problem

The current SkiaSharp GUI implementation (sources/Cairo/wrapper/, +20,777 lines across 30 files) keeps native libcairo-2 surfaces alive alongside a custom command recorder (SurfaceRecorder, ManagedGraphicsState, RecordedGuiDrawing, RecordedPreparationCache):

  • Every Cairo.Context call records intermediate command objects and clones clip/path/paint state into SurfaceRecorder, while also maintaining fallback paths to materialize commands back onto a native libcairo-2 surface.
  • Keeping both libcairo-2 and SkiaSharp active duplicates graphics state tracking, inflates memory allocations during GuiComposer.Compose(), and prevents removing the native libcairo-2 dependency.

Proposed Fix

  • Back Cairo.ImageSurface directly with an SKSurface (GPU-backed when on the render thread with an active GRContext, or raster SKSurface when accessed from CPU pixel APIs such as DataPtr).
  • Make Cairo.Context a thin translation wrapper (~1,000 lines) that forwards drawing calls (MoveTo, LineTo, Arc, Rectangle, Fill, Stroke, Clip, ShowText, SetSource*) directly to the underlying SKCanvas, SKPath, SKPaint, and SKFont.
  • Eliminate SurfaceRecorder, ManagedGraphicsState, and the Cairo pixel-emulation layers once direct SKCanvas backing is in place.
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.