diff --git a/src/gpu/v1/Device.cpp b/src/gpu/v1/Device.cpp index e467ca2d25..68f3a7444d 100644 --- a/src/gpu/v1/Device.cpp +++ b/src/gpu/v1/Device.cpp @@ -344,20 +344,47 @@ void Device::drawPoints(SkCanvas::PointMode mode, GrAA aa = fSurfaceDrawContext->chooseAA(paint); - if (paint.getPathEffect() && 2 == count && SkCanvas::kLines_PointMode == mode) { - GrStyle style(paint, SkPaint::kStroke_Style); - GrPaint grPaint; - if (!SkPaintToGrPaint(this->recordingContext(), fSurfaceDrawContext->colorInfo(), paint, - this->asMatrixProvider(), &grPaint)) { + if (count == 2 && mode == SkCanvas::kLines_PointMode) { + if (paint.getPathEffect()) { + // Probably a dashed line. Draw as a path. + GrPaint grPaint; + if (SkPaintToGrPaint(this->recordingContext(), + fSurfaceDrawContext->colorInfo(), + paint, + this->asMatrixProvider(), + &grPaint)) { + SkPath path; + path.setIsVolatile(true); + path.moveTo(pts[0]); + path.lineTo(pts[1]); + fSurfaceDrawContext->drawPath(this->clip(), + std::move(grPaint), + aa, + this->localToDevice(), + path, + GrStyle(paint, SkPaint::kStroke_Style)); + } + return; + } + if (!paint.getMaskFilter() && + paint.getStrokeWidth() > 0 && // drawStrokedLine doesn't support hairlines. + paint.getStrokeCap() != SkPaint::kRound_Cap) { // drawStrokedLine doesn't do round caps. + // Simple stroked line. Bypass path rendering. + GrPaint grPaint; + if (SkPaintToGrPaint(this->recordingContext(), + fSurfaceDrawContext->colorInfo(), + paint, + this->asMatrixProvider(), + &grPaint)) { + fSurfaceDrawContext->drawStrokedLine(this->clip(), + std::move(grPaint), + aa, + this->localToDevice(), + pts, + SkStrokeRec(paint, SkPaint::kStroke_Style)); + } return; } - SkPath path; - path.setIsVolatile(true); - path.moveTo(pts[0]); - path.lineTo(pts[1]); - fSurfaceDrawContext->drawPath(this->clip(), std::move(grPaint), aa, this->localToDevice(), - path, style); - return; } SkScalar scales[2]; diff --git a/src/gpu/v1/SurfaceDrawContext_v1.h b/src/gpu/v1/SurfaceDrawContext_v1.h index f0c5b88f39..783c3c07d6 100644 --- a/src/gpu/v1/SurfaceDrawContext_v1.h +++ b/src/gpu/v1/SurfaceDrawContext_v1.h @@ -645,6 +645,9 @@ public: void testingOnly_SetPreserveOpsOnFullClear() { fPreserveOpsOnFullClear_TestingOnly = true; } #endif + void drawStrokedLine(const GrClip*, GrPaint&&, GrAA, const SkMatrix&, const SkPoint[2], + const SkStrokeRec&); + private: enum class QuadOptimization; @@ -692,9 +695,6 @@ private: DrawQuad* quad, const SkRect* subset = nullptr); - void drawStrokedLine(const GrClip*, GrPaint&&, GrAA, const SkMatrix&, const SkPoint[2], - const SkStrokeRec&); - // Tries to detect if the given shape is a simple, and draws it without path rendering if // we know how. bool drawSimpleShape(const GrClip*, GrPaint*, GrAA, const SkMatrix&, const GrStyledShape&);