Fix RenderTargetBitmap looses effects#20790
Fix RenderTargetBitmap looses effects#20790timunie wants to merge 9 commits intoAvaloniaUI:masterfrom
Conversation
|
You can test this PR using the following package version. |
There was a problem hiding this comment.
Pull request overview
Fixes missing effect rendering (e.g., DropShadowEffect/BoxShadow) when rendering via RenderTargetBitmap.Render by introducing effect push/pop support in DrawingContext implementations and wiring effects into the immediate renderer/recording paths.
Changes:
- Added
DrawingContext.PushEffect(...)/PopEffectCore()plumbing across platform and composition drawing contexts. - Updated
ImmediateRendererto applyVisual.Effectduring immediate (RTB) rendering. - Added/updated Skia render tests + expected PNGs to cover RTB effects and
DrawingGroupeffects.
Reviewed changes
Copilot reviewed 9 out of 11 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Avalonia.Base/Media/DrawingContext.cs | Adds public PushEffect + new abstract core methods and restore-state handling. |
| src/Avalonia.Base/Rendering/ImmediateRenderer.cs | Pushes Visual.Effect during immediate tree traversal. |
| src/Avalonia.Base/Media/PlatformDrawingContext.cs | Implements effect push/pop for platform contexts that support effects. |
| src/Avalonia.Base/Rendering/Composition/Drawing/RenderDataDrawingContext.cs | Records effect nodes into composition render data. |
| src/Avalonia.Base/Rendering/Composition/Drawing/Nodes/RenderDataNodes.cs | Adds a render-data node to push/pop effects at playback time. |
| src/Avalonia.Base/Media/DrawingGroup.cs | Adds Effect property and records effect pushes when building drawing groups. |
| tests/Avalonia.RenderTests/Media/RenderTargetBitmapTests.cs | Adds RTB regression test for DropShadow rendering. |
| tests/Avalonia.RenderTests/Media/DrawingContextTests.cs | Adds render test for DrawingGroup with an effect push. |
| tests/Avalonia.Controls.UnitTests/Shapes/ShapeTests.cs | Updates test drawing context stub for new abstract methods. |
| tests/TestFiles/.../*.expected.png | Adds/updates expected outputs for new effect rendering behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
You can test this PR using the following package version. |
don't get lost at some point in time
32413df to
4f36cf4
Compare
|
You can test this PR using the following package version. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 12 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/Avalonia.Base/Rendering/ImmediateRenderer.cs:73
- ImmediateRenderer still uses
visualBounds = rect.TransformToAABB(totalTransform)for culling, which ignores the extra pixels produced byvisual.Effect(blur/drop shadow). This can cause a visual to be skipped entirely when its original bounds are outsideclipRectbut its effect output would intersect it. Consider inflatingrect(orvisualBounds) byeffect.GetEffectOutputPadding()before the intersection test, similar to how compositor subtree bounds are inflated for effects.
var totalTransform = transform * parentTransform;
var visualBounds = rect.TransformToAABB(totalTransform);
if (visualBounds.Intersects(clipRect))
{
visual.Render(context);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Avalonia.Base/Rendering/Composition/Drawing/RenderDataDrawingContext.cs
Outdated
Show resolved
Hide resolved
|
You can test this PR using the following package version. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 10 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
What does the pull request do?
RTB currently does not render effects such as
BoxShadow. This is caused by immediate renderer which has no API for it.What is the current behavior?
Effects are excluded from the RTB
What is the updated/expected behavior with this PR?
RTB can also save effects
How was the solution implemented (if it's not obvious)?
Added the needed Push / Pop-Effect methods
Checklist
Breaking changes
this adds Effect as a new API member
Obsoletions / Deprecations
Fixed issues
Fixes #20779
Fixes #19519 (cc @evanchen6185 if you want to add some feedback on this topic)