Browse Source

Glitches

pull/8105/head
Nikita Tsukanov 4 years ago
parent
commit
85c5377307
  1. 2
      src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs
  2. 18
      src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs

2
src/Avalonia.Base/Rendering/Composition/Server/ServerCompositionTarget.cs

@ -152,6 +152,8 @@ namespace Avalonia.Rendering.Composition.Server
} }
} }
public Rect SnapToDevicePixels(Rect rect) => SnapToDevicePixels(rect, Scaling);
private static Rect SnapToDevicePixels(Rect rect, double scale) private static Rect SnapToDevicePixels(Rect rect, double scale)
{ {
return new Rect( return new Rect(

18
src/Avalonia.Base/Rendering/Composition/Server/ServerVisual.cs

@ -47,7 +47,7 @@ namespace Avalonia.Rendering.Composition.Server
canvas.PushOpacity(Opacity); canvas.PushOpacity(Opacity);
var boundsRect = new Rect(new Size(Size.X, Size.Y)); var boundsRect = new Rect(new Size(Size.X, Size.Y));
if(ClipToBounds) if(ClipToBounds)
canvas.PushClip(boundsRect); canvas.PushClip(Root!.SnapToDevicePixels(boundsRect));
if (Clip != null) if (Clip != null)
canvas.PushGeometryClip(Clip); canvas.PushGeometryClip(Clip);
if(OpacityMaskBrush != null) if(OpacityMaskBrush != null)
@ -162,22 +162,28 @@ namespace Avalonia.Rendering.Composition.Server
if (wasVisible != IsVisibleInFrame) if (wasVisible != IsVisibleInFrame)
_isDirtyForUpdate = true; _isDirtyForUpdate = true;
var dirtyOldBounds = false;
// Invalidate previous rect and queue new rect based on visibility // Invalidate previous rect and queue new rect based on visibility
if (positionChanged) if (positionChanged)
{ {
if(wasVisible) if (wasVisible)
AddDirtyRect(oldTransformedContentBounds.Intersect(oldCombinedTransformedClipBounds)); dirtyOldBounds = true;
if (IsVisibleInFrame) if (IsVisibleInFrame)
_isDirtyForUpdate = true; _isDirtyForUpdate = true;
} }
// Invalidate new bounds // Invalidate new bounds
if (IsVisibleInFrame && _isDirtyForUpdate) if (IsVisibleInFrame && _isDirtyForUpdate)
{
dirtyOldBounds = true;
AddDirtyRect(TransformedOwnContentBounds.Intersect(_combinedTransformedClipBounds)); AddDirtyRect(TransformedOwnContentBounds.Intersect(_combinedTransformedClipBounds));
}
if (dirtyOldBounds && wasVisible)
AddDirtyRect(oldTransformedContentBounds.Intersect(oldCombinedTransformedClipBounds));
_isDirtyForUpdate = false; _isDirtyForUpdate = false;
// Update readback indices // Update readback indices

Loading…
Cancel
Save