Skip to content

Commit

Permalink
perf: Specialized binding for BorderLayerRenderer.GetOverlayDrawable()
Browse files Browse the repository at this point in the history
  • Loading branch information
ebariche committed Nov 1, 2022
1 parent b6c132e commit e4e87de
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package Uno.UI;

import android.graphics.*;
import android.graphics.drawable.*;
import android.graphics.drawable.shapes.*;

public final class BorderLayerRendererNative
{
private static Paint.Style paintStyleFillStroke = Paint.Style.FILL_AND_STROKE;

private BorderLayerRendererNative() {
}

public static void buildBorderCornerRadius(
PaintDrawable drawable,
Path borderPath,
Paint strokePaint,
float width,
float height)
{
drawable.setShape(new PathShape(borderPath, width, height));

Paint paint = drawable.getPaint();
paint.setAlpha(strokePaint.getAlpha());
paint.setColor(strokePaint.getColor());
paint.setShader(strokePaint.getShader());
paint.setStyle(paintStyleFillStroke);
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma warning disable 0618 // Used for compatibility with SetBackgroundDrawable and previous API Levels
#pragma warning disable 0618 // Used for compatibility with SetBackgroundDrawable and previous API Levels

using Android.Graphics;
using Android.Graphics.Drawables;
Expand Down Expand Up @@ -336,13 +336,11 @@ private static Drawable GetOverlayDrawable(
if (borderPath != null)
{
borderPath.SetFillType(Path.FillType.EvenOdd);

var drawable = new PaintDrawable();
drawable.Shape = new PathShape(borderPath, viewSize.Width, viewSize.Height);
var paint = drawable.Paint;
paint.Color = strokePaint.Color;
paint.SetShader(strokePaint.Shader);
paint.SetStyle(Paint.Style.FillAndStroke);
paint.Alpha = strokePaint.Alpha;

BorderLayerRendererNative.BuildBorderCornerRadius(drawable, borderPath, strokePaint, viewSize.Width, viewSize.Height);

return drawable;
}
else if (!viewSize.IsEmpty)
Expand Down

0 comments on commit e4e87de

Please sign in to comment.