Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(272)

Unified Diff: src/gpu/GrPipelineBuilder.h

Issue 1962243002: Separate user and raw stencil settings (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrPipeline.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « src/gpu/GrPipeline.cpp ('k') | src/gpu/GrPipelineBuilder.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698