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

Unified Diff: src/gpu/gl/GrGLPathRange.cpp

Issue 1471763002: Fix stroking of zero length paths with end caps on NVPR (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 1 month 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/gl/GrGLPath.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/gl/GrGLPathRange.cpp
diff --git a/src/gpu/gl/GrGLPathRange.cpp b/src/gpu/gl/GrGLPathRange.cpp
index bd213d4e09b9042ccad312a6619d671e7ddd3f22..4714b924ab4d94e3ad41ae4f86d4d38c6637209e 100644
--- a/src/gpu/gl/GrGLPathRange.cpp
+++ b/src/gpu/gl/GrGLPathRange.cpp
@@ -34,7 +34,13 @@ GrGLPathRange::GrGLPathRange(GrGLGpu* gpu,
}
void GrGLPathRange::init() {
- if (fStroke.isDashed()) {
+ // Must force fill:
+ // * dashing: NVPR stroke dashing is different to Skia.
+ // * end caps: NVPR stroking degenerate contours with end caps is different to Skia.
+ bool forceFill = fStroke.isDashed() ||
+ (fStroke.needToApply() && fStroke.getCap() != SkPaint::kButt_Cap);
+
+ if (forceFill) {
fShouldStroke = false;
fShouldFill = true;
} else {
@@ -56,32 +62,39 @@ void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index)));
SkASSERT(GR_GL_FALSE == isPath);
- const SkPath* skPath = &origSkPath;
- SkTLazy<SkPath> tmpPath;
- const GrStrokeInfo* stroke = &fStroke;
- GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
-
- // Dashing must be applied to the path. However, if dashing is present,
- // we must convert all the paths to fills. The GrStrokeInfo::applyDash leaves
- // simple paths as strokes but converts other paths to fills.
- // Thus we must stroke the strokes here, so that all paths in the
- // path range are using the same style.
- if (fStroke.isDashed()) {
- if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
- return;
+ if (origSkPath.isEmpty()) {
+ GrGLPath::InitPathObjectEmptyPath(gpu, fBasePathID + index);
+ } else if (fShouldStroke) {
+ GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, origSkPath);
+ GrGLPath::InitPathObjectStroke(gpu, fBasePathID + index, fStroke);
+ } else {
+ const SkPath* skPath = &origSkPath;
+ SkTLazy<SkPath> tmpPath;
+ const GrStrokeInfo* stroke = &fStroke;
+ GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
+
+ // Dashing must be applied to the path. However, if dashing is present,
+ // we must convert all the paths to fills. The GrStrokeInfo::applyDash leaves
+ // simple paths as strokes but converts other paths to fills.
+ // Thus we must stroke the strokes here, so that all paths in the
+ // path range are using the same style.
+ if (fStroke.isDashed()) {
+ if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
+ return;
+ }
+ skPath = tmpPath.get();
+ stroke = &tmpStroke;
}
- skPath = tmpPath.get();
- stroke = &tmpStroke;
- if (tmpStroke.needToApply()) {
- if (!tmpStroke.applyToPath(tmpPath.get(), *tmpPath.get())) {
+ if (stroke->needToApply()) {
+ if (!tmpPath.isValid()) {
+ tmpPath.init();
+ }
+ if (!stroke->applyToPath(tmpPath.get(), *tmpPath.get())) {
return;
}
- tmpStroke.setFillStyle();
}
+ GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath);
}
-
- GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke);
-
// TODO: Use a better approximation for the individual path sizes.
fGpuMemorySize += 100;
}
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698