blob: 6306c336c6a6f0e5804dd0c492ef5e84583c42d0 [file] [log] [blame]
tomhudson@google.com93813632011-10-27 20:21:16 +00001/*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef GrDrawState_DEFINED
9#define GrDrawState_DEFINED
10
11#include "GrColor.h"
12#include "GrMatrix.h"
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000013#include "GrNoncopyable.h"
bsalomon@google.com2e3d1442012-03-26 20:33:54 +000014#include "GrRefCnt.h"
tomhudson@google.com93813632011-10-27 20:21:16 +000015#include "GrSamplerState.h"
16#include "GrStencil.h"
bsalomon@google.com64aef2b2012-06-11 15:36:13 +000017#include "GrTexture.h"
robertphillips@google.com9ec07532012-06-22 12:01:30 +000018#include "GrRenderTarget.h"
tomhudson@google.com1e8f0162012-07-20 16:25:18 +000019#include "effects/GrSingleTextureEffect.h"
tomhudson@google.com93813632011-10-27 20:21:16 +000020
21#include "SkXfermode.h"
22
bsalomon@google.comaf84e742012-10-05 13:23:24 +000023class GrPaint;
tomhudson@google.com93813632011-10-27 20:21:16 +000024
bsalomon@google.com2e3d1442012-03-26 20:33:54 +000025class GrDrawState : public GrRefCnt {
bsalomon@google.com2e3d1442012-03-26 20:33:54 +000026public:
reed@google.comfa35e3d2012-06-26 20:16:17 +000027 SK_DECLARE_INST_COUNT(GrDrawState)
rmistry@google.comd6176b02012-08-23 18:14:13 +000028
tomhudson@google.com93813632011-10-27 20:21:16 +000029 /**
30 * Number of texture stages. Each stage takes as input a color and
31 * 2D texture coordinates. The color input to the first enabled stage is the
32 * per-vertex color or the constant color (setColor/setAlpha) if there are
33 * no per-vertex colors. For subsequent stages the input color is the output
34 * color from the previous enabled stage. The output color of each stage is
35 * the input color modulated with the result of a texture lookup. Texture
36 * lookups are specified by a texture a sampler (setSamplerState). Texture
37 * coordinates for each stage come from the vertices based on a
38 * GrVertexLayout bitfield. The output fragment color is the output color of
39 * the last enabled stage. The presence or absence of texture coordinates
40 * for each stage in the vertex layout indicates whether a stage is enabled
41 * or not.
robertphillips@google.combf5cad42012-05-10 12:40:40 +000042 *
43 * Stages 0 through GrPaint::kTotalStages-1 are reserved for setting up
rmistry@google.comd6176b02012-08-23 18:14:13 +000044 * the draw (i.e., textures and filter masks). Stages GrPaint::kTotalStages
45 * through kNumStages-1 are earmarked for use by GrTextContext and
robertphillips@google.combf5cad42012-05-10 12:40:40 +000046 * GrPathRenderer-derived classes.
tomhudson@google.com93813632011-10-27 20:21:16 +000047 */
48 enum {
twiz@google.com58071162012-07-18 21:41:50 +000049 kNumStages = 5,
tomhudson@google.com93813632011-10-27 20:21:16 +000050 kMaxTexCoords = kNumStages
51 };
52
rmistry@google.comd6176b02012-08-23 18:14:13 +000053 GrDrawState()
robertphillips@google.com9ec07532012-06-22 12:01:30 +000054 : fRenderTarget(NULL) {
55
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000056 this->reset();
57 }
bsalomon@google.com46f7afb2012-01-18 19:51:55 +000058
rmistry@google.comd6176b02012-08-23 18:14:13 +000059 GrDrawState(const GrDrawState& state)
robertphillips@google.com9ec07532012-06-22 12:01:30 +000060 : fRenderTarget(NULL) {
61
bsalomon@google.com46f7afb2012-01-18 19:51:55 +000062 *this = state;
63 }
64
robertphillips@google.com9ec07532012-06-22 12:01:30 +000065 virtual ~GrDrawState() {
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +000066 this->disableStages();
robertphillips@google.com9ec07532012-06-22 12:01:30 +000067 GrSafeSetNull(fRenderTarget);
68 }
69
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000070 /**
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +000071 * Resets to the default state.
72 * Sampler states *will* be modified: textures or CustomStage objects
73 * will be released.
rmistry@google.comd6176b02012-08-23 18:14:13 +000074 */
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000075 void reset() {
robertphillips@google.com9ec07532012-06-22 12:01:30 +000076
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +000077 this->disableStages();
robertphillips@google.com9ec07532012-06-22 12:01:30 +000078
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000079 fColor = 0xffffffff;
bsalomon@google.com861b3a22012-09-26 17:28:25 +000080 fViewMatrix.reset();
81 GrSafeSetNull(fRenderTarget);
bsalomon@google.com47059542012-06-06 20:51:20 +000082 fSrcBlend = kOne_GrBlendCoeff;
83 fDstBlend = kZero_GrBlendCoeff;
bsalomon@google.com861b3a22012-09-26 17:28:25 +000084 fBlendConstant = 0x0;
85 fFlagBits = 0x0;
86 fVertexEdgeType = kHairLine_EdgeType;
87 fStencilSettings.setDisabled();
88 fFirstCoverageStage = kNumStages;
89 fCoverage = 0xffffffff;
90 fColorFilterMode = SkXfermode::kDst_Mode;
91 fColorFilterColor = 0x0;
92 fDrawFace = kBoth_DrawFace;
bsalomon@google.comaf84e742012-10-05 13:23:24 +000093 }
94
95 /**
96 * Initializes the GrDrawState based on a GrPaint. Note that GrDrawState
bsalomon@google.com1e269b52012-10-15 14:25:31 +000097 * encompasses more than GrPaint. Aspects of GrDrawState that have no
bsalomon@google.comaf84e742012-10-05 13:23:24 +000098 * GrPaint equivalents are not modified. GrPaint has fewer stages than
99 * GrDrawState. The extra GrDrawState stages are disabled.
100 */
101 void setFromPaint(const GrPaint& paint);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000102
103 ///////////////////////////////////////////////////////////////////////////
104 /// @name Color
105 ////
106
107 /**
108 * Sets color for next draw to a premultiplied-alpha color.
109 *
110 * @param color the color to set.
111 */
112 void setColor(GrColor color) { fColor = color; }
113
114 GrColor getColor() const { return fColor; }
115
116 /**
117 * Sets the color to be used for the next draw to be
118 * (r,g,b,a) = (alpha, alpha, alpha, alpha).
119 *
120 * @param alpha The alpha value to set as the color.
121 */
122 void setAlpha(uint8_t a) {
123 this->setColor((a << 24) | (a << 16) | (a << 8) | a);
124 }
125
126 /**
127 * Add a color filter that can be represented by a color and a mode. Applied
128 * after color-computing texture stages.
129 */
130 void setColorFilter(GrColor c, SkXfermode::Mode mode) {
131 fColorFilterColor = c;
132 fColorFilterMode = mode;
133 }
134
135 GrColor getColorFilterColor() const { return fColorFilterColor; }
136 SkXfermode::Mode getColorFilterMode() const { return fColorFilterMode; }
137
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000138 /**
139 * Constructor sets the color to be 'color' which is undone by the destructor.
140 */
141 class AutoColorRestore : public ::GrNoncopyable {
142 public:
143 AutoColorRestore(GrDrawState* drawState, GrColor color) {
144 fDrawState = drawState;
145 fOldColor = fDrawState->getColor();
146 fDrawState->setColor(color);
147 }
148 ~AutoColorRestore() {
149 fDrawState->setColor(fOldColor);
150 }
151 private:
152 GrDrawState* fDrawState;
153 GrColor fOldColor;
154 };
155
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000156 /// @}
157
158 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000159 /// @name Coverage
160 ////
161
162 /**
rmistry@google.comd6176b02012-08-23 18:14:13 +0000163 * Sets a constant fractional coverage to be applied to the draw. The
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000164 * initial value (after construction or reset()) is 0xff. The constant
165 * coverage is ignored when per-vertex coverage is provided.
166 */
167 void setCoverage(uint8_t coverage) {
168 fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage);
169 }
170
171 /**
172 * Version of above that specifies 4 channel per-vertex color. The value
173 * should be premultiplied.
174 */
175 void setCoverage4(GrColor coverage) {
176 fCoverage = coverage;
177 }
178
179 GrColor getCoverage() const {
180 return fCoverage;
181 }
182
183 /// @}
184
185 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000186 /// @name Textures
187 ////
188
189 /**
tomhudson@google.com1e8f0162012-07-20 16:25:18 +0000190 * Creates a GrSingleTextureEffect.
tomhudson@google.com1e8f0162012-07-20 16:25:18 +0000191 */
192 void createTextureEffect(int stage, GrTexture* texture) {
193 GrAssert(!this->getSampler(stage).getCustomStage());
194 this->sampler(stage)->setCustomStage(
195 SkNEW_ARGS(GrSingleTextureEffect, (texture)))->unref();
196 }
bsalomon@google.comb0221772012-10-16 14:16:11 +0000197 void createTextureEffect(int stage, GrTexture* texture, const GrMatrix& matrix) {
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +0000198 GrAssert(!this->getSampler(stage).getCustomStage());
bsalomon@google.comb0221772012-10-16 14:16:11 +0000199 GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture));
200 this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
201 }
202 void createTextureEffect(int stage, GrTexture* texture,
203 const GrMatrix& matrix,
204 const GrTextureParams& params) {
205 GrAssert(!this->getSampler(stage).getCustomStage());
206 GrCustomStage* customStage = SkNEW_ARGS(GrSingleTextureEffect, (texture, params));
207 this->sampler(stage)->setCustomStage(customStage, matrix)->unref();
bsalomon@google.com1ce49fc2012-09-18 14:14:49 +0000208 }
209
tomhudson@google.com1e8f0162012-07-20 16:25:18 +0000210
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000211 bool stagesDisabled() {
212 for (int i = 0; i < kNumStages; ++i) {
bsalomon@google.comcddaf342012-07-30 13:09:05 +0000213 if (NULL != fSamplerStates[i].getCustomStage()) {
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000214 return false;
215 }
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000216 }
tomhudson@google.com3eee8fb2012-06-25 12:30:34 +0000217 return true;
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000218 }
tomhudson@google.com676e6602012-07-10 17:21:48 +0000219
220 void disableStage(int index) {
tomhudson@google.com676e6602012-07-10 17:21:48 +0000221 fSamplerStates[index].setCustomStage(NULL);
222 }
223
robertphillips@google.com972265d2012-06-13 18:49:30 +0000224 /**
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000225 * Release all the textures and custom stages referred to by this
226 * draw state.
robertphillips@google.com972265d2012-06-13 18:49:30 +0000227 */
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000228 void disableStages() {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000229 for (int i = 0; i < kNumStages; ++i) {
tomhudson@google.com676e6602012-07-10 17:21:48 +0000230 this->disableStage(i);
robertphillips@google.com972265d2012-06-13 18:49:30 +0000231 }
232 }
233
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000234 class AutoStageDisable : public ::GrNoncopyable {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000235 public:
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000236 AutoStageDisable(GrDrawState* ds) : fDrawState(ds) {}
237 ~AutoStageDisable() {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000238 if (NULL != fDrawState) {
tomhudson@google.com7d6afdd2012-06-22 20:10:50 +0000239 fDrawState->disableStages();
robertphillips@google.com972265d2012-06-13 18:49:30 +0000240 }
241 }
242 private:
243 GrDrawState* fDrawState;
244 };
245
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000246 /// @}
247
248 ///////////////////////////////////////////////////////////////////////////
249 /// @name Samplers
250 ////
251
252 /**
253 * Returns the current sampler for a stage.
254 */
255 const GrSamplerState& getSampler(int stage) const {
256 GrAssert((unsigned)stage < kNumStages);
257 return fSamplerStates[stage];
258 }
259
260 /**
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000261 * Writable pointer to a stage's sampler.
262 */
263 GrSamplerState* sampler(int stage) {
264 GrAssert((unsigned)stage < kNumStages);
265 return fSamplerStates + stage;
266 }
267
268 /**
bsalomon@google.come3d32162012-07-20 13:37:06 +0000269 * Preconcats the matrix of all samplers of enabled stages with a matrix.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000270 */
bsalomon@google.come3d32162012-07-20 13:37:06 +0000271 void preConcatSamplerMatrices(const GrMatrix& matrix) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000272 for (int i = 0; i < kNumStages; ++i) {
bsalomon@google.come3d32162012-07-20 13:37:06 +0000273 if (this->isStageEnabled(i)) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000274 fSamplerStates[i].preConcatMatrix(matrix);
275 }
276 }
277 }
278
bsalomon@google.come3d32162012-07-20 13:37:06 +0000279 /**
280 * Preconcats the matrix of all samplers in the mask with the inverse of a
281 * matrix. If the matrix inverse cannot be computed (and there is at least
282 * one enabled stage) then false is returned.
283 */
284 bool preConcatSamplerMatricesWithInverse(const GrMatrix& matrix) {
285 GrMatrix inv;
286 bool computed = false;
287 for (int i = 0; i < kNumStages; ++i) {
288 if (this->isStageEnabled(i)) {
289 if (!computed && !matrix.invert(&inv)) {
290 return false;
291 } else {
292 computed = true;
293 }
294 fSamplerStates[i].preConcatMatrix(inv);
295 }
296 }
297 return true;
298 }
299
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000300 /// @}
301
302 ///////////////////////////////////////////////////////////////////////////
303 /// @name Coverage / Color Stages
304 ////
305
306 /**
307 * A common pattern is to compute a color with the initial stages and then
308 * modulate that color by a coverage value in later stage(s) (AA, mask-
rmistry@google.comd6176b02012-08-23 18:14:13 +0000309 * filters, glyph mask, etc). Color-filters, xfermodes, etc should be
310 * computed based on the pre-coverage-modulated color. The division of
311 * stages between color-computing and coverage-computing is specified by
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000312 * this method. Initially this is kNumStages (all stages
313 * are color-computing).
314 */
315 void setFirstCoverageStage(int firstCoverageStage) {
316 GrAssert((unsigned)firstCoverageStage <= kNumStages);
rmistry@google.comd6176b02012-08-23 18:14:13 +0000317 fFirstCoverageStage = firstCoverageStage;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000318 }
319
320 /**
321 * Gets the index of the first coverage-computing stage.
322 */
323 int getFirstCoverageStage() const {
rmistry@google.comd6176b02012-08-23 18:14:13 +0000324 return fFirstCoverageStage;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000325 }
326
327 ///@}
328
329 ///////////////////////////////////////////////////////////////////////////
330 /// @name Blending
331 ////
332
333 /**
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000334 * Sets the blending function coefficients.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000335 *
336 * The blend function will be:
337 * D' = sat(S*srcCoef + D*dstCoef)
338 *
339 * where D is the existing destination color, S is the incoming source
340 * color, and D' is the new destination color that will be written. sat()
341 * is the saturation function.
342 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000343 * @param srcCoef coefficient applied to the src color.
344 * @param dstCoef coefficient applied to the dst color.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000345 */
346 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
347 fSrcBlend = srcCoeff;
348 fDstBlend = dstCoeff;
349 #if GR_DEBUG
350 switch (dstCoeff) {
bsalomon@google.com47059542012-06-06 20:51:20 +0000351 case kDC_GrBlendCoeff:
352 case kIDC_GrBlendCoeff:
353 case kDA_GrBlendCoeff:
354 case kIDA_GrBlendCoeff:
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000355 GrPrintf("Unexpected dst blend coeff. Won't work correctly with"
356 "coverage stages.\n");
357 break;
358 default:
359 break;
360 }
361 switch (srcCoeff) {
bsalomon@google.com47059542012-06-06 20:51:20 +0000362 case kSC_GrBlendCoeff:
363 case kISC_GrBlendCoeff:
364 case kSA_GrBlendCoeff:
365 case kISA_GrBlendCoeff:
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000366 GrPrintf("Unexpected src blend coeff. Won't work correctly with"
367 "coverage stages.\n");
368 break;
369 default:
370 break;
371 }
372 #endif
373 }
374
375 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; }
376 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; }
377
378 void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff,
379 GrBlendCoeff* dstBlendCoeff) const {
380 *srcBlendCoeff = fSrcBlend;
381 *dstBlendCoeff = fDstBlend;
382 }
383
384 /**
385 * Sets the blending function constant referenced by the following blending
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000386 * coefficients:
bsalomon@google.com47059542012-06-06 20:51:20 +0000387 * kConstC_GrBlendCoeff
388 * kIConstC_GrBlendCoeff
389 * kConstA_GrBlendCoeff
390 * kIConstA_GrBlendCoeff
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000391 *
392 * @param constant the constant to set
393 */
394 void setBlendConstant(GrColor constant) { fBlendConstant = constant; }
395
396 /**
397 * Retrieves the last value set by setBlendConstant()
398 * @return the blending constant value
399 */
400 GrColor getBlendConstant() const { return fBlendConstant; }
401
402 /// @}
403
404 ///////////////////////////////////////////////////////////////////////////
405 /// @name View Matrix
406 ////
407
408 /**
robertphillips@google.coma72eef32012-05-01 17:22:59 +0000409 * Sets the matrix applied to vertex positions.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000410 *
411 * In the post-view-matrix space the rectangle [0,w]x[0,h]
412 * fully covers the render target. (w and h are the width and height of the
413 * the rendertarget.)
414 */
415 void setViewMatrix(const GrMatrix& m) { fViewMatrix = m; }
416
417 /**
418 * Gets a writable pointer to the view matrix.
419 */
420 GrMatrix* viewMatrix() { return &fViewMatrix; }
421
422 /**
423 * Multiplies the current view matrix by a matrix
424 *
425 * After this call V' = V*m where V is the old view matrix,
426 * m is the parameter to this function, and V' is the new view matrix.
427 * (We consider positions to be column vectors so position vector p is
428 * transformed by matrix X as p' = X*p.)
429 *
430 * @param m the matrix used to modify the view matrix.
431 */
432 void preConcatViewMatrix(const GrMatrix& m) { fViewMatrix.preConcat(m); }
433
434 /**
435 * Multiplies the current view matrix by a matrix
436 *
437 * After this call V' = m*V where V is the old view matrix,
438 * m is the parameter to this function, and V' is the new view matrix.
439 * (We consider positions to be column vectors so position vector p is
440 * transformed by matrix X as p' = X*p.)
441 *
442 * @param m the matrix used to modify the view matrix.
443 */
444 void postConcatViewMatrix(const GrMatrix& m) { fViewMatrix.postConcat(m); }
445
446 /**
447 * Retrieves the current view matrix
448 * @return the current view matrix.
449 */
450 const GrMatrix& getViewMatrix() const { return fViewMatrix; }
451
452 /**
453 * Retrieves the inverse of the current view matrix.
454 *
455 * If the current view matrix is invertible, return true, and if matrix
456 * is non-null, copy the inverse into it. If the current view matrix is
457 * non-invertible, return false and ignore the matrix parameter.
458 *
459 * @param matrix if not null, will receive a copy of the current inverse.
460 */
461 bool getViewInverse(GrMatrix* matrix) const {
462 // TODO: determine whether we really need to leave matrix unmodified
463 // at call sites when inversion fails.
464 GrMatrix inverse;
465 if (fViewMatrix.invert(&inverse)) {
466 if (matrix) {
467 *matrix = inverse;
468 }
469 return true;
470 }
471 return false;
472 }
473
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000474 ////////////////////////////////////////////////////////////////////////////
475
476 /**
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000477 * Preconcats the current view matrix and restores the previous view matrix in the destructor.
478 * Stage matrices are automatically adjusted to compensate.
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000479 */
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000480 class AutoViewMatrixRestore : public ::GrNoncopyable {
481 public:
482 AutoViewMatrixRestore() : fDrawState(NULL) {}
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000483
484 AutoViewMatrixRestore(GrDrawState* ds,
485 const GrMatrix& preconcatMatrix,
486 uint32_t explicitCoordStageMask = 0) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000487 fDrawState = NULL;
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000488 this->set(ds, preconcatMatrix, explicitCoordStageMask);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000489 }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000490
491 ~AutoViewMatrixRestore() { this->restore(); }
492
bsalomon@google.coma8347462012-10-08 18:59:39 +0000493 /**
494 * Can be called prior to destructor to restore the original matrix.
495 */
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000496 void restore();
skia.committer@gmail.comf467ce72012-10-09 02:01:37 +0000497
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000498 void set(GrDrawState* drawState,
499 const GrMatrix& preconcatMatrix,
500 uint32_t explicitCoordStageMask = 0);
501
bsalomon@google.comded4f4b2012-06-28 18:48:06 +0000502 bool isSet() const { return NULL != fDrawState; }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000503
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000504 private:
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000505 GrDrawState* fDrawState;
506 GrMatrix fViewMatrix;
507 GrMatrix fSamplerMatrices[GrDrawState::kNumStages];
508 uint32_t fRestoreMask;
tomhudson@google.com93813632011-10-27 20:21:16 +0000509 };
510
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000511 ////////////////////////////////////////////////////////////////////////////
512
513 /**
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000514 * This sets the view matrix to identity and adjusts stage matrices to compensate. The
515 * destructor undoes the changes, restoring the view matrix that was set before the
516 * constructor. It is similar to passing the inverse of the current view matrix to
517 * AutoViewMatrixRestore, but lazily computes the inverse only if necessary.
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000518 */
519 class AutoDeviceCoordDraw : ::GrNoncopyable {
520 public:
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000521 AutoDeviceCoordDraw() : fDrawState(NULL) {}
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000522 /**
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000523 * If a stage's texture matrix is applied to explicit per-vertex coords, rather than to
524 * positions, then we don't want to modify its matrix. The explicitCoordStageMask is used
525 * to specify such stages.
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000526 */
527 AutoDeviceCoordDraw(GrDrawState* drawState,
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000528 uint32_t explicitCoordStageMask = 0) {
529 fDrawState = NULL;
530 this->set(drawState, explicitCoordStageMask);
531 }
532
bsalomon@google.coma8347462012-10-08 18:59:39 +0000533 ~AutoDeviceCoordDraw() { this->restore(); }
534
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000535 bool set(GrDrawState* drawState, uint32_t explicitCoordStageMask = 0);
536
bsalomon@google.coma8347462012-10-08 18:59:39 +0000537 /**
538 * Returns true if this object was successfully initialized on to a GrDrawState. It may
539 * return false because a non-default constructor or set() were never called or because
540 * the view matrix was not invertible.
541 */
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000542 bool succeeded() const { return NULL != fDrawState; }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000543
bsalomon@google.coma8347462012-10-08 18:59:39 +0000544 /**
545 * Returns the matrix that was set previously set on the drawState. This is only valid
546 * if succeeded returns true.
547 */
548 const GrMatrix& getOriginalMatrix() const {
549 GrAssert(this->succeeded());
550 return fViewMatrix;
551 }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000552
bsalomon@google.coma8347462012-10-08 18:59:39 +0000553 /**
554 * Can be called prior to destructor to restore the original matrix.
555 */
556 void restore();
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000557
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000558 private:
559 GrDrawState* fDrawState;
560 GrMatrix fViewMatrix;
561 GrMatrix fSamplerMatrices[GrDrawState::kNumStages];
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000562 uint32_t fRestoreMask;
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000563 };
564
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000565 /// @}
566
567 ///////////////////////////////////////////////////////////////////////////
568 /// @name Render Target
569 ////
570
571 /**
572 * Sets the rendertarget used at the next drawing call
573 *
574 * @param target The render target to set.
575 */
rmistry@google.comd6176b02012-08-23 18:14:13 +0000576 void setRenderTarget(GrRenderTarget* target) {
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000577 GrSafeAssign(fRenderTarget, target);
578 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000579
580 /**
581 * Retrieves the currently set rendertarget.
582 *
583 * @return The currently set render target.
584 */
585 const GrRenderTarget* getRenderTarget() const { return fRenderTarget; }
586 GrRenderTarget* getRenderTarget() { return fRenderTarget; }
587
588 class AutoRenderTargetRestore : public ::GrNoncopyable {
589 public:
bsalomon@google.comcadbcb82012-01-06 19:22:11 +0000590 AutoRenderTargetRestore() : fDrawState(NULL), fSavedTarget(NULL) {}
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000591 AutoRenderTargetRestore(GrDrawState* ds, GrRenderTarget* newTarget) {
592 fDrawState = NULL;
robertphillips@google.com7460b372012-04-25 16:54:51 +0000593 fSavedTarget = NULL;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000594 this->set(ds, newTarget);
595 }
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000596 ~AutoRenderTargetRestore() { this->restore(); }
597
598 void restore() {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000599 if (NULL != fDrawState) {
600 fDrawState->setRenderTarget(fSavedTarget);
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000601 fDrawState = NULL;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000602 }
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000603 GrSafeSetNull(fSavedTarget);
604 }
605
606 void set(GrDrawState* ds, GrRenderTarget* newTarget) {
607 this->restore();
608
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000609 if (NULL != ds) {
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000610 GrAssert(NULL == fSavedTarget);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000611 fSavedTarget = ds->getRenderTarget();
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000612 SkSafeRef(fSavedTarget);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000613 ds->setRenderTarget(newTarget);
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000614 fDrawState = ds;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000615 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000616 }
617 private:
618 GrDrawState* fDrawState;
619 GrRenderTarget* fSavedTarget;
620 };
621
622 /// @}
623
624 ///////////////////////////////////////////////////////////////////////////
625 /// @name Stencil
626 ////
627
628 /**
629 * Sets the stencil settings to use for the next draw.
630 * Changing the clip has the side-effect of possibly zeroing
631 * out the client settable stencil bits. So multipass algorithms
632 * using stencil should not change the clip between passes.
633 * @param settings the stencil settings to use.
634 */
635 void setStencil(const GrStencilSettings& settings) {
636 fStencilSettings = settings;
637 }
638
639 /**
640 * Shortcut to disable stencil testing and ops.
641 */
642 void disableStencil() {
643 fStencilSettings.setDisabled();
644 }
645
646 const GrStencilSettings& getStencil() const { return fStencilSettings; }
647
648 GrStencilSettings* stencil() { return &fStencilSettings; }
649
650 /// @}
651
652 ///////////////////////////////////////////////////////////////////////////
senorblanco@chromium.org50bdad82012-01-03 20:51:57 +0000653 /// @name Color Matrix
654 ////
655
656 /**
657 * Sets the color matrix to use for the next draw.
658 * @param matrix the 5x4 matrix to apply to the incoming color
659 */
660 void setColorMatrix(const float matrix[20]) {
661 memcpy(fColorMatrix, matrix, sizeof(fColorMatrix));
662 }
663
664 const float* getColorMatrix() const { return fColorMatrix; }
665
666 /// @}
667
668 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000669 // @name Edge AA
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000670 // Edge equations can be specified to perform anti-aliasing. Because the
bsalomon@google.com7ffe6812012-05-11 17:32:43 +0000671 // edges are specified as per-vertex data, vertices that are shared by
672 // multiple edges must be split.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000673 //
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000674 ////
675
676 /**
tomhudson@google.com93813632011-10-27 20:21:16 +0000677 * When specifying edges as vertex data this enum specifies what type of
678 * edges are in use. The edges are always 4 GrScalars in memory, even when
679 * the edge type requires fewer than 4.
bsalomon@google.com93c96602012-04-27 13:05:21 +0000680 *
681 * TODO: Fix the fact that HairLine and Circle edge types use y-down coords.
682 * (either adjust in VS or use origin_upper_left in GLSL)
tomhudson@google.com93813632011-10-27 20:21:16 +0000683 */
684 enum VertexEdgeType {
685 /* 1-pixel wide line
686 2D implicit line eq (a*x + b*y +c = 0). 4th component unused */
687 kHairLine_EdgeType,
rmistry@google.comd6176b02012-08-23 18:14:13 +0000688 /* Quadratic specified by u^2-v canonical coords (only 2
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +0000689 components used). Coverage based on signed distance with negative
bsalomon@google.com93c96602012-04-27 13:05:21 +0000690 being inside, positive outside. Edge specified in window space
691 (y-down) */
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +0000692 kQuad_EdgeType,
693 /* Same as above but for hairline quadratics. Uses unsigned distance.
694 Coverage is min(0, 1-distance). */
695 kHairQuad_EdgeType,
bsalomon@google.com93c96602012-04-27 13:05:21 +0000696 /* Circle specified as center_x, center_y, outer_radius, inner_radius
697 all in window space (y-down). */
698 kCircle_EdgeType,
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +0000699
700 kVertexEdgeTypeCnt
tomhudson@google.com93813632011-10-27 20:21:16 +0000701 };
702
703 /**
rmistry@google.comd6176b02012-08-23 18:14:13 +0000704 * Determines the interpretation per-vertex edge data when the
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000705 * kEdge_VertexLayoutBit is set (see GrDrawTarget). When per-vertex edges
706 * are not specified the value of this setting has no effect.
707 */
708 void setVertexEdgeType(VertexEdgeType type) {
bsalomon@google.com69cc6ad2012-01-17 14:25:10 +0000709 GrAssert(type >=0 && type < kVertexEdgeTypeCnt);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000710 fVertexEdgeType = type;
711 }
712
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +0000713 VertexEdgeType getVertexEdgeType() const { return fVertexEdgeType; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000714
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000715 /// @}
tomhudson@google.com62b09682011-11-09 16:39:17 +0000716
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000717 ///////////////////////////////////////////////////////////////////////////
718 /// @name State Flags
719 ////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000720
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000721 /**
722 * Flags that affect rendering. Controlled using enable/disableState(). All
723 * default to disabled.
724 */
725 enum StateBits {
726 /**
727 * Perform dithering. TODO: Re-evaluate whether we need this bit
728 */
729 kDither_StateBit = 0x01,
730 /**
731 * Perform HW anti-aliasing. This means either HW FSAA, if supported
732 * by the render target, or smooth-line rendering if a line primitive
733 * is drawn and line smoothing is supported by the 3D API.
734 */
735 kHWAntialias_StateBit = 0x02,
736 /**
737 * Draws will respect the clip, otherwise the clip is ignored.
738 */
739 kClip_StateBit = 0x04,
740 /**
741 * Disables writing to the color buffer. Useful when performing stencil
742 * operations.
743 */
744 kNoColorWrites_StateBit = 0x08,
745 /**
senorblanco@chromium.org50bdad82012-01-03 20:51:57 +0000746 * Draws will apply the color matrix, otherwise the color matrix is
747 * ignored.
748 */
bsalomon@google.com0342a852012-08-20 19:22:38 +0000749 kColorMatrix_StateBit = 0x10,
750
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000751 // Users of the class may add additional bits to the vector
752 kDummyStateBit,
753 kLastPublicStateBit = kDummyStateBit-1,
754 };
755
756 void resetStateFlags() {
757 fFlagBits = 0;
758 }
759
760 /**
761 * Enable render state settings.
762 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000763 * @param stateBits bitfield of StateBits specifying the states to enable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000764 */
765 void enableState(uint32_t stateBits) {
766 fFlagBits |= stateBits;
767 }
768
769 /**
770 * Disable render state settings.
771 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000772 * @param stateBits bitfield of StateBits specifying the states to disable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000773 */
774 void disableState(uint32_t stateBits) {
775 fFlagBits &= ~(stateBits);
776 }
777
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000778 /**
779 * Enable or disable stateBits based on a boolean.
780 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000781 * @param stateBits bitfield of StateBits to enable or disable
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000782 * @param enable if true enable stateBits, otherwise disable
783 */
784 void setState(uint32_t stateBits, bool enable) {
785 if (enable) {
786 this->enableState(stateBits);
787 } else {
788 this->disableState(stateBits);
789 }
790 }
791
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000792 bool isDitherState() const {
793 return 0 != (fFlagBits & kDither_StateBit);
794 }
795
796 bool isHWAntialiasState() const {
797 return 0 != (fFlagBits & kHWAntialias_StateBit);
798 }
799
800 bool isClipState() const {
801 return 0 != (fFlagBits & kClip_StateBit);
802 }
803
804 bool isColorWriteDisabled() const {
805 return 0 != (fFlagBits & kNoColorWrites_StateBit);
806 }
807
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000808 bool isStateFlagEnabled(uint32_t stateBit) const {
809 return 0 != (stateBit & fFlagBits);
810 }
811
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000812 /// @}
813
814 ///////////////////////////////////////////////////////////////////////////
815 /// @name Face Culling
816 ////
817
818 enum DrawFace {
bsalomon@google.com978c8c62012-05-21 14:45:49 +0000819 kInvalid_DrawFace = -1,
820
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000821 kBoth_DrawFace,
822 kCCW_DrawFace,
823 kCW_DrawFace,
824 };
825
826 /**
827 * Controls whether clockwise, counterclockwise, or both faces are drawn.
828 * @param face the face(s) to draw.
829 */
830 void setDrawFace(DrawFace face) {
bsalomon@google.com978c8c62012-05-21 14:45:49 +0000831 GrAssert(kInvalid_DrawFace != face);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000832 fDrawFace = face;
833 }
834
835 /**
836 * Gets whether the target is drawing clockwise, counterclockwise,
837 * or both faces.
838 * @return the current draw face(s).
839 */
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +0000840 DrawFace getDrawFace() const { return fDrawFace; }
rmistry@google.comd6176b02012-08-23 18:14:13 +0000841
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000842 /// @}
843
844 ///////////////////////////////////////////////////////////////////////////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000845
tomhudson@google.comf13f5882012-06-25 17:27:28 +0000846 bool isStageEnabled(int s) const {
847 GrAssert((unsigned)s < kNumStages);
bsalomon@google.comcddaf342012-07-30 13:09:05 +0000848 return (NULL != fSamplerStates[s].getCustomStage());
tomhudson@google.comf13f5882012-06-25 17:27:28 +0000849 }
850
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000851 // Most stages are usually not used, so conditionals here
852 // reduce the expected number of bytes touched by 50%.
853 bool operator ==(const GrDrawState& s) const {
bsalomon@google.com861b3a22012-09-26 17:28:25 +0000854 if (fColor != s.fColor ||
855 !s.fViewMatrix.cheapEqualTo(fViewMatrix) ||
856 fRenderTarget != s.fRenderTarget ||
857 fSrcBlend != s.fSrcBlend ||
858 fDstBlend != s.fDstBlend ||
859 fBlendConstant != s.fBlendConstant ||
860 fFlagBits != s.fFlagBits ||
861 fVertexEdgeType != s.fVertexEdgeType ||
862 fStencilSettings != s.fStencilSettings ||
863 fFirstCoverageStage != s.fFirstCoverageStage ||
864 fCoverage != s.fCoverage ||
865 fColorFilterMode != s.fColorFilterMode ||
866 fColorFilterColor != s.fColorFilterColor ||
867 fDrawFace != s.fDrawFace) {
bsalomon@google.com8fe84b52012-03-26 15:24:27 +0000868 return false;
869 }
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000870
871 for (int i = 0; i < kNumStages; i++) {
bsalomon@google.comf2f8fc32012-07-18 18:25:07 +0000872 bool enabled = this->isStageEnabled(i);
873 if (enabled != s.isStageEnabled(i)) {
874 return false;
875 }
876 if (enabled && this->fSamplerStates[i] != s.fSamplerStates[i]) {
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000877 return false;
878 }
879 }
bsalomon@google.com9b1517e2012-03-05 17:58:34 +0000880 if (kColorMatrix_StateBit & s.fFlagBits) {
881 if (memcmp(fColorMatrix,
882 s.fColorMatrix,
883 sizeof(fColorMatrix))) {
884 return false;
885 }
886 }
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000887
888 return true;
889 }
890 bool operator !=(const GrDrawState& s) const { return !(*this == s); }
891
rmistry@google.comd6176b02012-08-23 18:14:13 +0000892 // Most stages are usually not used, so conditionals here
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000893 // reduce the expected number of bytes touched by 50%.
894 GrDrawState& operator =(const GrDrawState& s) {
bsalomon@google.com861b3a22012-09-26 17:28:25 +0000895 fColor = s.fColor;
bsalomon@google.com8fe84b52012-03-26 15:24:27 +0000896 fViewMatrix = s.fViewMatrix;
bsalomon@google.com861b3a22012-09-26 17:28:25 +0000897 SkRefCnt_SafeAssign(fRenderTarget, s.fRenderTarget);
898 fSrcBlend = s.fSrcBlend;
899 fDstBlend = s.fDstBlend;
900 fBlendConstant = s.fBlendConstant;
901 fFlagBits = s.fFlagBits;
902 fVertexEdgeType = s.fVertexEdgeType;
903 fStencilSettings = s.fStencilSettings;
904 fFirstCoverageStage = s.fFirstCoverageStage;
905 fCoverage = s.fCoverage;
906 fColorFilterMode = s.fColorFilterMode;
907 fColorFilterColor = s.fColorFilterColor;
908 fDrawFace = s.fDrawFace;
bsalomon@google.com8fe84b52012-03-26 15:24:27 +0000909
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000910 for (int i = 0; i < kNumStages; i++) {
tomhudson@google.come742bf02012-07-13 19:54:19 +0000911 if (s.isStageEnabled(i)) {
tomhudson@google.com02b1ea22012-04-30 20:19:07 +0000912 this->fSamplerStates[i] = s.fSamplerStates[i];
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000913 }
914 }
robertphillips@google.com9ec07532012-06-22 12:01:30 +0000915
bsalomon@google.com9b1517e2012-03-05 17:58:34 +0000916 if (kColorMatrix_StateBit & s.fFlagBits) {
917 memcpy(this->fColorMatrix, s.fColorMatrix, sizeof(fColorMatrix));
918 }
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000919
920 return *this;
921 }
922
923private:
bsalomon@google.com2e3d1442012-03-26 20:33:54 +0000924
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000925 // These fields are roughly sorted by decreasing likelihood of being different in op==
bsalomon@google.com861b3a22012-09-26 17:28:25 +0000926 GrColor fColor;
927 GrMatrix fViewMatrix;
928 GrRenderTarget* fRenderTarget;
929 GrBlendCoeff fSrcBlend;
930 GrBlendCoeff fDstBlend;
931 GrColor fBlendConstant;
932 uint32_t fFlagBits;
robertphillips@google.comc077d1e2012-05-28 14:10:15 +0000933 VertexEdgeType fVertexEdgeType;
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +0000934 GrStencilSettings fStencilSettings;
robertphillips@google.com69ffcf02012-06-26 21:01:05 +0000935 int fFirstCoverageStage;
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000936 GrColor fCoverage;
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +0000937 SkXfermode::Mode fColorFilterMode;
bsalomon@google.com861b3a22012-09-26 17:28:25 +0000938 GrColor fColorFilterColor;
939 DrawFace fDrawFace;
bsalomon@google.com8fe84b52012-03-26 15:24:27 +0000940
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000941 // This field must be last; it will not be copied or compared
942 // if the corresponding fTexture[] is NULL.
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +0000943 GrSamplerState fSamplerStates[kNumStages];
bsalomon@google.com9b1517e2012-03-05 17:58:34 +0000944 // only compared if the color matrix enable flag is set
945 float fColorMatrix[20]; // 5 x 4 matrix
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000946
reed@google.comfa35e3d2012-06-26 20:16:17 +0000947 typedef GrRefCnt INHERITED;
tomhudson@google.com93813632011-10-27 20:21:16 +0000948};
949
950#endif