[GUI] Replace Pixman 16.16 fixed-point gradient shader emulation (RecordedCairoGradient) with native SKShader gradients

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

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
52/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
csharp
Domain
performance

Research direction

Start with sources/Cairo/wrapper/RecordedCairoGradient.cs and inspect how Create records gradient stops and the matrix; then read RecordedCairoIntegerBlend.cs to see which blend modes use custom runtime effects. Compare those paths with Skia's native gradient and blend APIs. Done means both wrappers use the proposed native APIs and the per-gradient bitmap stop encoding is removed.

Written by the indexing model from the issue text.

Description

complexity: easy performance rendering

Problem

RecordedCairoGradient.Create (sources/Cairo/wrapper/RecordedCairoGradient.cs:14-95) bypasses Skia's native GPU gradient shaders (SKShader.CreateLinearGradient and SKShader.CreateRadialGradient) in order to emulate Pixman's 16.16 fixed-point gradient interpolation quirks:

  • Allocates a new SKBitmap(256, ...) on the CPU for every gradient.
  • Encodes stop offsets and 16-bit color channels into pixels via bitmap.SetPixel(...) calls.
  • Uploads the stop table bitmap as an SKImage child texture (SKImage.FromBitmap(bitmap)).
  • Evaluates a custom SkSL SKRuntimeEffect shader that reproduces Cairo's fixed16 matrix quantization and stop lookup math.

Similarly, RecordedCairoIntegerBlend.cs compiles custom SKRuntimeEffect blenders just to replicate 8-bit integer rounding differences in Difference and Exclusion blend modes.

Proposed Fix

  • Replace RecordedCairoGradient with direct calls to SKShader.CreateLinearGradient and SKShader.CreateRadialGradient using the recorded gradient stops and matrix.
  • Replace RecordedCairoIntegerBlend with native SKBlendMode.Difference and SKBlendMode.Exclusion.
  • Remove the per-gradient SKBitmap allocation and SetPixel stop-encoding loop.
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.