blob: ae9ca9b067b585795a921241c735833dd4f1aa0f [file] [log] [blame]
tomhudson@google.com93813632011-10-27 20:21:16 +00001/*
egdaniel8dd688b2015-01-22 10:16:09 -08002 * Copyright 2015 Google Inc.
tomhudson@google.com93813632011-10-27 20:21:16 +00003 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
egdaniel8dd688b2015-01-22 10:16:09 -08008#ifndef GrPipelineBuilder_DEFINED
9#define GrPipelineBuilder_DEFINED
tomhudson@google.com93813632011-10-27 20:21:16 +000010
commit-bot@chromium.org24ab3b02013-08-14 21:56:37 +000011#include "GrBlend.h"
joshualitt44701df2015-02-23 14:44:57 -080012#include "GrClip.h"
egdanielc0648242014-09-22 13:17:02 -070013#include "GrDrawTargetCaps.h"
bsalomonf96ba022014-09-17 08:05:40 -070014#include "GrGpuResourceRef.h"
bsalomonae59b772014-11-19 08:23:49 -080015#include "GrFragmentStage.h"
egdanielb6cbc382014-11-13 11:00:34 -080016#include "GrProcOptInfo.h"
egdaniel89af44a2014-09-26 06:15:04 -070017#include "GrRenderTarget.h"
18#include "GrStencil.h"
egdaniel95131432014-12-09 11:15:43 -080019#include "GrXferProcessor.h"
egdaniel89af44a2014-09-26 06:15:04 -070020#include "SkMatrix.h"
egdaniel87509242014-12-17 13:37:13 -080021#include "effects/GrCoverageSetOpXP.h"
egdaniel080e6732014-12-22 07:35:52 -080022#include "effects/GrDisableColorXP.h"
egdaniel95131432014-12-09 11:15:43 -080023#include "effects/GrPorterDuffXferProcessor.h"
bsalomon@google.com68b58c92013-01-17 16:50:08 +000024#include "effects/GrSimpleTextureEffect.h"
tomhudson@google.com93813632011-10-27 20:21:16 +000025
joshualitt5bf99f12015-03-13 11:47:42 -070026class GrBatch;
egdaniel89af44a2014-09-26 06:15:04 -070027class GrDrawTargetCaps;
egdaniel89af44a2014-09-26 06:15:04 -070028class GrPaint;
29class GrTexture;
egdaniel170f90b2014-09-16 12:54:40 -070030
egdaniel8dd688b2015-01-22 10:16:09 -080031class GrPipelineBuilder {
bsalomon@google.com2e3d1442012-03-26 20:33:54 +000032public:
egdaniel8dd688b2015-01-22 10:16:09 -080033 GrPipelineBuilder();
34
35 GrPipelineBuilder(const GrPipelineBuilder& pipelineBuilder) {
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +000036 SkDEBUGCODE(fBlockEffectRemovalCnt = 0;)
egdaniel8dd688b2015-01-22 10:16:09 -080037 *this = pipelineBuilder;
bsalomon@google.com46f7afb2012-01-18 19:51:55 +000038 }
39
egdaniel8dd688b2015-01-22 10:16:09 -080040 virtual ~GrPipelineBuilder();
bsalomon@google.com137f1342013-05-29 21:27:53 +000041
bsalomon@google.com52a5dcb2012-01-17 16:01:37 +000042 /**
egdaniel8dd688b2015-01-22 10:16:09 -080043 * Initializes the GrPipelineBuilder based on a GrPaint, view matrix and render target. Note
44 * that GrPipelineBuilder encompasses more than GrPaint. Aspects of GrPipelineBuilder that have
45 * no GrPaint equivalents are set to default values with the exception of vertex attribute state
46 * which is unmodified by this function and clipping which will be enabled.
bsalomon@google.comaf84e742012-10-05 13:23:24 +000047 */
joshualitt570d2f82015-02-25 13:19:48 -080048 void setFromPaint(const GrPaint&, GrRenderTarget*, const GrClip&);
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000049
bsalomon@google.com2401ae82012-01-17 21:03:05 +000050 ///////////////////////////////////////////////////////////////////////////
bsalomon6be6f7c2015-02-26 13:05:21 -080051 /// @name Fragment Processors
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000052 ///
bsalomon6be6f7c2015-02-26 13:05:21 -080053 /// GrFragmentProcessors are used to compute per-pixel color and per-pixel fractional coverage.
54 /// There are two chains of FPs, one for color and one for coverage. The first FP in each
55 /// chain gets the initial color/coverage from the GrPrimitiveProcessor. It computes an output
56 /// color/coverage which is fed to the next FP in the chain. The last color and coverage FPs
57 /// feed their output to the GrXferProcessor which controls blending.
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000058 ////
59
bsalomon6be6f7c2015-02-26 13:05:21 -080060 int numColorFragmentStages() const { return fColorStages.count(); }
61 int numCoverageFragmentStages() const { return fCoverageStages.count(); }
62 int numFragmentStages() const { return this->numColorFragmentStages() +
63 this->numCoverageFragmentStages(); }
egdaniel378092f2014-12-03 10:40:13 -080064
bsalomon6be6f7c2015-02-26 13:05:21 -080065 const GrFragmentStage& getColorFragmentStage(int idx) const { return fColorStages[idx]; }
66 const GrFragmentStage& getCoverageFragmentStage(int idx) const { return fCoverageStages[idx]; }
egdaniel080e6732014-12-22 07:35:52 -080067
joshualittb0a8a372014-09-23 09:50:21 -070068 const GrFragmentProcessor* addColorProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -070069 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -070070 SkNEW_APPEND_TO_TARRAY(&fColorStages, GrFragmentStage, (effect));
egdanielb6cbc382014-11-13 11:00:34 -080071 fColorProcInfoValid = false;
jvanverth@google.com65eb4d52013-03-19 18:51:02 +000072 return effect;
73 }
skia.committer@gmail.com01c34ee2013-03-20 07:01:02 +000074
joshualittb0a8a372014-09-23 09:50:21 -070075 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* effect) {
bsalomon49f085d2014-09-05 13:34:00 -070076 SkASSERT(effect);
joshualittb0a8a372014-09-23 09:50:21 -070077 SkNEW_APPEND_TO_TARRAY(&fCoverageStages, GrFragmentStage, (effect));
egdanielb6cbc382014-11-13 11:00:34 -080078 fCoverageProcInfoValid = false;
bsalomon@google.comadc65362013-01-28 14:26:09 +000079 return effect;
80 }
81
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +000082 /**
bsalomon@google.comc7818882013-03-20 19:19:53 +000083 * Creates a GrSimpleTextureEffect that uses local coords as texture coordinates.
tomhudson@google.com1e8f0162012-07-20 16:25:18 +000084 */
joshualittb0a8a372014-09-23 09:50:21 -070085 void addColorTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
86 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comdfdb7e52012-10-16 15:19:45 +000087 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000088
joshualittb0a8a372014-09-23 09:50:21 -070089 void addCoverageTextureProcessor(GrTexture* texture, const SkMatrix& matrix) {
90 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix))->unref();
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000091 }
92
joshualittb0a8a372014-09-23 09:50:21 -070093 void addColorTextureProcessor(GrTexture* texture,
bsalomon@google.comeb6879f2013-06-13 19:34:18 +000094 const SkMatrix& matrix,
95 const GrTextureParams& params) {
joshualittb0a8a372014-09-23 09:50:21 -070096 this->addColorProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
97 }
98
99 void addCoverageTextureProcessor(GrTexture* texture,
100 const SkMatrix& matrix,
101 const GrTextureParams& params) {
102 this->addCoverageProcessor(GrSimpleTextureEffect::Create(texture, matrix, params))->unref();
commit-bot@chromium.orgff6ea262013-03-12 12:26:08 +0000103 }
tomhudson@google.com676e6602012-07-10 17:21:48 +0000104
robertphillips@google.com972265d2012-06-13 18:49:30 +0000105 /**
bsalomon6be6f7c2015-02-26 13:05:21 -0800106 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder
107 * that were added after its constructor.
robertphillips@google.com972265d2012-06-13 18:49:30 +0000108 */
bsalomon6be6f7c2015-02-26 13:05:21 -0800109 class AutoRestoreFragmentProcessors : public ::SkNoncopyable {
robertphillips@google.com972265d2012-06-13 18:49:30 +0000110 public:
bsalomon6be6f7c2015-02-26 13:05:21 -0800111 AutoRestoreFragmentProcessors()
egdaniel8dd688b2015-01-22 10:16:09 -0800112 : fPipelineBuilder(NULL)
bsalomon9b536522014-09-05 09:18:51 -0700113 , fColorEffectCnt(0)
114 , fCoverageEffectCnt(0) {}
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000115
bsalomon6be6f7c2015-02-26 13:05:21 -0800116 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds)
egdaniel8dd688b2015-01-22 10:16:09 -0800117 : fPipelineBuilder(NULL)
bsalomon9b536522014-09-05 09:18:51 -0700118 , fColorEffectCnt(0)
119 , fCoverageEffectCnt(0) {
skia.committer@gmail.com5c493d52013-06-14 07:00:49 +0000120 this->set(ds);
robertphillips@google.comf09b87d2013-06-13 20:06:44 +0000121 }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000122
bsalomon6be6f7c2015-02-26 13:05:21 -0800123 ~AutoRestoreFragmentProcessors() { this->set(NULL); }
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000124
egdaniel8dd688b2015-01-22 10:16:09 -0800125 void set(GrPipelineBuilder* ds);
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000126
egdaniel8dd688b2015-01-22 10:16:09 -0800127 bool isSet() const { return SkToBool(fPipelineBuilder); }
bsalomon8af05232014-06-03 06:34:58 -0700128
robertphillips@google.com972265d2012-06-13 18:49:30 +0000129 private:
egdaniel8dd688b2015-01-22 10:16:09 -0800130 GrPipelineBuilder* fPipelineBuilder;
bsalomon9b536522014-09-05 09:18:51 -0700131 int fColorEffectCnt;
132 int fCoverageEffectCnt;
robertphillips@google.com972265d2012-06-13 18:49:30 +0000133 };
134
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000135 /// @}
136
137 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000138 /// @name Blending
139 ////
140
egdaniel89af44a2014-09-26 06:15:04 -0700141 /**
142 * Determines whether multiplying the computed per-pixel color by the pixel's fractional
143 * coverage before the blend will give the correct final destination color. In general it
144 * will not as coverage is applied after blending.
145 */
146 bool canTweakAlphaForCoverage() const;
147
bsalomon6be6f7c2015-02-26 13:05:21 -0800148 /**
149 * This function returns true if the render target destination pixel values will be read for
150 * blending during draw.
151 */
152 bool willBlendWithDst(const GrPrimitiveProcessor*) const;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000153
bsalomon6be6f7c2015-02-26 13:05:21 -0800154 /**
155 * Installs a GrXPFactory. This object controls how src color, fractional pixel coverage,
156 * and the dst color are blended.
157 */
158 const GrXPFactory* setXPFactory(const GrXPFactory* xpFactory) {
159 fXPFactory.reset(SkRef(xpFactory));
160 return xpFactory;
161 }
162
163 /**
164 * Sets a GrXPFactory that will ignore src color and perform a set operation between the draws
165 * output coverage and the destination. This is useful to render coverage masks as CSG.
166 */
167 void setCoverageSetOpXPFactory(SkRegion::Op regionOp, bool invertCoverage = false) {
168 fXPFactory.reset(GrCoverageSetOpXPFactory::Create(regionOp, invertCoverage));
169 }
170
171 /**
172 * Sets a GrXPFactory that disables color writes to the destination. This is useful when
173 * rendering to the stencil buffer.
174 */
175 void setDisableColorXPFactory() {
176 fXPFactory.reset(GrDisableColorXPFactory::Create());
177 }
178
179 const GrXPFactory* getXPFactory() const {
180 if (!fXPFactory) {
181 fXPFactory.reset(GrPorterDuffXPFactory::Create(SkXfermode::kSrc_Mode));
182 }
183 return fXPFactory.get();
184 }
185
186 /**
187 * Checks whether the xp will need a copy of the destination to correctly blend.
188 */
189 bool willXPNeedDstCopy(const GrDrawTargetCaps& caps, const GrProcOptInfo& colorPOI,
190 const GrProcOptInfo& coveragePOI) const;
joshualittd27f73e2014-12-29 07:43:36 -0800191
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000192 /// @}
193
bsalomon6be6f7c2015-02-26 13:05:21 -0800194
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000195 ///////////////////////////////////////////////////////////////////////////
196 /// @name Render Target
197 ////
198
199 /**
egdaniel89af44a2014-09-26 06:15:04 -0700200 * Retrieves the currently set render-target.
201 *
202 * @return The currently set render target.
203 */
bsalomon37dd3312014-11-03 08:47:23 -0800204 GrRenderTarget* getRenderTarget() const { return fRenderTarget.get(); }
egdaniel89af44a2014-09-26 06:15:04 -0700205
206 /**
bsalomon@google.comca432082013-01-23 19:53:46 +0000207 * Sets the render-target used at the next drawing call
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000208 *
209 * @param target The render target to set.
210 */
bsalomonae59b772014-11-19 08:23:49 -0800211 void setRenderTarget(GrRenderTarget* target) { fRenderTarget.reset(SkSafeRef(target)); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000212
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000213 /// @}
214
215 ///////////////////////////////////////////////////////////////////////////
216 /// @name Stencil
217 ////
218
egdaniel89af44a2014-09-26 06:15:04 -0700219 const GrStencilSettings& getStencil() const { return fStencilSettings; }
220
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000221 /**
222 * Sets the stencil settings to use for the next draw.
223 * Changing the clip has the side-effect of possibly zeroing
224 * out the client settable stencil bits. So multipass algorithms
225 * using stencil should not change the clip between passes.
226 * @param settings the stencil settings to use.
227 */
bsalomon04ddf892014-11-19 12:36:22 -0800228 void setStencil(const GrStencilSettings& settings) { fStencilSettings = settings; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000229
230 /**
231 * Shortcut to disable stencil testing and ops.
232 */
bsalomon04ddf892014-11-19 12:36:22 -0800233 void disableStencil() { fStencilSettings.setDisabled(); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000234
bsalomon2ed5ef82014-07-07 08:44:05 -0700235 GrStencilSettings* stencil() { return &fStencilSettings; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000236
bsalomon6be6f7c2015-02-26 13:05:21 -0800237 /**
238 * AutoRestoreStencil
239 *
240 * This simple struct saves and restores the stencil settings
241 */
242 class AutoRestoreStencil : public ::SkNoncopyable {
243 public:
244 AutoRestoreStencil() : fPipelineBuilder(NULL) {}
245
246 AutoRestoreStencil(GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); }
247
248 ~AutoRestoreStencil() { this->set(NULL); }
249
250 void set(GrPipelineBuilder* ds) {
251 if (fPipelineBuilder) {
252 fPipelineBuilder->setStencil(fStencilSettings);
253 }
254 fPipelineBuilder = ds;
255 if (ds) {
256 fStencilSettings = ds->getStencil();
257 }
258 }
259
260 bool isSet() const { return SkToBool(fPipelineBuilder); }
261
262 private:
263 GrPipelineBuilder* fPipelineBuilder;
264 GrStencilSettings fStencilSettings;
265 };
266
267
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000268 /// @}
269
270 ///////////////////////////////////////////////////////////////////////////
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000271 /// @name State Flags
272 ////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000273
egdaniel89af44a2014-09-26 06:15:04 -0700274 /**
275 * Flags that affect rendering. Controlled using enable/disableState(). All
276 * default to disabled.
277 */
278 enum StateBits {
279 /**
280 * Perform dithering. TODO: Re-evaluate whether we need this bit
281 */
282 kDither_StateBit = 0x01,
283 /**
284 * Perform HW anti-aliasing. This means either HW FSAA, if supported by the render target,
285 * or smooth-line rendering if a line primitive is drawn and line smoothing is supported by
286 * the 3D API.
287 */
288 kHWAntialias_StateBit = 0x02,
egdaniel89af44a2014-09-26 06:15:04 -0700289
joshualitt44701df2015-02-23 14:44:57 -0800290 kLast_StateBit = kHWAntialias_StateBit,
egdaniel89af44a2014-09-26 06:15:04 -0700291 };
292
bsalomon04ddf892014-11-19 12:36:22 -0800293 bool isDither() const { return 0 != (fFlagBits & kDither_StateBit); }
294 bool isHWAntialias() const { return 0 != (fFlagBits & kHWAntialias_StateBit); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000295
296 /**
297 * Enable render state settings.
298 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000299 * @param stateBits bitfield of StateBits specifying the states to enable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000300 */
bsalomon04ddf892014-11-19 12:36:22 -0800301 void enableState(uint32_t stateBits) { fFlagBits |= stateBits; }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000302
303 /**
304 * Disable render state settings.
305 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000306 * @param stateBits bitfield of StateBits specifying the states to disable
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000307 */
bsalomon04ddf892014-11-19 12:36:22 -0800308 void disableState(uint32_t stateBits) { fFlagBits &= ~(stateBits); }
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000309
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000310 /**
311 * Enable or disable stateBits based on a boolean.
312 *
bsalomon@google.com1e269b52012-10-15 14:25:31 +0000313 * @param stateBits bitfield of StateBits to enable or disable
bsalomon@google.comd5d69ff2012-10-04 19:42:00 +0000314 * @param enable if true enable stateBits, otherwise disable
315 */
316 void setState(uint32_t stateBits, bool enable) {
317 if (enable) {
318 this->enableState(stateBits);
319 } else {
320 this->disableState(stateBits);
321 }
322 }
323
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000324 /// @}
325
326 ///////////////////////////////////////////////////////////////////////////
327 /// @name Face Culling
328 ////
329
egdaniel89af44a2014-09-26 06:15:04 -0700330 enum DrawFace {
331 kInvalid_DrawFace = -1,
332
333 kBoth_DrawFace,
334 kCCW_DrawFace,
335 kCW_DrawFace,
336 };
337
338 /**
339 * Gets whether the target is drawing clockwise, counterclockwise,
340 * or both faces.
341 * @return the current draw face(s).
342 */
343 DrawFace getDrawFace() const { return fDrawFace; }
344
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000345 /**
346 * Controls whether clockwise, counterclockwise, or both faces are drawn.
347 * @param face the face(s) to draw.
348 */
349 void setDrawFace(DrawFace face) {
tfarina@chromium.orgf6de4752013-08-17 00:02:59 +0000350 SkASSERT(kInvalid_DrawFace != face);
bsalomon2ed5ef82014-07-07 08:44:05 -0700351 fDrawFace = face;
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000352 }
353
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000354 /// @}
355
356 ///////////////////////////////////////////////////////////////////////////
tomhudson@google.com62b09682011-11-09 16:39:17 +0000357
bsalomon6be6f7c2015-02-26 13:05:21 -0800358 GrPipelineBuilder& operator=(const GrPipelineBuilder& that);
bsalomon@google.com3d0835b2011-12-08 16:12:03 +0000359
joshualitt4d8da812015-01-28 12:53:54 -0800360 // TODO delete when we have Batch
joshualitt56995b52014-12-11 15:44:02 -0800361 const GrProcOptInfo& colorProcInfo(const GrPrimitiveProcessor* pp) const {
362 this->calcColorInvariantOutput(pp);
egdaniel912b3d22014-11-17 07:45:53 -0800363 return fColorProcInfo;
364 }
365
joshualitt56995b52014-12-11 15:44:02 -0800366 const GrProcOptInfo& coverageProcInfo(const GrPrimitiveProcessor* pp) const {
367 this->calcCoverageInvariantOutput(pp);
egdaniel912b3d22014-11-17 07:45:53 -0800368 return fCoverageProcInfo;
369 }
370
joshualitt4d8da812015-01-28 12:53:54 -0800371 const GrProcOptInfo& colorProcInfo(const GrBatch* batch) const {
372 this->calcColorInvariantOutput(batch);
373 return fColorProcInfo;
374 }
375
376 const GrProcOptInfo& coverageProcInfo(const GrBatch* batch) const {
377 this->calcCoverageInvariantOutput(batch);
378 return fCoverageProcInfo;
379 }
joshualitt44701df2015-02-23 14:44:57 -0800380
381 void setClip(const GrClip& clip) { fClip = clip; }
382 const GrClip& clip() const { return fClip; }
383
egdaniele36914c2015-02-13 09:00:33 -0800384private:
385 // Calculating invariant color / coverage information is expensive, so we partially cache the
386 // results.
387 //
388 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches results but only for a
389 // specific color and coverage. May be called multiple times
390 // willBlendWithDst() - only called by Nvpr, does not cache results
391 // GrOptDrawState constructor - never caches results
joshualittd15e4e42015-01-26 13:30:10 -0800392
393 /**
joshualitt4d8da812015-01-28 12:53:54 -0800394 * Primproc variants of the calc functions
395 * TODO remove these when batch is everywhere
joshualittd5a7db42015-01-27 15:39:06 -0800396 */
joshualitt4d8da812015-01-28 12:53:54 -0800397 void calcColorInvariantOutput(const GrPrimitiveProcessor*) const;
joshualittc2893c52015-01-28 06:54:30 -0800398 void calcCoverageInvariantOutput(const GrPrimitiveProcessor*) const;
joshualittd5a7db42015-01-27 15:39:06 -0800399
400 /**
joshualitt4d8da812015-01-28 12:53:54 -0800401 * GrBatch provides the initial seed for these loops based off of its initial geometry data
402 */
403 void calcColorInvariantOutput(const GrBatch*) const;
404 void calcCoverageInvariantOutput(const GrBatch*) const;
405
406 /**
egdanielb6cbc382014-11-13 11:00:34 -0800407 * If fColorProcInfoValid is false, function calculates the invariant output for the color
bsalomon6be6f7c2015-02-26 13:05:21 -0800408 * processors and results are stored in fColorProcInfo.
egdanielb6cbc382014-11-13 11:00:34 -0800409 */
joshualitt2e3b3e32014-12-09 13:31:14 -0800410 void calcColorInvariantOutput(GrColor) const;
egdanielb6cbc382014-11-13 11:00:34 -0800411
412 /**
413 * If fCoverageProcInfoValid is false, function calculates the invariant output for the coverage
bsalomon6be6f7c2015-02-26 13:05:21 -0800414 * processors and results are stored in fCoverageProcInfo.
egdanielb6cbc382014-11-13 11:00:34 -0800415 */
joshualitt2e3b3e32014-12-09 13:31:14 -0800416 void calcCoverageInvariantOutput(GrColor) const;
egdanielb6cbc382014-11-13 11:00:34 -0800417
bsalomon@google.comeb6879f2013-06-13 19:34:18 +0000418 // Some of the auto restore objects assume that no effects are removed during their lifetime.
419 // This is used to assert that this condition holds.
commit-bot@chromium.org1acc3d72013-09-06 23:13:05 +0000420 SkDEBUGCODE(int fBlockEffectRemovalCnt;)
bsalomon@google.com8f9cbd62011-12-09 15:55:34 +0000421
joshualitta5305a12014-10-10 17:47:00 -0700422 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray;
egdaniel89af44a2014-09-26 06:15:04 -0700423
bsalomonae59b772014-11-19 08:23:49 -0800424 SkAutoTUnref<GrRenderTarget> fRenderTarget;
bsalomonae59b772014-11-19 08:23:49 -0800425 uint32_t fFlagBits;
bsalomonae59b772014-11-19 08:23:49 -0800426 GrStencilSettings fStencilSettings;
bsalomonae59b772014-11-19 08:23:49 -0800427 DrawFace fDrawFace;
joshualitt2fdeda02015-01-22 07:11:44 -0800428 mutable SkAutoTUnref<const GrXPFactory> fXPFactory;
bsalomonae59b772014-11-19 08:23:49 -0800429 FragmentStageArray fColorStages;
430 FragmentStageArray fCoverageStages;
joshualitt44701df2015-02-23 14:44:57 -0800431 GrClip fClip;
egdaniel89af44a2014-09-26 06:15:04 -0700432
egdanielb6cbc382014-11-13 11:00:34 -0800433 mutable GrProcOptInfo fColorProcInfo;
434 mutable GrProcOptInfo fCoverageProcInfo;
435 mutable bool fColorProcInfoValid;
436 mutable bool fCoverageProcInfoValid;
joshualitt2e3b3e32014-12-09 13:31:14 -0800437 mutable GrColor fColorCache;
438 mutable GrColor fCoverageCache;
egdanielb6cbc382014-11-13 11:00:34 -0800439
egdaniel8dd688b2015-01-22 10:16:09 -0800440 friend class GrPipeline;
tomhudson@google.com93813632011-10-27 20:21:16 +0000441};
442
443#endif