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

Side by Side Diff: src/gpu/GrPathRenderer.h

Issue 1967513002: Revert of Replace GrStrokeInfo with GrStyle. (Closed) Base URL: https://chromium.googlesource.com/skia.git@resscale
Patch Set: Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | 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 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef GrPathRenderer_DEFINED 8 #ifndef GrPathRenderer_DEFINED
9 #define GrPathRenderer_DEFINED 9 #define GrPathRenderer_DEFINED
10 10
11 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
12 #include "GrStencil.h" 12 #include "GrStencil.h"
13 #include "GrStyle.h" 13 #include "GrStrokeInfo.h"
14 14
15 #include "SkDrawProcs.h" 15 #include "SkDrawProcs.h"
16 #include "SkTArray.h" 16 #include "SkTArray.h"
17 17
18 class SkPath; 18 class SkPath;
19
19 struct GrPoint; 20 struct GrPoint;
20 21
21 /** 22 /**
22 * Base class for drawing paths into a GrDrawTarget. 23 * Base class for drawing paths into a GrDrawTarget.
23 * 24 *
24 * Derived classes can use stages GrPaint::kTotalStages through GrPipelineBuild er::kNumStages-1. 25 * Derived classes can use stages GrPaint::kTotalStages through GrPipelineBuild er::kNumStages-1.
25 * The stages before GrPaint::kTotalStages are reserved for setting up the draw (i.e., textures and 26 * The stages before GrPaint::kTotalStages are reserved for setting up the draw (i.e., textures and
26 * filter masks). 27 * filter masks).
27 */ 28 */
28 class SK_API GrPathRenderer : public SkRefCnt { 29 class SK_API GrPathRenderer : public SkRefCnt {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 SkASSERT(!path.isInverseFillType()); 65 SkASSERT(!path.isInverseFillType());
65 return this->onGetStencilSupport(path); 66 return this->onGetStencilSupport(path);
66 } 67 }
67 68
68 /** Args to canDrawPath() 69 /** Args to canDrawPath()
69 * 70 *
70 * fShaderCaps The shader caps 71 * fShaderCaps The shader caps
71 * fPipelineBuilder The pipelineBuilder 72 * fPipelineBuilder The pipelineBuilder
72 * fViewMatrix The viewMatrix 73 * fViewMatrix The viewMatrix
73 * fPath The path to draw 74 * fPath The path to draw
74 * fStyle The styling info (path effect, stroking info) 75 * fStroke The stroke information (width, join, cap)
75 * fAntiAlias True if anti-aliasing is required. 76 * fAntiAlias True if anti-aliasing is required.
76 */ 77 */
77 struct CanDrawPathArgs { 78 struct CanDrawPathArgs {
78 const GrShaderCaps* fShaderCaps; 79 const GrShaderCaps* fShaderCaps;
79 const SkMatrix* fViewMatrix; 80 const SkMatrix* fViewMatrix;
80 const SkPath* fPath; 81 const SkPath* fPath;
81 const GrStyle* fStyle; 82 const GrStrokeInfo* fStroke;
82 bool fAntiAlias; 83 bool fAntiAlias;
83 84
84 // These next two are only used by GrStencilAndCoverPathRenderer 85 // These next two are only used by GrStencilAndCoverPathRenderer
85 bool fIsStencilDisabled; 86 bool fIsStencilDisabled;
86 bool fIsStencilBufferMSAA; 87 bool fIsStencilBufferMSAA;
87 88
88 void validate() const { 89 void validate() const {
89 SkASSERT(fShaderCaps); 90 SkASSERT(fShaderCaps);
90 SkASSERT(fViewMatrix); 91 SkASSERT(fViewMatrix);
91 SkASSERT(fPath); 92 SkASSERT(fPath);
92 SkASSERT(fStyle); 93 SkASSERT(fStroke);
93 SkASSERT(!fPath->isEmpty()); 94 SkASSERT(!fPath->isEmpty());
94 } 95 }
95 }; 96 };
96 97
97 /** 98 /**
98 * Returns true if this path renderer is able to render the path. Returning false allows the 99 * Returns true if this path renderer is able to render the path. Returning false allows the
99 * caller to fallback to another path renderer This function is called when searching for a path 100 * caller to fallback to another path renderer This function is called when searching for a path
100 * renderer capable of rendering a path. 101 * renderer capable of rendering a path.
101 * 102 *
102 * @return true if the path can be drawn by this object, false otherwise. 103 * @return true if the path can be drawn by this object, false otherwise.
103 */ 104 */
104 bool canDrawPath(const CanDrawPathArgs& args) const { 105 bool canDrawPath(const CanDrawPathArgs& args) const {
105 SkDEBUGCODE(args.validate();) 106 SkDEBUGCODE(args.validate();)
106 return this->onCanDrawPath(args); 107 return this->onCanDrawPath(args);
107 } 108 }
108 109
109 /** 110 /**
110 * Args to drawPath() 111 * Args to drawPath()
111 * 112 *
112 * fTarget The target that the path will be rendered to 113 * fTarget The target that the path will be rendered to
113 * fResourceProvider The resource provider for creating gpu resources t o render the path 114 * fResourceProvider The resource provider for creating gpu resources t o render the path
114 * fPipelineBuilder The pipelineBuilder 115 * fPipelineBuilder The pipelineBuilder
115 * fColor Color to render with 116 * fColor Color to render with
116 * fViewMatrix The viewMatrix 117 * fViewMatrix The viewMatrix
117 * fPath the path to draw. 118 * fPath the path to draw.
118 * fStyle the style information (path effect, stroke info) 119 * fStroke the stroke information (width, join, cap)
119 * fAntiAlias true if anti-aliasing is required. 120 * fAntiAlias true if anti-aliasing is required.
120 * fGammaCorrect true if gamma-correct rendering is to be used. 121 * fGammaCorrect true if gamma-correct rendering is to be used.
121 */ 122 */
122 struct DrawPathArgs { 123 struct DrawPathArgs {
123 GrDrawTarget* fTarget; 124 GrDrawTarget* fTarget;
124 GrResourceProvider* fResourceProvider; 125 GrResourceProvider* fResourceProvider;
125 GrPipelineBuilder* fPipelineBuilder; 126 GrPipelineBuilder* fPipelineBuilder;
126 GrColor fColor; 127 GrColor fColor;
127 const SkMatrix* fViewMatrix; 128 const SkMatrix* fViewMatrix;
128 const SkPath* fPath; 129 const SkPath* fPath;
129 const GrStyle* fStyle; 130 const GrStrokeInfo* fStroke;
130 bool fAntiAlias; 131 bool fAntiAlias;
131 bool fGammaCorrect; 132 bool fGammaCorrect;
132 133
133 void validate() const { 134 void validate() const {
134 SkASSERT(fTarget); 135 SkASSERT(fTarget);
135 SkASSERT(fResourceProvider); 136 SkASSERT(fResourceProvider);
136 SkASSERT(fPipelineBuilder); 137 SkASSERT(fPipelineBuilder);
137 SkASSERT(fViewMatrix); 138 SkASSERT(fViewMatrix);
138 SkASSERT(fPath); 139 SkASSERT(fPath);
139 SkASSERT(fStyle); 140 SkASSERT(fStroke);
140 SkASSERT(!fPath->isEmpty()); 141 SkASSERT(!fPath->isEmpty());
141 } 142 }
142 }; 143 };
143 144
144 /** 145 /**
145 * Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then 146 * Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then
146 * the subclass must respect the stencil settings of the GrPipelineBuilder. 147 * the subclass must respect the stencil settings of the GrPipelineBuilder.
147 */ 148 */
148 bool drawPath(const DrawPathArgs& args) { 149 bool drawPath(const DrawPathArgs& args) {
149 SkDEBUGCODE(args.validate();) 150 SkDEBUGCODE(args.validate();)
150 #ifdef SK_DEBUG 151 #ifdef SK_DEBUG
151 CanDrawPathArgs canArgs; 152 CanDrawPathArgs canArgs;
152 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps(); 153 canArgs.fShaderCaps = args.fTarget->caps()->shaderCaps();
153 canArgs.fViewMatrix = args.fViewMatrix; 154 canArgs.fViewMatrix = args.fViewMatrix;
154 canArgs.fPath = args.fPath; 155 canArgs.fPath = args.fPath;
155 canArgs.fStyle = args.fStyle; 156 canArgs.fStroke = args.fStroke;
156 canArgs.fAntiAlias = args.fAntiAlias; 157 canArgs.fAntiAlias = args.fAntiAlias;
157 158
158 canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisab led(); 159 canArgs.fIsStencilDisabled = args.fPipelineBuilder->getStencil().isDisab led();
159 canArgs.fIsStencilBufferMSAA = 160 canArgs.fIsStencilBufferMSAA =
160 args.fPipelineBuilder->getRenderTarget()->isStencilBuf ferMultisampled(); 161 args.fPipelineBuilder->getRenderTarget()->isStencilBuf ferMultisampled();
161 SkASSERT(this->canDrawPath(canArgs)); 162 SkASSERT(this->canDrawPath(canArgs));
162 if (!args.fPipelineBuilder->getStencil().isDisabled()) { 163 if (!args.fPipelineBuilder->getStencil().isDisabled()) {
163 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a rgs.fPath)); 164 SkASSERT(kNoRestriction_StencilSupport == this->getStencilSupport(*a rgs.fPath));
164 SkASSERT(args.fStyle->isSimpleFill()); 165 SkASSERT(!args.fStroke->isDashed());
166 SkASSERT(args.fStroke->isFillStyle());
165 } 167 }
166 #endif 168 #endif
167 return this->onDrawPath(args); 169 return this->onDrawPath(args);
168 } 170 }
169 171
170 /* Args to stencilPath(). 172 /* Args to stencilPath().
171 * 173 *
172 * fTarget The target that the path will be rendered to. 174 * fTarget The target that the path will be rendered to.
173 * fResourceProvider The resource provider for creating gpu resources t o render the path 175 * fResourceProvider The resource provider for creating gpu resources t o render the path
174 * fPipelineBuilder The pipeline builder. 176 * fPipelineBuilder The pipeline builder.
(...skipping 13 matching lines...) Expand all
188 SkASSERT(fPipelineBuilder); 190 SkASSERT(fPipelineBuilder);
189 SkASSERT(fViewMatrix); 191 SkASSERT(fViewMatrix);
190 SkASSERT(fPath); 192 SkASSERT(fPath);
191 SkASSERT(!fPath->isEmpty()); 193 SkASSERT(!fPath->isEmpty());
192 } 194 }
193 }; 195 };
194 196
195 /** 197 /**
196 * Draws the path to the stencil buffer. Assume the writable stencil bits ar e already 198 * Draws the path to the stencil buffer. Assume the writable stencil bits ar e already
197 * initialized to zero. The pixels inside the path will have non-zero stenci l values afterwards. 199 * initialized to zero. The pixels inside the path will have non-zero stenci l values afterwards.
200 *
198 */ 201 */
199 void stencilPath(const StencilPathArgs& args) { 202 void stencilPath(const StencilPathArgs& args) {
200 SkDEBUGCODE(args.validate();) 203 SkDEBUGCODE(args.validate();)
201 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPat h)); 204 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(*args.fPat h));
205
202 this->onStencilPath(args); 206 this->onStencilPath(args);
203 } 207 }
204 208
205 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage. 209 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage.
206 // If we can, we draw lots faster (raster device does this same test). 210 // If we can, we draw lots faster (raster device does this same test).
207 static bool IsStrokeHairlineOrEquivalent(const GrStyle& style, const SkMatri x& matrix, 211 static bool IsStrokeHairlineOrEquivalent(const GrStrokeInfo& stroke, const S kMatrix& matrix,
208 SkScalar* outCoverage) { 212 SkScalar* outCoverage) {
209 if (style.pathEffect()) { 213 if (stroke.isDashed()) {
210 return false; 214 return false;
211 } 215 }
212 const SkStrokeRec& stroke = style.strokeRec();
213 if (stroke.isHairlineStyle()) { 216 if (stroke.isHairlineStyle()) {
214 if (outCoverage) { 217 if (outCoverage) {
215 *outCoverage = SK_Scalar1; 218 *outCoverage = SK_Scalar1;
216 } 219 }
217 return true; 220 return true;
218 } 221 }
219 return stroke.getStyle() == SkStrokeRec::kStroke_Style && 222 return stroke.getStyle() == SkStrokeRec::kStroke_Style &&
220 SkDrawTreatAAStrokeAsHairline(stroke.getWidth(), matrix, outCoverage ); 223 SkDrawTreatAAStrokeAsHairline(stroke.getWidth(), matrix, outCoverage );
221 } 224 }
222 225
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 0xffff); 272 0xffff);
270 args.fPipelineBuilder->setStencil(kIncrementStencil); 273 args.fPipelineBuilder->setStencil(kIncrementStencil);
271 args.fPipelineBuilder->setDisableColorXPFactory(); 274 args.fPipelineBuilder->setDisableColorXPFactory();
272 DrawPathArgs drawArgs; 275 DrawPathArgs drawArgs;
273 drawArgs.fTarget = args.fTarget; 276 drawArgs.fTarget = args.fTarget;
274 drawArgs.fResourceProvider = args.fResourceProvider; 277 drawArgs.fResourceProvider = args.fResourceProvider;
275 drawArgs.fPipelineBuilder = args.fPipelineBuilder; 278 drawArgs.fPipelineBuilder = args.fPipelineBuilder;
276 drawArgs.fColor = 0xFFFFFFFF; 279 drawArgs.fColor = 0xFFFFFFFF;
277 drawArgs.fViewMatrix = args.fViewMatrix; 280 drawArgs.fViewMatrix = args.fViewMatrix;
278 drawArgs.fPath = args.fPath; 281 drawArgs.fPath = args.fPath;
279 drawArgs.fStyle = &GrStyle::SimpleFill(); 282 drawArgs.fStroke = &GrStrokeInfo::FillInfo();
280 drawArgs.fAntiAlias = false; 283 drawArgs.fAntiAlias = false;
281 drawArgs.fGammaCorrect = false; 284 drawArgs.fGammaCorrect = false;
282 this->drawPath(drawArgs); 285 this->drawPath(drawArgs);
283 } 286 }
284 287
288
285 typedef SkRefCnt INHERITED; 289 typedef SkRefCnt INHERITED;
286 }; 290 };
287 291
288 #endif 292 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrPath.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698