Index: src/gpu/GrPipelineBuilder.h |
diff --git a/src/gpu/GrPipelineBuilder.h b/src/gpu/GrPipelineBuilder.h |
index 2f78fc519862ca72f4cfbdabfabef3189868b81e..18f817ba85b5ffaa302795342f9190d129fe7469 100644 |
--- a/src/gpu/GrPipelineBuilder.h |
+++ b/src/gpu/GrPipelineBuilder.h |
@@ -14,7 +14,7 @@ |
#include "GrGpuResourceRef.h" |
#include "GrProcOptInfo.h" |
#include "GrRenderTarget.h" |
-#include "GrStencil.h" |
+#include "GrUserStencilSettings.h" |
#include "GrXferProcessor.h" |
#include "SkMatrix.h" |
#include "effects/GrCoverageSetOpXP.h" |
@@ -199,57 +199,20 @@ public: |
/// @name Stencil |
//// |
- const GrStencilSettings& getStencil() const { return fStencilSettings; } |
+ bool hasUserStencilSettings() const { |
+ return &GrUserStencilSettings::kUnused != fUserStencilSettings; |
+ } |
+ const GrUserStencilSettings* getUserStencil() const { return fUserStencilSettings; } |
/** |
- * Sets the stencil settings to use for the next draw. |
- * Changing the clip has the side-effect of possibly zeroing |
- * out the client settable stencil bits. So multipass algorithms |
- * using stencil should not change the clip between passes. |
+ * Sets the user stencil settings for the next draw. |
+ * This class only stores pointers to stencil settings objects. |
+ * The caller guarantees the pointer will remain valid until it |
+ * changes or goes out of scope. |
* @param settings the stencil settings to use. |
*/ |
- void setStencil(const GrStencilSettings& settings) { fStencilSettings = settings; } |
- |
- GrStencilSettings* stencil() { return &fStencilSettings; } |
- |
- /** |
- * AutoRestoreStencil |
- * |
- * This simple struct saves and restores the stencil settings |
- * This class can transiently modify its "const" GrPipelineBuilder object but will restore it |
- * when done - so it is notionally "const" correct. |
- */ |
- class AutoRestoreStencil : public ::SkNoncopyable { |
- public: |
- AutoRestoreStencil() : fPipelineBuilder(nullptr) {} |
- |
- AutoRestoreStencil(const GrPipelineBuilder& ds) : fPipelineBuilder(nullptr) { this->set(&ds); } |
- |
- ~AutoRestoreStencil() { this->set(nullptr); } |
- |
- void set(const GrPipelineBuilder* ds) { |
- if (fPipelineBuilder) { |
- fPipelineBuilder->setStencil(fStencilSettings); |
- } |
- fPipelineBuilder = const_cast<GrPipelineBuilder*>(ds); |
- if (ds) { |
- fStencilSettings = ds->getStencil(); |
- } |
- } |
- |
- bool isSet() const { return SkToBool(fPipelineBuilder); } |
- |
- void setStencil(const GrStencilSettings& settings) { |
- SkASSERT(this->isSet()); |
- fPipelineBuilder->setStencil(settings); |
- } |
- |
- private: |
- // notionally const (as marginalia) |
- GrPipelineBuilder* fPipelineBuilder; |
- GrStencilSettings fStencilSettings; |
- }; |
- |
+ void setUserStencil(const GrUserStencilSettings* settings) { fUserStencilSettings = settings; } |
+ void disableUserStencil() { fUserStencilSettings = &GrUserStencilSettings::kUnused; } |
/// @} |
@@ -371,7 +334,7 @@ private: |
SkAutoTUnref<GrRenderTarget> fRenderTarget; |
uint32_t fFlags; |
- GrStencilSettings fStencilSettings; |
+ const GrUserStencilSettings* fUserStencilSettings; |
DrawFace fDrawFace; |
mutable SkAutoTUnref<const GrXPFactory> fXPFactory; |
FragmentProcessorArray fColorFragmentProcessors; |