OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef GrPipelineBuilder_DEFINED | 8 #ifndef GrPipelineBuilder_DEFINED |
9 #define GrPipelineBuilder_DEFINED | 9 #define GrPipelineBuilder_DEFINED |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
103 void addCoverageTextureProcessor(GrTexture* texture, | 103 void addCoverageTextureProcessor(GrTexture* texture, |
104 const SkMatrix& matrix, | 104 const SkMatrix& matrix, |
105 const GrTextureParams& params) { | 105 const GrTextureParams& params) { |
106 this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManage r, texture, matrix, | 106 this->addCoverageProcessor(GrSimpleTextureEffect::Create(fProcDataManage r, texture, matrix, |
107 params))->unref (); | 107 params))->unref (); |
108 } | 108 } |
109 | 109 |
110 /** | 110 /** |
111 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder | 111 * When this object is destroyed it will remove any color/coverage FPs from the pipeline builder |
112 * that were added after its constructor. | 112 * that were added after its constructor. |
113 */ | 113 */ |
robertphillips
2015/07/10 17:25:45
// This class can transiently modify its "const" G
| |
114 class AutoRestoreFragmentProcessors : public ::SkNoncopyable { | 114 class AutoRestoreFragmentProcessors : public ::SkNoncopyable { |
115 public: | 115 public: |
116 AutoRestoreFragmentProcessors() | 116 AutoRestoreFragmentProcessors() |
117 : fPipelineBuilder(NULL) | 117 : fPipelineBuilder(NULL) |
118 , fColorEffectCnt(0) | 118 , fColorEffectCnt(0) |
119 , fCoverageEffectCnt(0) {} | 119 , fCoverageEffectCnt(0) {} |
120 | 120 |
robertphillips
2015/07/10 17:25:45
Should this be const in solidarity ?
| |
121 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds) | 121 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds) |
122 : fPipelineBuilder(NULL) | 122 : fPipelineBuilder(NULL) |
123 , fColorEffectCnt(0) | 123 , fColorEffectCnt(0) |
124 , fCoverageEffectCnt(0) { | 124 , fCoverageEffectCnt(0) { |
125 this->set(ds); | 125 this->set(ds); |
126 } | 126 } |
127 | 127 |
128 ~AutoRestoreFragmentProcessors() { this->set(NULL); } | 128 ~AutoRestoreFragmentProcessors() { this->set(NULL); } |
129 | 129 |
130 void set(GrPipelineBuilder* ds); | 130 void set(const GrPipelineBuilder* ds); |
131 | 131 |
132 bool isSet() const { return SkToBool(fPipelineBuilder); } | 132 bool isSet() const { return SkToBool(fPipelineBuilder); } |
133 | 133 |
134 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) { | |
135 SkASSERT(this->isSet()); | |
136 return fPipelineBuilder->addCoverageProcessor(processor); | |
137 } | |
138 | |
134 private: | 139 private: |
robertphillips
2015/07/10 17:25:44
// notionally const (as marginalia)
?
| |
135 GrPipelineBuilder* fPipelineBuilder; | 140 GrPipelineBuilder* fPipelineBuilder; |
136 int fColorEffectCnt; | 141 int fColorEffectCnt; |
137 int fCoverageEffectCnt; | 142 int fCoverageEffectCnt; |
138 }; | 143 }; |
139 | 144 |
140 /// @} | 145 /// @} |
141 | 146 |
142 /////////////////////////////////////////////////////////////////////////// | 147 /////////////////////////////////////////////////////////////////////////// |
143 /// @name Blending | 148 /// @name Blending |
144 //// | 149 //// |
145 | 150 |
146 /** | 151 /** |
147 * Returns true if this pipeline's color output will be affected by the exis ting render target | 152 * Returns true if this pipeline's color output will be affected by the exis ting render target |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
239 * Shortcut to disable stencil testing and ops. | 244 * Shortcut to disable stencil testing and ops. |
240 */ | 245 */ |
241 void disableStencil() { fStencilSettings.setDisabled(); } | 246 void disableStencil() { fStencilSettings.setDisabled(); } |
242 | 247 |
243 GrStencilSettings* stencil() { return &fStencilSettings; } | 248 GrStencilSettings* stencil() { return &fStencilSettings; } |
244 | 249 |
245 /** | 250 /** |
246 * AutoRestoreStencil | 251 * AutoRestoreStencil |
247 * | 252 * |
248 * This simple struct saves and restores the stencil settings | 253 * This simple struct saves and restores the stencil settings |
249 */ | 254 */ |
robertphillips
2015/07/10 17:25:45
// This class can transiently modify its "const" G
| |
250 class AutoRestoreStencil : public ::SkNoncopyable { | 255 class AutoRestoreStencil : public ::SkNoncopyable { |
251 public: | 256 public: |
252 AutoRestoreStencil() : fPipelineBuilder(NULL) {} | 257 AutoRestoreStencil() : fPipelineBuilder(NULL) {} |
253 | 258 |
254 AutoRestoreStencil(GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { thi s->set(ds); } | 259 AutoRestoreStencil(const GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); } |
255 | 260 |
256 ~AutoRestoreStencil() { this->set(NULL); } | 261 ~AutoRestoreStencil() { this->set(NULL); } |
257 | 262 |
258 void set(GrPipelineBuilder* ds) { | 263 void set(const GrPipelineBuilder* ds) { |
259 if (fPipelineBuilder) { | 264 if (fPipelineBuilder) { |
260 fPipelineBuilder->setStencil(fStencilSettings); | 265 fPipelineBuilder->setStencil(fStencilSettings); |
261 } | 266 } |
262 fPipelineBuilder = ds; | 267 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
263 if (ds) { | 268 if (ds) { |
264 fStencilSettings = ds->getStencil(); | 269 fStencilSettings = ds->getStencil(); |
265 } | 270 } |
266 } | 271 } |
267 | 272 |
268 bool isSet() const { return SkToBool(fPipelineBuilder); } | 273 bool isSet() const { return SkToBool(fPipelineBuilder); } |
269 | 274 |
275 void setStencil(const GrStencilSettings& settings) { | |
276 SkASSERT(this->isSet()); | |
277 fPipelineBuilder->setStencil(settings); | |
278 } | |
279 | |
270 private: | 280 private: |
robertphillips
2015/07/10 17:25:45
// notionally const (as marginalia)
?
| |
271 GrPipelineBuilder* fPipelineBuilder; | 281 GrPipelineBuilder* fPipelineBuilder; |
272 GrStencilSettings fStencilSettings; | 282 GrStencilSettings fStencilSettings; |
273 }; | 283 }; |
274 | 284 |
275 | 285 |
276 /// @} | 286 /// @} |
277 | 287 |
278 /////////////////////////////////////////////////////////////////////////// | 288 /////////////////////////////////////////////////////////////////////////// |
279 /// @name State Flags | 289 /// @name State Flags |
280 //// | 290 //// |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 this->calcCoverageInvariantOutput(batch); | 402 this->calcCoverageInvariantOutput(batch); |
393 return fCoverageProcInfo; | 403 return fCoverageProcInfo; |
394 } | 404 } |
395 | 405 |
396 void setClip(const GrClip& clip) { fClip = clip; } | 406 void setClip(const GrClip& clip) { fClip = clip; } |
397 const GrClip& clip() const { return fClip; } | 407 const GrClip& clip() const { return fClip; } |
398 | 408 |
399 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } | 409 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } |
400 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } | 410 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } |
401 | 411 |
412 /** | |
413 * When this object is destroyed it will remove any additions to the GrProce ssorDataManager | |
414 * owned by the GrPipelineBuilder | |
robertphillips
2015/07/10 17:25:44
// This class can transiently modify its "const" G
| |
415 */ | |
416 class AutoRestoreProcessorDataManager : public ::SkNoncopyable { | |
417 public: | |
418 AutoRestoreProcessorDataManager() : fPipelineBuilder(NULL), fSaveMarker( 0) {} | |
419 | |
robertphillips
2015/07/10 17:25:45
const here ?
| |
420 AutoRestoreProcessorDataManager(GrPipelineBuilder* ds) | |
421 : fPipelineBuilder(NULL) | |
422 , fSaveMarker(0) { | |
423 this->set(ds); | |
424 } | |
425 | |
426 ~AutoRestoreProcessorDataManager() { this->set(NULL); } | |
427 | |
428 void set(const GrPipelineBuilder* ds) { | |
429 if (fPipelineBuilder) { | |
430 fPipelineBuilder->getProcessorDataManager()->restoreSaveMarker(f SaveMarker); | |
431 } | |
432 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); | |
433 if (ds) { | |
434 fSaveMarker = ds->processorDataManager()->currentSaveMarker(); | |
435 } | |
436 } | |
437 | |
438 bool isSet() const { return SkToBool(fPipelineBuilder); } | |
439 | |
440 GrProcessorDataManager* getProcessorDataManager() { | |
441 SkASSERT(this->isSet()); | |
442 return fPipelineBuilder->getProcessorDataManager(); | |
443 } | |
444 | |
445 private: | |
robertphillips
2015/07/10 17:25:44
// notionally const (as marginalia)
?
| |
446 GrPipelineBuilder* fPipelineBuilder; | |
robertphillips
2015/07/10 17:25:44
line this guy up ?
| |
447 uint32_t fSaveMarker; | |
448 }; | |
449 | |
450 | |
402 private: | 451 private: |
403 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the | 452 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the |
404 // results. | 453 // results. |
405 // | 454 // |
406 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a | 455 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a |
407 // specific color and coverage. May be calle d multiple times | 456 // specific color and coverage. May be calle d multiple times |
408 // willColorBlendWithDst() - only called by Nvpr, does not cache results | 457 // willColorBlendWithDst() - only called by Nvpr, does not cache results |
409 // GrOptDrawState constructor - never caches results | 458 // GrOptDrawState constructor - never caches results |
410 | 459 |
411 /** | 460 /** |
(...skipping 16 matching lines...) Expand all Loading... | |
428 void calcColorInvariantOutput(GrColor) const; | 477 void calcColorInvariantOutput(GrColor) const; |
429 | 478 |
430 /** | 479 /** |
431 * If fCoverageProcInfoValid is false, function calculates the invariant out put for the coverage | 480 * If fCoverageProcInfoValid is false, function calculates the invariant out put for the coverage |
432 * processors and results are stored in fCoverageProcInfo. | 481 * processors and results are stored in fCoverageProcInfo. |
433 */ | 482 */ |
434 void calcCoverageInvariantOutput(GrColor) const; | 483 void calcCoverageInvariantOutput(GrColor) const; |
435 | 484 |
436 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. | 485 // Some of the auto restore objects assume that no effects are removed durin g their lifetime. |
437 // This is used to assert that this condition holds. | 486 // This is used to assert that this condition holds. |
438 SkDEBUGCODE(int fBlockEffectRemovalCnt;) | 487 SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) |
439 | 488 |
440 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; | 489 typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; |
441 | 490 |
442 SkAutoTUnref<GrProcessorDataManager> fProcDataManager; | 491 SkAutoTUnref<GrProcessorDataManager> fProcDataManager; |
443 SkAutoTUnref<GrRenderTarget> fRenderTarget; | 492 SkAutoTUnref<GrRenderTarget> fRenderTarget; |
444 uint32_t fFlags; | 493 uint32_t fFlags; |
445 GrStencilSettings fStencilSettings; | 494 GrStencilSettings fStencilSettings; |
446 DrawFace fDrawFace; | 495 DrawFace fDrawFace; |
447 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; | 496 mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
448 FragmentStageArray fColorStages; | 497 FragmentStageArray fColorStages; |
449 FragmentStageArray fCoverageStages; | 498 FragmentStageArray fCoverageStages; |
450 GrClip fClip; | 499 GrClip fClip; |
451 | 500 |
452 mutable GrProcOptInfo fColorProcInfo; | 501 mutable GrProcOptInfo fColorProcInfo; |
453 mutable GrProcOptInfo fCoverageProcInfo; | 502 mutable GrProcOptInfo fCoverageProcInfo; |
454 mutable bool fColorProcInfoValid; | 503 mutable bool fColorProcInfoValid; |
455 mutable bool fCoverageProcInfoValid; | 504 mutable bool fCoverageProcInfoValid; |
456 mutable GrColor fColorCache; | 505 mutable GrColor fColorCache; |
457 mutable GrColor fCoverageCache; | 506 mutable GrColor fCoverageCache; |
458 | 507 |
459 friend class GrPipeline; | 508 friend class GrPipeline; |
460 }; | 509 }; |
461 | 510 |
462 #endif | 511 #endif |
OLD | NEW |