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

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

Issue 815553003: Move ViewMatrix off of drawstate (Closed) Base URL: https://skia.googlesource.com/skia.git@remove-fragment-stage
Patch Set: more cleaning Created 5 years, 11 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/GrOvalRenderer.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 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 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 #ifndef GrPathRenderer_DEFINED 9 #ifndef GrPathRenderer_DEFINED
10 #define GrPathRenderer_DEFINED 10 #define GrPathRenderer_DEFINED
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const SkStrokeRec& stroke) const { 87 const SkStrokeRec& stroke) const {
88 SkASSERT(!path.isInverseFillType()); 88 SkASSERT(!path.isInverseFillType());
89 return this->onGetStencilSupport(target, drawState, path, stroke); 89 return this->onGetStencilSupport(target, drawState, path, stroke);
90 } 90 }
91 91
92 /** 92 /**
93 * Returns true if this path renderer is able to render the path. Returning false allows the 93 * Returns true if this path renderer is able to render the path. Returning false allows the
94 * caller to fallback to another path renderer This function is called when searching for a path 94 * caller to fallback to another path renderer This function is called when searching for a path
95 * renderer capable of rendering a path. 95 * renderer capable of rendering a path.
96 * 96 *
97 * @param target The target that the path will be rendered to
98 * @param drawState The drawState
99 * @param viewMatrix The viewMatrix
97 * @param path The path to draw 100 * @param path The path to draw
98 * @param stroke The stroke information (width, join, cap) 101 * @param stroke The stroke information (width, join, cap)
99 * @param target The target that the path will be rendered to
100 * @param antiAlias True if anti-aliasing is required. 102 * @param antiAlias True if anti-aliasing is required.
101 * 103 *
102 * @return true if the path can be drawn by this object, false otherwise. 104 * @return true if the path can be drawn by this object, false otherwise.
103 */ 105 */
104 virtual bool canDrawPath(const GrDrawTarget* target, 106 virtual bool canDrawPath(const GrDrawTarget* target,
105 const GrDrawState* drawState, 107 const GrDrawState* drawState,
108 const SkMatrix& viewMatrix,
106 const SkPath& path, 109 const SkPath& path,
107 const SkStrokeRec& rec, 110 const SkStrokeRec& rec,
108 bool antiAlias) const = 0; 111 bool antiAlias) const = 0;
109 /** 112 /**
110 * Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then 113 * Draws the path into the draw target. If getStencilSupport() would return kNoRestriction then
111 * the subclass must respect the stencil settings of the target's draw state . 114 * the subclass must respect the stencil settings of the target's draw state .
112 * 115 *
116 * @param target The target that the path will be rendered to
117 * @param drawState The drawState
118 * @param viewMatrix The viewMatrix
113 * @param path the path to draw. 119 * @param path the path to draw.
114 * @param stroke the stroke information (width, join, cap) 120 * @param stroke the stroke information (width, join, cap)
115 * @param target target that the path will be rendered to
116 * @param antiAlias true if anti-aliasing is required. 121 * @param antiAlias true if anti-aliasing is required.
117 */ 122 */
118 bool drawPath(GrDrawTarget* target, 123 bool drawPath(GrDrawTarget* target,
119 GrDrawState* ds, 124 GrDrawState* ds,
120 GrColor color, 125 GrColor color,
126 const SkMatrix& viewMatrix,
121 const SkPath& path, 127 const SkPath& path,
122 const SkStrokeRec& stroke, 128 const SkStrokeRec& stroke,
123 bool antiAlias) { 129 bool antiAlias) {
124 SkASSERT(!path.isEmpty()); 130 SkASSERT(!path.isEmpty());
125 SkASSERT(this->canDrawPath(target, ds, path, stroke, antiAlias)); 131 SkASSERT(this->canDrawPath(target, ds, viewMatrix, path, stroke, antiAli as));
126 SkASSERT(ds->getStencil().isDisabled() || 132 SkASSERT(ds->getStencil().isDisabled() ||
127 kNoRestriction_StencilSupport == this->getStencilSupport(target , ds, path, 133 kNoRestriction_StencilSupport == this->getStencilSupport(target , ds, path,
128 stroke )); 134 stroke ));
129 return this->onDrawPath(target, ds, color, path, stroke, antiAlias); 135 return this->onDrawPath(target, ds, color, viewMatrix, path, stroke, ant iAlias);
130 } 136 }
131 137
132 /** 138 /**
133 * Draws the path to the stencil buffer. Assume the writable stencil bits ar e already 139 * Draws the path to the stencil buffer. Assume the writable stencil bits ar e already
134 * initialized to zero. The pixels inside the path will have non-zero stenci l values afterwards. 140 * initialized to zero. The pixels inside the path will have non-zero stenci l values afterwards.
135 * 141 *
136 * @param path the path to draw. 142 * @param path the path to draw.
137 * @param stroke the stroke information (width, join, cap) 143 * @param stroke the stroke information (width, join, cap)
138 * @param target target that the path will be rendered to 144 * @param target target that the path will be rendered to
139 */ 145 */
140 void stencilPath(GrDrawTarget* target, 146 void stencilPath(GrDrawTarget* target,
141 GrDrawState* ds, 147 GrDrawState* ds,
148 const SkMatrix& viewMatrix,
142 const SkPath& path, 149 const SkPath& path,
143 const SkStrokeRec& stroke) { 150 const SkStrokeRec& stroke) {
144 SkASSERT(!path.isEmpty()); 151 SkASSERT(!path.isEmpty());
145 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(target, ds , path, stroke)); 152 SkASSERT(kNoSupport_StencilSupport != this->getStencilSupport(target, ds , path, stroke));
146 this->onStencilPath(target, ds, path, stroke); 153 this->onStencilPath(target, ds, viewMatrix, path, stroke);
147 } 154 }
148 155
149 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage. 156 // Helper for determining if we can treat a thin stroke as a hairline w/ cov erage.
150 // If we can, we draw lots faster (raster device does this same test). 157 // If we can, we draw lots faster (raster device does this same test).
151 static bool IsStrokeHairlineOrEquivalent(const SkStrokeRec& stroke, const Sk Matrix& matrix, 158 static bool IsStrokeHairlineOrEquivalent(const SkStrokeRec& stroke, const Sk Matrix& matrix,
152 SkScalar* outCoverage) { 159 SkScalar* outCoverage) {
153 if (stroke.isHairlineStyle()) { 160 if (stroke.isHairlineStyle()) {
154 if (outCoverage) { 161 if (outCoverage) {
155 *outCoverage = SK_Scalar1; 162 *outCoverage = SK_Scalar1;
156 } 163 }
(...skipping 13 matching lines...) Expand all
170 const SkStrokeRec&) const { 177 const SkStrokeRec&) const {
171 return kNoRestriction_StencilSupport; 178 return kNoRestriction_StencilSupport;
172 } 179 }
173 180
174 /** 181 /**
175 * Subclass implementation of drawPath() 182 * Subclass implementation of drawPath()
176 */ 183 */
177 virtual bool onDrawPath(GrDrawTarget*, 184 virtual bool onDrawPath(GrDrawTarget*,
178 GrDrawState*, 185 GrDrawState*,
179 GrColor, 186 GrColor,
187 const SkMatrix& viewMatrix,
180 const SkPath&, 188 const SkPath&,
181 const SkStrokeRec&, 189 const SkStrokeRec&,
182 bool antiAlias) = 0; 190 bool antiAlias) = 0;
183 191
184 /** 192 /**
185 * Subclass implementation of stencilPath(). Subclass must override iff it e ver returns 193 * Subclass implementation of stencilPath(). Subclass must override iff it e ver returns
186 * kStencilOnly in onGetStencilSupport(). 194 * kStencilOnly in onGetStencilSupport().
187 */ 195 */
188 virtual void onStencilPath(GrDrawTarget* target, 196 virtual void onStencilPath(GrDrawTarget* target,
189 GrDrawState* drawState, 197 GrDrawState* drawState,
198 const SkMatrix& viewMatrix,
190 const SkPath& path, 199 const SkPath& path,
191 const SkStrokeRec& stroke) { 200 const SkStrokeRec& stroke) {
192 GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil, 201 GR_STATIC_CONST_SAME_STENCIL(kIncrementStencil,
193 kReplace_StencilOp, 202 kReplace_StencilOp,
194 kReplace_StencilOp, 203 kReplace_StencilOp,
195 kAlways_StencilFunc, 204 kAlways_StencilFunc,
196 0xffff, 205 0xffff,
197 0xffff, 206 0xffff,
198 0xffff); 207 0xffff);
199 drawState->setStencil(kIncrementStencil); 208 drawState->setStencil(kIncrementStencil);
200 drawState->setDisableColorXPFactory(); 209 drawState->setDisableColorXPFactory();
201 this->drawPath(target, drawState, GrColor_WHITE, path, stroke, false); 210 this->drawPath(target, drawState, GrColor_WHITE, viewMatrix, path, strok e, false);
202 } 211 }
203 212
204 // Helper for getting the device bounds of a path. Inverse filled paths will have bounds set 213 // Helper for getting the device bounds of a path. Inverse filled paths will have bounds set
205 // by devSize. Non-inverse path bounds will not necessarily be clipped to de vSize. 214 // by devSize. Non-inverse path bounds will not necessarily be clipped to de vSize.
206 static void GetPathDevBounds(const SkPath& path, 215 static void GetPathDevBounds(const SkPath& path,
207 int devW, 216 int devW,
208 int devH, 217 int devH,
209 const SkMatrix& matrix, 218 const SkMatrix& matrix,
210 SkRect* bounds); 219 SkRect* bounds);
211 220
212 // Helper version that gets the dev width and height from a GrSurface. 221 // Helper version that gets the dev width and height from a GrSurface.
213 static void GetPathDevBounds(const SkPath& path, 222 static void GetPathDevBounds(const SkPath& path,
214 const GrSurface* device, 223 const GrSurface* device,
215 const SkMatrix& matrix, 224 const SkMatrix& matrix,
216 SkRect* bounds) { 225 SkRect* bounds) {
217 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds ); 226 GetPathDevBounds(path, device->width(), device->height(), matrix, bounds );
218 } 227 }
219 228
220 private: 229 private:
221 230
222 typedef SkRefCnt INHERITED; 231 typedef SkRefCnt INHERITED;
223 }; 232 };
224 233
225 #endif 234 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrOvalRenderer.cpp ('k') | src/gpu/GrPathRendererChain.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698