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

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

Issue 2301353004: Make AALinearizingConvexPathRenderer able to handle stroke and fill (Closed)
Patch Set: Fix bug Created 4 years, 3 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/GrAAConvexTessellator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
diff --git a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
index 20d93d8e9009935e7e8c70aee1559b3e5b26610e..c2873b6a404b4bf0dc52872ddbde41b0c5a4da6f 100644
--- a/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
+++ b/src/gpu/batches/GrAALinearizingConvexPathRenderer.cpp
@@ -50,12 +50,17 @@ bool GrAALinearizingConvexPathRenderer::onCanDrawPath(const CanDrawPathArgs& arg
return false;
}
const SkStrokeRec& stroke = args.fShape->style().strokeRec();
- if (stroke.getStyle() == SkStrokeRec::kStroke_Style) {
+
+ if (stroke.getStyle() == SkStrokeRec::kStroke_Style ||
+ stroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style) {
if (!args.fViewMatrix->isSimilarity()) {
return false;
}
SkScalar strokeWidth = args.fViewMatrix->getMaxScale() * stroke.getWidth();
- return strokeWidth >= 1.0f && strokeWidth <= kMaxStrokeWidth &&
+ if (strokeWidth < 1.0f && stroke.getStyle() == SkStrokeRec::kStroke_Style) {
+ return false;
+ }
+ return strokeWidth <= kMaxStrokeWidth &&
args.fShape->knownToBeClosed() &&
stroke.getJoin() != SkPaint::Join::kRound_Join;
}
@@ -126,9 +131,11 @@ public:
const SkMatrix& viewMatrix,
const SkPath& path,
SkScalar strokeWidth,
+ SkStrokeRec::Style style,
SkPaint::Join join,
SkScalar miterLimit) : INHERITED(ClassID()) {
- fGeoData.emplace_back(Geometry{color, viewMatrix, path, strokeWidth, join, miterLimit});
+ fGeoData.emplace_back(Geometry{ color, viewMatrix, path,
+ strokeWidth, style, join, miterLimit });
// compute bounds
SkRect bounds = path.getBounds();
@@ -229,7 +236,8 @@ private:
uint16_t* indices = (uint16_t*) sk_malloc_throw(maxIndices * sizeof(uint16_t));
for (int i = 0; i < instanceCount; i++) {
const Geometry& args = fGeoData[i];
- GrAAConvexTessellator tess(args.fStrokeWidth, args.fJoin, args.fMiterLimit);
+ GrAAConvexTessellator tess(args.fStyle, args.fStrokeWidth,
+ args.fJoin, args.fMiterLimit);
if (!tess.tessellate(args.fViewMatrix, args.fPath)) {
continue;
@@ -309,6 +317,7 @@ private:
SkMatrix fViewMatrix;
SkPath fPath;
SkScalar fStrokeWidth;
+ SkStrokeRec::Style fStyle;
SkPaint::Join fJoin;
SkScalar fMiterLimit;
};
@@ -324,6 +333,7 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
"GrAALinearizingConvexPathRenderer::onDrawPath");
SkASSERT(!args.fDrawContext->isUnifiedMultisampled());
SkASSERT(!args.fShape->isEmpty());
+ SkASSERT(!args.fShape->style().pathEffect());
SkPath path;
args.fShape->asPath(&path);
@@ -335,8 +345,9 @@ bool GrAALinearizingConvexPathRenderer::onDrawPath(const DrawPathArgs& args) {
SkAutoTUnref<GrDrawBatch> batch(new AAFlatteningConvexPathBatch(args.fPaint->getColor(),
*args.fViewMatrix,
- path, strokeWidth, join,
- miterLimit));
+ path, strokeWidth,
+ stroke.getStyle(),
+ join, miterLimit));
GrPipelineBuilder pipelineBuilder(*args.fPaint);
pipelineBuilder.setUserStencil(args.fUserStencilSettings);
@@ -354,10 +365,29 @@ DRAW_BATCH_TEST_DEFINE(AAFlatteningConvexPathBatch) {
GrColor color = GrRandomColor(random);
SkMatrix viewMatrix = GrTest::TestMatrixInvertible(random);
SkPath path = GrTest::TestPathConvex(random);
- SkScalar strokeWidth = random->nextBool() ? -1.f : 2.f;
+
+ SkStrokeRec::Style styles[3] = { SkStrokeRec::kFill_Style,
+ SkStrokeRec::kStroke_Style,
+ SkStrokeRec::kStrokeAndFill_Style };
+
+ SkStrokeRec::Style style = styles[random->nextU() % 3];
+
+ SkScalar strokeWidth = -1.f;
SkPaint::Join join = SkPaint::kMiter_Join;
SkScalar miterLimit = 0.5f;
- return new AAFlatteningConvexPathBatch(color, viewMatrix, path, strokeWidth, join, miterLimit);
+
+ if (SkStrokeRec::kFill_Style != style) {
+ strokeWidth = random->nextRangeF(1.0f, 10.0f);
+ if (random->nextBool()) {
+ join = SkPaint::kMiter_Join;
+ } else {
+ join = SkPaint::kBevel_Join;
+ }
+ miterLimit = random->nextRangeF(0.5f, 2.0f);
+ }
+
+ return new AAFlatteningConvexPathBatch(color, viewMatrix, path, strokeWidth,
+ style, join, miterLimit);
}
#endif
« no previous file with comments | « src/gpu/batches/GrAAConvexTessellator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698