Hello,
I'm quite new to Skia and work with SkiaSharp. I work under Win 10 with Wpf SkiaSharp implementation, but don't assume, that this is the problem.
If I create a path (polygon with hole) with very long lines (around 10000000 pixels width and height) and draw this path, than dashed lines are drawn solid. If I shorten them to max 2^32 pixels per line, they are drawn dashed, but horrible slow. They aren't clipped. If I clip them by hand, it works all ok.
I created a fiddl to show this, but don't know, how to save this. So I put the code here:
void draw(SkCanvas* canvas) {
canvas->drawColor(SK_ColorBLACK);
canvas->scale(1.0f, 1.0f);
SkPaint paint1;
paint1.setStyle(SkPaint::kFill_Style);
paint1.setStrokeWidth(1);
paint1.setColor(0xff808080);
paint1.setAntiAlias(true);
paint1.setStrokeCap(SkPaint::kRound_Cap);
SkPath path0;
path0.moveTo(-2000000, -2000000);
path0.lineTo(100, -2000000);
path0.lineTo(100, 100);
path0.lineTo(-2000000, 100);
path0.moveTo(-1999900, -1999900);
path0.lineTo(-1999900, 90);
path0.lineTo(90, 90);
path0.lineTo(90, -1999900);
path0.lineTo(-1999900, -1999900);
canvas->drawPath(path0, paint1);
SkPaint paint2;
SkScalar intervals[] = {10, 10};
paint2.setStyle(SkPaint::kStroke_Style);
paint2.setStrokeWidth(2);
paint2.setColor(0xffffffff);
paint2.setAntiAlias(true);
paint2.setStrokeCap(SkPaint::kRound_Cap);
paint2.setPathEffect(SkDashPathEffect::Make(intervals, SK_ARRAY_COUNT(intervals), 1));
canvas->drawPath(path0, paint2);
}
Here DrawPath needs around 400 ms to draw the screen. Same without path effect: under 1 ms.
And another funny thing: if I use "SkScalar intervals[] = {30, 10};" as dash array, it is rendered twice as fast as " {10, 10}" :)
Is there a reason, why Skia doesn't clip such polygons? And why is the length of dashed lines limited?