diff --git a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs
index e9a1a2a6ae..e2fefffecc 100644
--- a/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs
+++ b/src/Avalonia.Visuals/Platform/IDrawingContextImpl.cs
@@ -31,7 +31,7 @@ namespace Avalonia.Platform
/// The rect in the output to draw to.
/// The bitmap interpolation mode.
/// The bitmap blending mode.
- void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default, BitmapBlendingMode bitmapBlendMode = BitmapBlendingMode.SourceOver);
+ void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default);
///
/// Draws a bitmap image.
@@ -149,6 +149,17 @@ namespace Avalonia.Platform
/// Pops the latest pushed geometry clip.
///
void PopGeometryClip();
+
+ ///
+ /// Pushes an bitmap blending value.
+ ///
+ /// The opacity.
+ void PushBitmapBlendMode(BitmapBlendingMode blendingMode);
+
+ ///
+ /// Pops the latest pushed bitmap blending value.
+ ///
+ void PopBitmapBlendMode();
///
/// Adds a custom draw operation
diff --git a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
index 692d40a653..b7d5d3ec59 100644
--- a/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
+++ b/src/Skia/Avalonia.Skia/DrawingContextImpl.cs
@@ -23,9 +23,11 @@ namespace Avalonia.Skia
private readonly Vector _dpi;
private readonly Stack _maskStack = new Stack();
private readonly Stack _opacityStack = new Stack();
+ private readonly Stack _blendingModeStack = new Stack();
private readonly Matrix? _postTransform;
private readonly IVisualBrushRenderer _visualBrushRenderer;
private double _currentOpacity = 1.0f;
+ private BitmapBlendingMode _currentBlendingMode = BitmapBlendingMode.SourceOver;
private readonly bool _canTextUseLcdRendering;
private Matrix _currentTransform;
private bool _disposed;
@@ -132,7 +134,7 @@ namespace Avalonia.Skia
}
///
- public void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode, BitmapBlendingMode bitmapBlendingMode)
+ public void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode)
{
var drawableImage = (IDrawableBitmapImpl)source.Item;
var s = sourceRect.ToSKRect();
@@ -145,7 +147,7 @@ namespace Avalonia.Skia
})
{
paint.FilterQuality = bitmapInterpolationMode.ToSKFilterQuality();
- paint.BlendMode = bitmapBlendingMode.ToSKBlendMode();
+ paint.BlendMode = _currentBlendingMode.ToSKBlendMode();
drawableImage.Draw(this, s, d, paint);
}
@@ -155,7 +157,7 @@ namespace Avalonia.Skia
public void DrawBitmap(IRef source, IBrush opacityMask, Rect opacityMaskRect, Rect destRect)
{
PushOpacityMask(opacityMask, opacityMaskRect);
- DrawBitmap(source, 1, new Rect(0, 0, source.Item.PixelSize.Width, source.Item.PixelSize.Height), destRect, BitmapInterpolationMode.Default, BitmapBlendingMode.SourceOver);
+ DrawBitmap(source, 1, new Rect(0, 0, source.Item.PixelSize.Width, source.Item.PixelSize.Height), destRect, BitmapInterpolationMode.Default);
PopOpacityMask();
}
@@ -509,6 +511,19 @@ namespace Avalonia.Skia
Canvas.Restore();
}
+ ///
+ public void PushBitmapBlendMode(BitmapBlendingMode blendingMode)
+ {
+ _blendingModeStack.Push(_currentBlendingMode);
+ _currentBlendingMode = blendingMode;
+ }
+
+ ///
+ public void PopBitmapBlendMode()
+ {
+ _currentBlendingMode = _blendingModeStack.Pop();
+ }
+
public void Custom(ICustomDrawOperation custom) => custom.Render(this);
///
diff --git a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs
index 0f5a932ef3..efe581ae0d 100644
--- a/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs
+++ b/src/Windows/Avalonia.Direct2D1/Media/DrawingContextImpl.cs
@@ -117,7 +117,7 @@ namespace Avalonia.Direct2D1.Media
/// The rect in the image to draw.
/// The rect in the output to draw to.
/// The bitmap interpolation mode.
- public void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode, BitmapBlendingMode bitmapBlendingMode)
+ public void DrawBitmap(IRef source, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode)
{
using (var d2d = ((BitmapImpl)source.Item).GetDirect2DBitmap(_deviceContext))
{
@@ -557,6 +557,16 @@ namespace Avalonia.Direct2D1.Media
PopLayer();
}
+ public void PushBitmapBlendMode(BitmapBlendingMode blendingMode)
+ {
+ // Stubs for now
+ }
+
+ public void PopBitmapBlendMode()
+ {
+ // Stubs for now
+ }
+
public void PushOpacityMask(IBrush mask, Rect bounds)
{
var parameters = new LayerParameters