Chromium Code Reviews| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 102 | 102 |
| 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. |
|
robertphillips
2015/07/13 16:16:09
... and remove any additions to the GrProcessorDat
| |
| 113 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it | 113 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it |
| 114 * when done - so it is notionally "const" correct. | 114 * when done - so it is notionally "const" correct. |
| 115 */ | 115 */ |
| 116 class AutoRestoreFragmentProcessors : public ::SkNoncopyable { | 116 class AutoRestoreFragmentProcessorState : public ::SkNoncopyable { |
| 117 public: | 117 public: |
| 118 AutoRestoreFragmentProcessors() | 118 AutoRestoreFragmentProcessorState() |
| 119 : fPipelineBuilder(NULL) | 119 : fPipelineBuilder(NULL) |
| 120 , fColorEffectCnt(0) | 120 , fColorEffectCnt(0) |
| 121 , fCoverageEffectCnt(0) {} | 121 , fCoverageEffectCnt(0) |
| 122 , fSaveMarker(0) {} | |
| 122 | 123 |
| 123 AutoRestoreFragmentProcessors(GrPipelineBuilder* ds) | 124 AutoRestoreFragmentProcessorState(const GrPipelineBuilder& ds) |
| 124 : fPipelineBuilder(NULL) | 125 : fPipelineBuilder(NULL) |
| 125 , fColorEffectCnt(0) | 126 , fColorEffectCnt(0) |
| 126 , fCoverageEffectCnt(0) { | 127 , fCoverageEffectCnt(0) |
| 127 this->set(ds); | 128 , fSaveMarker(0) { |
| 129 this->set(&ds); | |
| 128 } | 130 } |
| 129 | 131 |
| 130 ~AutoRestoreFragmentProcessors() { this->set(NULL); } | 132 ~AutoRestoreFragmentProcessorState() { this->set(NULL); } |
| 131 | 133 |
| 132 void set(const GrPipelineBuilder* ds); | 134 void set(const GrPipelineBuilder* ds); |
| 133 | 135 |
| 134 bool isSet() const { return SkToBool(fPipelineBuilder); } | 136 bool isSet() const { return SkToBool(fPipelineBuilder); } |
| 135 | 137 |
| 138 GrProcessorDataManager* getProcessorDataManager() { | |
| 139 SkASSERT(this->isSet()); | |
| 140 return fPipelineBuilder->getProcessorDataManager(); | |
| 141 } | |
| 142 | |
| 136 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) { | 143 const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcesso r* processor) { |
| 137 SkASSERT(this->isSet()); | 144 SkASSERT(this->isSet()); |
| 138 return fPipelineBuilder->addCoverageProcessor(processor); | 145 return fPipelineBuilder->addCoverageProcessor(processor); |
| 139 } | 146 } |
| 140 | 147 |
| 141 private: | 148 private: |
| 142 // notionally const (as marginalia) | 149 // notionally const (as marginalia) |
| 143 GrPipelineBuilder* fPipelineBuilder; | 150 GrPipelineBuilder* fPipelineBuilder; |
| 144 int fColorEffectCnt; | 151 int fColorEffectCnt; |
| 145 int fCoverageEffectCnt; | 152 int fCoverageEffectCnt; |
| 153 uint32_t fSaveMarker; | |
| 146 }; | 154 }; |
| 147 | 155 |
| 148 /// @} | 156 /// @} |
| 149 | 157 |
| 150 /////////////////////////////////////////////////////////////////////////// | 158 /////////////////////////////////////////////////////////////////////////// |
| 151 /// @name Blending | 159 /// @name Blending |
| 152 //// | 160 //// |
| 153 | 161 |
| 154 /** | 162 /** |
| 155 * Returns true if this pipeline's color output will be affected by the exis ting render target | 163 * Returns true if this pipeline's color output will be affected by the exis ting render target |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 * AutoRestoreStencil | 262 * AutoRestoreStencil |
| 255 * | 263 * |
| 256 * This simple struct saves and restores the stencil settings | 264 * This simple struct saves and restores the stencil settings |
| 257 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it | 265 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it |
| 258 * when done - so it is notionally "const" correct. | 266 * when done - so it is notionally "const" correct. |
| 259 */ | 267 */ |
| 260 class AutoRestoreStencil : public ::SkNoncopyable { | 268 class AutoRestoreStencil : public ::SkNoncopyable { |
| 261 public: | 269 public: |
| 262 AutoRestoreStencil() : fPipelineBuilder(NULL) {} | 270 AutoRestoreStencil() : fPipelineBuilder(NULL) {} |
| 263 | 271 |
| 264 AutoRestoreStencil(const GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); } | 272 AutoRestoreStencil(const GrPipelineBuilder& ds) : fPipelineBuilder(NULL) { this->set(&ds); } |
| 265 | 273 |
| 266 ~AutoRestoreStencil() { this->set(NULL); } | 274 ~AutoRestoreStencil() { this->set(NULL); } |
| 267 | 275 |
| 268 void set(const GrPipelineBuilder* ds) { | 276 void set(const GrPipelineBuilder* ds) { |
| 269 if (fPipelineBuilder) { | 277 if (fPipelineBuilder) { |
| 270 fPipelineBuilder->setStencil(fStencilSettings); | 278 fPipelineBuilder->setStencil(fStencilSettings); |
| 271 } | 279 } |
| 272 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); | 280 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
| 273 if (ds) { | 281 if (ds) { |
| 274 fStencilSettings = ds->getStencil(); | 282 fStencilSettings = ds->getStencil(); |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 408 this->calcCoverageInvariantOutput(batch); | 416 this->calcCoverageInvariantOutput(batch); |
| 409 return fCoverageProcInfo; | 417 return fCoverageProcInfo; |
| 410 } | 418 } |
| 411 | 419 |
| 412 void setClip(const GrClip& clip) { fClip = clip; } | 420 void setClip(const GrClip& clip) { fClip = clip; } |
| 413 const GrClip& clip() const { return fClip; } | 421 const GrClip& clip() const { return fClip; } |
| 414 | 422 |
| 415 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } | 423 GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager. get(); } |
| 416 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } | 424 const GrProcessorDataManager* processorDataManager() const { return fProcDat aManager.get(); } |
| 417 | 425 |
| 418 /** | |
| 419 * When this object is destroyed it will remove any additions to the GrProce ssorDataManager | |
| 420 * owned by the GrPipelineBuilder | |
| 421 * This class can transiently modify its "const" GrPipelineBuilder object bu t will restore it | |
| 422 * when done - so it is notionally "const" correct. | |
| 423 */ | |
| 424 class AutoRestoreProcessorDataManager : public ::SkNoncopyable { | |
| 425 public: | |
| 426 AutoRestoreProcessorDataManager() : fPipelineBuilder(NULL), fSaveMarker( 0) {} | |
| 427 | |
| 428 AutoRestoreProcessorDataManager(GrPipelineBuilder* ds) | |
| 429 : fPipelineBuilder(NULL) | |
| 430 , fSaveMarker(0) { | |
| 431 this->set(ds); | |
| 432 } | |
| 433 | |
| 434 ~AutoRestoreProcessorDataManager() { this->set(NULL); } | |
| 435 | |
| 436 void set(const GrPipelineBuilder* ds) { | |
| 437 if (fPipelineBuilder) { | |
| 438 fPipelineBuilder->getProcessorDataManager()->restoreToSaveMarker (/*fSaveMarker*/); | |
| 439 } | |
| 440 fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); | |
| 441 if (ds) { | |
| 442 fSaveMarker = ds->processorDataManager()->currentSaveMarker(); | |
| 443 } | |
| 444 } | |
| 445 | |
| 446 bool isSet() const { return SkToBool(fPipelineBuilder); } | |
| 447 | |
| 448 GrProcessorDataManager* getProcessorDataManager() { | |
| 449 SkASSERT(this->isSet()); | |
| 450 return fPipelineBuilder->getProcessorDataManager(); | |
| 451 } | |
| 452 | |
| 453 private: | |
| 454 // notionally const (as marginalia) | |
| 455 GrPipelineBuilder* fPipelineBuilder; | |
| 456 uint32_t fSaveMarker; | |
| 457 }; | |
| 458 | |
| 459 | |
| 460 private: | 426 private: |
| 461 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the | 427 // Calculating invariant color / coverage information is expensive, so we pa rtially cache the |
| 462 // results. | 428 // results. |
| 463 // | 429 // |
| 464 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a | 430 // canUseFracCoveragePrimProc() - Called in regular skia draw, caches result s but only for a |
| 465 // specific color and coverage. May be calle d multiple times | 431 // specific color and coverage. May be calle d multiple times |
| 466 // willColorBlendWithDst() - only called by Nvpr, does not cache results | 432 // willColorBlendWithDst() - only called by Nvpr, does not cache results |
| 467 // GrOptDrawState constructor - never caches results | 433 // GrOptDrawState constructor - never caches results |
| 468 | 434 |
| 469 /** | 435 /** |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 511 mutable GrProcOptInfo fCoverageProcInfo; | 477 mutable GrProcOptInfo fCoverageProcInfo; |
| 512 mutable bool fColorProcInfoValid; | 478 mutable bool fColorProcInfoValid; |
| 513 mutable bool fCoverageProcInfoValid; | 479 mutable bool fCoverageProcInfoValid; |
| 514 mutable GrColor fColorCache; | 480 mutable GrColor fColorCache; |
| 515 mutable GrColor fCoverageCache; | 481 mutable GrColor fCoverageCache; |
| 516 | 482 |
| 517 friend class GrPipeline; | 483 friend class GrPipeline; |
| 518 }; | 484 }; |
| 519 | 485 |
| 520 #endif | 486 #endif |
| OLD | NEW |