blob: 036c4a517238d0b5d172d07f876e55c48beeff91 [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
egdaniel89af44a2014-09-26 06:15:04 -070011
commit-bot@chromium.org24ab3b02013-08-14 21:56:37 +000012#include "GrBlend.h"
egdanielc0648242014-09-22 13:17:02 -070013#include "GrDrawTargetCaps.h"
bsalomon6251d172014-10-15 10:50:36 -070014#include "GrGeometryProcessor.h"
bsalomonf96ba022014-09-17 08:05:40 -070015#include "GrGpuResourceRef.h"
egdaniel89af44a2014-09-26 06:15:04 -070016#include "GrProcessorStage.h"
17#include "GrRenderTarget.h"
18#include "GrStencil.h"
19#include "SkMatrix.h"
bsalomon@google.com68b58c92013-01-17 16:50:08 +000020#include "effects/GrSimpleTextureEffect.h"
tomhudson@google.com93813632011-10-27 20:21:16 +000021
egdaniel89af44a2014-09-26 06:15:04 -070022class GrDrawTargetCaps;
egdaniel170f90b2014-09-16 12:54:40 -070023class GrOptDrawState;
egdaniel89af44a2014-09-26 06:15:04 -070024class GrPaint;
25class GrTexture;
egdaniel170f90b2014-09-16 12:54:40 -070026
egdaniel89af44a2014-09-26 06:15:04 -070027class GrDrawState : public SkRefCnt {
bsalomon@google.com2e3d1442012-03-26 20:33:54 +000028public:
reed@google.comfa35e3d2012-06-26 20:16:17 +000029 SK_DECLARE_INST_COUNT(GrDrawState)
rmistry@google.comd6176b02012-08-23 18:14:13 +000030
egdaniel3658f382014-09-15 07:01:59 -070031 GrDrawState() : fCachedOptState(NULL) {
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +000032 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000033 this->reset();
34 }
tomhudson@google.com93813632011-10-27 20:21:16 +000035
egdaniel3658f382014-09-15 07:01:59 -070036 GrDrawState(const SkMatrix& initialViewMatrix) : fCachedOptState(NULL) {
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +000037 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000038 this->reset(initialViewMatrix);
39 }
bsalomon@google.com137f1342013-05-29 21:27:53 +000040
41 /**
42 * Copies another draw state.
43 **/
egdaniel3658f382014-09-15 07:01:59 -070044 GrDrawState(const GrDrawState& state) : INHERITED(), fCachedOptState(NULL) {
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +000045 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
bsalomon@google.com46f7afb2012-01-18 19:51:55 +000046 *this = state;
47 }
48
bsalomon@google.com137f1342013-05-29 21:27:53 +000049 /**
50 * Copies another draw state with a preconcat to the view matrix.
51 **/
bsalomon8f727332014-08-05 07:50:06 -070052 GrDrawState(const GrDrawState& state, const SkMatrix& preConcatMatrix);
robertphillips@google.com9ec07532012-06-22 12:01:30 +000053
egdaniel170f90b2014-09-16 12:54:40 -070054 virtual ~GrDrawState();
bsalomon@google.com137f1342013-05-29 21:27:53 +000055
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000056 /**
joshualittb0a8a372014-09-23 09:50:21 -070057 * Resets to the default state. GrProcessors will be removed from all stages.
rmistry@google.comd6176b02012-08-23 18:14:13 +000058 */
bsalomon@google.com137f1342013-05-29 21:27:53 +000059 void reset() { this->onReset(NULL); }
robertphillips@google.com9ec07532012-06-22 12:01:30 +000060
bsalomon@google.com137f1342013-05-29 21:27:53 +000061 void reset(const SkMatrix& initialViewMatrix) { this->onReset(&initialViewMatrix); }
bsalomon@google.comaf84e742012-10-05 13:23:24 +000062
63 /**
commit-bot@chromium.orgbb6a3172013-05-28 17:25:49 +000064 * Initializes the GrDrawState based on a GrPaint, view matrix and render target. Note that
65 * GrDrawState encompasses more than GrPaint. Aspects of GrDrawState that have no GrPaint
bsalomon9c0822a2014-08-11 11:07:48 -070066 * equivalents are set to default values with the exception of vertex attribute state which
67 * is unmodified by this function and clipping which will be enabled.
bsalomon@google.comaf84e742012-10-05 13:23:24 +000068 */
commit-bot@chromium.orgbb6a3172013-05-28 17:25:49 +000069 void setFromPaint(const GrPaint& , const SkMatrix& viewMatrix, GrRenderTarget*);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000070
71 ///////////////////////////////////////////////////////////////////////////
jvanverth@google.com9b855c72013-03-01 18:21:22 +000072 /// @name Vertex Attributes
jvanverth@google.comcc782382013-01-28 20:39:48 +000073 ////
74
egdaniel89af44a2014-09-26 06:15:04 -070075 enum {
76 kMaxVertexAttribCnt = kLast_GrVertexAttribBinding + 4,
77 };
78
79 const GrVertexAttrib* getVertexAttribs() const { return fVAPtr; }
80 int getVertexAttribCount() const { return fVACount; }
81
82 size_t getVertexStride() const { return fVAStride; }
83
84 bool hasLocalCoordAttribute() const {
85 return -1 != fFixedFunctionVertexAttribIndices[kLocalCoord_GrVertexAttribBinding];
86 }
87 bool hasColorVertexAttribute() const {
88 return -1 != fFixedFunctionVertexAttribIndices[kColor_GrVertexAttribBinding];
89 }
90 bool hasCoverageVertexAttribute() const {
91 return -1 != fFixedFunctionVertexAttribIndices[kCoverage_GrVertexAttribBinding];
92 }
93
94 const int* getFixedFunctionVertexAttribIndices() const {
95 return fFixedFunctionVertexAttribIndices;
96 }
97
98 bool validateVertexAttribs() const;
99
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000100 /**
jvanverth@google.com054ae992013-04-01 20:06:51 +0000101 * The format of vertices is represented as an array of GrVertexAttribs, with each representing
102 * the type of the attribute, its offset, and semantic binding (see GrVertexAttrib in
103 * GrTypesPriv.h).
jvanverth@google.comb8b705b2013-02-28 16:28:34 +0000104 *
joshualittb0a8a372014-09-23 09:50:21 -0700105 * The mapping of attributes with kEffect bindings to GrProcessor inputs is specified when
jvanverth@google.com054ae992013-04-01 20:06:51 +0000106 * setEffect is called.
jvanverth@google.comb8b705b2013-02-28 16:28:34 +0000107 */
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000108
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000109 /**
robertphillips@google.com42903302013-04-20 12:26:07 +0000110 * Sets vertex attributes for next draw. The object driving the templatization
111 * should be a global GrVertexAttrib array that is never changed.
egdaniel7b3d5ee2014-08-28 05:41:14 -0700112 *
113 * @param count the number of attributes being set, limited to kMaxVertexAttribCnt.
114 * @param stride the number of bytes between successive vertex data.
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000115 */
egdaniel7b3d5ee2014-08-28 05:41:14 -0700116 template <const GrVertexAttrib A[]> void setVertexAttribs(int count, size_t stride) {
117 this->internalSetVertexAttribs(A, count, stride);
robertphillips@google.com42903302013-04-20 12:26:07 +0000118 }
jvanverth@google.comb8b705b2013-02-28 16:28:34 +0000119
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000120 /**
jvanverth@google.com054ae992013-04-01 20:06:51 +0000121 * Sets default vertex attributes for next draw. The default is a single attribute:
122 * {kVec2f_GrVertexAttribType, 0, kPosition_GrVertexAttribType}
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000123 */
124 void setDefaultVertexAttribs();
jvanverth@google.comb75b0a02013-02-05 20:33:30 +0000125
jvanverth@google.com054ae992013-04-01 20:06:51 +0000126 /**
bsalomon@google.com0406b9e2013-04-02 21:00:15 +0000127 * Helper to save/restore vertex attribs
128 */
129 class AutoVertexAttribRestore {
130 public:
bsalomon8f727332014-08-05 07:50:06 -0700131 AutoVertexAttribRestore(GrDrawState* drawState);
bsalomon@google.com0406b9e2013-04-02 21:00:15 +0000132
egdaniel3658f382014-09-15 07:01:59 -0700133 ~AutoVertexAttribRestore() { fDrawState->internalSetVertexAttribs(fVAPtr, fVACount,
134 fVAStride); }
bsalomon@google.com0406b9e2013-04-02 21:00:15 +0000135
136 private:
robertphillips@google.com42903302013-04-20 12:26:07 +0000137 GrDrawState* fDrawState;
138 const GrVertexAttrib* fVAPtr;
139 int fVACount;
egdaniel7b3d5ee2014-08-28 05:41:14 -0700140 size_t fVAStride;
bsalomon@google.com0406b9e2013-04-02 21:00:15 +0000141 };
142
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000143 /// @}
144
jvanverth@google.com9b855c72013-03-01 18:21:22 +0000145 /**
bsalomon62c447d2014-08-08 08:08:50 -0700146 * Depending on features available in the underlying 3D API and the color blend mode requested
147 * it may or may not be possible to correctly blend with fractional pixel coverage generated by
148 * the fragment shader.
149 *
150 * This function considers the current draw state and the draw target's capabilities to
151 * determine whether coverage can be handled correctly. This function assumes that the caller
152 * intends to specify fractional pixel coverage (via setCoverage(), through a coverage vertex
153 * attribute, or a coverage effect) but may not have specified it yet.
154 */
155 bool couldApplyCoverage(const GrDrawTargetCaps& caps) const;
156
egdaniel89af44a2014-09-26 06:15:04 -0700157 /**
158 * Determines whether the output coverage is guaranteed to be one for all pixels hit by a draw.
159 */
160 bool hasSolidCoverage() const;
161
jvanverth@google.comcc782382013-01-28 20:39:48 +0000162 /// @}
163
164 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000165 /// @name Color
166 ////
167
egdaniel89af44a2014-09-26 06:15:04 -0700168 GrColor getColor() const { return fColor; }
169
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000170 /**
171 * Sets color for next draw to a premultiplied-alpha color.
172 *
173 * @param color the color to set.
174 */
egdaniel9514d242014-07-18 06:15:43 -0700175 void setColor(GrColor color) {
egdaniel3658f382014-09-15 07:01:59 -0700176 if (color != fColor) {
177 fColor = color;
178 this->invalidateOptState();
179 }
egdaniel9514d242014-07-18 06:15:43 -0700180 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000181
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000182 /**
183 * Sets the color to be used for the next draw to be
184 * (r,g,b,a) = (alpha, alpha, alpha, alpha).
185 *
186 * @param alpha The alpha value to set as the color.
187 */
bsalomon62c447d2014-08-08 08:08:50 -0700188 void setAlpha(uint8_t a) { this->setColor((a << 24) | (a << 16) | (a << 8) | a); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000189
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000190 /// @}
191
192 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000193 /// @name Coverage
194 ////
195
egdaniel89af44a2014-09-26 06:15:04 -0700196 uint8_t getCoverage() const { return fCoverage; }
197
198 GrColor getCoverageColor() const {
199 return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage);
200 }
201
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000202 /**
rmistry@google.comd6176b02012-08-23 18:14:13 +0000203 * Sets a constant fractional coverage to be applied to the draw. The
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000204 * initial value (after construction or reset()) is 0xff. The constant
205 * coverage is ignored when per-vertex coverage is provided.
206 */
207 void setCoverage(uint8_t coverage) {
egdaniel3658f382014-09-15 07:01:59 -0700208 if (coverage != fCoverage) {
209 fCoverage = coverage;
210 this->invalidateOptState();
211 }
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000212 }
213
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000214 /// @}
215
joshualittbd769d02014-09-04 08:56:46 -0700216 /**
217 * The geometry processor is the sole element of the skia pipeline which can use the vertex,
218 * geometry, and tesselation shaders. The GP may also compute a coverage in its fragment shader
219 * but is never put in the color processing pipeline.
220 */
221
joshualittb0a8a372014-09-23 09:50:21 -0700222 const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* geometryProcessor) {
223 SkASSERT(geometryProcessor);
joshualittbd769d02014-09-04 08:56:46 -0700224 SkASSERT(!this->hasGeometryProcessor());
joshualitta5305a12014-10-10 17:47:00 -0700225 fGeometryProcessor.reset(SkRef(geometryProcessor));
egdaniel3658f382014-09-15 07:01:59 -0700226 this->invalidateOptState();
joshualittb0a8a372014-09-23 09:50:21 -0700227 return geometryProcessor;
joshualittbd769d02014-09-04 08:56:46 -0700228 }
229
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000230 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.comadc65362013-01-28 14:26:09 +0000231 /// @name Effect Stages
joshualittb0a8a372014-09-23 09:50:21 -0700232 /// Each stage hosts a GrProcessor. The effect produces an output color or coverage in the
233 /// fragment shader. Its inputs are the output from the previous stage as well as some variables
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000234 /// available to it in the fragment and vertex shader (e.g. the vertex position, the dst color,
235 /// the fragment position, local coordinates).
236 ///
237 /// The stages are divided into two sets, color-computing and coverage-computing. The final
238 /// color stage produces the final pixel color. The coverage-computing stages function exactly
239 /// as the color-computing but the output of the final coverage stage is treated as a fractional
240 /// pixel coverage rather than as input to the src/dst color blend step.
241 ///
242 /// The input color to the first color-stage is either the constant color or interpolated
243 /// per-vertex colors. The input to the first coverage stage is either a constant coverage
244 /// (usually full-coverage) or interpolated per-vertex coverage.
245 ///
246 /// See the documentation of kCoverageDrawing_StateBit for information about disabling the
247 /// the color / coverage distinction.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000248 ////
249
egdaniel89af44a2014-09-26 06:15:04 -0700250 int numColorStages() const { return fColorStages.count(); }
251 int numCoverageStages() const { return fCoverageStages.count(); }
252 int numTotalStages() const {
253 return this->numColorStages() + this->numCoverageStages() +
254 (this->hasGeometryProcessor() ? 1 : 0);
255 }
256
257 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
joshualitta5305a12014-10-10 17:47:00 -0700258 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryProcessor.get(); }
egdaniel89af44a2014-09-26 06:15:04 -0700259 const GrFragmentStage& getColorStage(int idx) const { return fColorStages[idx]; }
260 const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageStages[idx]; }
261
262 /**
263 * Checks whether any of the effects will read the dst pixel color.
264 */
265 bool willEffectReadDstColor() const;
266
joshualittb0a8a372014-09-23 09:50:21 -0700267 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -0700268 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -0700269 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
egdaniel3658f382014-09-15 07:01:59 -0700270 this->invalidateOptState();
jvanverth@google.com65eb4d52013-03-19 18:51:02 +0000271 return effect;
272 }
skia.committer@gmail.com01c34ee2013-03-20 07:01:02 +0000273
joshualittb0a8a372014-09-23 09:50:21 -0700274 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -0700275 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -0700276 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
egdaniel3658f382014-09-15 07:01:59 -0700277 this->invalidateOptState();
bsalomon@google.comadc65362013-01-28 14:26:09 +0000278 return effect;
279 }
280
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000281 /**
bsalomon@google.comc7818882013-03-20 19:19:53 +0000282 * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
tomhudson@google.com1e8f0162012-07-20 16:25:18 +0000283 */
joshualittb0a8a372014-09-23 09:50:21 -0700284 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
285 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comdfdb7e52012-10-16 15:19:45 +0000286 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000287
joshualittb0a8a372014-09-23 09:50:21 -0700288 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
289 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000290 }
291
joshualittb0a8a372014-09-23 09:50:21 -0700292 void addColorTextureProcessor(GrTexture* texture,
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000293 const SkMatrix& matrix,
294 const GrTextureParams& params) {
joshualittb0a8a372014-09-23 09:50:21 -0700295 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
296 }
297
298 void addCoverageTextureProcessor(GrTexture* texture,
299 const SkMatrix& matrix,
300 const GrTextureParams& params) {
301 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
commit-bot@chromium.orgff6ea262013-03-12 12:26:08 +0000302 }
tomhudson@google.com676e6602012-07-10 17:21:48 +0000303
robertphillips@google.com972265d2012-06-13 18:49:30 +0000304 /**
bsalomon9b536522014-09-05 09:18:51 -0700305 * When this object is destroyed it will remove any color/coverage effects from the draw state
306 * that were added after its constructor.
307 *
308 * This class has strange behavior around geometry processor. If there is a GP on the draw state
309 * it will assert that the GP is not modified until after the destructor of the ARE. If the
310 * draw state has a NULL GP when the ARE is constructed then it will reset it to null in the
311 * destructor.
312 *
313 * TODO: We'd prefer for the ARE to just save and restore the GP. However, this would add
314 * significant complexity to the multi-ref architecture for deferred drawing. Once GrDrawState
315 * and GrOptDrawState are fully separated then GrDrawState will never be in the deferred
316 * execution state and GrOptDrawState always will be (and will be immutable and therefore
317 * unable to have an ARE). At this point we can restore sanity and have the ARE save and restore
318 * the GP.
robertphillips@google.com972265d2012-06-13 18:49:30 +0000319 */
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +0000320 class AutoRestoreEffects : public ::SkNoncopyable {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000321 public:
bsalomon9b536522014-09-05 09:18:51 -0700322 AutoRestoreEffects()
323 : fDrawState(NULL)
bsalomon52e9d632014-09-05 12:23:12 -0700324 , fOriginalGPID(SK_InvalidUniqueID)
bsalomon9b536522014-09-05 09:18:51 -0700325 , fColorEffectCnt(0)
326 , fCoverageEffectCnt(0) {}
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000327
bsalomon9b536522014-09-05 09:18:51 -0700328 AutoRestoreEffects(GrDrawState* ds)
329 : fDrawState(NULL)
bsalomon52e9d632014-09-05 12:23:12 -0700330 , fOriginalGPID(SK_InvalidUniqueID)
bsalomon9b536522014-09-05 09:18:51 -0700331 , fColorEffectCnt(0)
332 , fCoverageEffectCnt(0) {
skia.committer@gmail.com5c493d52013-06-14 07:00:49 +0000333 this->set(ds);
robertphillips@google.comf09b87d2013-06-13 20:06:44 +0000334 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000335
336 ~AutoRestoreEffects() { this->set(NULL); }
337
bsalomon8f727332014-08-05 07:50:06 -0700338 void set(GrDrawState* ds);
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000339
bsalomon49f085d2014-09-05 13:34:00 -0700340 bool isSet() const { return SkToBool(fDrawState); }
bsalomon8af05232014-06-03 06:34:58 -0700341
robertphillips@google.com972265d2012-06-13 18:49:30 +0000342 private:
bsalomon9b536522014-09-05 09:18:51 -0700343 GrDrawState* fDrawState;
bsalomon52e9d632014-09-05 12:23:12 -0700344 uint32_t fOriginalGPID;
bsalomon9b536522014-09-05 09:18:51 -0700345 int fColorEffectCnt;
346 int fCoverageEffectCnt;
robertphillips@google.com972265d2012-06-13 18:49:30 +0000347 };
348
joshualitta58fe352014-10-27 08:39:00 -0700349 /**
350 * AutoRestoreStencil
351 *
352 * This simple struct saves and restores the stencil settings
353 */
354 class AutoRestoreStencil : public ::SkNoncopyable {
355 public:
356 AutoRestoreStencil() : fDrawState(NULL) {}
357
358 AutoRestoreStencil(GrDrawState* ds) : fDrawState(NULL) { this->set(ds); }
359
360 ~AutoRestoreStencil() { this->set(NULL); }
361
362 void set(GrDrawState* ds) {
363 if (fDrawState) {
364 fDrawState->setStencil(fStencilSettings);
365 }
366 fDrawState = ds;
367 if (ds) {
368 fStencilSettings = ds->getStencil();
369 }
370 }
371
372 bool isSet() const { return SkToBool(fDrawState); }
373
374 private:
375 GrDrawState* fDrawState;
376 GrStencilSettings fStencilSettings;
377 };
378
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000379 /// @}
380
381 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000382 /// @name Blending
383 ////
384
egdaniel89af44a2014-09-26 06:15:04 -0700385 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; }
386 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; }
387
388 /**
389 * Retrieves the last value set by setBlendConstant()
390 * @return the blending constant value
391 */
392 GrColor getBlendConstant() const { return fBlendConstant; }
393
394 /**
395 * Determines whether multiplying the computed per-pixel color by the pixel's fractional
396 * coverage before the blend will give the correct final destination color. In general it
397 * will not as coverage is applied after blending.
398 */
399 bool canTweakAlphaForCoverage() const;
400
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000401 /**
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000402 * Sets the blending function coefficients.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000403 *
404 * The blend function will be:
405 * D' = sat(S*srcCoef + D*dstCoef)
406 *
407 * where D is the existing destination color, S is the incoming source
408 * color, and D' is the new destination color that will be written. sat()
409 * is the saturation function.
410 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000411 * @param srcCoef coefficient applied to the src color.
412 * @param dstCoef coefficient applied to the dst color.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000413 */
414 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
egdaniel3658f382014-09-15 07:01:59 -0700415 if (srcCoeff != fSrcBlend || dstCoeff != fDstBlend) {
416 fSrcBlend = srcCoeff;
417 fDstBlend = dstCoeff;
418 this->invalidateOptState();
419 }
commit-bot@chromium.org515dcd32013-08-28 14:17:03 +0000420 #ifdef SK_DEBUG
commit-bot@chromium.org24ab3b02013-08-14 21:56:37 +0000421 if (GrBlendCoeffRefsDst(dstCoeff)) {
422 GrPrintf("Unexpected dst blend coeff. Won't work correctly with coverage stages.\n");
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000423 }
commit-bot@chromium.org24ab3b02013-08-14 21:56:37 +0000424 if (GrBlendCoeffRefsSrc(srcCoeff)) {
425 GrPrintf("Unexpected src blend coeff. Won't work correctly with coverage stages.\n");
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000426 }
427 #endif
428 }
429
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000430 /**
431 * Sets the blending function constant referenced by the following blending
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000432 * coefficients:
bsalomon@google.com47059542012-06-06 20:51:20 +0000433 * kConstC_GrBlendCoeff
434 * kIConstC_GrBlendCoeff
435 * kConstA_GrBlendCoeff
436 * kIConstA_GrBlendCoeff
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000437 *
438 * @param constant the constant to set
439 */
egdaniel9514d242014-07-18 06:15:43 -0700440 void setBlendConstant(GrColor constant) {
egdaniel3658f382014-09-15 07:01:59 -0700441 if (constant != fBlendConstant) {
442 fBlendConstant = constant;
443 this->invalidateOptState();
444 }
egdaniel9514d242014-07-18 06:15:43 -0700445 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000446
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000447 /// @}
448
449 ///////////////////////////////////////////////////////////////////////////
450 /// @name View Matrix
451 ////
452
453 /**
egdaniel89af44a2014-09-26 06:15:04 -0700454 * Retrieves the current view matrix
455 * @return the current view matrix.
456 */
457 const SkMatrix& getViewMatrix() const { return fViewMatrix; }
458
459 /**
460 * Retrieves the inverse of the current view matrix.
461 *
462 * If the current view matrix is invertible, return true, and if matrix
463 * is non-null, copy the inverse into it. If the current view matrix is
464 * non-invertible, return false and ignore the matrix parameter.
465 *
466 * @param matrix if not null, will receive a copy of the current inverse.
467 */
468 bool getViewInverse(SkMatrix* matrix) const {
469 SkMatrix inverse;
470 if (fViewMatrix.invert(&inverse)) {
471 if (matrix) {
472 *matrix = inverse;
473 }
474 return true;
475 }
476 return false;
477 }
478
479 /**
bsalomon@google.com137f1342013-05-29 21:27:53 +0000480 * Sets the view matrix to identity and updates any installed effects to compensate for the
481 * coord system change.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000482 */
bsalomon@google.com137f1342013-05-29 21:27:53 +0000483 bool setIdentityViewMatrix();
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000484
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000485 ////////////////////////////////////////////////////////////////////////////
486
487 /**
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000488 * Preconcats the current view matrix and restores the previous view matrix in the destructor.
bsalomon@google.com137f1342013-05-29 21:27:53 +0000489 * Effect matrices are automatically adjusted to compensate and adjusted back in the destructor.
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000490 */
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +0000491 class AutoViewMatrixRestore : public ::SkNoncopyable {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000492 public:
493 AutoViewMatrixRestore() : fDrawState(NULL) {}
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000494
bsalomon@google.comc7818882013-03-20 19:19:53 +0000495 AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000496 fDrawState = NULL;
bsalomon@google.comc7818882013-03-20 19:19:53 +0000497 this->set(ds, preconcatMatrix);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000498 }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000499
500 ~AutoViewMatrixRestore() { this->restore(); }
501
bsalomon@google.coma8347462012-10-08 18:59:39 +0000502 /**
503 * Can be called prior to destructor to restore the original matrix.
504 */
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000505 void restore();
skia.committer@gmail.comf467ce72012-10-09 02:01:37 +0000506
bsalomon@google.comc7818882013-03-20 19:19:53 +0000507 void set(GrDrawState* drawState, const SkMatrix& preconcatMatrix);
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000508
bsalomon@google.com137f1342013-05-29 21:27:53 +0000509 /** Sets the draw state's matrix to identity. This can fail because the current view matrix
510 is not invertible. */
511 bool setIdentity(GrDrawState* drawState);
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000512
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000513 private:
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000514 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix);
515
joshualittb0a8a372014-09-23 09:50:21 -0700516 GrDrawState* fDrawState;
517 SkMatrix fViewMatrix;
518 int fNumColorStages;
joshualitta5305a12014-10-10 17:47:00 -0700519 SkAutoSTArray<8, GrFragmentStage::SavedCoordChange> fSavedCoordChanges;
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000520 };
521
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000522 /// @}
523
524 ///////////////////////////////////////////////////////////////////////////
525 /// @name Render Target
526 ////
527
528 /**
egdaniel89af44a2014-09-26 06:15:04 -0700529 * Retrieves the currently set render-target.
530 *
531 * @return The currently set render target.
532 */
533 GrRenderTarget* getRenderTarget() const {
534 return static_cast<GrRenderTarget*>(fRenderTarget.getResource());
535 }
536
537 /**
bsalomon@google.comca432082013-01-23 19:53:46 +0000538 * Sets the render-target used at the next drawing call
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000539 *
540 * @param target The render target to set.
541 */
bsalomon2a9ca782014-09-05 14:27:43 -0700542 void setRenderTarget(GrRenderTarget* target) {
bsalomonbcf0a522014-10-08 08:40:09 -0700543 fRenderTarget.set(SkSafeRef(target), kWrite_GrIOType);
egdaniel3658f382014-09-15 07:01:59 -0700544 this->invalidateOptState();
bsalomon2a9ca782014-09-05 14:27:43 -0700545 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000546
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000547 /// @}
548
549 ///////////////////////////////////////////////////////////////////////////
550 /// @name Stencil
551 ////
552
egdaniel89af44a2014-09-26 06:15:04 -0700553 const GrStencilSettings& getStencil() const { return fStencilSettings; }
554
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000555 /**
556 * Sets the stencil settings to use for the next draw.
557 * Changing the clip has the side-effect of possibly zeroing
558 * out the client settable stencil bits. So multipass algorithms
559 * using stencil should not change the clip between passes.
560 * @param settings the stencil settings to use.
561 */
562 void setStencil(const GrStencilSettings& settings) {
egdaniel3658f382014-09-15 07:01:59 -0700563 if (settings != fStencilSettings) {
564 fStencilSettings = settings;
565 this->invalidateOptState();
566 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000567 }
568
569 /**
570 * Shortcut to disable stencil testing and ops.
571 */
572 void disableStencil() {
egdaniel3658f382014-09-15 07:01:59 -0700573 if (!fStencilSettings.isDisabled()) {
574 fStencilSettings.setDisabled();
575 this->invalidateOptState();
576 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000577 }
578
bsalomon2ed5ef82014-07-07 08:44:05 -0700579 GrStencilSettings* stencil() { return &fStencilSettings; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000580
581 /// @}
582
583 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000584 /// @name State Flags
585 ////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000586
egdaniel89af44a2014-09-26 06:15:04 -0700587 /**
588 * Flags that affect rendering. Controlled using enable/disableState(). All
589 * default to disabled.
590 */
591 enum StateBits {
592 /**
593 * Perform dithering. TODO: Re-evaluate whether we need this bit
594 */
595 kDither_StateBit = 0x01,
596 /**
597 * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target,
598 * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by
599 * the 3D API.
600 */
601 kHWAntialias_StateBit = 0x02,
602 /**
603 * Draws will respect the clip, otherwise the clip is ignored.
604 */
605 kClip_StateBit = 0x04,
606 /**
607 * Disables writing to the color buffer. Useful when performing stencil
608 * operations.
609 */
610 kNoColorWrites_StateBit = 0x08,
611
612 /**
613 * Usually coverage is applied after color blending. The color is blended using the coeffs
614 * specified by setBlendFunc(). The blended color is then combined with dst using coeffs
615 * of src_coverage, 1-src_coverage. Sometimes we are explicitly drawing a coverage mask. In
616 * this case there is no distinction between coverage and color and the caller needs direct
617 * control over the blend coeffs. When set, there will be a single blend step controlled by
618 * setBlendFunc() which will use coverage*color as the src color.
619 */
620 kCoverageDrawing_StateBit = 0x10,
joshualitt7a6184f2014-10-29 18:29:27 -0700621 kLast_StateBit = kCoverageDrawing_StateBit,
egdaniel89af44a2014-09-26 06:15:04 -0700622 };
623
624 uint32_t getFlagBits() const { return fFlagBits; }
625
626 bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & fFlagBits); }
627
628 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); }
629 bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_StateBit); }
630 bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_StateBit); }
631
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000632 void resetStateFlags() {
egdaniel3658f382014-09-15 07:01:59 -0700633 if (0 != fFlagBits) {
634 fFlagBits = 0;
635 this->invalidateOptState();
636 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000637 }
638
639 /**
640 * Enable render state settings.
641 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000642 * @param stateBits bitfield of StateBits specifying the states to enable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000643 */
644 void enableState(uint32_t stateBits) {
egdaniel3658f382014-09-15 07:01:59 -0700645 if (stateBits & ~fFlagBits) {
646 fFlagBits |= stateBits;
647 this->invalidateOptState();
648 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000649 }
650
651 /**
652 * Disable render state settings.
653 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000654 * @param stateBits bitfield of StateBits specifying the states to disable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000655 */
656 void disableState(uint32_t stateBits) {
egdaniel3658f382014-09-15 07:01:59 -0700657 if (stateBits & fFlagBits) {
658 fFlagBits &= ~(stateBits);
659 this->invalidateOptState();
660 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000661 }
662
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000663 /**
664 * Enable or disable stateBits based on a boolean.
665 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000666 * @param stateBits bitfield of StateBits to enable or disable
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000667 * @param enable if true enable stateBits, otherwise disable
668 */
669 void setState(uint32_t stateBits, bool enable) {
670 if (enable) {
671 this->enableState(stateBits);
672 } else {
673 this->disableState(stateBits);
674 }
675 }
676
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000677 /// @}
678
679 ///////////////////////////////////////////////////////////////////////////
680 /// @name Face Culling
681 ////
682
egdaniel89af44a2014-09-26 06:15:04 -0700683 enum DrawFace {
684 kInvalid_DrawFace = -1,
685
686 kBoth_DrawFace,
687 kCCW_DrawFace,
688 kCW_DrawFace,
689 };
690
691 /**
692 * Gets whether the target is drawing clockwise, counterclockwise,
693 * or both faces.
694 * @return the current draw face(s).
695 */
696 DrawFace getDrawFace() const { return fDrawFace; }
697
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000698 /**
699 * Controls whether clockwise, counterclockwise, or both faces are drawn.
700 * @param face the face(s) to draw.
701 */
702 void setDrawFace(DrawFace face) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000703 SkASSERT(kInvalid_DrawFace != face);
bsalomon2ed5ef82014-07-07 08:44:05 -0700704 fDrawFace = face;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000705 }
706
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000707 /// @}
708
709 ///////////////////////////////////////////////////////////////////////////
bsalomon62c447d2014-08-08 08:08:50 -0700710 /// @name Hints
711 /// Hints that when provided can enable optimizations.
712 ////
713
joshualitt65171342014-10-09 07:25:36 -0700714 enum Hints {
715 kVertexColorsAreOpaque_Hint = 0x1,
716 kLast_Hint = kVertexColorsAreOpaque_Hint
717 };
egdaniel89af44a2014-09-26 06:15:04 -0700718
bsalomon62c447d2014-08-08 08:08:50 -0700719 void setHint(Hints hint, bool value) { fHints = value ? (fHints | hint) : (fHints & ~hint); }
720
egdaniel89af44a2014-09-26 06:15:04 -0700721 bool vertexColorsAreOpaque() const { return kVertexColorsAreOpaque_Hint & fHints; }
722
bsalomon62c447d2014-08-08 08:08:50 -0700723 /// @}
724
725 ///////////////////////////////////////////////////////////////////////////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000726
bsalomon838f62d2014-08-05 07:15:57 -0700727 /** Return type for CombineIfPossible. */
728 enum CombinedState {
729 /** The GrDrawStates cannot be combined. */
730 kIncompatible_CombinedState,
731 /** Either draw state can be used in place of the other. */
732 kAOrB_CombinedState,
733 /** Use the first draw state. */
734 kA_CombinedState,
735 /** Use the second draw state. */
736 kB_CombinedState,
737 };
738
739 /** This function determines whether the GrDrawStates used for two draws can be combined into
740 a single GrDrawState. This is used to avoid storing redundant GrDrawStates and to determine
741 if draws can be batched. The return value indicates whether combining is possible and, if
742 so, which of the two inputs should be used. */
bsalomon62c447d2014-08-08 08:08:50 -0700743 static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b,
744 const GrDrawTargetCaps& caps);
bsalomon72336ed2014-08-05 07:35:56 -0700745
bsalomon8f727332014-08-05 07:50:06 -0700746 GrDrawState& operator= (const GrDrawState& that);
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000747
748private:
egdaniel89af44a2014-09-26 06:15:04 -0700749 /**
750 * Converts refs on GrGpuResources owned directly or indirectly by this GrDrawState into
751 * pending reads and writes. This should be called when a GrDrawState is recorded into
752 * a GrDrawTarget for later execution. Subclasses of GrDrawState may add setters. However,
753 * once this call has been made the GrDrawState is immutable. It is also no longer copyable.
754 * In the future this conversion will automatically happen when converting a GrDrawState into
755 * an optimized draw state.
756 */
757 void convertToPendingExec();
758
759 friend class GrDrawTarget;
760
761 bool isEqual(const GrDrawState& that) const;
762
763 /**
764 * Optimizations for blending / coverage to that can be applied based on the current state.
765 */
766 enum BlendOptFlags {
767 /**
768 * No optimization
769 */
770 kNone_BlendOpt = 0,
771 /**
772 * Don't draw at all
773 */
774 kSkipDraw_BlendOptFlag = 0x1,
775 /**
776 * The coverage value does not have to be computed separately from alpha, the the output
777 * color can be the modulation of the two.
778 */
779 kCoverageAsAlpha_BlendOptFlag = 0x2,
780 /**
781 * Instead of emitting a src color, emit coverage in the alpha channel and r,g,b are
782 * "don't cares".
783 */
784 kEmitCoverage_BlendOptFlag = 0x4,
785 /**
786 * Emit transparent black instead of the src color, no need to compute coverage.
787 */
788 kEmitTransBlack_BlendOptFlag = 0x8,
789 };
790 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
791
792 /**
793 * Determines what optimizations can be applied based on the blend. The coefficients may have
794 * to be tweaked in order for the optimization to work. srcCoeff and dstCoeff are optional
795 * params that receive the tweaked coefficients. Normally the function looks at the current
796 * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively
797 * determine the blend optimizations that would be used if there was partial pixel coverage.
798 *
799 * Subclasses of GrDrawTarget that actually draw (as opposed to those that just buffer for
800 * playback) must call this function and respect the flags that replace the output color.
801 *
802 * If the cached BlendOptFlags does not have the invalidate bit set, then getBlendOpts will
803 * simply returned the cached flags and coefficients. Otherwise it will calculate the values.
804 */
805 BlendOptFlags getBlendOpts(bool forceCoverage = false,
806 GrBlendCoeff* srcCoeff = NULL,
807 GrBlendCoeff* dstCoeff = NULL) const;
808
809 /**
810 * Determines whether src alpha is guaranteed to be one for all src pixels
811 */
812 bool srcAlphaWillBeOne() const;
813
egdaniel170f90b2014-09-16 12:54:40 -0700814 void invalidateOptState() const;
egdaniel3658f382014-09-15 07:01:59 -0700815
bsalomon8f727332014-08-05 07:50:06 -0700816 void onReset(const SkMatrix* initialViewMatrix);
bsalomon@google.com137f1342013-05-29 21:27:53 +0000817
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000818 // Some of the auto restore objects assume that no effects are removed during their lifetime.
819 // This is used to assert that this condition holds.
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +0000820 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000821
egdaniel7b3d5ee2014-08-28 05:41:14 -0700822 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, size_t stride);
robertphillips@google.com42903302013-04-20 12:26:07 +0000823
egdaniel89af44a2014-09-26 06:15:04 -0700824 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget;
825 // These fields are roughly sorted by decreasing likelihood of being different in op==
826 ProgramRenderTarget fRenderTarget;
827 GrColor fColor;
828 SkMatrix fViewMatrix;
829 GrColor fBlendConstant;
830 uint32_t fFlagBits;
831 const GrVertexAttrib* fVAPtr;
832 int fVACount;
833 size_t fVAStride;
834 GrStencilSettings fStencilSettings;
835 uint8_t fCoverage;
836 DrawFace fDrawFace;
837 GrBlendCoeff fSrcBlend;
838 GrBlendCoeff fDstBlend;
839
joshualitta5305a12014-10-10 17:47:00 -0700840 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
841 typedef GrProgramElementRef<const GrGeometryProcessor> ProgramGeometryProcessor;
842 ProgramGeometryProcessor fGeometryProcessor;
843 FragmentStageArray fColorStages;
844 FragmentStageArray fCoverageStages;
egdaniel89af44a2014-09-26 06:15:04 -0700845
846 uint32_t fHints;
847
848 // This is simply a different representation of info in fVertexAttribs and thus does
849 // not need to be compared in op==.
850 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt];
851
egdaniel3658f382014-09-15 07:01:59 -0700852 mutable GrOptDrawState* fCachedOptState;
egdanielc0648242014-09-22 13:17:02 -0700853 mutable uint32_t fCachedCapsID;
egdaniel3658f382014-09-15 07:01:59 -0700854
egdanielb109ac22014-10-07 06:45:44 -0700855 friend class GrOptDrawState;
856
egdaniel89af44a2014-09-26 06:15:04 -0700857 typedef SkRefCnt INHERITED;
tomhudson@google.com93813632011-10-27 20:21:16 +0000858};
859
egdanielb109ac22014-10-07 06:45:44 -0700860GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
egdaniel89af44a2014-09-26 06:15:04 -0700861
tomhudson@google.com93813632011-10-27 20:21:16 +0000862#endif