Chromium Code Reviews| Index: src/gpu/GrPipelineBuilder.h |
| diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h |
| index af98c3676f13d1374c76e46000b54db7b44dc111..aa0d376468ebc8d752ffb4cb64b7bc9d2b7e31e4 100644 |
| --- a/src/gpu/GrPipelineBuilder.h |
| +++ b/src/gpu/GrPipelineBuilder.h |
| @@ -127,14 +127,19 @@ public: |
| ~AutoRestoreFragmentProcessors() { this->set(NULL); } |
| - void set(GrPipelineBuilder* ds); |
| + void set(const GrPipelineBuilder* ds); |
| bool isSet() const { return SkToBool(fPipelineBuilder); } |
| + const GrFragmentProcessor* addCoverageProcessor(const GrFragmentProcessor* processor) { |
| + SkASSERT(this->isSet()); |
| + return fPipelineBuilder->addCoverageProcessor(processor); |
| + } |
| + |
| private: |
| GrPipelineBuilder* fPipelineBuilder; |
| - int fColorEffectCnt; |
| - int fCoverageEffectCnt; |
| + int fColorEffectCnt; |
| + int fCoverageEffectCnt; |
| }; |
| /// @} |
| @@ -251,15 +256,15 @@ public: |
| public: |
| AutoRestoreStencil() : fPipelineBuilder(NULL) {} |
| - AutoRestoreStencil(GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); } |
| + AutoRestoreStencil(const GrPipelineBuilder* ds) : fPipelineBuilder(NULL) { this->set(ds); } |
| ~AutoRestoreStencil() { this->set(NULL); } |
| - void set(GrPipelineBuilder* ds) { |
| + void set(const GrPipelineBuilder* ds) { |
| if (fPipelineBuilder) { |
| fPipelineBuilder->setStencil(fStencilSettings); |
| } |
| - fPipelineBuilder = ds; |
| + fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
| if (ds) { |
| fStencilSettings = ds->getStencil(); |
| } |
| @@ -267,6 +272,11 @@ public: |
| bool isSet() const { return SkToBool(fPipelineBuilder); } |
| + void setStencil(const GrStencilSettings& settings) { |
| + SkASSERT(this->isSet()); |
| + fPipelineBuilder->setStencil(settings); |
| + } |
| + |
| private: |
| GrPipelineBuilder* fPipelineBuilder; |
| GrStencilSettings fStencilSettings; |
| @@ -399,6 +409,48 @@ public: |
| GrProcessorDataManager* getProcessorDataManager() { return fProcDataManager.get(); } |
| const GrProcessorDataManager* processorDataManager() const { return fProcDataManager.get(); } |
| + /** |
| + * When this object is destroyed it will remove any additions to the GrProcessorDataManager |
| + * owned by the GrPipelineBuilder |
| + */ |
| + class AutoRestoreProcessorDataManager : public ::SkNoncopyable { |
| + public: |
|
robertphillips
2015/07/10 14:34:10
Will this entire ctor fit on one line ?
|
| + AutoRestoreProcessorDataManager() |
| + : fPipelineBuilder(NULL) |
| + , fStackHeight(0) { |
| + } |
| + |
| + AutoRestoreProcessorDataManager(GrPipelineBuilder* ds) |
| + : fPipelineBuilder(NULL) |
| + , fStackHeight(0) { |
| + this->set(ds); |
| + } |
| + |
| + ~AutoRestoreProcessorDataManager() { this->set(NULL); } |
| + |
| + void set(const GrPipelineBuilder* ds) { |
| + if (fPipelineBuilder) { |
| + fPipelineBuilder->getProcessorDataManager()->restoreHeight(fStackHeight); |
| + } |
| + fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
| + if (ds) { |
|
robertphillips
2015/07/10 14:34:09
currentHeight -> numDataFrames, dataPlaceHolder, r
|
| + fStackHeight = ds->processorDataManager()->currentHeight(); |
| + } |
| + } |
| + |
| + bool isSet() const { return SkToBool(fPipelineBuilder); } |
| + |
| + GrProcessorDataManager* getProcessorDataManager() { |
| + SkASSERT(this->isSet()); |
| + return fPipelineBuilder->getProcessorDataManager(); |
| + } |
| + |
| + private: |
| + GrPipelineBuilder* fPipelineBuilder; |
| + uint32_t fStackHeight; |
| + }; |
| + |
| + |
| private: |
| // Calculating invariant color / coverage information is expensive, so we partially cache the |
| // results. |
| @@ -435,7 +487,7 @@ private: |
| // Some of the auto restore objects assume that no effects are removed during their lifetime. |
| // This is used to assert that this condition holds. |
| - SkDEBUGCODE(int fBlockEffectRemovalCnt;) |
| + SkDEBUGCODE(mutable int fBlockEffectRemovalCnt;) |
| typedef SkSTArray<4, GrFragmentStage> FragmentStageArray; |