diff options
author | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-20 19:19:53 +0000 |
---|---|---|
committer | bsalomon@google.com <bsalomon@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2013-03-20 19:19:53 +0000 |
commit | c78188896e28a4ae49e406a7422b345ae177dafe (patch) | |
tree | 8345c0828c94fc81cd4c54a0fe7778e5b159394d /include/gpu/GrDrawEffect.h | |
parent | b8210f20ce3da43f55b773a2fad3f2244d3ba74d (diff) |
Attempt to reland 8264-5 with warning-as-error fixes.
git-svn-id: http://skia.googlecode.com/svn/trunk@8272 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'include/gpu/GrDrawEffect.h')
-rw-r--r-- | include/gpu/GrDrawEffect.h | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/include/gpu/GrDrawEffect.h b/include/gpu/GrDrawEffect.h new file mode 100644 index 0000000000..005de417ee --- /dev/null +++ b/include/gpu/GrDrawEffect.h @@ -0,0 +1,51 @@ + +#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. GrGLEffectMatrix is a handy class that implements a local coordinate matrix that + * automatically accounts for the coord-change matrix. + */ +class GrDrawEffect { +public: + GrDrawEffect(const GrEffectStage& stage, bool explicitLocalCoords) + : fEffectStage(&stage) + , fExplicitLocalCoords(explicitLocalCoords) { + GrAssert(NULL != fEffectStage); + GrAssert(NULL != fEffectStage->getEffect()); + } + const GrEffectRef* effect() const { return fEffectStage->getEffect(); } + + template <typename T> + const T& castEffect() const { return *static_cast<const T*>(this->effect()->get()); } + + const SkMatrix& getCoordChangeMatrix() const { + if (fExplicitLocalCoords) { + return SkMatrix::I(); + } else { + return fEffectStage->getCoordChangeMatrix(); + } + } + + bool programHasExplicitLocalCoords() const { return fExplicitLocalCoords; } + + const int* getVertexAttribIndices() const { return fEffectStage->getVertexAttribIndices(); } + int getVertexAttribIndexCount() const { return fEffectStage->getVertexAttribIndexCount(); } + +private: + const GrEffectStage* fEffectStage; + bool fExplicitLocalCoords; +}; + +#endif |