Browse Source
Merge pull request #2318 from AvaloniaUI/fixes/2015-snap-dirty-rects
Snap dirty rects in DeferredRenderer to device pixels.
pull/2366/head
Steven Kirk
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
15 additions and
3 deletions
-
src/Avalonia.Visuals/Rendering/DeferredRenderer.cs
|
|
|
@ -393,24 +393,36 @@ namespace Avalonia.Rendering |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
var scale = scene.Scaling; |
|
|
|
|
|
|
|
foreach (var rect in layer.Dirty) |
|
|
|
{ |
|
|
|
var snappedRect = SnapToDevicePixels(rect, scale); |
|
|
|
context.Transform = Matrix.Identity; |
|
|
|
context.PushClip(rect); |
|
|
|
context.PushClip(snappedRect); |
|
|
|
context.Clear(Colors.Transparent); |
|
|
|
Render(context, node, layer.LayerRoot, rect); |
|
|
|
Render(context, node, layer.LayerRoot, snappedRect); |
|
|
|
context.PopClip(); |
|
|
|
|
|
|
|
if (DrawDirtyRects) |
|
|
|
{ |
|
|
|
_dirtyRectsDisplay.Add(rect); |
|
|
|
_dirtyRectsDisplay.Add(snappedRect); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static Rect SnapToDevicePixels(Rect rect, double scale) |
|
|
|
{ |
|
|
|
return new Rect( |
|
|
|
Math.Floor(rect.X * scale) / scale, |
|
|
|
Math.Floor(rect.Y * scale) / scale, |
|
|
|
Math.Ceiling(rect.Width * scale) / scale, |
|
|
|
Math.Ceiling(rect.Height * scale) / scale); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void RenderOverlay(Scene scene, IDrawingContextImpl parentContent) |
|
|
|
|