Chromium Code Reviews| Index: src/gpu/GrPipelineBuilder.h |
| diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h |
| index 725b4fd290ba4bf44c54e60986979d0a87cdb153..bb687fadec208f79b0afddfc8fc6602c9000c6b0 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: |
|
robertphillips
2015/07/10 17:25:44
// notionally const (as marginalia)
?
|
| 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: |
|
robertphillips
2015/07/10 17:25:45
// notionally const (as marginalia)
?
|
| GrPipelineBuilder* fPipelineBuilder; |
| GrStencilSettings fStencilSettings; |
| @@ -399,6 +409,45 @@ 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 |
|
robertphillips
2015/07/10 17:25:44
// This class can transiently modify its "const" G
|
| + */ |
| + class AutoRestoreProcessorDataManager : public ::SkNoncopyable { |
| + public: |
| + AutoRestoreProcessorDataManager() : fPipelineBuilder(NULL), fSaveMarker(0) {} |
| + |
|
robertphillips
2015/07/10 17:25:45
const here ?
|
| + AutoRestoreProcessorDataManager(GrPipelineBuilder* ds) |
| + : fPipelineBuilder(NULL) |
| + , fSaveMarker(0) { |
| + this->set(ds); |
| + } |
| + |
| + ~AutoRestoreProcessorDataManager() { this->set(NULL); } |
| + |
| + void set(const GrPipelineBuilder* ds) { |
| + if (fPipelineBuilder) { |
| + fPipelineBuilder->getProcessorDataManager()->restoreSaveMarker(fSaveMarker); |
| + } |
| + fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
| + if (ds) { |
| + fSaveMarker = ds->processorDataManager()->currentSaveMarker(); |
| + } |
| + } |
| + |
| + bool isSet() const { return SkToBool(fPipelineBuilder); } |
| + |
| + GrProcessorDataManager* getProcessorDataManager() { |
| + SkASSERT(this->isSet()); |
| + return fPipelineBuilder->getProcessorDataManager(); |
| + } |
| + |
| + private: |
|
robertphillips
2015/07/10 17:25:44
// notionally const (as marginalia)
?
|
| + GrPipelineBuilder* fPipelineBuilder; |
|
robertphillips
2015/07/10 17:25:44
line this guy up ?
|
| + uint32_t fSaveMarker; |
| + }; |
| + |
| + |
| private: |
| // Calculating invariant color / coverage information is expensive, so we partially cache the |
| // results. |
| @@ -435,7 +484,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; |