Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2417)

Unified Diff: src/gpu/batches/GrAAStrokeRectBatch.cpp

Issue 2125663003: Add gm that tests shaded stroked rectangles. (Closed) Base URL: https://skia.googlesource.com/skia.git@fixgmwidth
Patch Set: fix windows double->scalar warning Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAAStrokeRectBatch.cpp
diff --git a/src/gpu/batches/GrAAStrokeRectBatch.cpp b/src/gpu/batches/GrAAStrokeRectBatch.cpp
index 98b764aa5b7106acbe780b99c9177c7cde7d16b6..3e0893236f8314806f678dd3c0122bdf2b3e0d35 100644
--- a/src/gpu/batches/GrAAStrokeRectBatch.cpp
+++ b/src/gpu/batches/GrAAStrokeRectBatch.cpp
@@ -516,14 +516,25 @@ void AAStrokeRectBatch::generateAAStrokeRectGeometry(void* vertices,
}
}
-inline static bool is_miter(const SkStrokeRec& stroke) {
+// We support all hairlines, bevels, and miters, but not round joins. Also, check whether the miter
+// limit makes a miter join effectively beveled.
+inline static bool allowed_stroke(const SkStrokeRec& stroke, bool* isMiter) {
+ SkASSERT(stroke.getStyle() == SkStrokeRec::kStroke_Style ||
+ stroke.getStyle() == SkStrokeRec::kHairline_Style);
// For hairlines, make bevel and round joins appear the same as mitered ones.
- // small miter limit means right angles show bevel...
- if ((stroke.getWidth() > 0) && (stroke.getJoin() != SkPaint::kMiter_Join ||
- stroke.getMiter() < SK_ScalarSqrt2)) {
- return false;
+ if (!stroke.getWidth()) {
+ *isMiter = true;
+ return true;
}
- return true;
+ if (stroke.getJoin() == SkPaint::kBevel_Join) {
+ *isMiter = false;
+ return true;
+ }
+ if (stroke.getJoin() == SkPaint::kMiter_Join) {
+ *isMiter = stroke.getMiter() >= SK_ScalarSqrt2;
+ return true;
+ }
+ return false;
}
static void compute_rects(SkRect* devOutside, SkRect* devOutsideAssist, SkRect* devInside,
@@ -596,7 +607,10 @@ GrDrawBatch* Create(GrColor color,
const SkMatrix& viewMatrix,
const SkRect& rect,
const SkStrokeRec& stroke) {
- bool isMiterStroke = is_miter(stroke);
+ bool isMiterStroke;
+ if (!allowed_stroke(stroke, &isMiterStroke)) {
+ return nullptr;
+ }
AAStrokeRectBatch* batch = AAStrokeRectBatch::Create(viewMatrix, isMiterStroke);
SkRect devOutside, devOutsideAssist, devInside;
@@ -609,28 +623,6 @@ GrDrawBatch* Create(GrColor color,
return batch;
}
-bool Append(GrBatch* origBatch,
- GrColor color,
- const SkMatrix& viewMatrix,
- const SkRect& rect,
- const SkStrokeRec& stroke) {
- AAStrokeRectBatch* batch = origBatch->cast<AAStrokeRectBatch>();
-
- // we can't batch across vm changes
- bool isMiterStroke = is_miter(stroke);
- if (!batch->canAppend(viewMatrix, isMiterStroke)) {
- return false;
- }
-
- SkRect devOutside, devOutsideAssist, devInside;
- bool isDegenerate;
- compute_rects(&devOutside, &devOutsideAssist, &devInside, &isDegenerate, viewMatrix,
- rect, stroke.getWidth(), isMiterStroke);
-
- batch->appendAndUpdateBounds(color, devOutside, devOutsideAssist, devInside, isDegenerate);
- return true;
-}
-
};
///////////////////////////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/batches/GrAAStrokeRectBatch.h ('k') | src/gpu/batches/GrNonAAStrokeRectBatch.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698