Skip to content

Commit

Permalink
fix(skia): Correctly handle SolidColorBrush opacity in inlines
Browse files Browse the repository at this point in the history
  • Loading branch information
Youssef1313 committed Feb 15, 2023
1 parent a5ebaf0 commit 8b05a85
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using System.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Uno.UI.RuntimeTests.Helpers;
using Windows.Foundation;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Documents;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Media.Imaging;
using static Private.Infrastructure.TestServices;

namespace Uno.UI.RuntimeTests.Tests.Windows_UI_Xaml_Controls
Expand Down Expand Up @@ -207,5 +211,25 @@ public async Task When_FontFamily_In_AndroidAsset()

Assert.AreNotEqual(originalSize, SUT.DesiredSize);
}

[TestMethod]
[RunsOnUIThread]
public async Task When_SolidColorBrush_With_Opacity()
{
var SUT = new TextBlock
{
Text = "••••••••",
FontSize = 24,
Foreground = new SolidColorBrush(Colors.Red) { Opacity = 0.5 },
};

WindowHelper.WindowContent = SUT;
await WindowHelper.WaitForIdle();

var renderer = new RenderTargetBitmap();
await renderer.RenderAsync(SUT);
var bitmap = await RawBitmap.From(renderer, SUT);
ImageAssert.HasColorInRectangle(bitmap, new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), Color.FromArgb(127, 127, 0, 0));
}
}
}
2 changes: 1 addition & 1 deletion src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ internal void Render(SKSurface surface, Compositor compositor)
red: scb.Color.R,
green: scb.Color.G,
blue: scb.Color.B,
alpha: (byte)(scb.Color.A * compositor.CurrentOpacity));
alpha: (byte)(scb.Color.A * scb.Opacity * compositor.CurrentOpacity));
}

var decorations = segment.Inline.TextDecorations;
Expand Down

0 comments on commit 8b05a85

Please sign in to comment.