Skip to content

Commit b9a091e

Browse files
Merge pull request #19427 from ramezgerges/textblock_foreground_fallbackcolor
2 parents 0a0e10c + 6894dbb commit b9a091e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/SamplesApp/UITests.Shared/Windows_UI_Xaml_Media/GradientBrushTests/GradientsPage.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@
328328
</Rectangle.Stroke>
329329
</Rectangle>
330330
</StackPanel>
331-
<TextBlock FontSize="15">Text with Radial/Linear gradient as foreground brush (fallback=green)</TextBlock>
331+
<TextBlock FontSize="15">Text with Radial/Linear gradient as foreground brush (fallback=red)</TextBlock>
332332
<StackPanel Orientation="Horizontal" Spacing="10">
333333
<TextBlock Text="UNO" FontSize="110" FontWeight="Bold">
334334
<TextBlock.Foreground>

src/Uno.UI/UI/Xaml/Documents/InlineCollection.skia.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,24 @@ internal void Draw(in Visual.PaintingSession session)
514514
blue: scbColor.B,
515515
alpha: (byte)(scbColor.A * scb.Opacity * session.Filters.Opacity));
516516
}
517+
else if (inline.Foreground is GradientBrush gb)
518+
{
519+
var gbColor = gb.FallbackColorWithOpacity;
520+
paint.Color = new SKColor(
521+
red: gbColor.R,
522+
green: gbColor.G,
523+
blue: gbColor.B,
524+
alpha: (byte)(gbColor.A * session.Filters.Opacity));
525+
}
526+
else if (inline.Foreground is XamlCompositionBrushBase xcbb)
527+
{
528+
var gbColor = xcbb.FallbackColorWithOpacity;
529+
paint.Color = new SKColor(
530+
red: gbColor.R,
531+
green: gbColor.G,
532+
blue: gbColor.B,
533+
alpha: (byte)(gbColor.A * session.Filters.Opacity));
534+
}
517535

518536
// TODO: Consider using a stackalloc for small values of GlyphsLength.
519537
// Note that using a stackalloc will require refactoring this code to a separate method to avoid having a stackalloc in a loop.

0 commit comments

Comments
 (0)