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

Unified Diff: include/gpu/GrDrawEffect.h

Issue 577593003: Revert of removing GrDrawEffect (Closed) Base URL: https://skia.googlesource.com/skia.git@gp3
Patch Set: Created 6 years, 3 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 | « include/gpu/GrBackendEffectFactory.h ('k') | include/gpu/GrEffect.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/gpu/GrDrawEffect.h
diff --git a/include/gpu/GrDrawEffect.h b/include/gpu/GrDrawEffect.h
new file mode 100644
index 0000000000000000000000000000000000000000..710b00035ff8757b5367e78579ff523811d277a5
--- /dev/null
+++ b/include/gpu/GrDrawEffect.h
@@ -0,0 +1,47 @@
+
+#ifndef GrDrawEffect_DEFINED
+#define GrDrawEffect_DEFINED
+
+#include "GrEffectStage.h"
+
+/**
+ * This class is used to communicate the particular GrEffect used in a draw to the backend-specific
+ * effect subclass (e.g. GrGLEffect). It is used to by the backend-specific class to generate a
+ * cache key for the effect, generate code on a program cache miss, and to upload uniform values to
+ * the program.
+ * In addition to the effect, it also communicates any changes between the relationship between
+ * the view matrix and local coordinate system since the effect was installed in its GrDrawState.
+ * The typical use case is that sometime after an effect was installed a decision was made to draw
+ * in device coordinates (i.e. use an identity view-matrix). In such a case the GrDrawEffect's
+ * coord-change-matrix would be the inverse of the view matrix that was set when the effect was
+ * installed.
+ */
+class GrDrawEffect {
+public:
+ GrDrawEffect(const GrEffectStage& stage, bool explicitLocalCoords)
+ : fEffectStage(&stage)
+ , fExplicitLocalCoords(explicitLocalCoords) {
+ SkASSERT(fEffectStage);
+ SkASSERT(fEffectStage->getEffect());
+ }
+ const GrEffect* effect() const { return fEffectStage->getEffect(); }
+
+ template <typename T>
+ const T& castEffect() const { return *static_cast<const T*>(this->effect()); }
+
+ const SkMatrix& getCoordChangeMatrix() const {
+ if (fExplicitLocalCoords) {
+ return SkMatrix::I();
+ } else {
+ return fEffectStage->getCoordChangeMatrix();
+ }
+ }
+
+ bool programHasExplicitLocalCoords() const { return fExplicitLocalCoords; }
+
+private:
+ const GrEffectStage* fEffectStage;
+ bool fExplicitLocalCoords;
+};
+
+#endif
« no previous file with comments | « include/gpu/GrBackendEffectFactory.h ('k') | include/gpu/GrEffect.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698