Skip to content

(Un)premultiply colors in begin/end modify image + another fix - #10

Merged
flabbet merged 2 commits into
mainfrom
graph-color-fixes
Aug 18, 2026
Merged

(Un)premultiply colors in begin/end modify image + another fix#10
flabbet merged 2 commits into
mainfrom
graph-color-fixes

Conversation

@Equbuxu

@Equbuxu Equbuxu commented Aug 12, 2026

Copy link
Copy Markdown
Member

@Equbuxu Equbuxu changed the title (Un)premultiply colors in begin/end modify image, other fixes (Un)premultiply colors in begin/end modify image + another fix Aug 12, 2026
@Equbuxu
Equbuxu marked this pull request as ready for review August 12, 2026 20:25
@Equbuxu
Equbuxu requested a review from flabbet August 12, 2026 20:25

@flabbet flabbet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good to me, requesting clanker for obvious mistakes

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the shader generation pipeline to work with straight-alpha colors during shader execution (by unpremultiplying sampled surface colors) and includes a parsing fix in the Skia shader implementation to correctly detect uniform types when the uniform name overlaps with layout/type tokens (e.g., layout(color) ... color).

Changes:

  • Unpremultiply sampled half4 surface colors in ShaderBuilder.Sample(...) before returning them to shader expressions.
  • Add a built-in Unpremultiply shader function (and a GetUnpremultiply(...) wrapper) to support the new sampling behavior.
  • Fix SkiaShaderImplementation.TryDetectType(...) by removing only the last occurrence of the uniform name when analyzing the declaration string.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/Drawie.Backend.Skia/Implementations/SkiaShaderImplementation.cs Fixes uniform type detection for edge cases where the uniform name appears in layout/type tokens.
src/Drawie.Backend.Core/Shaders/Generation/ShaderBuilder.cs Unpremultiplies sampled surface colors before returning them to shader expressions.
src/Drawie.Backend.Core/Shaders/Generation/BuiltInFunctions.cs Adds an Unpremultiply built-in shader function used by ShaderBuilder.Sample(...).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

return null;
}

private static string RemoveLastOccurance(string text, string toRemove)
@flabbet
flabbet merged commit 63ff38d into main Aug 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants