Skip to content

Commit

Permalink
Merge pull request #75 from taublast/2-A
Browse files Browse the repository at this point in the history
changes for prod
  • Loading branch information
taublast authored Jun 25, 2024
2 parents 1e9525a + c5eb9ef commit f76cf57
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
16 changes: 8 additions & 8 deletions src/Engine/Draw/Cache/SkiaRenderObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,22 +41,22 @@ public void Draw(SKCanvas canvas, SKRect destination, SKPaint paint)
{
if (Picture != null)
{
var x = destination.Left - Bounds.Left;
var y = destination.Top - Bounds.Top;
//var x = destination.Left - Bounds.Left;
//var y = destination.Top - Bounds.Top;

//var x = (float)Math.Round(destination.Left - Bounds.Left);
//var y = (float)Math.Round(destination.Top - Bounds.Top);
var x = (float)Math.Round(destination.Left - Bounds.Left);
var y = (float)Math.Round(destination.Top - Bounds.Top);

canvas.DrawPicture(Picture, x, y, paint);
}
else
if (Image != null)
{
var x = destination.Left;
var y = destination.Top;
//var x = destination.Left;
//var y = destination.Top;

//var x = (float)Math.Round(destination.Left);
//var y = (float)Math.Round(destination.Top);
var x = (float)Math.Round(destination.Left);
var y = (float)Math.Round(destination.Top);

canvas.DrawImage(Image, x, y, paint);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Engine/Draw/Layout/SkiaLayout.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ public ViewsAdapter ChildrenFactory
propertyChanged: NeedUpdateItemsSource);

/// <summary>
/// Number of columns/rows to split into, If 0 will not split at all, if 1 will have single column/row.
/// For Wrap number of columns/rows to split into, If 0 will use auto, if 1+ will have 1+ columns.
/// </summary>
public int Split
{
Expand Down
4 changes: 2 additions & 2 deletions src/Engine/Draw/Scroll/SkiaScroll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2693,8 +2693,8 @@ protected override void Draw(SkiaDrawingContext context, SKRect destination,

if (!CheckIsGhost())
{
var posX = (ViewportOffsetX * _zoomedScale);
var posY = (ViewportOffsetY * _zoomedScale);
var posX = (float)Math.Round(ViewportOffsetX * _zoomedScale);
var posY = (float)Math.Round(ViewportOffsetY * _zoomedScale);

var needReposition =
_updatedViewportForPixY != posY
Expand Down
12 changes: 12 additions & 0 deletions src/Engine/Draw/Text/SkiaLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -357,16 +357,19 @@ void UpdateFontMetrics(SKPaint paint)
public SKPaint PaintDefault = new SKPaint
{
IsAntialias = true,
IsDither = true
};

public SKPaint PaintStroke = new SKPaint
{
IsAntialias = true,
IsDither = true
};

public SKPaint PaintShadow = new SKPaint
{
IsAntialias = true,
IsDither = true
};

public SKPaint PaintDeco = new SKPaint
Expand Down Expand Up @@ -1119,11 +1122,15 @@ float PositionBaseline(float calcBaselineY)
}
}



//DRAW LINE SPANS
float offsetX = 0;
var spanIndex = 0;
foreach (var lineSpan in line.Spans)
{


SKRect rectPrecalculatedSpanBounds = SKRect.Empty;

var paint = paintDefault;
Expand Down Expand Up @@ -1244,6 +1251,11 @@ float MoveOffsetAdjustmentX(float x, string p)

var posX = alignedLineDrawingStartX + offsetX + lineSpan.Glyphs[charIndex].Position + offsetAdjustmentX;

//if (Tag == "Debug")
//{
// Debug.WriteLine($"Drawing span {lineSpan.Span.Text} with {paint.Typeface.FamilyName} -> {glyph.Text} {glyph.Symbol}");
//}

DrawCharacter(canvas, lineNb - 1, charIndex, print, posX,
baselineY, paint, paintStroke, paintDropShadow, line.Bounds, (float)scale);

Expand Down
5 changes: 3 additions & 2 deletions src/Engine/Draw/Text/TextSpan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ public SKPaint SetupPaint(double scale, SKPaint defaultPaint)
{
Paint = new()
{
IsAntialias = true
IsAntialias = true,
IsDither = true
};
};

Expand Down Expand Up @@ -150,7 +151,7 @@ public SKPaint SetupPaint(double scale, SKPaint defaultPaint)
Paint.TextSkewX = 0;
}

//todo stroke and gradient..
//todo stroke and gradient for spans..

return Paint;
}
Expand Down
3 changes: 1 addition & 2 deletions src/samples/Sandbox/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@
<draw:SkiaLayout
HorizontalOptions="Fill"
Spacing="0"
Split="1"
Tag="ScrollContent"
Type="Wrap"
Type="Column"
UseCache="ImageComposite">

<!--
Expand Down

0 comments on commit f76cf57

Please sign in to comment.