Fix cached color glyph paint replay and add a Paint overload with a text cache - #422
Merged
Merged
Conversation
The Paint image processing extension created a private text cache for each frame canvas. The new overload passes an application-owned cache to every frame canvas so glyph geometry is shared across draws, matching the CreateCanvas overloads.
Cached color glyph layers re-create their paint brushes on replay. The cache stored the device-space glyph origin and appended the device-space delta after the drawing transform, so a draw whose transform carries an origin applied that offset twice and the gradient drifted off the glyph. Store the glyph origin before the drawing transform and apply the delta before it.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/3.1.x #422 +/- ##
=============================================
- Coverage 80% 80% -1%
=============================================
Files 232 232
Lines 27392 27407 +15
Branches 3120 3121 +1
=============================================
+ Hits 21969 21980 +11
Misses 4535 4535
- Partials 888 892 +4
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Prerequisites
Description
Fixes the wrong color of cached color emoji glyphs when a shared
DrawingTextCachereplays them at a new position, and adds aPaintoverload that takes aDrawingTextCache.Bug.
WebGPUWindowDemoscrolls a text block through a shared cache. The emoji in the block rendered flat brown except near one screen position. The same output appears on the CPU backend, so the cause is in the text renderer, not the GPU.Cause. Layered color glyphs re-create their paint brushes on replay.
RichTextGlyphRendererstored the device-space glyph origin in the cache and appended the device-space delta after the drawing transform. WhenDrawText(TextBlock, point)passes its origin throughDrawingOptions.Transform, that offset was applied twice. The radial gradient moved off the glyph and the pad color filled the face.Fix. The cache now stores the glyph origin before the drawing transform, and the replay applies the delta before the drawing transform. The replayed brush then matches a fresh build at the new position exactly.
API.
Paint(IImageProcessingContext, DrawingOptions, DrawingTextCache, CanvasAction)passes an application-owned cache to every frame canvas.PaintProcessorgets a matching constructor and aTextCacheproperty. This mirrors theCreateCanvasoverloads and lets theImage.Mutatepath share a cache.Tests.
DrawingTextCacheTests.LayeredGlyph_ReplayAtNewPositionMatchesFreshBuilddraws a color emoji through a shared cache at one point, then at a second point, and compares exactly against a fresh-cache draw at the second point. It fails on the old code and passes with the fix.ProcessWithCanvas.CanvasActionWithOptionsAndTextCachechecks that the processor receives the cache.