blob: 5c76aed6a3bcdca88cfbd35ae664e93d1b524770 [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
egdaniel69bb90c2014-11-11 07:32:45 -080031 GrDrawState() {
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
egdaniel69bb90c2014-11-11 07:32:45 -080036 GrDrawState(const SkMatrix& initialViewMatrix) {
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 **/
egdaniel69bb90c2014-11-11 07:32:45 -080044 GrDrawState(const GrDrawState& state) : INHERITED() {
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
egdanielcd8b6302014-11-11 14:46:05 -0800162 /**
163 * This function returns true if the render target destination pixel values will be read for
164 * blending during draw.
165 */
166 bool willBlendWithDst() const;
167
jvanverth@google.comcc782382013-01-28 20:39:48 +0000168 /// @}
169
170 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000171 /// @name Color
172 ////
173
egdaniel89af44a2014-09-26 06:15:04 -0700174 GrColor getColor() const { return fColor; }
175
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000176 /**
177 * Sets color for next draw to a premultiplied-alpha color.
178 *
179 * @param color the color to set.
180 */
egdaniel9514d242014-07-18 06:15:43 -0700181 void setColor(GrColor color) {
egdaniel3658f382014-09-15 07:01:59 -0700182 if (color != fColor) {
183 fColor = color;
egdaniel3658f382014-09-15 07:01:59 -0700184 }
egdaniel9514d242014-07-18 06:15:43 -0700185 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000186
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000187 /**
188 * Sets the color to be used for the next draw to be
189 * (r,g,b,a) = (alpha, alpha, alpha, alpha).
190 *
191 * @param alpha The alpha value to set as the color.
192 */
bsalomon62c447d2014-08-08 08:08:50 -0700193 void setAlpha(uint8_t a) { this->setColor((a << 24) | (a << 16) | (a << 8) | a); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000194
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000195 /// @}
196
197 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000198 /// @name Coverage
199 ////
200
egdaniel89af44a2014-09-26 06:15:04 -0700201 uint8_t getCoverage() const { return fCoverage; }
202
203 GrColor getCoverageColor() const {
204 return GrColorPackRGBA(fCoverage, fCoverage, fCoverage, fCoverage);
205 }
206
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000207 /**
rmistry@google.comd6176b02012-08-23 18:14:13 +0000208 * Sets a constant fractional coverage to be applied to the draw. The
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000209 * initial value (after construction or reset()) is 0xff. The constant
210 * coverage is ignored when per-vertex coverage is provided.
211 */
212 void setCoverage(uint8_t coverage) {
egdaniel3658f382014-09-15 07:01:59 -0700213 if (coverage != fCoverage) {
214 fCoverage = coverage;
egdaniel3658f382014-09-15 07:01:59 -0700215 }
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000216 }
217
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000218 /// @}
219
joshualittbd769d02014-09-04 08:56:46 -0700220 /**
221 * The geometry processor is the sole element of the skia pipeline which can use the vertex,
222 * geometry, and tesselation shaders. The GP may also compute a coverage in its fragment shader
223 * but is never put in the color processing pipeline.
224 */
225
joshualittb0a8a372014-09-23 09:50:21 -0700226 const GrGeometryProcessor* setGeometryProcessor(const GrGeometryProcessor* geometryProcessor) {
227 SkASSERT(geometryProcessor);
joshualittbd769d02014-09-04 08:56:46 -0700228 SkASSERT(!this->hasGeometryProcessor());
joshualitta5305a12014-10-10 17:47:00 -0700229 fGeometryProcessor.reset(SkRef(geometryProcessor));
joshualittb0a8a372014-09-23 09:50:21 -0700230 return geometryProcessor;
joshualittbd769d02014-09-04 08:56:46 -0700231 }
232
bsalomon@google.com2401ae82012-01-17 21:03:05 +0000233 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.comadc65362013-01-28 14:26:09 +0000234 /// @name Effect Stages
joshualittb0a8a372014-09-23 09:50:21 -0700235 /// Each stage hosts a GrProcessor. The effect produces an output color or coverage in the
236 /// fragment shader. Its inputs are the output from the previous stage as well as some variables
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000237 /// available to it in the fragment and vertex shader (e.g. the vertex position, the dst color,
238 /// the fragment position, local coordinates).
239 ///
240 /// The stages are divided into two sets, color-computing and coverage-computing. The final
241 /// color stage produces the final pixel color. The coverage-computing stages function exactly
242 /// as the color-computing but the output of the final coverage stage is treated as a fractional
243 /// pixel coverage rather than as input to the src/dst color blend step.
244 ///
245 /// The input color to the first color-stage is either the constant color or interpolated
246 /// per-vertex colors. The input to the first coverage stage is either a constant coverage
247 /// (usually full-coverage) or interpolated per-vertex coverage.
248 ///
249 /// See the documentation of kCoverageDrawing_StateBit for information about disabling the
250 /// the color / coverage distinction.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000251 ////
252
egdaniel89af44a2014-09-26 06:15:04 -0700253 int numColorStages() const { return fColorStages.count(); }
254 int numCoverageStages() const { return fCoverageStages.count(); }
joshualitt4dd99882014-11-11 08:51:30 -0800255 int numFragmentStages() const { return this->numColorStages() + this->numCoverageStages(); }
egdaniel89af44a2014-09-26 06:15:04 -0700256 int numTotalStages() const {
joshualitt4dd99882014-11-11 08:51:30 -0800257 return this->numFragmentStages() + (this->hasGeometryProcessor() ? 1 : 0);
egdaniel89af44a2014-09-26 06:15:04 -0700258 }
259
260 bool hasGeometryProcessor() const { return SkToBool(fGeometryProcessor.get()); }
joshualitta5305a12014-10-10 17:47:00 -0700261 const GrGeometryProcessor* getGeometryProcessor() const { return fGeometryProcessor.get(); }
egdaniel89af44a2014-09-26 06:15:04 -0700262 const GrFragmentStage& getColorStage(int idx) const { return fColorStages[idx]; }
263 const GrFragmentStage& getCoverageStage(int idx) const { return fCoverageStages[idx]; }
264
265 /**
266 * Checks whether any of the effects will read the dst pixel color.
267 */
268 bool willEffectReadDstColor() const;
269
joshualittb0a8a372014-09-23 09:50:21 -0700270 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -0700271 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -0700272 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
jvanverth@google.com65eb4d52013-03-19 18:51:02 +0000273 return effect;
274 }
skia.committer@gmail.com01c34ee2013-03-20 07:01:02 +0000275
joshualittb0a8a372014-09-23 09:50:21 -0700276 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -0700277 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -0700278 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
bsalomon@google.comadc65362013-01-28 14:26:09 +0000279 return effect;
280 }
281
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000282 /**
bsalomon@google.comc7818882013-03-20 19:19:53 +0000283 * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
tomhudson@google.com1e8f0162012-07-20 16:25:18 +0000284 */
joshualittb0a8a372014-09-23 09:50:21 -0700285 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
286 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comdfdb7e52012-10-16 15:19:45 +0000287 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000288
joshualittb0a8a372014-09-23 09:50:21 -0700289 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
290 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000291 }
292
joshualittb0a8a372014-09-23 09:50:21 -0700293 void addColorTextureProcessor(GrTexture* texture,
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000294 const SkMatrix& matrix,
295 const GrTextureParams& params) {
joshualittb0a8a372014-09-23 09:50:21 -0700296 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
297 }
298
299 void addCoverageTextureProcessor(GrTexture* texture,
300 const SkMatrix& matrix,
301 const GrTextureParams& params) {
302 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
commit-bot@chromium.orgff6ea262013-03-12 12:26:08 +0000303 }
tomhudson@google.com676e6602012-07-10 17:21:48 +0000304
robertphillips@google.com972265d2012-06-13 18:49:30 +0000305 /**
bsalomon9b536522014-09-05 09:18:51 -0700306 * When this object is destroyed it will remove any color/coverage effects from the draw state
307 * that were added after its constructor.
308 *
309 * This class has strange behavior around geometry processor. If there is a GP on the draw state
310 * it will assert that the GP is not modified until after the destructor of the ARE. If the
311 * draw state has a NULL GP when the ARE is constructed then it will reset it to null in the
312 * destructor.
313 *
314 * TODO: We'd prefer for the ARE to just save and restore the GP. However, this would add
315 * significant complexity to the multi-ref architecture for deferred drawing. Once GrDrawState
316 * and GrOptDrawState are fully separated then GrDrawState will never be in the deferred
317 * execution state and GrOptDrawState always will be (and will be immutable and therefore
318 * unable to have an ARE). At this point we can restore sanity and have the ARE save and restore
319 * the GP.
robertphillips@google.com972265d2012-06-13 18:49:30 +0000320 */
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +0000321 class AutoRestoreEffects : public ::SkNoncopyable {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000322 public:
bsalomon9b536522014-09-05 09:18:51 -0700323 AutoRestoreEffects()
324 : fDrawState(NULL)
bsalomon52e9d632014-09-05 12:23:12 -0700325 , fOriginalGPID(SK_InvalidUniqueID)
bsalomon9b536522014-09-05 09:18:51 -0700326 , fColorEffectCnt(0)
327 , fCoverageEffectCnt(0) {}
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000328
bsalomon9b536522014-09-05 09:18:51 -0700329 AutoRestoreEffects(GrDrawState* ds)
330 : fDrawState(NULL)
bsalomon52e9d632014-09-05 12:23:12 -0700331 , fOriginalGPID(SK_InvalidUniqueID)
bsalomon9b536522014-09-05 09:18:51 -0700332 , fColorEffectCnt(0)
333 , fCoverageEffectCnt(0) {
skia.committer@gmail.com5c493d52013-06-14 07:00:49 +0000334 this->set(ds);
robertphillips@google.comf09b87d2013-06-13 20:06:44 +0000335 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000336
337 ~AutoRestoreEffects() { this->set(NULL); }
338
bsalomon8f727332014-08-05 07:50:06 -0700339 void set(GrDrawState* ds);
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000340
bsalomon49f085d2014-09-05 13:34:00 -0700341 bool isSet() const { return SkToBool(fDrawState); }
bsalomon8af05232014-06-03 06:34:58 -0700342
robertphillips@google.com972265d2012-06-13 18:49:30 +0000343 private:
bsalomon9b536522014-09-05 09:18:51 -0700344 GrDrawState* fDrawState;
bsalomon52e9d632014-09-05 12:23:12 -0700345 uint32_t fOriginalGPID;
bsalomon9b536522014-09-05 09:18:51 -0700346 int fColorEffectCnt;
347 int fCoverageEffectCnt;
robertphillips@google.com972265d2012-06-13 18:49:30 +0000348 };
349
joshualitta58fe352014-10-27 08:39:00 -0700350 /**
351 * AutoRestoreStencil
352 *
353 * This simple struct saves and restores the stencil settings
354 */
355 class AutoRestoreStencil : public ::SkNoncopyable {
356 public:
357 AutoRestoreStencil() : fDrawState(NULL) {}
358
359 AutoRestoreStencil(GrDrawState* ds) : fDrawState(NULL) { this->set(ds); }
360
361 ~AutoRestoreStencil() { this->set(NULL); }
362
363 void set(GrDrawState* ds) {
364 if (fDrawState) {
365 fDrawState->setStencil(fStencilSettings);
366 }
367 fDrawState = ds;
368 if (ds) {
369 fStencilSettings = ds->getStencil();
370 }
371 }
372
373 bool isSet() const { return SkToBool(fDrawState); }
374
375 private:
376 GrDrawState* fDrawState;
377 GrStencilSettings fStencilSettings;
378 };
379
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000380 /// @}
381
382 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000383 /// @name Blending
384 ////
385
egdaniel89af44a2014-09-26 06:15:04 -0700386 GrBlendCoeff getSrcBlendCoeff() const { return fSrcBlend; }
387 GrBlendCoeff getDstBlendCoeff() const { return fDstBlend; }
388
389 /**
390 * Retrieves the last value set by setBlendConstant()
391 * @return the blending constant value
392 */
393 GrColor getBlendConstant() const { return fBlendConstant; }
394
395 /**
396 * Determines whether multiplying the computed per-pixel color by the pixel's fractional
397 * coverage before the blend will give the correct final destination color. In general it
398 * will not as coverage is applied after blending.
399 */
400 bool canTweakAlphaForCoverage() const;
401
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000402 /**
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000403 * Sets the blending function coefficients.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000404 *
405 * The blend function will be:
406 * D' = sat(S*srcCoef + D*dstCoef)
407 *
408 * where D is the existing destination color, S is the incoming source
409 * color, and D' is the new destination color that will be written. sat()
410 * is the saturation function.
411 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000412 * @param srcCoef coefficient applied to the src color.
413 * @param dstCoef coefficient applied to the dst color.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000414 */
415 void setBlendFunc(GrBlendCoeff srcCoeff, GrBlendCoeff dstCoeff) {
egdaniel3658f382014-09-15 07:01:59 -0700416 if (srcCoeff != fSrcBlend || dstCoeff != fDstBlend) {
417 fSrcBlend = srcCoeff;
418 fDstBlend = dstCoeff;
egdaniel3658f382014-09-15 07:01:59 -0700419 }
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)) {
tfarina38406c82014-10-31 07:11:12 -0700422 SkDebugf("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)) {
tfarina38406c82014-10-31 07:11:12 -0700425 SkDebugf("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;
egdaniel3658f382014-09-15 07:01:59 -0700443 }
egdaniel9514d242014-07-18 06:15:43 -0700444 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000445
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000446 /// @}
447
448 ///////////////////////////////////////////////////////////////////////////
449 /// @name View Matrix
450 ////
451
452 /**
egdaniel89af44a2014-09-26 06:15:04 -0700453 * Retrieves the current view matrix
454 * @return the current view matrix.
455 */
456 const SkMatrix& getViewMatrix() const { return fViewMatrix; }
457
458 /**
459 * Retrieves the inverse of the current view matrix.
460 *
461 * If the current view matrix is invertible, return true, and if matrix
462 * is non-null, copy the inverse into it. If the current view matrix is
463 * non-invertible, return false and ignore the matrix parameter.
464 *
465 * @param matrix if not null, will receive a copy of the current inverse.
466 */
467 bool getViewInverse(SkMatrix* matrix) const {
468 SkMatrix inverse;
469 if (fViewMatrix.invert(&inverse)) {
470 if (matrix) {
471 *matrix = inverse;
472 }
473 return true;
474 }
475 return false;
476 }
477
478 /**
bsalomon@google.com137f1342013-05-29 21:27:53 +0000479 * Sets the view matrix to identity and updates any installed effects to compensate for the
480 * coord system change.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000481 */
bsalomon@google.com137f1342013-05-29 21:27:53 +0000482 bool setIdentityViewMatrix();
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000483
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000484 ////////////////////////////////////////////////////////////////////////////
485
486 /**
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000487 * Preconcats the current view matrix and restores the previous view matrix in the destructor.
bsalomon@google.com137f1342013-05-29 21:27:53 +0000488 * Effect matrices are automatically adjusted to compensate and adjusted back in the destructor.
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000489 */
commit-bot@chromium.orga0b40282013-09-18 13:00:55 +0000490 class AutoViewMatrixRestore : public ::SkNoncopyable {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000491 public:
492 AutoViewMatrixRestore() : fDrawState(NULL) {}
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000493
bsalomon@google.comc7818882013-03-20 19:19:53 +0000494 AutoViewMatrixRestore(GrDrawState* ds, const SkMatrix& preconcatMatrix) {
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000495 fDrawState = NULL;
bsalomon@google.comc7818882013-03-20 19:19:53 +0000496 this->set(ds, preconcatMatrix);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000497 }
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000498
499 ~AutoViewMatrixRestore() { this->restore(); }
500
bsalomon@google.coma8347462012-10-08 18:59:39 +0000501 /**
502 * Can be called prior to destructor to restore the original matrix.
503 */
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000504 void restore();
skia.committer@gmail.comf467ce72012-10-09 02:01:37 +0000505
bsalomon@google.comc7818882013-03-20 19:19:53 +0000506 void set(GrDrawState* drawState, const SkMatrix& preconcatMatrix);
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000507
bsalomon@google.com137f1342013-05-29 21:27:53 +0000508 /** Sets the draw state's matrix to identity. This can fail because the current view matrix
509 is not invertible. */
510 bool setIdentity(GrDrawState* drawState);
bsalomon@google.com2fdcdeb2012-10-08 17:15:55 +0000511
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000512 private:
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000513 void doEffectCoordChanges(const SkMatrix& coordChangeMatrix);
514
joshualittb0a8a372014-09-23 09:50:21 -0700515 GrDrawState* fDrawState;
516 SkMatrix fViewMatrix;
517 int fNumColorStages;
joshualitta5305a12014-10-10 17:47:00 -0700518 SkAutoSTArray<8, GrFragmentStage::SavedCoordChange> fSavedCoordChanges;
bsalomon@google.com5b3e8902012-10-05 20:13:28 +0000519 };
520
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000521 /// @}
522
523 ///////////////////////////////////////////////////////////////////////////
524 /// @name Render Target
525 ////
526
527 /**
egdaniel89af44a2014-09-26 06:15:04 -0700528 * Retrieves the currently set render-target.
529 *
530 * @return The currently set render target.
531 */
bsalomon37dd3312014-11-03 08:47:23 -0800532 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
egdaniel89af44a2014-09-26 06:15:04 -0700533
534 /**
bsalomon@google.comca432082013-01-23 19:53:46 +0000535 * Sets the render-target used at the next drawing call
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000536 *
537 * @param target The render target to set.
538 */
bsalomon2a9ca782014-09-05 14:27:43 -0700539 void setRenderTarget(GrRenderTarget* target) {
bsalomonbcf0a522014-10-08 08:40:09 -0700540 fRenderTarget.set(SkSafeRef(target), kWrite_GrIOType);
bsalomon2a9ca782014-09-05 14:27:43 -0700541 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000542
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000543 /// @}
544
545 ///////////////////////////////////////////////////////////////////////////
546 /// @name Stencil
547 ////
548
egdaniel89af44a2014-09-26 06:15:04 -0700549 const GrStencilSettings& getStencil() const { return fStencilSettings; }
550
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000551 /**
552 * Sets the stencil settings to use for the next draw.
553 * Changing the clip has the side-effect of possibly zeroing
554 * out the client settable stencil bits. So multipass algorithms
555 * using stencil should not change the clip between passes.
556 * @param settings the stencil settings to use.
557 */
558 void setStencil(const GrStencilSettings& settings) {
egdaniel3658f382014-09-15 07:01:59 -0700559 if (settings != fStencilSettings) {
560 fStencilSettings = settings;
egdaniel3658f382014-09-15 07:01:59 -0700561 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000562 }
563
564 /**
565 * Shortcut to disable stencil testing and ops.
566 */
567 void disableStencil() {
egdaniel3658f382014-09-15 07:01:59 -0700568 if (!fStencilSettings.isDisabled()) {
569 fStencilSettings.setDisabled();
egdaniel3658f382014-09-15 07:01:59 -0700570 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000571 }
572
bsalomon2ed5ef82014-07-07 08:44:05 -0700573 GrStencilSettings* stencil() { return &fStencilSettings; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000574
575 /// @}
576
577 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000578 /// @name State Flags
579 ////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000580
egdaniel89af44a2014-09-26 06:15:04 -0700581 /**
582 * Flags that affect rendering. Controlled using enable/disableState(). All
583 * default to disabled.
584 */
585 enum StateBits {
586 /**
587 * Perform dithering. TODO: Re-evaluate whether we need this bit
588 */
589 kDither_StateBit = 0x01,
590 /**
591 * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target,
592 * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by
593 * the 3D API.
594 */
595 kHWAntialias_StateBit = 0x02,
596 /**
597 * Draws will respect the clip, otherwise the clip is ignored.
598 */
599 kClip_StateBit = 0x04,
600 /**
601 * Disables writing to the color buffer. Useful when performing stencil
602 * operations.
603 */
604 kNoColorWrites_StateBit = 0x08,
605
606 /**
607 * Usually coverage is applied after color blending. The color is blended using the coeffs
608 * specified by setBlendFunc(). The blended color is then combined with dst using coeffs
609 * of src_coverage, 1-src_coverage. Sometimes we are explicitly drawing a coverage mask. In
610 * this case there is no distinction between coverage and color and the caller needs direct
611 * control over the blend coeffs. When set, there will be a single blend step controlled by
612 * setBlendFunc() which will use coverage*color as the src color.
613 */
614 kCoverageDrawing_StateBit = 0x10,
joshualitt7a6184f2014-10-29 18:29:27 -0700615 kLast_StateBit = kCoverageDrawing_StateBit,
egdaniel89af44a2014-09-26 06:15:04 -0700616 };
617
618 uint32_t getFlagBits() const { return fFlagBits; }
619
620 bool isStateFlagEnabled(uint32_t stateBit) const { return 0 != (stateBit & fFlagBits); }
621
622 bool isClipState() const { return 0 != (fFlagBits & kClip_StateBit); }
623 bool isColorWriteDisabled() const { return 0 != (fFlagBits & kNoColorWrites_StateBit); }
624 bool isCoverageDrawing() const { return 0 != (fFlagBits & kCoverageDrawing_StateBit); }
625
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000626 void resetStateFlags() {
egdaniel3658f382014-09-15 07:01:59 -0700627 if (0 != fFlagBits) {
628 fFlagBits = 0;
egdaniel3658f382014-09-15 07:01:59 -0700629 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000630 }
631
632 /**
633 * Enable render state settings.
634 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000635 * @param stateBits bitfield of StateBits specifying the states to enable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000636 */
637 void enableState(uint32_t stateBits) {
egdaniel3658f382014-09-15 07:01:59 -0700638 if (stateBits & ~fFlagBits) {
639 fFlagBits |= stateBits;
egdaniel3658f382014-09-15 07:01:59 -0700640 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000641 }
642
643 /**
644 * Disable render state settings.
645 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000646 * @param stateBits bitfield of StateBits specifying the states to disable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000647 */
648 void disableState(uint32_t stateBits) {
egdaniel3658f382014-09-15 07:01:59 -0700649 if (stateBits & fFlagBits) {
650 fFlagBits &= ~(stateBits);
egdaniel3658f382014-09-15 07:01:59 -0700651 }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000652 }
653
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000654 /**
655 * Enable or disable stateBits based on a boolean.
656 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000657 * @param stateBits bitfield of StateBits to enable or disable
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000658 * @param enable if true enable stateBits, otherwise disable
659 */
660 void setState(uint32_t stateBits, bool enable) {
661 if (enable) {
662 this->enableState(stateBits);
663 } else {
664 this->disableState(stateBits);
665 }
666 }
667
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000668 /// @}
669
670 ///////////////////////////////////////////////////////////////////////////
671 /// @name Face Culling
672 ////
673
egdaniel89af44a2014-09-26 06:15:04 -0700674 enum DrawFace {
675 kInvalid_DrawFace = -1,
676
677 kBoth_DrawFace,
678 kCCW_DrawFace,
679 kCW_DrawFace,
680 };
681
682 /**
683 * Gets whether the target is drawing clockwise, counterclockwise,
684 * or both faces.
685 * @return the current draw face(s).
686 */
687 DrawFace getDrawFace() const { return fDrawFace; }
688
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000689 /**
690 * Controls whether clockwise, counterclockwise, or both faces are drawn.
691 * @param face the face(s) to draw.
692 */
693 void setDrawFace(DrawFace face) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000694 SkASSERT(kInvalid_DrawFace != face);
bsalomon2ed5ef82014-07-07 08:44:05 -0700695 fDrawFace = face;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000696 }
697
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000698 /// @}
699
700 ///////////////////////////////////////////////////////////////////////////
bsalomon62c447d2014-08-08 08:08:50 -0700701 /// @name Hints
702 /// Hints that when provided can enable optimizations.
703 ////
704
joshualitt65171342014-10-09 07:25:36 -0700705 enum Hints {
706 kVertexColorsAreOpaque_Hint = 0x1,
707 kLast_Hint = kVertexColorsAreOpaque_Hint
708 };
egdaniel89af44a2014-09-26 06:15:04 -0700709
bsalomon62c447d2014-08-08 08:08:50 -0700710 void setHint(Hints hint, bool value) { fHints = value ? (fHints | hint) : (fHints & ~hint); }
711
egdaniel89af44a2014-09-26 06:15:04 -0700712 bool vertexColorsAreOpaque() const { return kVertexColorsAreOpaque_Hint & fHints; }
713
bsalomon62c447d2014-08-08 08:08:50 -0700714 /// @}
715
716 ///////////////////////////////////////////////////////////////////////////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000717
bsalomon838f62d2014-08-05 07:15:57 -0700718 /** Return type for CombineIfPossible. */
719 enum CombinedState {
720 /** The GrDrawStates cannot be combined. */
721 kIncompatible_CombinedState,
722 /** Either draw state can be used in place of the other. */
723 kAOrB_CombinedState,
724 /** Use the first draw state. */
725 kA_CombinedState,
726 /** Use the second draw state. */
727 kB_CombinedState,
728 };
729
730 /** This function determines whether the GrDrawStates used for two draws can be combined into
731 a single GrDrawState. This is used to avoid storing redundant GrDrawStates and to determine
732 if draws can be batched. The return value indicates whether combining is possible and, if
733 so, which of the two inputs should be used. */
bsalomon62c447d2014-08-08 08:08:50 -0700734 static CombinedState CombineIfPossible(const GrDrawState& a, const GrDrawState& b,
735 const GrDrawTargetCaps& caps);
bsalomon72336ed2014-08-05 07:35:56 -0700736
bsalomon8f727332014-08-05 07:50:06 -0700737 GrDrawState& operator= (const GrDrawState& that);
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000738
739private:
egdaniel89af44a2014-09-26 06:15:04 -0700740 /**
741 * Converts refs on GrGpuResources owned directly or indirectly by this GrDrawState into
742 * pending reads and writes. This should be called when a GrDrawState is recorded into
743 * a GrDrawTarget for later execution. Subclasses of GrDrawState may add setters. However,
744 * once this call has been made the GrDrawState is immutable. It is also no longer copyable.
745 * In the future this conversion will automatically happen when converting a GrDrawState into
746 * an optimized draw state.
747 */
748 void convertToPendingExec();
749
750 friend class GrDrawTarget;
751
752 bool isEqual(const GrDrawState& that) const;
753
754 /**
755 * Optimizations for blending / coverage to that can be applied based on the current state.
756 */
757 enum BlendOptFlags {
758 /**
759 * No optimization
760 */
761 kNone_BlendOpt = 0,
762 /**
763 * Don't draw at all
764 */
765 kSkipDraw_BlendOptFlag = 0x1,
766 /**
767 * The coverage value does not have to be computed separately from alpha, the the output
768 * color can be the modulation of the two.
769 */
770 kCoverageAsAlpha_BlendOptFlag = 0x2,
771 /**
772 * Instead of emitting a src color, emit coverage in the alpha channel and r,g,b are
773 * "don't cares".
774 */
775 kEmitCoverage_BlendOptFlag = 0x4,
776 /**
777 * Emit transparent black instead of the src color, no need to compute coverage.
778 */
779 kEmitTransBlack_BlendOptFlag = 0x8,
780 };
781 GR_DECL_BITFIELD_OPS_FRIENDS(BlendOptFlags);
782
783 /**
784 * Determines what optimizations can be applied based on the blend. The coefficients may have
785 * to be tweaked in order for the optimization to work. srcCoeff and dstCoeff are optional
786 * params that receive the tweaked coefficients. Normally the function looks at the current
787 * state to see if coverage is enabled. By setting forceCoverage the caller can speculatively
788 * determine the blend optimizations that would be used if there was partial pixel coverage.
789 *
790 * Subclasses of GrDrawTarget that actually draw (as opposed to those that just buffer for
791 * playback) must call this function and respect the flags that replace the output color.
792 *
793 * If the cached BlendOptFlags does not have the invalidate bit set, then getBlendOpts will
794 * simply returned the cached flags and coefficients. Otherwise it will calculate the values.
795 */
796 BlendOptFlags getBlendOpts(bool forceCoverage = false,
797 GrBlendCoeff* srcCoeff = NULL,
798 GrBlendCoeff* dstCoeff = NULL) const;
799
800 /**
801 * Determines whether src alpha is guaranteed to be one for all src pixels
802 */
803 bool srcAlphaWillBeOne() const;
804
bsalomon8f727332014-08-05 07:50:06 -0700805 void onReset(const SkMatrix* initialViewMatrix);
bsalomon@google.com137f1342013-05-29 21:27:53 +0000806
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000807 // Some of the auto restore objects assume that no effects are removed during their lifetime.
808 // This is used to assert that this condition holds.
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +0000809 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000810
egdaniel7b3d5ee2014-08-28 05:41:14 -0700811 void internalSetVertexAttribs(const GrVertexAttrib attribs[], int count, size_t stride);
robertphillips@google.com42903302013-04-20 12:26:07 +0000812
egdaniel89af44a2014-09-26 06:15:04 -0700813 typedef GrTGpuResourceRef<GrRenderTarget> ProgramRenderTarget;
814 // These fields are roughly sorted by decreasing likelihood of being different in op==
815 ProgramRenderTarget fRenderTarget;
816 GrColor fColor;
817 SkMatrix fViewMatrix;
818 GrColor fBlendConstant;
819 uint32_t fFlagBits;
820 const GrVertexAttrib* fVAPtr;
821 int fVACount;
822 size_t fVAStride;
823 GrStencilSettings fStencilSettings;
824 uint8_t fCoverage;
825 DrawFace fDrawFace;
826 GrBlendCoeff fSrcBlend;
827 GrBlendCoeff fDstBlend;
828
joshualitta5305a12014-10-10 17:47:00 -0700829 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
830 typedef GrProgramElementRef<const GrGeometryProcessor> ProgramGeometryProcessor;
831 ProgramGeometryProcessor fGeometryProcessor;
832 FragmentStageArray fColorStages;
833 FragmentStageArray fCoverageStages;
egdaniel89af44a2014-09-26 06:15:04 -0700834
835 uint32_t fHints;
836
837 // This is simply a different representation of info in fVertexAttribs and thus does
838 // not need to be compared in op==.
839 int fFixedFunctionVertexAttribIndices[kGrFixedFunctionVertexAttribBindingCnt];
840
egdanielb109ac22014-10-07 06:45:44 -0700841 friend class GrOptDrawState;
842
egdaniel89af44a2014-09-26 06:15:04 -0700843 typedef SkRefCnt INHERITED;
tomhudson@google.com93813632011-10-27 20:21:16 +0000844};
845
egdanielb109ac22014-10-07 06:45:44 -0700846GR_MAKE_BITFIELD_OPS(GrDrawState::BlendOptFlags);
egdaniel89af44a2014-09-26 06:15:04 -0700847
tomhudson@google.com93813632011-10-27 20:21:16 +0000848#endif