tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 1 | /* |
| 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 | |
bsalomon@google.com | 2eaaefd | 2012-10-29 19:51:22 +0000 | [diff] [blame] | 11 | #include "GrBackendEffectFactory.h" |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 12 | #include "GrColor.h" |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 13 | #include "SkMatrix.h" |
bsalomon@google.com | 2e3d144 | 2012-03-26 20:33:54 +0000 | [diff] [blame] | 14 | #include "GrRefCnt.h" |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 15 | #include "GrEffectStage.h" |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 16 | #include "GrStencil.h" |
bsalomon@google.com | 64aef2b | 2012-06-11 15:36:13 +0000 | [diff] [blame] | 17 | #include "GrTexture.h" |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 18 | #include "GrRenderTarget.h" |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 19 | #include "effects/GrSimpleTextureEffect.h" |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 20 | |
| 21 | #include "SkXfermode.h" |
| 22 | |
bsalomon@google.com | af84e74 | 2012-10-05 13:23:24 +0000 | [diff] [blame] | 23 | class GrPaint; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 24 | |
bsalomon@google.com | 2e3d144 | 2012-03-26 20:33:54 +0000 | [diff] [blame] | 25 | class GrDrawState : public GrRefCnt { |
bsalomon@google.com | 2e3d144 | 2012-03-26 20:33:54 +0000 | [diff] [blame] | 26 | public: |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 27 | SK_DECLARE_INST_COUNT(GrDrawState) |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 28 | |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 29 | /** |
bsalomon@google.com | 1322134 | 2012-10-26 13:41:59 +0000 | [diff] [blame] | 30 | * Total number of effect stages. Each stage can host a GrEffect. A stage is enabled if it has a |
| 31 | * GrEffect. The effect produces an output color in the fragment shader. It's inputs are the |
| 32 | * output from the previous enabled stage and a position. The position is either derived from |
| 33 | * the interpolated vertex positions or explicit per-vertex coords, depending upon the |
| 34 | * GrVertexLayout used to draw. |
robertphillips@google.com | bf5cad4 | 2012-05-10 12:40:40 +0000 | [diff] [blame] | 35 | * |
bsalomon@google.com | 1322134 | 2012-10-26 13:41:59 +0000 | [diff] [blame] | 36 | * The stages are divided into two sets, color-computing and coverage-computing. The final color |
| 37 | * stage produces the final pixel color. The coverage-computing stages function exactly as the |
| 38 | * color-computing but the output of the final coverage stage is treated as a fractional pixel |
| 39 | * coverage rather than as input to the src/dst color blend step. |
| 40 | * |
| 41 | * The input color to the first enabled color-stage is either the constant color or interpolated |
| 42 | * per-vertex colors, depending upon GrVertexLayout. The input to the first coverage stage is |
| 43 | * either a constant coverage (usually full-coverage), interpolated per-vertex coverage, or |
| 44 | * edge-AA computed coverage. (This latter is going away as soon as it can be rewritten as a |
| 45 | * GrEffect). |
| 46 | * |
bsalomon@google.com | cf939ae | 2012-12-13 19:59:23 +0000 | [diff] [blame] | 47 | * See the documentation of kCoverageDrawing_StateBit for information about disabling the |
| 48 | * the color / coverage distinction. |
| 49 | * |
bsalomon@google.com | 1322134 | 2012-10-26 13:41:59 +0000 | [diff] [blame] | 50 | * Stages 0 through GrPaint::kTotalStages-1 are reserved for stages copied from the client's |
| 51 | * GrPaint. Stages GrPaint::kTotalStages through kNumStages-2 are earmarked for use by |
| 52 | * GrTextContext and GrPathRenderer-derived classes. kNumStages-1 is earmarked for clipping |
bsalomon@google.com | dfdb7e5 | 2012-10-16 15:19:45 +0000 | [diff] [blame] | 53 | * by GrClipMaskManager. |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 54 | */ |
| 55 | enum { |
twiz@google.com | 5807116 | 2012-07-18 21:41:50 +0000 | [diff] [blame] | 56 | kNumStages = 5, |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 57 | kMaxTexCoords = kNumStages |
| 58 | }; |
| 59 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 60 | GrDrawState() |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 61 | : fRenderTarget(NULL) { |
| 62 | |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 63 | this->reset(); |
| 64 | } |
bsalomon@google.com | 46f7afb | 2012-01-18 19:51:55 +0000 | [diff] [blame] | 65 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 66 | GrDrawState(const GrDrawState& state) |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 67 | : fRenderTarget(NULL) { |
| 68 | |
bsalomon@google.com | 46f7afb | 2012-01-18 19:51:55 +0000 | [diff] [blame] | 69 | *this = state; |
| 70 | } |
| 71 | |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 72 | virtual ~GrDrawState() { |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 73 | this->disableStages(); |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 74 | GrSafeSetNull(fRenderTarget); |
| 75 | } |
| 76 | |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 77 | /** |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 78 | * Resets to the default state. |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 79 | * GrEffects will be removed from all stages. |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 80 | */ |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 81 | void reset() { |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 82 | |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 83 | this->disableStages(); |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 84 | |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 85 | fColor = 0xffffffff; |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 86 | fViewMatrix.reset(); |
| 87 | GrSafeSetNull(fRenderTarget); |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 88 | fSrcBlend = kOne_GrBlendCoeff; |
| 89 | fDstBlend = kZero_GrBlendCoeff; |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 90 | fBlendConstant = 0x0; |
| 91 | fFlagBits = 0x0; |
| 92 | fVertexEdgeType = kHairLine_EdgeType; |
| 93 | fStencilSettings.setDisabled(); |
| 94 | fFirstCoverageStage = kNumStages; |
| 95 | fCoverage = 0xffffffff; |
| 96 | fColorFilterMode = SkXfermode::kDst_Mode; |
| 97 | fColorFilterColor = 0x0; |
| 98 | fDrawFace = kBoth_DrawFace; |
bsalomon@google.com | af84e74 | 2012-10-05 13:23:24 +0000 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Initializes the GrDrawState based on a GrPaint. Note that GrDrawState |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 103 | * encompasses more than GrPaint. Aspects of GrDrawState that have no |
bsalomon@google.com | af84e74 | 2012-10-05 13:23:24 +0000 | [diff] [blame] | 104 | * GrPaint equivalents are not modified. GrPaint has fewer stages than |
| 105 | * GrDrawState. The extra GrDrawState stages are disabled. |
| 106 | */ |
| 107 | void setFromPaint(const GrPaint& paint); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 108 | |
| 109 | /////////////////////////////////////////////////////////////////////////// |
| 110 | /// @name Color |
| 111 | //// |
| 112 | |
| 113 | /** |
| 114 | * Sets color for next draw to a premultiplied-alpha color. |
| 115 | * |
| 116 | * @param color the color to set. |
| 117 | */ |
| 118 | void setColor(GrColor color) { fColor = color; } |
| 119 | |
| 120 | GrColor getColor() const { return fColor; } |
| 121 | |
| 122 | /** |
| 123 | * Sets the color to be used for the next draw to be |
| 124 | * (r,g,b,a) = (alpha, alpha, alpha, alpha). |
| 125 | * |
| 126 | * @param alpha The alpha value to set as the color. |
| 127 | */ |
| 128 | void setAlpha(uint8_t a) { |
| 129 | this->setColor((a << 24) | (a << 16) | (a << 8) | a); |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Add a color filter that can be represented by a color and a mode. Applied |
| 134 | * after color-computing texture stages. |
| 135 | */ |
| 136 | void setColorFilter(GrColor c, SkXfermode::Mode mode) { |
| 137 | fColorFilterColor = c; |
| 138 | fColorFilterMode = mode; |
| 139 | } |
| 140 | |
| 141 | GrColor getColorFilterColor() const { return fColorFilterColor; } |
| 142 | SkXfermode::Mode getColorFilterMode() const { return fColorFilterMode; } |
| 143 | |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 144 | /** |
| 145 | * Constructor sets the color to be 'color' which is undone by the destructor. |
| 146 | */ |
| 147 | class AutoColorRestore : public ::GrNoncopyable { |
| 148 | public: |
| 149 | AutoColorRestore(GrDrawState* drawState, GrColor color) { |
| 150 | fDrawState = drawState; |
| 151 | fOldColor = fDrawState->getColor(); |
| 152 | fDrawState->setColor(color); |
| 153 | } |
| 154 | ~AutoColorRestore() { |
| 155 | fDrawState->setColor(fOldColor); |
| 156 | } |
| 157 | private: |
| 158 | GrDrawState* fDrawState; |
| 159 | GrColor fOldColor; |
| 160 | }; |
| 161 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 162 | /// @} |
| 163 | |
| 164 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 2401ae8 | 2012-01-17 21:03:05 +0000 | [diff] [blame] | 165 | /// @name Coverage |
| 166 | //// |
| 167 | |
| 168 | /** |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 169 | * Sets a constant fractional coverage to be applied to the draw. The |
bsalomon@google.com | 2401ae8 | 2012-01-17 21:03:05 +0000 | [diff] [blame] | 170 | * initial value (after construction or reset()) is 0xff. The constant |
| 171 | * coverage is ignored when per-vertex coverage is provided. |
| 172 | */ |
| 173 | void setCoverage(uint8_t coverage) { |
| 174 | fCoverage = GrColorPackRGBA(coverage, coverage, coverage, coverage); |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Version of above that specifies 4 channel per-vertex color. The value |
| 179 | * should be premultiplied. |
| 180 | */ |
| 181 | void setCoverage4(GrColor coverage) { |
| 182 | fCoverage = coverage; |
| 183 | } |
| 184 | |
| 185 | GrColor getCoverage() const { |
| 186 | return fCoverage; |
| 187 | } |
| 188 | |
| 189 | /// @} |
| 190 | |
| 191 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 192 | /// @name Textures |
| 193 | //// |
| 194 | |
| 195 | /** |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 196 | * Creates a GrSimpleTextureEffect. |
tomhudson@google.com | 1e8f016 | 2012-07-20 16:25:18 +0000 | [diff] [blame] | 197 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 198 | void createTextureEffect(int stageIdx, GrTexture* texture, const SkMatrix& matrix) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 199 | GrAssert(!this->getStage(stageIdx).getEffect()); |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 200 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix); |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 201 | this->stage(stageIdx)->setEffect(effect)->unref(); |
bsalomon@google.com | dfdb7e5 | 2012-10-16 15:19:45 +0000 | [diff] [blame] | 202 | } |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 203 | void createTextureEffect(int stageIdx, |
| 204 | GrTexture* texture, |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 205 | const SkMatrix& matrix, |
bsalomon@google.com | dfdb7e5 | 2012-10-16 15:19:45 +0000 | [diff] [blame] | 206 | const GrTextureParams& params) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 207 | GrAssert(!this->getStage(stageIdx).getEffect()); |
bsalomon@google.com | 68b58c9 | 2013-01-17 16:50:08 +0000 | [diff] [blame] | 208 | GrEffectRef* effect = GrSimpleTextureEffect::Create(texture, matrix, params); |
bsalomon@google.com | d8b5fac | 2012-11-01 17:02:46 +0000 | [diff] [blame] | 209 | this->stage(stageIdx)->setEffect(effect)->unref(); |
bsalomon@google.com | 1ce49fc | 2012-09-18 14:14:49 +0000 | [diff] [blame] | 210 | } |
| 211 | |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 212 | bool stagesDisabled() { |
| 213 | for (int i = 0; i < kNumStages; ++i) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 214 | if (NULL != fStages[i].getEffect()) { |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 215 | return false; |
| 216 | } |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 217 | } |
tomhudson@google.com | 3eee8fb | 2012-06-25 12:30:34 +0000 | [diff] [blame] | 218 | return true; |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 219 | } |
tomhudson@google.com | 676e660 | 2012-07-10 17:21:48 +0000 | [diff] [blame] | 220 | |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 221 | void disableStage(int stageIdx) { |
| 222 | fStages[stageIdx].setEffect(NULL); |
tomhudson@google.com | 676e660 | 2012-07-10 17:21:48 +0000 | [diff] [blame] | 223 | } |
| 224 | |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 225 | /** |
bsalomon@google.com | f271cc7 | 2012-10-24 19:35:13 +0000 | [diff] [blame] | 226 | * Release all the GrEffects referred to by this draw state. |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 227 | */ |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 228 | void disableStages() { |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 229 | for (int i = 0; i < kNumStages; ++i) { |
tomhudson@google.com | 676e660 | 2012-07-10 17:21:48 +0000 | [diff] [blame] | 230 | this->disableStage(i); |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 231 | } |
| 232 | } |
| 233 | |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 234 | class AutoStageDisable : public ::GrNoncopyable { |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 235 | public: |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 236 | AutoStageDisable(GrDrawState* ds) : fDrawState(ds) {} |
| 237 | ~AutoStageDisable() { |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 238 | if (NULL != fDrawState) { |
tomhudson@google.com | 7d6afdd | 2012-06-22 20:10:50 +0000 | [diff] [blame] | 239 | fDrawState->disableStages(); |
robertphillips@google.com | 972265d | 2012-06-13 18:49:30 +0000 | [diff] [blame] | 240 | } |
| 241 | } |
| 242 | private: |
| 243 | GrDrawState* fDrawState; |
| 244 | }; |
| 245 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 246 | /// @} |
| 247 | |
| 248 | /////////////////////////////////////////////////////////////////////////// |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 249 | /// @name Stages |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 250 | //// |
| 251 | |
| 252 | /** |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 253 | * Returns the current stage by index. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 254 | */ |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 255 | const GrEffectStage& getStage(int stageIdx) const { |
| 256 | GrAssert((unsigned)stageIdx < kNumStages); |
| 257 | return fStages[stageIdx]; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | /** |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 261 | * Writable pointer to a stage. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 262 | */ |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 263 | GrEffectStage* stage(int stageIdx) { |
| 264 | GrAssert((unsigned)stageIdx < kNumStages); |
| 265 | return fStages + stageIdx; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | /** |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 269 | * Called when the source coord system is changing. preConcat gives the transformation from the |
| 270 | * old coord system to the new coord system. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 271 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 272 | void preConcatStageMatrices(const SkMatrix& preConcat) { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 273 | for (int i = 0; i < kNumStages; ++i) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 274 | if (this->isStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 275 | fStages[i].preConcatCoordChange(preConcat); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 276 | } |
| 277 | } |
| 278 | } |
| 279 | |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 280 | /** |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 281 | * Called when the source coord system is changing. preConcatInverse is the inverse of the |
| 282 | * transformation from the old coord system to the new coord system. Returns false if the matrix |
| 283 | * cannot be inverted. |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 284 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 285 | bool preConcatStageMatricesWithInverse(const SkMatrix& preConcatInverse) { |
| 286 | SkMatrix inv; |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 287 | bool computed = false; |
| 288 | for (int i = 0; i < kNumStages; ++i) { |
| 289 | if (this->isStageEnabled(i)) { |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 290 | if (!computed && !preConcatInverse.invert(&inv)) { |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 291 | return false; |
| 292 | } else { |
| 293 | computed = true; |
| 294 | } |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 295 | fStages[i].preConcatCoordChange(preConcatInverse); |
bsalomon@google.com | e3d3216 | 2012-07-20 13:37:06 +0000 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | return true; |
| 299 | } |
| 300 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 301 | /// @} |
| 302 | |
| 303 | /////////////////////////////////////////////////////////////////////////// |
| 304 | /// @name Coverage / Color Stages |
| 305 | //// |
| 306 | |
| 307 | /** |
| 308 | * A common pattern is to compute a color with the initial stages and then |
| 309 | * modulate that color by a coverage value in later stage(s) (AA, mask- |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 310 | * filters, glyph mask, etc). Color-filters, xfermodes, etc should be |
| 311 | * computed based on the pre-coverage-modulated color. The division of |
| 312 | * stages between color-computing and coverage-computing is specified by |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 313 | * this method. Initially this is kNumStages (all stages |
| 314 | * are color-computing). |
| 315 | */ |
| 316 | void setFirstCoverageStage(int firstCoverageStage) { |
| 317 | GrAssert((unsigned)firstCoverageStage <= kNumStages); |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 318 | fFirstCoverageStage = firstCoverageStage; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 319 | } |
| 320 | |
| 321 | /** |
| 322 | * Gets the index of the first coverage-computing stage. |
| 323 | */ |
| 324 | int getFirstCoverageStage() const { |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 325 | return fFirstCoverageStage; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 326 | } |
| 327 | |
| 328 | ///@} |
| 329 | |
| 330 | /////////////////////////////////////////////////////////////////////////// |
| 331 | /// @name Blending |
| 332 | //// |
| 333 | |
| 334 | /** |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 335 | * Sets the blending function coefficients. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 336 | * |
| 337 | * The blend function will be: |
| 338 | * D' = sat(S*srcCoef + D*dstCoef) |
| 339 | * |
| 340 | * where D is the existing destination color, S is the incoming source |
| 341 | * color, and D' is the new destination color that will be written. sat() |
| 342 | * is the saturation function. |
| 343 | * |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 344 | * @param srcCoef coefficient applied to the src color. |
| 345 | * @param dstCoef coefficient applied to the dst color. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 346 | */ |
| 347 | void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) { |
| 348 | fSrcBlend = srcCoeff; |
| 349 | fDstBlend = dstCoeff; |
| 350 | #if GR_DEBUG |
| 351 | switch (dstCoeff) { |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 352 | case kDC_GrBlendCoeff: |
| 353 | case kIDC_GrBlendCoeff: |
| 354 | case kDA_GrBlendCoeff: |
| 355 | case kIDA_GrBlendCoeff: |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 356 | GrPrintf("Unexpected dst blend coeff. Won't work correctly with" |
| 357 | "coverage stages.\n"); |
| 358 | break; |
| 359 | default: |
| 360 | break; |
| 361 | } |
| 362 | switch (srcCoeff) { |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 363 | case kSC_GrBlendCoeff: |
| 364 | case kISC_GrBlendCoeff: |
| 365 | case kSA_GrBlendCoeff: |
| 366 | case kISA_GrBlendCoeff: |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 367 | GrPrintf("Unexpected src blend coeff. Won't work correctly with" |
| 368 | "coverage stages.\n"); |
| 369 | break; |
| 370 | default: |
| 371 | break; |
| 372 | } |
| 373 | #endif |
| 374 | } |
| 375 | |
| 376 | GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; } |
| 377 | GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; } |
| 378 | |
| 379 | void getDstBlendCoeff(GrBlendCoeff* srcBlendCoeff, |
| 380 | GrBlendCoeff* dstBlendCoeff) const { |
| 381 | *srcBlendCoeff = fSrcBlend; |
| 382 | *dstBlendCoeff = fDstBlend; |
| 383 | } |
| 384 | |
| 385 | /** |
| 386 | * Sets the blending function constant referenced by the following blending |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 387 | * coefficients: |
bsalomon@google.com | 4705954 | 2012-06-06 20:51:20 +0000 | [diff] [blame] | 388 | * kConstC_GrBlendCoeff |
| 389 | * kIConstC_GrBlendCoeff |
| 390 | * kConstA_GrBlendCoeff |
| 391 | * kIConstA_GrBlendCoeff |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 392 | * |
| 393 | * @param constant the constant to set |
| 394 | */ |
| 395 | void setBlendConstant(GrColor constant) { fBlendConstant = constant; } |
| 396 | |
| 397 | /** |
| 398 | * Retrieves the last value set by setBlendConstant() |
| 399 | * @return the blending constant value |
| 400 | */ |
| 401 | GrColor getBlendConstant() const { return fBlendConstant; } |
| 402 | |
| 403 | /// @} |
| 404 | |
| 405 | /////////////////////////////////////////////////////////////////////////// |
| 406 | /// @name View Matrix |
| 407 | //// |
| 408 | |
| 409 | /** |
robertphillips@google.com | a72eef3 | 2012-05-01 17:22:59 +0000 | [diff] [blame] | 410 | * Sets the matrix applied to vertex positions. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 411 | * |
| 412 | * In the post-view-matrix space the rectangle [0,w]x[0,h] |
| 413 | * fully covers the render target. (w and h are the width and height of the |
| 414 | * the rendertarget.) |
| 415 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 416 | void setViewMatrix(const SkMatrix& m) { fViewMatrix = m; } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 417 | |
| 418 | /** |
| 419 | * Gets a writable pointer to the view matrix. |
| 420 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 421 | SkMatrix* viewMatrix() { return &fViewMatrix; } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 422 | |
| 423 | /** |
| 424 | * Multiplies the current view matrix by a matrix |
| 425 | * |
| 426 | * After this call V' = V*m where V is the old view matrix, |
| 427 | * m is the parameter to this function, and V' is the new view matrix. |
| 428 | * (We consider positions to be column vectors so position vector p is |
| 429 | * transformed by matrix X as p' = X*p.) |
| 430 | * |
| 431 | * @param m the matrix used to modify the view matrix. |
| 432 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 433 | void preConcatViewMatrix(const SkMatrix& m) { fViewMatrix.preConcat(m); } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 434 | |
| 435 | /** |
| 436 | * Multiplies the current view matrix by a matrix |
| 437 | * |
| 438 | * After this call V' = m*V where V is the old view matrix, |
| 439 | * m is the parameter to this function, and V' is the new view matrix. |
| 440 | * (We consider positions to be column vectors so position vector p is |
| 441 | * transformed by matrix X as p' = X*p.) |
| 442 | * |
| 443 | * @param m the matrix used to modify the view matrix. |
| 444 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 445 | void postConcatViewMatrix(const SkMatrix& m) { fViewMatrix.postConcat(m); } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 446 | |
| 447 | /** |
| 448 | * Retrieves the current view matrix |
| 449 | * @return the current view matrix. |
| 450 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 451 | const SkMatrix& getViewMatrix() const { return fViewMatrix; } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 452 | |
| 453 | /** |
| 454 | * Retrieves the inverse of the current view matrix. |
| 455 | * |
| 456 | * If the current view matrix is invertible, return true, and if matrix |
| 457 | * is non-null, copy the inverse into it. If the current view matrix is |
| 458 | * non-invertible, return false and ignore the matrix parameter. |
| 459 | * |
| 460 | * @param matrix if not null, will receive a copy of the current inverse. |
| 461 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 462 | bool getViewInverse(SkMatrix* matrix) const { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 463 | // TODO: determine whether we really need to leave matrix unmodified |
| 464 | // at call sites when inversion fails. |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 465 | SkMatrix inverse; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 466 | if (fViewMatrix.invert(&inverse)) { |
| 467 | if (matrix) { |
| 468 | *matrix = inverse; |
| 469 | } |
| 470 | return true; |
| 471 | } |
| 472 | return false; |
| 473 | } |
| 474 | |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 475 | //////////////////////////////////////////////////////////////////////////// |
| 476 | |
| 477 | /** |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 478 | * Preconcats the current view matrix and restores the previous view matrix in the destructor. |
bsalomon@google.com | c196b52 | 2012-10-25 21:52:43 +0000 | [diff] [blame] | 479 | * Effect matrices are automatically adjusted to compensate. |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 480 | */ |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 481 | class AutoViewMatrixRestore : public ::GrNoncopyable { |
| 482 | public: |
| 483 | AutoViewMatrixRestore() : fDrawState(NULL) {} |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 484 | |
| 485 | AutoViewMatrixRestore(GrDrawState* ds, |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 486 | const SkMatrix& preconcatMatrix, |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 487 | uint32_t explicitCoordStageMask = 0) { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 488 | fDrawState = NULL; |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 489 | this->set(ds, preconcatMatrix, explicitCoordStageMask); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 490 | } |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 491 | |
| 492 | ~AutoViewMatrixRestore() { this->restore(); } |
| 493 | |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 494 | /** |
| 495 | * Can be called prior to destructor to restore the original matrix. |
| 496 | */ |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 497 | void restore(); |
skia.committer@gmail.com | f467ce7 | 2012-10-09 02:01:37 +0000 | [diff] [blame] | 498 | |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 499 | void set(GrDrawState* drawState, |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 500 | const SkMatrix& preconcatMatrix, |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 501 | uint32_t explicitCoordStageMask = 0); |
| 502 | |
bsalomon@google.com | ded4f4b | 2012-06-28 18:48:06 +0000 | [diff] [blame] | 503 | bool isSet() const { return NULL != fDrawState; } |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 504 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 505 | private: |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 506 | GrDrawState* fDrawState; |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 507 | SkMatrix fViewMatrix; |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 508 | GrEffectStage::SavedCoordChange fSavedCoordChanges[GrDrawState::kNumStages]; |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 509 | uint32_t fRestoreMask; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 510 | }; |
| 511 | |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 512 | //////////////////////////////////////////////////////////////////////////// |
| 513 | |
| 514 | /** |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 515 | * This sets the view matrix to identity and adjusts stage matrices to compensate. The |
| 516 | * destructor undoes the changes, restoring the view matrix that was set before the |
| 517 | * constructor. It is similar to passing the inverse of the current view matrix to |
| 518 | * AutoViewMatrixRestore, but lazily computes the inverse only if necessary. |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 519 | */ |
| 520 | class AutoDeviceCoordDraw : ::GrNoncopyable { |
| 521 | public: |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 522 | AutoDeviceCoordDraw() : fDrawState(NULL) {} |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 523 | /** |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 524 | * If a stage's texture matrix is applied to explicit per-vertex coords, rather than to |
| 525 | * positions, then we don't want to modify its matrix. The explicitCoordStageMask is used |
| 526 | * to specify such stages. |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 527 | */ |
| 528 | AutoDeviceCoordDraw(GrDrawState* drawState, |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 529 | uint32_t explicitCoordStageMask = 0) { |
| 530 | fDrawState = NULL; |
| 531 | this->set(drawState, explicitCoordStageMask); |
| 532 | } |
| 533 | |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 534 | ~AutoDeviceCoordDraw() { this->restore(); } |
| 535 | |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 536 | bool set(GrDrawState* drawState, uint32_t explicitCoordStageMask = 0); |
| 537 | |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 538 | /** |
| 539 | * Returns true if this object was successfully initialized on to a GrDrawState. It may |
| 540 | * return false because a non-default constructor or set() were never called or because |
| 541 | * the view matrix was not invertible. |
| 542 | */ |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 543 | bool succeeded() const { return NULL != fDrawState; } |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 544 | |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 545 | /** |
| 546 | * Returns the matrix that was set previously set on the drawState. This is only valid |
| 547 | * if succeeded returns true. |
| 548 | */ |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 549 | const SkMatrix& getOriginalMatrix() const { |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 550 | GrAssert(this->succeeded()); |
| 551 | return fViewMatrix; |
| 552 | } |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 553 | |
bsalomon@google.com | a834746 | 2012-10-08 18:59:39 +0000 | [diff] [blame] | 554 | /** |
| 555 | * Can be called prior to destructor to restore the original matrix. |
| 556 | */ |
| 557 | void restore(); |
bsalomon@google.com | 2fdcdeb | 2012-10-08 17:15:55 +0000 | [diff] [blame] | 558 | |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 559 | private: |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 560 | GrDrawState* fDrawState; |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 561 | SkMatrix fViewMatrix; |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 562 | GrEffectStage::SavedCoordChange fSavedCoordChanges[GrDrawState::kNumStages]; |
bsalomon@google.com | 288d954 | 2012-10-17 12:53:54 +0000 | [diff] [blame] | 563 | uint32_t fRestoreMask; |
bsalomon@google.com | 5b3e890 | 2012-10-05 20:13:28 +0000 | [diff] [blame] | 564 | }; |
| 565 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 566 | /// @} |
| 567 | |
| 568 | /////////////////////////////////////////////////////////////////////////// |
| 569 | /// @name Render Target |
| 570 | //// |
| 571 | |
| 572 | /** |
| 573 | * Sets the rendertarget used at the next drawing call |
| 574 | * |
| 575 | * @param target The render target to set. |
| 576 | */ |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 577 | void setRenderTarget(GrRenderTarget* target) { |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 578 | GrSafeAssign(fRenderTarget, target); |
| 579 | } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 580 | |
| 581 | /** |
| 582 | * Retrieves the currently set rendertarget. |
| 583 | * |
| 584 | * @return The currently set render target. |
| 585 | */ |
| 586 | const GrRenderTarget* getRenderTarget() const { return fRenderTarget; } |
| 587 | GrRenderTarget* getRenderTarget() { return fRenderTarget; } |
| 588 | |
| 589 | class AutoRenderTargetRestore : public ::GrNoncopyable { |
| 590 | public: |
bsalomon@google.com | cadbcb8 | 2012-01-06 19:22:11 +0000 | [diff] [blame] | 591 | AutoRenderTargetRestore() : fDrawState(NULL), fSavedTarget(NULL) {} |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 592 | AutoRenderTargetRestore(GrDrawState* ds, GrRenderTarget* newTarget) { |
| 593 | fDrawState = NULL; |
robertphillips@google.com | 7460b37 | 2012-04-25 16:54:51 +0000 | [diff] [blame] | 594 | fSavedTarget = NULL; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 595 | this->set(ds, newTarget); |
| 596 | } |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 597 | ~AutoRenderTargetRestore() { this->restore(); } |
| 598 | |
| 599 | void restore() { |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 600 | if (NULL != fDrawState) { |
| 601 | fDrawState->setRenderTarget(fSavedTarget); |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 602 | fDrawState = NULL; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 603 | } |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 604 | GrSafeSetNull(fSavedTarget); |
| 605 | } |
| 606 | |
| 607 | void set(GrDrawState* ds, GrRenderTarget* newTarget) { |
| 608 | this->restore(); |
| 609 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 610 | if (NULL != ds) { |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 611 | GrAssert(NULL == fSavedTarget); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 612 | fSavedTarget = ds->getRenderTarget(); |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 613 | SkSafeRef(fSavedTarget); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 614 | ds->setRenderTarget(newTarget); |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 615 | fDrawState = ds; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 616 | } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 617 | } |
| 618 | private: |
| 619 | GrDrawState* fDrawState; |
| 620 | GrRenderTarget* fSavedTarget; |
| 621 | }; |
| 622 | |
| 623 | /// @} |
| 624 | |
| 625 | /////////////////////////////////////////////////////////////////////////// |
| 626 | /// @name Stencil |
| 627 | //// |
| 628 | |
| 629 | /** |
| 630 | * Sets the stencil settings to use for the next draw. |
| 631 | * Changing the clip has the side-effect of possibly zeroing |
| 632 | * out the client settable stencil bits. So multipass algorithms |
| 633 | * using stencil should not change the clip between passes. |
| 634 | * @param settings the stencil settings to use. |
| 635 | */ |
| 636 | void setStencil(const GrStencilSettings& settings) { |
| 637 | fStencilSettings = settings; |
| 638 | } |
| 639 | |
| 640 | /** |
| 641 | * Shortcut to disable stencil testing and ops. |
| 642 | */ |
| 643 | void disableStencil() { |
| 644 | fStencilSettings.setDisabled(); |
| 645 | } |
| 646 | |
| 647 | const GrStencilSettings& getStencil() const { return fStencilSettings; } |
| 648 | |
| 649 | GrStencilSettings* stencil() { return &fStencilSettings; } |
| 650 | |
| 651 | /// @} |
| 652 | |
| 653 | /////////////////////////////////////////////////////////////////////////// |
| 654 | // @name Edge AA |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 655 | // Edge equations can be specified to perform anti-aliasing. Because the |
bsalomon@google.com | 7ffe681 | 2012-05-11 17:32:43 +0000 | [diff] [blame] | 656 | // edges are specified as per-vertex data, vertices that are shared by |
| 657 | // multiple edges must be split. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 658 | // |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 659 | //// |
| 660 | |
| 661 | /** |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 662 | * When specifying edges as vertex data this enum specifies what type of |
bsalomon@google.com | 8171288 | 2012-11-01 17:12:34 +0000 | [diff] [blame] | 663 | * edges are in use. The edges are always 4 SkScalars in memory, even when |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 664 | * the edge type requires fewer than 4. |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 665 | * |
| 666 | * TODO: Fix the fact that HairLine and Circle edge types use y-down coords. |
| 667 | * (either adjust in VS or use origin_upper_left in GLSL) |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 668 | */ |
| 669 | enum VertexEdgeType { |
| 670 | /* 1-pixel wide line |
| 671 | 2D implicit line eq (a*x + b*y +c = 0). 4th component unused */ |
| 672 | kHairLine_EdgeType, |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 673 | /* Quadratic specified by u^2-v canonical coords (only 2 |
bsalomon@google.com | 69cc6ad | 2012-01-17 14:25:10 +0000 | [diff] [blame] | 674 | components used). Coverage based on signed distance with negative |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 675 | being inside, positive outside. Edge specified in window space |
| 676 | (y-down) */ |
bsalomon@google.com | 69cc6ad | 2012-01-17 14:25:10 +0000 | [diff] [blame] | 677 | kQuad_EdgeType, |
| 678 | /* Same as above but for hairline quadratics. Uses unsigned distance. |
| 679 | Coverage is min(0, 1-distance). */ |
| 680 | kHairQuad_EdgeType, |
bsalomon@google.com | 93c9660 | 2012-04-27 13:05:21 +0000 | [diff] [blame] | 681 | /* Circle specified as center_x, center_y, outer_radius, inner_radius |
| 682 | all in window space (y-down). */ |
| 683 | kCircle_EdgeType, |
bsalomon@google.com | 69cc6ad | 2012-01-17 14:25:10 +0000 | [diff] [blame] | 684 | |
| 685 | kVertexEdgeTypeCnt |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 686 | }; |
| 687 | |
| 688 | /** |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 689 | * Determines the interpretation per-vertex edge data when the |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 690 | * kEdge_VertexLayoutBit is set (see GrDrawTarget). When per-vertex edges |
| 691 | * are not specified the value of this setting has no effect. |
| 692 | */ |
| 693 | void setVertexEdgeType(VertexEdgeType type) { |
bsalomon@google.com | 69cc6ad | 2012-01-17 14:25:10 +0000 | [diff] [blame] | 694 | GrAssert(type >=0 && type < kVertexEdgeTypeCnt); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 695 | fVertexEdgeType = type; |
| 696 | } |
| 697 | |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 698 | VertexEdgeType getVertexEdgeType() const { return fVertexEdgeType; } |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 699 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 700 | /// @} |
tomhudson@google.com | 62b0968 | 2011-11-09 16:39:17 +0000 | [diff] [blame] | 701 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 702 | /////////////////////////////////////////////////////////////////////////// |
| 703 | /// @name State Flags |
| 704 | //// |
tomhudson@google.com | 62b0968 | 2011-11-09 16:39:17 +0000 | [diff] [blame] | 705 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 706 | /** |
| 707 | * Flags that affect rendering. Controlled using enable/disableState(). All |
| 708 | * default to disabled. |
| 709 | */ |
| 710 | enum StateBits { |
| 711 | /** |
| 712 | * Perform dithering. TODO: Re-evaluate whether we need this bit |
| 713 | */ |
| 714 | kDither_StateBit = 0x01, |
| 715 | /** |
bsalomon@google.com | cf939ae | 2012-12-13 19:59:23 +0000 | [diff] [blame] | 716 | * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target, |
| 717 | * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by |
| 718 | * the 3D API. |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 719 | */ |
| 720 | kHWAntialias_StateBit = 0x02, |
| 721 | /** |
| 722 | * Draws will respect the clip, otherwise the clip is ignored. |
| 723 | */ |
| 724 | kClip_StateBit = 0x04, |
| 725 | /** |
| 726 | * Disables writing to the color buffer. Useful when performing stencil |
| 727 | * operations. |
| 728 | */ |
| 729 | kNoColorWrites_StateBit = 0x08, |
bsalomon@google.com | 0342a85 | 2012-08-20 19:22:38 +0000 | [diff] [blame] | 730 | |
bsalomon@google.com | cf939ae | 2012-12-13 19:59:23 +0000 | [diff] [blame] | 731 | /** |
| 732 | * Usually coverage is applied after color blending. The color is blended using the coeffs |
| 733 | * specified by setBlendFunc(). The blended color is then combined with dst using coeffs |
| 734 | * of src_coverage, 1-src_coverage. Sometimes we are explicitly drawing a coverage mask. In |
| 735 | * this case there is no distinction between coverage and color and the caller needs direct |
| 736 | * control over the blend coeffs. When set, there will be a single blend step controlled by |
| 737 | * setBlendFunc() which will use coverage*color as the src color. |
| 738 | */ |
| 739 | kCoverageDrawing_StateBit = 0x10, |
| 740 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 741 | // Users of the class may add additional bits to the vector |
| 742 | kDummyStateBit, |
| 743 | kLastPublicStateBit = kDummyStateBit-1, |
| 744 | }; |
| 745 | |
| 746 | void resetStateFlags() { |
| 747 | fFlagBits = 0; |
| 748 | } |
| 749 | |
| 750 | /** |
| 751 | * Enable render state settings. |
| 752 | * |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 753 | * @param stateBits bitfield of StateBits specifying the states to enable |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 754 | */ |
| 755 | void enableState(uint32_t stateBits) { |
| 756 | fFlagBits |= stateBits; |
| 757 | } |
| 758 | |
| 759 | /** |
| 760 | * Disable render state settings. |
| 761 | * |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 762 | * @param stateBits bitfield of StateBits specifying the states to disable |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 763 | */ |
| 764 | void disableState(uint32_t stateBits) { |
| 765 | fFlagBits &= ~(stateBits); |
| 766 | } |
| 767 | |
bsalomon@google.com | d5d69ff | 2012-10-04 19:42:00 +0000 | [diff] [blame] | 768 | /** |
| 769 | * Enable or disable stateBits based on a boolean. |
| 770 | * |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 771 | * @param stateBits bitfield of StateBits to enable or disable |
bsalomon@google.com | d5d69ff | 2012-10-04 19:42:00 +0000 | [diff] [blame] | 772 | * @param enable if true enable stateBits, otherwise disable |
| 773 | */ |
| 774 | void setState(uint32_t stateBits, bool enable) { |
| 775 | if (enable) { |
| 776 | this->enableState(stateBits); |
| 777 | } else { |
| 778 | this->disableState(stateBits); |
| 779 | } |
| 780 | } |
| 781 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 782 | bool isDitherState() const { |
| 783 | return 0 != (fFlagBits & kDither_StateBit); |
| 784 | } |
| 785 | |
| 786 | bool isHWAntialiasState() const { |
| 787 | return 0 != (fFlagBits & kHWAntialias_StateBit); |
| 788 | } |
| 789 | |
| 790 | bool isClipState() const { |
| 791 | return 0 != (fFlagBits & kClip_StateBit); |
| 792 | } |
| 793 | |
| 794 | bool isColorWriteDisabled() const { |
| 795 | return 0 != (fFlagBits & kNoColorWrites_StateBit); |
| 796 | } |
| 797 | |
bsalomon@google.com | cf939ae | 2012-12-13 19:59:23 +0000 | [diff] [blame] | 798 | bool isCoverageDrawing() const { |
| 799 | return 0 != (fFlagBits & kCoverageDrawing_StateBit); |
| 800 | } |
| 801 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 802 | bool isStateFlagEnabled(uint32_t stateBit) const { |
| 803 | return 0 != (stateBit & fFlagBits); |
| 804 | } |
| 805 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 806 | /// @} |
| 807 | |
| 808 | /////////////////////////////////////////////////////////////////////////// |
| 809 | /// @name Face Culling |
| 810 | //// |
| 811 | |
| 812 | enum DrawFace { |
bsalomon@google.com | 978c8c6 | 2012-05-21 14:45:49 +0000 | [diff] [blame] | 813 | kInvalid_DrawFace = -1, |
| 814 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 815 | kBoth_DrawFace, |
| 816 | kCCW_DrawFace, |
| 817 | kCW_DrawFace, |
| 818 | }; |
| 819 | |
| 820 | /** |
| 821 | * Controls whether clockwise, counterclockwise, or both faces are drawn. |
| 822 | * @param face the face(s) to draw. |
| 823 | */ |
| 824 | void setDrawFace(DrawFace face) { |
bsalomon@google.com | 978c8c6 | 2012-05-21 14:45:49 +0000 | [diff] [blame] | 825 | GrAssert(kInvalid_DrawFace != face); |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 826 | fDrawFace = face; |
| 827 | } |
| 828 | |
| 829 | /** |
| 830 | * Gets whether the target is drawing clockwise, counterclockwise, |
| 831 | * or both faces. |
| 832 | * @return the current draw face(s). |
| 833 | */ |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 834 | DrawFace getDrawFace() const { return fDrawFace; } |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 835 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 836 | /// @} |
| 837 | |
| 838 | /////////////////////////////////////////////////////////////////////////// |
tomhudson@google.com | 62b0968 | 2011-11-09 16:39:17 +0000 | [diff] [blame] | 839 | |
tomhudson@google.com | f13f588 | 2012-06-25 17:27:28 +0000 | [diff] [blame] | 840 | bool isStageEnabled(int s) const { |
| 841 | GrAssert((unsigned)s < kNumStages); |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 842 | return (NULL != fStages[s].getEffect()); |
tomhudson@google.com | f13f588 | 2012-06-25 17:27:28 +0000 | [diff] [blame] | 843 | } |
| 844 | |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 845 | // Most stages are usually not used, so conditionals here |
| 846 | // reduce the expected number of bytes touched by 50%. |
| 847 | bool operator ==(const GrDrawState& s) const { |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 848 | if (fColor != s.fColor || |
| 849 | !s.fViewMatrix.cheapEqualTo(fViewMatrix) || |
| 850 | fRenderTarget != s.fRenderTarget || |
| 851 | fSrcBlend != s.fSrcBlend || |
| 852 | fDstBlend != s.fDstBlend || |
| 853 | fBlendConstant != s.fBlendConstant || |
| 854 | fFlagBits != s.fFlagBits || |
| 855 | fVertexEdgeType != s.fVertexEdgeType || |
| 856 | fStencilSettings != s.fStencilSettings || |
| 857 | fFirstCoverageStage != s.fFirstCoverageStage || |
| 858 | fCoverage != s.fCoverage || |
| 859 | fColorFilterMode != s.fColorFilterMode || |
| 860 | fColorFilterColor != s.fColorFilterColor || |
| 861 | fDrawFace != s.fDrawFace) { |
bsalomon@google.com | 8fe84b5 | 2012-03-26 15:24:27 +0000 | [diff] [blame] | 862 | return false; |
| 863 | } |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 864 | |
| 865 | for (int i = 0; i < kNumStages; i++) { |
bsalomon@google.com | f2f8fc3 | 2012-07-18 18:25:07 +0000 | [diff] [blame] | 866 | bool enabled = this->isStageEnabled(i); |
| 867 | if (enabled != s.isStageEnabled(i)) { |
| 868 | return false; |
| 869 | } |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 870 | if (enabled && this->fStages[i] != s.fStages[i]) { |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 871 | return false; |
| 872 | } |
| 873 | } |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 874 | return true; |
| 875 | } |
| 876 | bool operator !=(const GrDrawState& s) const { return !(*this == s); } |
| 877 | |
rmistry@google.com | d6176b0 | 2012-08-23 18:14:13 +0000 | [diff] [blame] | 878 | // Most stages are usually not used, so conditionals here |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 879 | // reduce the expected number of bytes touched by 50%. |
| 880 | GrDrawState& operator =(const GrDrawState& s) { |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 881 | fColor = s.fColor; |
bsalomon@google.com | 8fe84b5 | 2012-03-26 15:24:27 +0000 | [diff] [blame] | 882 | fViewMatrix = s.fViewMatrix; |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 883 | SkRefCnt_SafeAssign(fRenderTarget, s.fRenderTarget); |
| 884 | fSrcBlend = s.fSrcBlend; |
| 885 | fDstBlend = s.fDstBlend; |
| 886 | fBlendConstant = s.fBlendConstant; |
| 887 | fFlagBits = s.fFlagBits; |
| 888 | fVertexEdgeType = s.fVertexEdgeType; |
| 889 | fStencilSettings = s.fStencilSettings; |
| 890 | fFirstCoverageStage = s.fFirstCoverageStage; |
| 891 | fCoverage = s.fCoverage; |
| 892 | fColorFilterMode = s.fColorFilterMode; |
| 893 | fColorFilterColor = s.fColorFilterColor; |
| 894 | fDrawFace = s.fDrawFace; |
bsalomon@google.com | 8fe84b5 | 2012-03-26 15:24:27 +0000 | [diff] [blame] | 895 | |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 896 | for (int i = 0; i < kNumStages; i++) { |
tomhudson@google.com | e742bf0 | 2012-07-13 19:54:19 +0000 | [diff] [blame] | 897 | if (s.isStageEnabled(i)) { |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 898 | this->fStages[i] = s.fStages[i]; |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 899 | } |
| 900 | } |
robertphillips@google.com | 9ec0753 | 2012-06-22 12:01:30 +0000 | [diff] [blame] | 901 | |
bsalomon@google.com | 3d0835b | 2011-12-08 16:12:03 +0000 | [diff] [blame] | 902 | return *this; |
| 903 | } |
| 904 | |
| 905 | private: |
bsalomon@google.com | 2e3d144 | 2012-03-26 20:33:54 +0000 | [diff] [blame] | 906 | |
bsalomon@google.com | 1e269b5 | 2012-10-15 14:25:31 +0000 | [diff] [blame] | 907 | // These fields are roughly sorted by decreasing likelihood of being different in op== |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 908 | GrColor fColor; |
bsalomon@google.com | b9086a0 | 2012-11-01 18:02:54 +0000 | [diff] [blame] | 909 | SkMatrix fViewMatrix; |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 910 | GrRenderTarget* fRenderTarget; |
| 911 | GrBlendCoeff fSrcBlend; |
| 912 | GrBlendCoeff fDstBlend; |
| 913 | GrColor fBlendConstant; |
| 914 | uint32_t fFlagBits; |
robertphillips@google.com | c077d1e | 2012-05-28 14:10:15 +0000 | [diff] [blame] | 915 | VertexEdgeType fVertexEdgeType; |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 916 | GrStencilSettings fStencilSettings; |
robertphillips@google.com | 69ffcf0 | 2012-06-26 21:01:05 +0000 | [diff] [blame] | 917 | int fFirstCoverageStage; |
bsalomon@google.com | 2401ae8 | 2012-01-17 21:03:05 +0000 | [diff] [blame] | 918 | GrColor fCoverage; |
bsalomon@google.com | 52a5dcb | 2012-01-17 16:01:37 +0000 | [diff] [blame] | 919 | SkXfermode::Mode fColorFilterMode; |
bsalomon@google.com | 861b3a2 | 2012-09-26 17:28:25 +0000 | [diff] [blame] | 920 | GrColor fColorFilterColor; |
| 921 | DrawFace fDrawFace; |
bsalomon@google.com | 8fe84b5 | 2012-03-26 15:24:27 +0000 | [diff] [blame] | 922 | |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 923 | // This field must be last; it will not be copied or compared |
| 924 | // if the corresponding fTexture[] is NULL. |
bsalomon@google.com | 08283af | 2012-10-26 13:01:20 +0000 | [diff] [blame] | 925 | GrEffectStage fStages[kNumStages]; |
bsalomon@google.com | 8f9cbd6 | 2011-12-09 15:55:34 +0000 | [diff] [blame] | 926 | |
reed@google.com | fa35e3d | 2012-06-26 20:16:17 +0000 | [diff] [blame] | 927 | typedef GrRefCnt INHERITED; |
tomhudson@google.com | 9381363 | 2011-10-27 20:21:16 +0000 | [diff] [blame] | 928 | }; |
| 929 | |
| 930 | #endif |