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

Side by Side 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 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 unified diff | Download patch
« no previous file with comments | « src/gpu/gl/GrGLPath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2014 Google Inc. 3 * Copyright 2014 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrGLPathRange.h" 9 #include "GrGLPathRange.h"
10 #include "GrGLPath.h" 10 #include "GrGLPath.h"
(...skipping 16 matching lines...) Expand all
27 const GrStrokeInfo& stroke) 27 const GrStrokeInfo& stroke)
28 : INHERITED(gpu, numPaths), 28 : INHERITED(gpu, numPaths),
29 fStroke(stroke), 29 fStroke(stroke),
30 fBasePathID(basePathID), 30 fBasePathID(basePathID),
31 fGpuMemorySize(gpuMemorySize) { 31 fGpuMemorySize(gpuMemorySize) {
32 this->init(); 32 this->init();
33 this->registerWithCache(); 33 this->registerWithCache();
34 } 34 }
35 35
36 void GrGLPathRange::init() { 36 void GrGLPathRange::init() {
37 if (fStroke.isDashed()) { 37 // Must force fill:
38 // * dashing: NVPR stroke dashing is different to Skia.
39 // * end caps: NVPR stroking degenerate contours with end caps is different to Skia.
40 bool forceFill = fStroke.isDashed() ||
41 (fStroke.needToApply() && fStroke.getCap() != SkPaint::kButt_Cap);
42
43 if (forceFill) {
38 fShouldStroke = false; 44 fShouldStroke = false;
39 fShouldFill = true; 45 fShouldFill = true;
40 } else { 46 } else {
41 fShouldStroke = fStroke.needToApply(); 47 fShouldStroke = fStroke.needToApply();
42 fShouldFill = fStroke.isFillStyle() || 48 fShouldFill = fStroke.isFillStyle() ||
43 fStroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style; 49 fStroke.getStyle() == SkStrokeRec::kStrokeAndFill_Style;
44 } 50 }
45 } 51 }
46 52
47 void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const { 53 void GrGLPathRange::onInitPath(int index, const SkPath& origSkPath) const {
48 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu()); 54 GrGLGpu* gpu = static_cast<GrGLGpu*>(this->getGpu());
49 if (nullptr == gpu) { 55 if (nullptr == gpu) {
50 return; 56 return;
51 } 57 }
52 58
53 // Make sure the path at this index hasn't been initted already. 59 // Make sure the path at this index hasn't been initted already.
54 SkDEBUGCODE( 60 SkDEBUGCODE(
55 GrGLboolean isPath; 61 GrGLboolean isPath;
56 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ; 62 GR_GL_CALL_RET(gpu->glInterface(), isPath, IsPath(fBasePathID + index))) ;
57 SkASSERT(GR_GL_FALSE == isPath); 63 SkASSERT(GR_GL_FALSE == isPath);
58 64
59 const SkPath* skPath = &origSkPath; 65 if (origSkPath.isEmpty()) {
60 SkTLazy<SkPath> tmpPath; 66 GrGLPath::InitPathObjectEmptyPath(gpu, fBasePathID + index);
61 const GrStrokeInfo* stroke = &fStroke; 67 } else if (fShouldStroke) {
62 GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle); 68 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, origSkPath);
69 GrGLPath::InitPathObjectStroke(gpu, fBasePathID + index, fStroke);
70 } else {
71 const SkPath* skPath = &origSkPath;
72 SkTLazy<SkPath> tmpPath;
73 const GrStrokeInfo* stroke = &fStroke;
74 GrStrokeInfo tmpStroke(SkStrokeRec::kFill_InitStyle);
63 75
64 // Dashing must be applied to the path. However, if dashing is present, 76 // Dashing must be applied to the path. However, if dashing is present,
65 // we must convert all the paths to fills. The GrStrokeInfo::applyDash leave s 77 // we must convert all the paths to fills. The GrStrokeInfo::applyDash l eaves
66 // simple paths as strokes but converts other paths to fills. 78 // simple paths as strokes but converts other paths to fills.
67 // Thus we must stroke the strokes here, so that all paths in the 79 // Thus we must stroke the strokes here, so that all paths in the
68 // path range are using the same style. 80 // path range are using the same style.
69 if (fStroke.isDashed()) { 81 if (fStroke.isDashed()) {
70 if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) { 82 if (!stroke->applyDashToPath(tmpPath.init(), &tmpStroke, *skPath)) {
71 return;
72 }
73 skPath = tmpPath.get();
74 stroke = &tmpStroke;
75 if (tmpStroke.needToApply()) {
76 if (!tmpStroke.applyToPath(tmpPath.get(), *tmpPath.get())) {
77 return; 83 return;
78 } 84 }
79 tmpStroke.setFillStyle(); 85 skPath = tmpPath.get();
86 stroke = &tmpStroke;
80 } 87 }
88 if (stroke->needToApply()) {
89 if (!tmpPath.isValid()) {
90 tmpPath.init();
91 }
92 if (!stroke->applyToPath(tmpPath.get(), *tmpPath.get())) {
93 return;
94 }
95 }
96 GrGLPath::InitPathObjectPathData(gpu, fBasePathID + index, *skPath);
81 } 97 }
82
83 GrGLPath::InitPathObject(gpu, fBasePathID + index, *skPath, *stroke);
84
85 // TODO: Use a better approximation for the individual path sizes. 98 // TODO: Use a better approximation for the individual path sizes.
86 fGpuMemorySize += 100; 99 fGpuMemorySize += 100;
87 } 100 }
88 101
89 void GrGLPathRange::onRelease() { 102 void GrGLPathRange::onRelease() {
90 SkASSERT(this->getGpu()); 103 SkASSERT(this->getGpu());
91 104
92 if (0 != fBasePathID && this->shouldFreeResources()) { 105 if (0 != fBasePathID && this->shouldFreeResources()) {
93 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID, 106 static_cast<GrGLGpu*>(this->getGpu())->glPathRendering()->deletePaths(fB asePathID,
94 th is->getNumPaths()); 107 th is->getNumPaths());
95 fBasePathID = 0; 108 fBasePathID = 0;
96 } 109 }
97 110
98 INHERITED::onRelease(); 111 INHERITED::onRelease();
99 } 112 }
100 113
101 void GrGLPathRange::onAbandon() { 114 void GrGLPathRange::onAbandon() {
102 fBasePathID = 0; 115 fBasePathID = 0;
103 116
104 INHERITED::onAbandon(); 117 INHERITED::onAbandon();
105 } 118 }
OLDNEW
« 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