gfx/skia/trunk/include/gpu/GrDrawEffect.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/include/gpu/GrDrawEffect.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +
     1.5 +#ifndef GrDrawEffect_DEFINED
     1.6 +#define GrDrawEffect_DEFINED
     1.7 +
     1.8 +#include "GrEffectStage.h"
     1.9 +
    1.10 +/**
    1.11 + * This class is used to communicate the particular GrEffect used in a draw to the backend-specific
    1.12 + * effect subclass (e.g. GrGLEffect). It is used to by the backend-specific class to generate a
    1.13 + * cache key for the effect, generate code on a program cache miss, and to upload uniform values to
    1.14 + * the program.
    1.15 + * In addition to the effect, it also communicates any changes between the relationship between
    1.16 + * the view matrix and local coordinate system since the effect was installed in its GrDrawState.
    1.17 + * The typical use case is that sometime after an effect was installed a decision was made to draw
    1.18 + * in device coordinates (i.e. use an identity view-matrix). In such a case the GrDrawEffect's
    1.19 + * coord-change-matrix would be the inverse of the view matrix that was set when the effect was
    1.20 + * installed.
    1.21 + */
    1.22 +class GrDrawEffect {
    1.23 +public:
    1.24 +    GrDrawEffect(const GrEffectStage& stage, bool explicitLocalCoords)
    1.25 +        : fEffectStage(&stage)
    1.26 +        , fExplicitLocalCoords(explicitLocalCoords) {
    1.27 +        SkASSERT(NULL != fEffectStage);
    1.28 +        SkASSERT(NULL != fEffectStage->getEffect());
    1.29 +    }
    1.30 +    const GrEffectRef* effect() const { return fEffectStage->getEffect(); }
    1.31 +
    1.32 +    template <typename T>
    1.33 +    const T& castEffect() const { return *static_cast<const T*>(this->effect()->get()); }
    1.34 +
    1.35 +    const SkMatrix& getCoordChangeMatrix() const {
    1.36 +        if (fExplicitLocalCoords) {
    1.37 +            return SkMatrix::I();
    1.38 +        } else {
    1.39 +            return fEffectStage->getCoordChangeMatrix();
    1.40 +        }
    1.41 +    }
    1.42 +
    1.43 +    bool programHasExplicitLocalCoords() const { return fExplicitLocalCoords; }
    1.44 +
    1.45 +    const int* getVertexAttribIndices() const { return fEffectStage->getVertexAttribIndices(); }
    1.46 +    int getVertexAttribIndexCount() const { return fEffectStage->getVertexAttribIndexCount(); }
    1.47 +
    1.48 +private:
    1.49 +    const GrEffectStage*    fEffectStage;
    1.50 +    bool                    fExplicitLocalCoords;
    1.51 +};
    1.52 +
    1.53 +#endif

mercurial