diff --git a/src/Avalonia.Controls/ComboBox.cs b/src/Avalonia.Controls/ComboBox.cs
index 02a9daee75..7f2acb58fe 100644
--- a/src/Avalonia.Controls/ComboBox.cs
+++ b/src/Avalonia.Controls/ComboBox.cs
@@ -173,11 +173,10 @@ namespace Avalonia.Controls
ComboBoxItem.ContentTemplateProperty);
}
- ///
- protected override void OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs e)
+ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
{
- base.OnAttachedToLogicalTree(e);
- this.UpdateSelectionBoxItem(this.SelectedItem);
+ base.OnAttachedToVisualTree(e);
+ this.UpdateSelectionBoxItem(SelectedItem);
}
///
@@ -373,19 +372,22 @@ namespace Avalonia.Controls
if (control != null)
{
- control.Measure(Size.Infinity);
-
- SelectionBoxItem = new Rectangle
+ if (VisualRoot is object)
{
- Width = control.DesiredSize.Width,
- Height = control.DesiredSize.Height,
- Fill = new VisualBrush
+ control.Measure(Size.Infinity);
+
+ SelectionBoxItem = new Rectangle
{
- Visual = control,
- Stretch = Stretch.None,
- AlignmentX = AlignmentX.Left,
- }
- };
+ Width = control.DesiredSize.Width,
+ Height = control.DesiredSize.Height,
+ Fill = new VisualBrush
+ {
+ Visual = control,
+ Stretch = Stretch.None,
+ AlignmentX = AlignmentX.Left,
+ }
+ };
+ }
}
else
{
diff --git a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
index 872f69c884..7d5d62a091 100644
--- a/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
+++ b/src/Avalonia.Visuals/Rendering/SceneGraph/SceneBuilder.cs
@@ -24,7 +24,8 @@ namespace Avalonia.Rendering.SceneGraph
using (var impl = new DeferredDrawingContextImpl(this, scene.Layers))
using (var context = new DrawingContext(impl))
{
- Update(context, scene, (VisualNode)scene.Root, scene.Root.Visual.Bounds, true);
+ var clip = new Rect(scene.Root.Visual.Bounds.Size);
+ Update(context, scene, (VisualNode)scene.Root, clip, true);
}
}
@@ -77,7 +78,7 @@ namespace Avalonia.Rendering.SceneGraph
using (var impl = new DeferredDrawingContextImpl(this, scene.Layers))
using (var context = new DrawingContext(impl))
{
- var clip = scene.Root.Visual.Bounds;
+ var clip = new Rect(scene.Root.Visual.Bounds.Size);
if (node.Parent != null)
{
@@ -174,7 +175,9 @@ namespace Avalonia.Rendering.SceneGraph
if (visual.IsVisible)
{
- var m = Matrix.CreateTranslation(visual.Bounds.Position);
+ var m = node != scene.Root ?
+ Matrix.CreateTranslation(visual.Bounds.Position) :
+ Matrix.Identity;
var renderTransform = Matrix.Identity;
diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
index 44e0c82110..2a79a4bb50 100644
--- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
+++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
@@ -434,7 +434,7 @@ namespace Avalonia.Skia
///
public IDrawingContextLayerImpl CreateLayer(Size size)
{
- return CreateRenderTarget( size);
+ return CreateRenderTarget(size, true);
}
///
@@ -673,7 +673,7 @@ namespace Avalonia.Skia
private void ConfigureTileBrush(ref PaintWrapper paintWrapper, Size targetSize, ITileBrush tileBrush, IDrawableBitmapImpl tileBrushImage)
{
var calc = new TileBrushCalculator(tileBrush, tileBrushImage.PixelSize.ToSizeWithDpi(_dpi), targetSize);
- var intermediate = CreateRenderTarget(calc.IntermediateSize);
+ var intermediate = CreateRenderTarget(calc.IntermediateSize, false);
paintWrapper.AddDisposable(intermediate);
@@ -748,7 +748,7 @@ namespace Avalonia.Skia
if (intermediateSize.Width >= 1 && intermediateSize.Height >= 1)
{
- var intermediate = CreateRenderTarget(intermediateSize);
+ var intermediate = CreateRenderTarget(intermediateSize, false);
using (var ctx = intermediate.CreateDrawingContext(visualBrushRenderer))
{
@@ -978,9 +978,10 @@ namespace Avalonia.Skia
/// Create new render target compatible with this drawing context.
///
/// The size of the render target in DIPs.
+ /// Whether the render target is being created for a layer.
/// Pixel format.
///
- private SurfaceRenderTarget CreateRenderTarget(Size size, PixelFormat? format = null)
+ private SurfaceRenderTarget CreateRenderTarget(Size size, bool isLayer, PixelFormat? format = null)
{
var pixelSize = PixelSize.FromSizeWithDpi(size, _dpi);
var createInfo = new SurfaceRenderTarget.CreateInfo
@@ -992,7 +993,8 @@ namespace Avalonia.Skia
DisableTextLcdRendering = !_canTextUseLcdRendering,
GrContext = _grContext,
Gpu = _gpu,
- Session = _session
+ Session = _session,
+ DisableManualFbo = !isLayer,
};
return new SurfaceRenderTarget(createInfo);
diff --git a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs
index d6f76a2c20..72700fb8fd 100644
--- a/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs
+++ b/src/Skia/Avalonia.Skia/PlatformRenderInterface.cs
@@ -124,7 +124,8 @@ namespace Avalonia.Skia
Width = size.Width,
Height = size.Height,
Dpi = dpi,
- DisableTextLcdRendering = false
+ DisableTextLcdRendering = false,
+ DisableManualFbo = true,
};
return new SurfaceRenderTarget(createInfo);
diff --git a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs
index 6347c64aed..01b7449b64 100644
--- a/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs
+++ b/src/Skia/Avalonia.Skia/SurfaceRenderTarget.cs
@@ -51,7 +51,8 @@ namespace Avalonia.Skia
_grContext = createInfo.GrContext;
_gpu = createInfo.Gpu;
- _surface = _gpu?.TryCreateSurface(PixelSize, createInfo.Session);
+ if (!createInfo.DisableManualFbo)
+ _surface = _gpu?.TryCreateSurface(PixelSize, createInfo.Session);
if (_surface == null)
_surface = new SkiaSurfaceWrapper(CreateSurface(createInfo.GrContext, PixelSize.Width, PixelSize.Height,
createInfo.Format));
@@ -220,6 +221,8 @@ namespace Avalonia.Skia
public ISkiaGpu Gpu;
public ISkiaGpuRenderSession Session;
+
+ public bool DisableManualFbo;
}
}
}
diff --git a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
index 783215fb5d..c8a30a42e9 100644
--- a/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
+++ b/tests/Avalonia.Controls.UnitTests/ComboBoxTests.cs
@@ -40,6 +40,7 @@ namespace Avalonia.Controls.UnitTests
Items = items,
SelectedIndex = 0,
};
+ var root = new TestRoot(target);
var rectangle = target.GetValue(ComboBox.SelectionBoxItemProperty) as Rectangle;
Assert.NotNull(rectangle);