removing GrDrawEffect
BUG=skia: R=bsalomon@google.com Author: joshualitt@chromium.org Review URL: https://codereview.chromium.org/571163002
This commit is contained in:
parent
ee6206572b
commit
8ddbe8b936
@ -16,7 +16,7 @@
|
||||
|
||||
class GrGLEffect;
|
||||
class GrGLCaps;
|
||||
class GrDrawEffect;
|
||||
class GrEffect;
|
||||
|
||||
/**
|
||||
* Used by effects to build their keys. It incorporates each per-effect key into a larger shader key.
|
||||
@ -96,13 +96,13 @@ public:
|
||||
* configuration that affect GLSL code generation. Two GrEffect instances that would cause
|
||||
* this->createGLInstance()->emitCode() to produce different code must produce different keys.
|
||||
*/
|
||||
virtual void getGLEffectKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0;
|
||||
virtual void getGLEffectKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) const = 0;
|
||||
|
||||
/**
|
||||
* Creates a GrGLEffect instance that is used both to generate code for the GrEffect in a GLSL
|
||||
* program and to manage updating uniforms for the program when it is used.
|
||||
*/
|
||||
virtual GrGLEffect* createGLInstance(const GrDrawEffect&) const = 0;
|
||||
virtual GrGLEffect* createGLInstance(const GrEffect&) const = 0;
|
||||
|
||||
/**
|
||||
* Produces a human-reable name for the effect.
|
||||
|
@ -1,47 +0,0 @@
|
||||
|
||||
#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
|
@ -130,6 +130,11 @@ public:
|
||||
::operator delete(target, placement);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for down-casting to a GrEffect subclass
|
||||
*/
|
||||
template <typename T> const T& cast() const { return *static_cast<const T*>(this); }
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Subclasses call this from their constructor to register coordinate transformations. The
|
||||
@ -154,13 +159,6 @@ protected:
|
||||
, fWillUseInputColor(true)
|
||||
, fRequiresVertexShader(false) {}
|
||||
|
||||
/**
|
||||
* Helper for down-casting to a GrEffect subclass
|
||||
*/
|
||||
template <typename T> static const T& CastEffect(const GrEffect& effect) {
|
||||
return *static_cast<const T*>(&effect);
|
||||
}
|
||||
|
||||
/**
|
||||
* If the effect subclass will read the destination pixel value then it must call this function
|
||||
* from its constructor. Otherwise, when its generated backend-specific effect class attempts
|
||||
|
@ -9,7 +9,6 @@
|
||||
#define GrTBackendEffectFactory_DEFINED
|
||||
|
||||
#include "GrBackendEffectFactory.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "gl/GrGLProgramEffects.h"
|
||||
|
||||
/**
|
||||
@ -27,7 +26,7 @@
|
||||
* 1. The GrGLEffect used by GrEffect subclass MyEffect must be named or typedef'ed to
|
||||
* MyEffect::GLEffect.
|
||||
* 2. MyEffect::GLEffect must have a static function:
|
||||
* EffectKey GenKey(const GrDrawEffect, const GrGLCaps&)
|
||||
* EffectKey GenKey(const GrEffect, const GrGLCaps&)
|
||||
* which generates a key that maps 1 to 1 with code variations emitted by
|
||||
* MyEffect::GLEffect::emitCode().
|
||||
* 3. MyEffect must have a static function:
|
||||
@ -46,17 +45,17 @@ public:
|
||||
|
||||
|
||||
/** Implemented using GLEffect::GenKey as described in this class's comment. */
|
||||
virtual void getGLEffectKey(const GrDrawEffect& drawEffect,
|
||||
virtual void getGLEffectKey(const GrEffect& effect,
|
||||
const GrGLCaps& caps,
|
||||
GrEffectKeyBuilder* b) const SK_OVERRIDE {
|
||||
GLEffect::GenKey(drawEffect, caps, b);
|
||||
GLEffect::GenKey(effect, caps, b);
|
||||
}
|
||||
|
||||
/** Returns a new instance of the appropriate *GL* implementation class
|
||||
for the given GrEffect; caller is responsible for deleting
|
||||
the object. */
|
||||
virtual GrGLEffect* createGLInstance(const GrDrawEffect& drawEffect) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLEffect, (*this, drawEffect));
|
||||
virtual GrGLEffect* createGLInstance(const GrEffect& effect) const SK_OVERRIDE {
|
||||
return SkNEW_ARGS(GLEffect, (*this, effect));
|
||||
}
|
||||
|
||||
/** This class is a singleton. This function returns the single instance. */
|
||||
|
@ -818,18 +818,19 @@ public:
|
||||
|
||||
class GLEffect : public GrGLEffect {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: GrGLEffect(factory) {
|
||||
}
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
SkXfermode::Mode mode = drawEffect.castEffect<XferEffect>().mode();
|
||||
const GrTexture* backgroundTex = drawEffect.castEffect<XferEffect>().backgroundAccess().getTexture();
|
||||
SkXfermode::Mode mode = effect.cast<XferEffect>().mode();
|
||||
const GrTexture* backgroundTex =
|
||||
effect.cast<XferEffect>().backgroundAccess().getTexture();
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
const char* dstColor;
|
||||
if (backgroundTex) {
|
||||
@ -970,12 +971,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
// The background may come from the dst or from a texture.
|
||||
uint32_t key = drawEffect.effect()->numTextures();
|
||||
uint32_t key = effect.numTextures();
|
||||
SkASSERT(key <= 1);
|
||||
key |= drawEffect.castEffect<XferEffect>().mode() << 1;
|
||||
key |= effect.cast<XferEffect>().mode() << 1;
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
@ -1214,7 +1215,7 @@ private:
|
||||
}
|
||||
}
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const XferEffect& s = CastEffect<XferEffect>(other);
|
||||
const XferEffect& s = other.cast<XferEffect>();
|
||||
return fMode == s.fMode &&
|
||||
fBackgroundAccess.getTexture() == s.fBackgroundAccess.getTexture();
|
||||
}
|
||||
|
@ -118,17 +118,17 @@ private:
|
||||
|
||||
class GrGLAlphaThresholdEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLAlphaThresholdEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLAlphaThresholdEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
@ -138,12 +138,13 @@ private:
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLAlphaThresholdEffect::GrGLAlphaThresholdEffect(const GrBackendEffectFactory& factory,
|
||||
const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GrGLAlphaThresholdEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -193,9 +194,8 @@ void GrGLAlphaThresholdEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLAlphaThresholdEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const AlphaThresholdEffect& alpha_threshold =
|
||||
drawEffect.castEffect<AlphaThresholdEffect>();
|
||||
const GrEffect& effect) {
|
||||
const AlphaThresholdEffect& alpha_threshold = effect.cast<AlphaThresholdEffect>();
|
||||
pdman.set1f(fInnerThresholdVar, alpha_threshold.innerThreshold());
|
||||
pdman.set1f(fOuterThresholdVar, alpha_threshold.outerThreshold());
|
||||
}
|
||||
@ -222,7 +222,7 @@ const GrBackendEffectFactory& AlphaThresholdEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool AlphaThresholdEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const AlphaThresholdEffect& s = CastEffect<AlphaThresholdEffect>(sBase);
|
||||
const AlphaThresholdEffect& s = sBase.cast<AlphaThresholdEffect>();
|
||||
return (this->texture(0) == s.texture(0) &&
|
||||
this->fInnerThreshold == s.fInnerThreshold &&
|
||||
this->fOuterThreshold == s.fOuterThreshold);
|
||||
|
@ -249,20 +249,20 @@ SkXfermode* SkArithmeticMode::Create(SkScalar k1, SkScalar k2,
|
||||
|
||||
class GrGLArithmeticEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLArithmeticEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
virtual ~GrGLArithmeticEffect();
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fKUni;
|
||||
@ -330,7 +330,7 @@ GrArithmeticEffect::~GrArithmeticEffect() {
|
||||
}
|
||||
|
||||
bool GrArithmeticEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrArithmeticEffect& s = CastEffect<GrArithmeticEffect>(sBase);
|
||||
const GrArithmeticEffect& s = sBase.cast<GrArithmeticEffect>();
|
||||
return fK1 == s.fK1 &&
|
||||
fK2 == s.fK2 &&
|
||||
fK3 == s.fK3 &&
|
||||
@ -351,7 +351,7 @@ void GrArithmeticEffect::getConstantColorComponents(GrColor* color, uint32_t* va
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLArithmeticEffect::GrGLArithmeticEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory),
|
||||
fEnforcePMColor(true) {
|
||||
}
|
||||
@ -360,14 +360,14 @@ GrGLArithmeticEffect::~GrGLArithmeticEffect() {
|
||||
}
|
||||
|
||||
void GrGLArithmeticEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
|
||||
GrTexture* backgroundTex = drawEffect.castEffect<GrArithmeticEffect>().backgroundTexture();
|
||||
GrTexture* backgroundTex = effect.cast<GrArithmeticEffect>().backgroundTexture();
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
const char* dstColor;
|
||||
if (backgroundTex) {
|
||||
@ -408,15 +408,15 @@ void GrGLArithmeticEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLArithmeticEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>();
|
||||
void GrGLArithmeticEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const GrArithmeticEffect& arith = effect.cast<GrArithmeticEffect>();
|
||||
pdman.set4f(fKUni, arith.k1(), arith.k2(), arith.k3(), arith.k4());
|
||||
fEnforcePMColor = arith.enforcePMColor();
|
||||
}
|
||||
|
||||
void GrGLArithmeticEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLArithmeticEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrArithmeticEffect& arith = drawEffect.castEffect<GrArithmeticEffect>();
|
||||
const GrArithmeticEffect& arith = effect.cast<GrArithmeticEffect>();
|
||||
uint32_t key = arith.enforcePMColor() ? 1 : 0;
|
||||
if (arith.backgroundTexture()) {
|
||||
key |= 2;
|
||||
|
@ -609,16 +609,16 @@ private:
|
||||
class GrGLRectBlurEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLRectBlurEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&);
|
||||
const GrEffect&);
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -631,7 +631,7 @@ private:
|
||||
|
||||
|
||||
|
||||
GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLRectBlurEffect::GrGLRectBlurEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
@ -652,7 +652,7 @@ void OutputRectBlurProfileLookup(GrGLFragmentShaderBuilder* fsBuilder,
|
||||
}
|
||||
|
||||
void GrGLRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -696,8 +696,8 @@ void GrGLRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrRectBlurEffect& rbe = drawEffect.castEffect<GrRectBlurEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrRectBlurEffect& rbe = effect.cast<GrRectBlurEffect>();
|
||||
SkRect rect = rbe.getRect();
|
||||
|
||||
pdman.set4f(fProxyRectUniform, rect.fLeft, rect.fTop, rect.fRight, rect.fBottom);
|
||||
@ -761,7 +761,7 @@ const GrBackendEffectFactory& GrRectBlurEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrRectBlurEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrRectBlurEffect& s = CastEffect<GrRectBlurEffect>(sBase);
|
||||
const GrRectBlurEffect& s = sBase.cast<GrRectBlurEffect>();
|
||||
return this->getSigma() == s.getSigma() && this->getRect() == s.getRect();
|
||||
}
|
||||
|
||||
@ -945,7 +945,7 @@ GrRRectBlurEffect::GrRRectBlurEffect(float sigma, const SkRRect& rrect, GrTextur
|
||||
}
|
||||
|
||||
bool GrRRectBlurEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrRRectBlurEffect& rrbe = CastEffect<GrRRectBlurEffect>(other);
|
||||
const GrRRectBlurEffect& rrbe = other.cast<GrRRectBlurEffect>();
|
||||
return fRRect.getSimpleRadii().fX == rrbe.fRRect.getSimpleRadii().fX && fSigma == rrbe.fSigma;
|
||||
}
|
||||
|
||||
@ -970,17 +970,17 @@ GrEffect* GrRRectBlurEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLRRectBlurEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLRRectBlurEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLRRectBlurEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fProxyRectUniform;
|
||||
@ -990,12 +990,12 @@ private:
|
||||
};
|
||||
|
||||
GrGLRRectBlurEffect::GrGLRRectBlurEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
void GrGLRRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -1052,8 +1052,8 @@ void GrGLRRectBlurEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLRRectBlurEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrRRectBlurEffect& brre = drawEffect.castEffect<GrRRectBlurEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrRRectBlurEffect& brre = effect.cast<GrRRectBlurEffect>();
|
||||
SkRRect rrect = brre.getRRect();
|
||||
|
||||
float blurRadius = 3.f*SkScalarCeilToScalar(brre.getSigma()-1/6.0f);
|
||||
|
@ -218,45 +218,47 @@ public:
|
||||
|
||||
class GLEffect : public GrGLEffect {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
SkXfermode::Mode mode = drawEffect.castEffect<ModeColorFilterEffect>().mode();
|
||||
SkXfermode::Mode mode = effect.cast<ModeColorFilterEffect>().mode();
|
||||
|
||||
SkASSERT(SkXfermode::kDst_Mode != mode);
|
||||
const char* colorFilterColorUniName = NULL;
|
||||
if (drawEffect.castEffect<ModeColorFilterEffect>().willUseFilterColor()) {
|
||||
if (effect.cast<ModeColorFilterEffect>().willUseFilterColor()) {
|
||||
fFilterColorUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType, "FilterColor",
|
||||
&colorFilterColorUniName);
|
||||
}
|
||||
|
||||
GrGLSLExpr4 filter =
|
||||
color_filter_expression(mode, GrGLSLExpr4(colorFilterColorUniName), GrGLSLExpr4(inputColor));
|
||||
color_filter_expression(mode, GrGLSLExpr4(colorFilterColorUniName),
|
||||
GrGLSLExpr4(inputColor));
|
||||
|
||||
builder->getFragmentShaderBuilder()->
|
||||
codeAppendf("\t%s = %s;\n", outputColor, filter.c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const ModeColorFilterEffect& colorModeFilter = drawEffect.castEffect<ModeColorFilterEffect>();
|
||||
const ModeColorFilterEffect& colorModeFilter = effect.cast<ModeColorFilterEffect>();
|
||||
// The SL code does not depend on filter color at the moment, so no need to represent it
|
||||
// in the key.
|
||||
b->add32(colorModeFilter.mode());
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
if (fFilterColorUni.isValid()) {
|
||||
const ModeColorFilterEffect& colorModeFilter = drawEffect.castEffect<ModeColorFilterEffect>();
|
||||
const ModeColorFilterEffect& colorModeFilter = effect.cast<ModeColorFilterEffect>();
|
||||
GrGLfloat c[4];
|
||||
GrColorToRGBAFloat(colorModeFilter.color(), c);
|
||||
pdman.set4fv(fFilterColorUni, 1, c);
|
||||
@ -280,13 +282,14 @@ private:
|
||||
SkXfermode::Coeff srcCoeff;
|
||||
SkAssertResult(SkXfermode::ModeAsCoeff(fMode, &srcCoeff, &dstCoeff));
|
||||
// These could be calculated from the blend equation with template trickery..
|
||||
if (SkXfermode::kZero_Coeff == dstCoeff && !GrBlendCoeffRefsDst(sk_blend_to_grblend(srcCoeff))) {
|
||||
if (SkXfermode::kZero_Coeff == dstCoeff &&
|
||||
!GrBlendCoeffRefsDst(sk_blend_to_grblend(srcCoeff))) {
|
||||
this->setWillNotUseInputColor();
|
||||
}
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const ModeColorFilterEffect& s = CastEffect<ModeColorFilterEffect>(other);
|
||||
const ModeColorFilterEffect& s = other.cast<ModeColorFilterEffect>();
|
||||
return fMode == s.fMode && fColor == s.fColor;
|
||||
}
|
||||
|
||||
|
@ -399,15 +399,15 @@ public:
|
||||
class GLEffect : public GrGLEffect {
|
||||
public:
|
||||
// this class always generates the same code.
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
|
||||
GLEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&)
|
||||
const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -438,8 +438,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& uniManager,
|
||||
const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
||||
const ColorMatrixEffect& cme = drawEffect.castEffect<ColorMatrixEffect>();
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
const ColorMatrixEffect& cme = effect.cast<ColorMatrixEffect>();
|
||||
const float* m = cme.fMatrix.fMat;
|
||||
// The GL matrix is transposed from SkColorMatrix.
|
||||
GrGLfloat mt[] = {
|
||||
@ -467,7 +467,7 @@ private:
|
||||
ColorMatrixEffect(const SkColorMatrix& matrix) : fMatrix(matrix) {}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& s) const {
|
||||
const ColorMatrixEffect& cme = CastEffect<ColorMatrixEffect>(s);
|
||||
const ColorMatrixEffect& cme = s.cast<ColorMatrixEffect>();
|
||||
return cme.fMatrix == fMatrix;
|
||||
}
|
||||
|
||||
|
@ -300,20 +300,20 @@ bool SkDisplacementMapEffect::onFilterBounds(const SkIRect& src, const SkMatrix&
|
||||
class GrGLDisplacementMapEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect);
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLDisplacementMapEffect();
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
SkDisplacementMapEffect::ChannelSelectorType fXChannelSelector;
|
||||
@ -480,7 +480,7 @@ GrDisplacementMapEffect::~GrDisplacementMapEffect() {
|
||||
}
|
||||
|
||||
bool GrDisplacementMapEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrDisplacementMapEffect& s = CastEffect<GrDisplacementMapEffect>(sBase);
|
||||
const GrDisplacementMapEffect& s = sBase.cast<GrDisplacementMapEffect>();
|
||||
return fDisplacementAccess.getTexture() == s.fDisplacementAccess.getTexture() &&
|
||||
fColorAccess.getTexture() == s.fColorAccess.getTexture() &&
|
||||
fXChannelSelector == s.fXChannelSelector &&
|
||||
@ -532,17 +532,17 @@ GrEffect* GrDisplacementMapEffect::TestCreate(SkRandom* random,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLDisplacementMapEffect::GrGLDisplacementMapEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fXChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().xChannelSelector())
|
||||
, fYChannelSelector(drawEffect.castEffect<GrDisplacementMapEffect>().yChannelSelector()) {
|
||||
, fXChannelSelector(effect.cast<GrDisplacementMapEffect>().xChannelSelector())
|
||||
, fYChannelSelector(effect.cast<GrDisplacementMapEffect>().yChannelSelector()) {
|
||||
}
|
||||
|
||||
GrGLDisplacementMapEffect::~GrGLDisplacementMapEffect() {
|
||||
}
|
||||
|
||||
void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -620,9 +620,8 @@ void GrGLDisplacementMapEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrDisplacementMapEffect& displacementMap =
|
||||
drawEffect.castEffect<GrDisplacementMapEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrDisplacementMapEffect& displacementMap = effect.cast<GrDisplacementMapEffect>();
|
||||
GrTexture* colorTex = displacementMap.texture(1);
|
||||
SkScalar scaleX = SkScalarDiv(displacementMap.scale().fX, SkIntToScalar(colorTex->width()));
|
||||
SkScalar scaleY = SkScalarDiv(displacementMap.scale().fY, SkIntToScalar(colorTex->height()));
|
||||
@ -631,10 +630,9 @@ void GrGLDisplacementMapEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
SkScalarToFloat(scaleY) : SkScalarToFloat(-scaleY));
|
||||
}
|
||||
|
||||
void GrGLDisplacementMapEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLDisplacementMapEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrDisplacementMapEffect& displacementMap =
|
||||
drawEffect.castEffect<GrDisplacementMapEffect>();
|
||||
const GrDisplacementMapEffect& displacementMap = effect.cast<GrDisplacementMapEffect>();
|
||||
|
||||
uint32_t xKey = displacementMap.xChannelSelector();
|
||||
uint32_t yKey = displacementMap.yChannelSelector() << kChannelSelectorKeyBits;
|
||||
|
@ -1206,23 +1206,23 @@ SkLight* create_random_light(SkRandom* random) {
|
||||
class GrGLLightingEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& effect);
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLLightingEffect();
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
|
||||
/**
|
||||
* Subclasses of GrGLLightingEffect must call INHERITED::setData();
|
||||
*/
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
protected:
|
||||
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) = 0;
|
||||
@ -1240,9 +1240,9 @@ private:
|
||||
class GrGLDiffuseLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect);
|
||||
const GrEffect& effect);
|
||||
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef GrGLLightingEffect INHERITED;
|
||||
@ -1255,9 +1255,9 @@ private:
|
||||
class GrGLSpecularLightingEffect : public GrGLLightingEffect {
|
||||
public:
|
||||
GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& effect);
|
||||
const GrEffect& effect);
|
||||
virtual void emitLightFunc(GrGLProgramBuilder*, SkString* funcName) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef GrGLLightingEffect INHERITED;
|
||||
@ -1287,7 +1287,7 @@ GrLightingEffect::~GrLightingEffect() {
|
||||
}
|
||||
|
||||
bool GrLightingEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrLightingEffect& s = CastEffect<GrLightingEffect>(sBase);
|
||||
const GrLightingEffect& s = sBase.cast<GrLightingEffect>();
|
||||
return this->texture(0) == s.texture(0) &&
|
||||
fLight->isEqual(*s.fLight) &&
|
||||
fSurfaceScale == s.fSurfaceScale;
|
||||
@ -1308,7 +1308,7 @@ const GrBackendEffectFactory& GrDiffuseLightingEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrDiffuseLightingEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrDiffuseLightingEffect& s = CastEffect<GrDiffuseLightingEffect>(sBase);
|
||||
const GrDiffuseLightingEffect& s = sBase.cast<GrDiffuseLightingEffect>();
|
||||
return INHERITED::onIsEqual(sBase) &&
|
||||
this->kd() == s.kd();
|
||||
}
|
||||
@ -1334,9 +1334,9 @@ GrEffect* GrDiffuseLightingEffect::TestCreate(SkRandom* random,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLLightingEffect::GrGLLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory) {
|
||||
const GrLightingEffect& m = drawEffect.castEffect<GrLightingEffect>();
|
||||
const GrLightingEffect& m = effect.cast<GrLightingEffect>();
|
||||
fLight = m.light()->createGLLight();
|
||||
}
|
||||
|
||||
@ -1345,7 +1345,7 @@ GrGLLightingEffect::~GrGLLightingEffect() {
|
||||
}
|
||||
|
||||
void GrGLLightingEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -1441,14 +1441,14 @@ void GrGLLightingEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
fsBuilder->codeAppend(modulate.c_str());
|
||||
}
|
||||
|
||||
void GrGLLightingEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLLightingEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps& caps, GrEffectKeyBuilder* b) {
|
||||
b->add32(drawEffect.castEffect<GrLightingEffect>().light()->type());
|
||||
b->add32(effect.cast<GrLightingEffect>().light()->type());
|
||||
}
|
||||
|
||||
void GrGLLightingEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrLightingEffect& lighting = drawEffect.castEffect<GrLightingEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrLightingEffect& lighting = effect.cast<GrLightingEffect>();
|
||||
GrTexture* texture = lighting.texture(0);
|
||||
float ySign = texture->origin() == kTopLeft_GrSurfaceOrigin ? -1.0f : 1.0f;
|
||||
pdman.set2f(fImageIncrementUni, 1.0f / texture->width(), ySign / texture->height());
|
||||
@ -1462,8 +1462,8 @@ void GrGLLightingEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLDiffuseLightingEffect::GrGLDiffuseLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
: INHERITED(factory, drawEffect) {
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory, effect) {
|
||||
}
|
||||
|
||||
void GrGLDiffuseLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkString* funcName) {
|
||||
@ -1490,9 +1490,9 @@ void GrGLDiffuseLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkStr
|
||||
}
|
||||
|
||||
void GrGLDiffuseLightingEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const GrDiffuseLightingEffect& diffuse = drawEffect.castEffect<GrDiffuseLightingEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const GrDiffuseLightingEffect& diffuse = effect.cast<GrDiffuseLightingEffect>();
|
||||
pdman.set1f(fKDUni, diffuse.kd());
|
||||
}
|
||||
|
||||
@ -1514,7 +1514,7 @@ const GrBackendEffectFactory& GrSpecularLightingEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrSpecularLightingEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrSpecularLightingEffect& s = CastEffect<GrSpecularLightingEffect>(sBase);
|
||||
const GrSpecularLightingEffect& s = sBase.cast<GrSpecularLightingEffect>();
|
||||
return INHERITED::onIsEqual(sBase) &&
|
||||
this->ks() == s.ks() &&
|
||||
this->shininess() == s.shininess();
|
||||
@ -1541,8 +1541,8 @@ GrEffect* GrSpecularLightingEffect::TestCreate(SkRandom* random,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLSpecularLightingEffect::GrGLSpecularLightingEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
: INHERITED(factory, drawEffect) {
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory, effect) {
|
||||
}
|
||||
|
||||
void GrGLSpecularLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkString* funcName) {
|
||||
@ -1573,9 +1573,9 @@ void GrGLSpecularLightingEffect::emitLightFunc(GrGLProgramBuilder* builder, SkSt
|
||||
}
|
||||
|
||||
void GrGLSpecularLightingEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const GrSpecularLightingEffect& spec = drawEffect.castEffect<GrSpecularLightingEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const GrSpecularLightingEffect& spec = effect.cast<GrSpecularLightingEffect>();
|
||||
pdman.set1f(fKSUni, spec.ks());
|
||||
pdman.set1f(fShininessUni, spec.shininess());
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ public:
|
||||
class GLEffect : public GrGLEffect {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&)
|
||||
const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -93,17 +93,17 @@ typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
class GrGLMagnifierEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLMagnifierEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
UniformHandle fOffsetVar;
|
||||
@ -113,12 +113,12 @@ private:
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GrGLMagnifierEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -172,8 +172,8 @@ void GrGLMagnifierEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrMagnifierEffect& zoom = drawEffect.castEffect<GrMagnifierEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrMagnifierEffect& zoom = effect.cast<GrMagnifierEffect>();
|
||||
pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset());
|
||||
pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom());
|
||||
pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset());
|
||||
@ -216,7 +216,7 @@ const GrBackendEffectFactory& GrMagnifierEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrMagnifierEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrMagnifierEffect& s = CastEffect<GrMagnifierEffect>(sBase);
|
||||
const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>();
|
||||
return (this->texture(0) == s.texture(0) &&
|
||||
this->fXOffset == s.fXOffset &&
|
||||
this->fYOffset == s.fYOffset &&
|
||||
|
@ -328,19 +328,19 @@ private:
|
||||
|
||||
class GrGLMorphologyEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLMorphologyEffect (const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
int width() const { return GrMorphologyEffect::WidthFromRadius(fRadius); }
|
||||
@ -353,15 +353,15 @@ private:
|
||||
};
|
||||
|
||||
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory) {
|
||||
const GrMorphologyEffect& m = drawEffect.castEffect<GrMorphologyEffect>();
|
||||
const GrMorphologyEffect& m = effect.cast<GrMorphologyEffect>();
|
||||
fRadius = m.radius();
|
||||
fType = m.type();
|
||||
}
|
||||
|
||||
void GrGLMorphologyEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -401,17 +401,17 @@ void GrGLMorphologyEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
fsBuilder->codeAppend(modulate.c_str());
|
||||
}
|
||||
|
||||
void GrGLMorphologyEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLMorphologyEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrMorphologyEffect& m = drawEffect.castEffect<GrMorphologyEffect>();
|
||||
const GrMorphologyEffect& m = effect.cast<GrMorphologyEffect>();
|
||||
uint32_t key = static_cast<uint32_t>(m.radius());
|
||||
key |= (m.type() << 8);
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
void GrGLMorphologyEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const Gr1DKernelEffect& kern = drawEffect.castEffect<Gr1DKernelEffect>();
|
||||
const GrEffect& effect) {
|
||||
const Gr1DKernelEffect& kern = effect.cast<Gr1DKernelEffect>();
|
||||
GrTexture& texture = *kern.texture(0);
|
||||
// the code we generated was for a specific kernel radius
|
||||
SkASSERT(kern.radius() == fRadius);
|
||||
@ -447,7 +447,7 @@ const GrBackendEffectFactory& GrMorphologyEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrMorphologyEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrMorphologyEffect& s = CastEffect<GrMorphologyEffect>(sBase);
|
||||
const GrMorphologyEffect& s = sBase.cast<GrMorphologyEffect>();
|
||||
return (this->texture(0) == s.texture(0) &&
|
||||
this->radius() == s.radius() &&
|
||||
this->direction() == s.direction() &&
|
||||
|
@ -512,20 +512,20 @@ void SkPerlinNoiseShader::PerlinNoiseShaderContext::shadeSpan16(
|
||||
class GrGLPerlinNoise : public GrGLEffect {
|
||||
public:
|
||||
GrGLPerlinNoise(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect);
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLPerlinNoise() {}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b);
|
||||
|
||||
private:
|
||||
|
||||
@ -574,7 +574,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const GrPerlinNoiseEffect& s = CastEffect<GrPerlinNoiseEffect>(sBase);
|
||||
const GrPerlinNoiseEffect& s = sBase.cast<GrPerlinNoiseEffect>();
|
||||
return fType == s.fType &&
|
||||
fPaintingData->fBaseFrequency == s.fPaintingData->fBaseFrequency &&
|
||||
fNumOctaves == s.fNumOctaves &&
|
||||
@ -656,15 +656,15 @@ GrEffect* GrPerlinNoiseEffect::TestCreate(SkRandom* random,
|
||||
return effect;
|
||||
}
|
||||
|
||||
GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
|
||||
GrGLPerlinNoise::GrGLPerlinNoise(const GrBackendEffectFactory& factory, const GrEffect& effect)
|
||||
: INHERITED (factory)
|
||||
, fType(drawEffect.castEffect<GrPerlinNoiseEffect>().type())
|
||||
, fStitchTiles(drawEffect.castEffect<GrPerlinNoiseEffect>().stitchTiles())
|
||||
, fNumOctaves(drawEffect.castEffect<GrPerlinNoiseEffect>().numOctaves()) {
|
||||
, fType(effect.cast<GrPerlinNoiseEffect>().type())
|
||||
, fStitchTiles(effect.cast<GrPerlinNoiseEffect>().stitchTiles())
|
||||
, fNumOctaves(effect.cast<GrPerlinNoiseEffect>().numOctaves()) {
|
||||
}
|
||||
|
||||
void GrGLPerlinNoise::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -919,8 +919,8 @@ void GrGLPerlinNoise::emitCode(GrGLProgramBuilder* builder,
|
||||
outputColor, outputColor, outputColor, outputColor);
|
||||
}
|
||||
|
||||
void GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseEffect>();
|
||||
void GrGLPerlinNoise::GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrPerlinNoiseEffect& turbulence = effect.cast<GrPerlinNoiseEffect>();
|
||||
|
||||
uint32_t key = turbulence.numOctaves();
|
||||
|
||||
@ -945,10 +945,10 @@ void GrGLPerlinNoise::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, Gr
|
||||
b->add32(key);
|
||||
}
|
||||
|
||||
void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
void GrGLPerlinNoise::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
|
||||
const GrPerlinNoiseEffect& turbulence = drawEffect.castEffect<GrPerlinNoiseEffect>();
|
||||
const GrPerlinNoiseEffect& turbulence = effect.cast<GrPerlinNoiseEffect>();
|
||||
|
||||
const SkVector& baseFrequency = turbulence.baseFrequency();
|
||||
pdman.set2f(fBaseFrequencyUni, baseFrequency.fX, baseFrequency.fY);
|
||||
|
@ -314,31 +314,31 @@ private:
|
||||
|
||||
class GLColorTableEffect : public GrGLEffect {
|
||||
public:
|
||||
GLColorTableEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLColorTableEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder* b) {}
|
||||
|
||||
private:
|
||||
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLColorTableEffect::GLColorTableEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GLColorTableEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -1001,9 +1001,9 @@ static inline void set_mul_color_uni(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
|
||||
void GrGLGradientEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrEffect& effect) {
|
||||
|
||||
const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>();
|
||||
const GrGradientEffect& e = effect.cast<GrGradientEffect>();
|
||||
|
||||
|
||||
if (SkGradientShaderBase::kTwo_GpuColorType == e.getColorType()){
|
||||
@ -1038,8 +1038,8 @@ void GrGLGradientEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
|
||||
|
||||
uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrDrawEffect& drawEffect) {
|
||||
const GrGradientEffect& e = drawEffect.castEffect<GrGradientEffect>();
|
||||
uint32_t GrGLGradientEffect::GenBaseGradientKey(const GrEffect& effect) {
|
||||
const GrGradientEffect& e = effect.cast<GrGradientEffect>();
|
||||
|
||||
uint32_t key = 0;
|
||||
|
||||
@ -1186,7 +1186,7 @@ GrGradientEffect::~GrGradientEffect() {
|
||||
}
|
||||
|
||||
bool GrGradientEffect::onIsEqual(const GrEffect& effect) const {
|
||||
const GrGradientEffect& s = CastEffect<GrGradientEffect>(effect);
|
||||
const GrGradientEffect& s = effect.cast<GrGradientEffect>();
|
||||
|
||||
if (this->fColorType == s.getColorType()){
|
||||
|
||||
|
@ -403,7 +403,7 @@ public:
|
||||
GrGLGradientEffect(const GrBackendEffectFactory& factory);
|
||||
virtual ~GrGLGradientEffect();
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
protected:
|
||||
/**
|
||||
@ -411,7 +411,7 @@ protected:
|
||||
* by the base class. The subclasses must stick it in their key and then pass it to the below
|
||||
* emit* functions from their emitCode function.
|
||||
*/
|
||||
static uint32_t GenBaseGradientKey(const GrDrawEffect&);
|
||||
static uint32_t GenBaseGradientKey(const GrEffect&);
|
||||
|
||||
// Emits the uniform used as the y-coord to texture samples in derived classes. Subclasses
|
||||
// should call this method from their emitCode().
|
||||
|
@ -468,21 +468,21 @@ void SkLinearGradient::LinearGradientContext::shadeSpan16(int x, int y,
|
||||
class GrGLLinearGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLLinearGradient(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) { }
|
||||
|
||||
virtual ~GrGLLinearGradient() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -551,7 +551,7 @@ GrEffect* GrLinearGradient::TestCreate(SkRandom* random,
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrGLLinearGradient::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -477,19 +477,19 @@ class GrGLRadialGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLRadialGradient(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&) : INHERITED (factory) { }
|
||||
const GrEffect&) : INHERITED (factory) { }
|
||||
virtual ~GrGLRadialGradient() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -560,7 +560,7 @@ GrEffect* GrRadialGradient::TestCreate(SkRandom* random,
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrGLRadialGradient::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -192,19 +192,19 @@ class GrGLSweepGradient : public GrGLGradientEffect {
|
||||
public:
|
||||
|
||||
GrGLSweepGradient(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&) : INHERITED (factory) { }
|
||||
const GrEffect&) : INHERITED (factory) { }
|
||||
virtual ~GrGLSweepGradient() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
private:
|
||||
@ -266,7 +266,7 @@ GrEffect* GrSweepGradient::TestCreate(SkRandom* random,
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
void GrGLSweepGradient::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const Edge2PtConicalEffect& s = CastEffect<Edge2PtConicalEffect>(sBase);
|
||||
const Edge2PtConicalEffect& s = sBase.cast<Edge2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fCenterX1 == s.fCenterX1 &&
|
||||
this->fRadius0 == s.fRadius0 &&
|
||||
@ -134,19 +134,19 @@ private:
|
||||
|
||||
class GLEdge2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GLEdge2PtConicalEffect() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
UniformHandle fParamUni;
|
||||
@ -210,7 +210,7 @@ GrEffect* Edge2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
@ -218,7 +218,7 @@ GLEdge2PtConicalEffect::GLEdge2PtConicalEffect(const GrBackendEffectFactory& fac
|
||||
, fCachedDiffRadius(-SK_ScalarMax) {}
|
||||
|
||||
void GLEdge2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -246,7 +246,8 @@ void GLEdge2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
if (kVec3f_GrSLType == coords[0].type()) {
|
||||
fsBuilder->codeAppendf("\tvec3 interpolants = vec3(%s.xy / %s.z, %s.x / %s.z);\n",
|
||||
coords[0].c_str(), coords[0].c_str(), coords[1].c_str(), coords[1].c_str());
|
||||
coords[0].c_str(), coords[0].c_str(), coords[1].c_str(),
|
||||
coords[1].c_str());
|
||||
coords2D = "interpolants.xy";
|
||||
bVar = "interpolants.z";
|
||||
} else {
|
||||
@ -275,9 +276,9 @@ void GLEdge2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GLEdge2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const Edge2PtConicalEffect& data = drawEffect.castEffect<Edge2PtConicalEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const Edge2PtConicalEffect& data = effect.cast<Edge2PtConicalEffect>();
|
||||
SkScalar radius0 = data.radius();
|
||||
SkScalar diffRadius = data.diffRadius();
|
||||
|
||||
@ -296,9 +297,9 @@ void GLEdge2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
void GLEdge2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GLEdge2PtConicalEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -388,7 +389,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const FocalOutside2PtConicalEffect& s = CastEffect<FocalOutside2PtConicalEffect>(sBase);
|
||||
const FocalOutside2PtConicalEffect& s = sBase.cast<FocalOutside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fFocalX == s.fFocalX &&
|
||||
this->fIsFlipped == s.fIsFlipped);
|
||||
@ -411,19 +412,19 @@ private:
|
||||
|
||||
class GLFocalOutside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GLFocalOutside2PtConicalEffect() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
UniformHandle fParamUni;
|
||||
@ -485,17 +486,17 @@ GrEffect* FocalOutside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
GLFocalOutside2PtConicalEffect::GLFocalOutside2PtConicalEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedFocal(SK_ScalarMax) {
|
||||
const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutside2PtConicalEffect>();
|
||||
const FocalOutside2PtConicalEffect& data = effect.cast<FocalOutside2PtConicalEffect>();
|
||||
fIsFlipped = data.isFlipped();
|
||||
}
|
||||
|
||||
void GLFocalOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -544,9 +545,9 @@ void GLFocalOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GLFocalOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const FocalOutside2PtConicalEffect& data = drawEffect.castEffect<FocalOutside2PtConicalEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const FocalOutside2PtConicalEffect& data = effect.cast<FocalOutside2PtConicalEffect>();
|
||||
SkASSERT(data.isFlipped() == fIsFlipped);
|
||||
SkScalar focal = data.focal();
|
||||
|
||||
@ -563,11 +564,11 @@ void GLFocalOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
|
||||
}
|
||||
}
|
||||
|
||||
void GLFocalOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GLFocalOutside2PtConicalEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
uint32_t* key = b->add32n(2);
|
||||
key[0] = GenBaseGradientKey(drawEffect);
|
||||
key[1] = drawEffect.castEffect<FocalOutside2PtConicalEffect>().isFlipped();
|
||||
key[0] = GenBaseGradientKey(effect);
|
||||
key[1] = effect.cast<FocalOutside2PtConicalEffect>().isFlipped();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -596,7 +597,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const FocalInside2PtConicalEffect& s = CastEffect<FocalInside2PtConicalEffect>(sBase);
|
||||
const FocalInside2PtConicalEffect& s = sBase.cast<FocalInside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fFocalX == s.fFocalX);
|
||||
}
|
||||
@ -617,19 +618,19 @@ private:
|
||||
|
||||
class GLFocalInside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GLFocalInside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
UniformHandle fFocalUni;
|
||||
@ -691,14 +692,14 @@ GrEffect* FocalInside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
GLFocalInside2PtConicalEffect::GLFocalInside2PtConicalEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
, fCachedFocal(SK_ScalarMax) {}
|
||||
|
||||
void GLFocalInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -727,9 +728,9 @@ void GLFocalInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GLFocalInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const FocalInside2PtConicalEffect& data = drawEffect.castEffect<FocalInside2PtConicalEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const FocalInside2PtConicalEffect& data = effect.cast<FocalInside2PtConicalEffect>();
|
||||
SkScalar focal = data.focal();
|
||||
|
||||
if (fCachedFocal != focal) {
|
||||
@ -738,9 +739,9 @@ void GLFocalInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
void GLFocalInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GLFocalInside2PtConicalEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -835,7 +836,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const CircleInside2PtConicalEffect& s = CastEffect<CircleInside2PtConicalEffect>(sBase);
|
||||
const CircleInside2PtConicalEffect& s = sBase.cast<CircleInside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
|
||||
this->fInfo.fA == s.fInfo.fA &&
|
||||
@ -859,19 +860,19 @@ private:
|
||||
|
||||
class GLCircleInside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GLCircleInside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
UniformHandle fCenterUni;
|
||||
@ -937,7 +938,7 @@ GrEffect* CircleInside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
@ -948,7 +949,7 @@ GLCircleInside2PtConicalEffect::GLCircleInside2PtConicalEffect(const GrBackendEf
|
||||
, fCachedC(SK_ScalarMax) {}
|
||||
|
||||
void GLCircleInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -982,7 +983,8 @@ void GLCircleInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
// d = dot(e, p) + B
|
||||
// t = d +/- sqrt(d^2 - A * dot(p, p) + C)
|
||||
fsBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D);
|
||||
fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, center.c_str(), params.c_str());
|
||||
fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, center.c_str(),
|
||||
params.c_str());
|
||||
fsBuilder->codeAppendf("\tfloat %s = d + sqrt(d * d - %s.x * pDotp + %s.z);\n",
|
||||
tName.c_str(), params.c_str(), params.c_str());
|
||||
|
||||
@ -990,9 +992,9 @@ void GLCircleInside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GLCircleInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const CircleInside2PtConicalEffect& data = drawEffect.castEffect<CircleInside2PtConicalEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const CircleInside2PtConicalEffect& data = effect.cast<CircleInside2PtConicalEffect>();
|
||||
SkScalar centerX = data.centerX();
|
||||
SkScalar centerY = data.centerY();
|
||||
SkScalar A = data.A();
|
||||
@ -1013,9 +1015,9 @@ void GLCircleInside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman
|
||||
}
|
||||
}
|
||||
|
||||
void GLCircleInside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GLCircleInside2PtConicalEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
b->add32(GenBaseGradientKey(drawEffect));
|
||||
b->add32(GenBaseGradientKey(effect));
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -1050,7 +1052,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const CircleOutside2PtConicalEffect& s = CastEffect<CircleOutside2PtConicalEffect>(sBase);
|
||||
const CircleOutside2PtConicalEffect& s = sBase.cast<CircleOutside2PtConicalEffect>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fInfo.fCenterEnd == s.fInfo.fCenterEnd &&
|
||||
this->fInfo.fA == s.fInfo.fA &&
|
||||
@ -1067,7 +1069,8 @@ private:
|
||||
const CircleConicalInfo& info)
|
||||
: INHERITED(ctx, shader, matrix, tm), fInfo(info) {
|
||||
if (shader.getStartRadius() != shader.getEndRadius()) {
|
||||
fTLimit = SkScalarDiv(shader.getStartRadius(), (shader.getStartRadius() - shader.getEndRadius()));
|
||||
fTLimit = SkScalarDiv(shader.getStartRadius(),
|
||||
(shader.getStartRadius() - shader.getEndRadius()));
|
||||
} else {
|
||||
fTLimit = SK_ScalarMin;
|
||||
}
|
||||
@ -1086,19 +1089,19 @@ private:
|
||||
|
||||
class GLCircleOutside2PtConicalEffect : public GrGLGradientEffect {
|
||||
public:
|
||||
GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GLCircleOutside2PtConicalEffect() {}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
UniformHandle fCenterUni;
|
||||
@ -1168,7 +1171,7 @@ GrEffect* CircleOutside2PtConicalEffect::TestCreate(SkRandom* random,
|
||||
}
|
||||
|
||||
GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
@ -1178,12 +1181,12 @@ GLCircleOutside2PtConicalEffect::GLCircleOutside2PtConicalEffect(const GrBackend
|
||||
, fCachedB(SK_ScalarMax)
|
||||
, fCachedC(SK_ScalarMax)
|
||||
, fCachedTLimit(SK_ScalarMax) {
|
||||
const CircleOutside2PtConicalEffect& data = drawEffect.castEffect<CircleOutside2PtConicalEffect>();
|
||||
const CircleOutside2PtConicalEffect& data = effect.cast<CircleOutside2PtConicalEffect>();
|
||||
fIsFlipped = data.isFlipped();
|
||||
}
|
||||
|
||||
void GLCircleOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -1222,8 +1225,10 @@ void GLCircleOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
// t = d +/- sqrt(d^2 - A * dot(p, p) + C)
|
||||
|
||||
fsBuilder->codeAppendf("\tfloat pDotp = dot(%s, %s);\n", coords2D, coords2D);
|
||||
fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, center.c_str(), params.c_str());
|
||||
fsBuilder->codeAppendf("\tfloat deter = d * d - %s.x * pDotp + %s.z;\n", params.c_str(), params.c_str());
|
||||
fsBuilder->codeAppendf("\tfloat d = dot(%s, %s) + %s.y;\n", coords2D, center.c_str(),
|
||||
params.c_str());
|
||||
fsBuilder->codeAppendf("\tfloat deter = d * d - %s.x * pDotp + %s.z;\n", params.c_str(),
|
||||
params.c_str());
|
||||
|
||||
// Must check to see if we flipped the circle order (to make sure start radius < end radius)
|
||||
// If so we must also flip sign on sqrt
|
||||
@ -1240,9 +1245,9 @@ void GLCircleOutside2PtConicalEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GLCircleOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const CircleOutside2PtConicalEffect& data = drawEffect.castEffect<CircleOutside2PtConicalEffect>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const CircleOutside2PtConicalEffect& data = effect.cast<CircleOutside2PtConicalEffect>();
|
||||
SkASSERT(data.isFlipped() == fIsFlipped);
|
||||
SkScalar centerX = data.centerX();
|
||||
SkScalar centerY = data.centerY();
|
||||
@ -1267,11 +1272,11 @@ void GLCircleOutside2PtConicalEffect::setData(const GrGLProgramDataManager& pdma
|
||||
}
|
||||
}
|
||||
|
||||
void GLCircleOutside2PtConicalEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GLCircleOutside2PtConicalEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
uint32_t* key = b->add32n(2);
|
||||
key[0] = GenBaseGradientKey(drawEffect);
|
||||
key[1] = drawEffect.castEffect<CircleOutside2PtConicalEffect>().isFlipped();
|
||||
key[0] = GenBaseGradientKey(effect);
|
||||
key[1] = effect.cast<CircleOutside2PtConicalEffect>().isFlipped();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -408,19 +408,19 @@ class GrGLRadial2Gradient : public GrGLGradientEffect {
|
||||
|
||||
public:
|
||||
|
||||
GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrDrawEffect&);
|
||||
GrGLRadial2Gradient(const GrBackendEffectFactory& factory, const GrEffect&);
|
||||
virtual ~GrGLRadial2Gradient() { }
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
static void GenKey(const GrEffect&, const GrGLCaps& caps, GrEffectKeyBuilder* b);
|
||||
|
||||
protected:
|
||||
|
||||
@ -474,7 +474,7 @@ public:
|
||||
|
||||
private:
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const SK_OVERRIDE {
|
||||
const GrRadial2Gradient& s = CastEffect<GrRadial2Gradient>(sBase);
|
||||
const GrRadial2Gradient& s = sBase.cast<GrRadial2Gradient>();
|
||||
return (INHERITED::onIsEqual(sBase) &&
|
||||
this->fCenterX1 == s.fCenterX1 &&
|
||||
this->fRadius0 == s.fRadius0 &&
|
||||
@ -555,7 +555,7 @@ GrEffect* GrRadial2Gradient::TestCreate(SkRandom* random,
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory)
|
||||
, fVSVaryingName(NULL)
|
||||
, fFSVaryingName(NULL)
|
||||
@ -563,12 +563,12 @@ GrGLRadial2Gradient::GrGLRadial2Gradient(const GrBackendEffectFactory& factory,
|
||||
, fCachedRadius(-SK_ScalarMax)
|
||||
, fCachedPosRoot(0) {
|
||||
|
||||
const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
|
||||
const GrRadial2Gradient& data = effect.cast<GrRadial2Gradient>();
|
||||
fIsDegenerate = data.isDegenerate();
|
||||
}
|
||||
|
||||
void GrGLRadial2Gradient::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -642,9 +642,9 @@ void GrGLRadial2Gradient::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLRadial2Gradient::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
INHERITED::setData(pdman, drawEffect);
|
||||
const GrRadial2Gradient& data = drawEffect.castEffect<GrRadial2Gradient>();
|
||||
const GrEffect& effect) {
|
||||
INHERITED::setData(pdman, effect);
|
||||
const GrRadial2Gradient& data = effect.cast<GrRadial2Gradient>();
|
||||
SkASSERT(data.isDegenerate() == fIsDegenerate);
|
||||
SkScalar centerX1 = data.center();
|
||||
SkScalar radius0 = data.radius();
|
||||
@ -675,11 +675,11 @@ void GrGLRadial2Gradient::setData(const GrGLProgramDataManager& pdman,
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLRadial2Gradient::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLRadial2Gradient::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
uint32_t* key = b->add32n(2);
|
||||
key[0] = GenBaseGradientKey(drawEffect);
|
||||
key[1] = drawEffect.castEffect<GrRadial2Gradient>().isDegenerate();
|
||||
key[0] = GenBaseGradientKey(effect);
|
||||
key[1] = effect.cast<GrRadial2Gradient>().isDegenerate();
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
@ -530,11 +530,11 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -569,14 +569,14 @@ public:
|
||||
fsBuilder->codeAppendf("\t%s = %s;\n", outputColor,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
|
||||
const GrShaderVar& inQuadEdge = drawEffect.castEffect<QuadEdgeEffect>().inQuadEdge();
|
||||
const GrShaderVar& inQuadEdge = effect.cast<QuadEdgeEffect>().inQuadEdge();
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
vsBuilder->codeAppendf("\t%s = %s;\n", vsName, inQuadEdge.c_str());
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
|
@ -43,11 +43,11 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -59,7 +59,7 @@ public:
|
||||
const char *vsRectName, *fsRectName;
|
||||
builder->addVarying(kVec4f_GrSLType, "Rect", &vsRectName, &fsRectName);
|
||||
|
||||
const GrShaderVar& inRect = drawEffect.castEffect<GrAlignedRectEffect>().inRect();
|
||||
const GrShaderVar& inRect = effect.cast<GrAlignedRectEffect>().inRect();
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
vsBuilder->codeAppendf("\t%s = %s;\n", vsRectName, inRect.c_str());
|
||||
|
||||
@ -92,9 +92,9 @@ public:
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
@ -169,11 +169,11 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -185,7 +185,7 @@ public:
|
||||
builder->addVarying(kVec4f_GrSLType, "RectEdge",
|
||||
&vsRectEdgeName, &fsRectEdgeName);
|
||||
|
||||
const GrRectEffect& rectEffect = drawEffect.castEffect<GrRectEffect>();
|
||||
const GrRectEffect& rectEffect = effect.cast<GrRectEffect>();
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
vsBuilder->codeAppendf("%s = %s;", vsRectEdgeName, rectEffect.inRectEdge().c_str());
|
||||
|
||||
@ -233,9 +233,9 @@ public:
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("coverage")).c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
|
@ -94,17 +94,17 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleEdgeEffect>();
|
||||
const CircleEdgeEffect& circleEffect = effect.cast<CircleEdgeEffect>();
|
||||
const char *vsName, *fsName;
|
||||
builder->addVarying(kVec4f_GrSLType, "CircleEdge", &vsName, &fsName);
|
||||
|
||||
@ -123,13 +123,13 @@ public:
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const CircleEdgeEffect& circleEffect = drawEffect.castEffect<CircleEdgeEffect>();
|
||||
const CircleEdgeEffect& circleEffect = effect.cast<CircleEdgeEffect>();
|
||||
b->add32(circleEffect.isStroked());
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
@ -146,7 +146,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const CircleEdgeEffect& cee = CastEffect<CircleEdgeEffect>(other);
|
||||
const CircleEdgeEffect& cee = other.cast<CircleEdgeEffect>();
|
||||
return cee.fStroke == fStroke;
|
||||
}
|
||||
|
||||
@ -212,17 +212,17 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<EllipseEdgeEffect>();
|
||||
const EllipseEdgeEffect& ellipseEffect = effect.cast<EllipseEdgeEffect>();
|
||||
|
||||
const char *vsOffsetName, *fsOffsetName;
|
||||
const char *vsRadiiName, *fsRadiiName;
|
||||
@ -260,13 +260,13 @@ public:
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const EllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<EllipseEdgeEffect>();
|
||||
const EllipseEdgeEffect& ellipseEffect = effect.cast<EllipseEdgeEffect>();
|
||||
b->add32(ellipseEffect.isStroked());
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {
|
||||
}
|
||||
|
||||
private:
|
||||
@ -287,7 +287,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const EllipseEdgeEffect& eee = CastEffect<EllipseEdgeEffect>(other);
|
||||
const EllipseEdgeEffect& eee = other.cast<EllipseEdgeEffect>();
|
||||
return eee.fStroke == fStroke;
|
||||
}
|
||||
|
||||
@ -361,17 +361,17 @@ public:
|
||||
|
||||
class GLEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GLEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const DIEllipseEdgeEffect& ellipseEffect = drawEffect.castEffect<DIEllipseEdgeEffect>();
|
||||
const DIEllipseEdgeEffect& ellipseEffect = effect.cast<DIEllipseEdgeEffect>();
|
||||
|
||||
const char *vsOffsetName0, *fsOffsetName0;
|
||||
builder->addVarying(kVec2f_GrSLType, "EllipseOffsets0",
|
||||
@ -427,15 +427,14 @@ public:
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
}
|
||||
|
||||
static void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const DIEllipseEdgeEffect& ellipseEffect =
|
||||
drawEffect.castEffect<DIEllipseEdgeEffect>();
|
||||
const DIEllipseEdgeEffect& ellipseEffect = effect.cast<DIEllipseEdgeEffect>();
|
||||
|
||||
b->add32(ellipseEffect.getMode());
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {
|
||||
}
|
||||
|
||||
private:
|
||||
@ -456,7 +455,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const DIEllipseEdgeEffect& eee = CastEffect<DIEllipseEdgeEffect>(other);
|
||||
const DIEllipseEdgeEffect& eee = other.cast<DIEllipseEdgeEffect>();
|
||||
return eee.fMode == fMode;
|
||||
}
|
||||
|
||||
|
@ -15,19 +15,19 @@
|
||||
|
||||
class GrGLConicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLConicEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLConicEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
GrEffectEdgeType fEdgeType;
|
||||
@ -36,14 +36,14 @@ private:
|
||||
};
|
||||
|
||||
GrGLConicEffect::GrGLConicEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>();
|
||||
const GrConicEffect& ce = effect.cast<GrConicEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -54,7 +54,7 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
builder->addVarying(kVec4f_GrSLType, "ConicCoeffs",
|
||||
&vsName, &fsName);
|
||||
|
||||
const GrShaderVar& inConicCoeffs = drawEffect.castEffect<GrConicEffect>().inConicCoeffs();
|
||||
const GrShaderVar& inConicCoeffs = effect.cast<GrConicEffect>().inConicCoeffs();
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
vsBuilder->codeAppendf("%s = %s;", vsName, inConicCoeffs.c_str());
|
||||
|
||||
@ -119,9 +119,9 @@ void GrGLConicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
}
|
||||
|
||||
void GrGLConicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLConicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrConicEffect& ce = drawEffect.castEffect<GrConicEffect>();
|
||||
const GrConicEffect& ce = effect.cast<GrConicEffect>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -142,7 +142,7 @@ GrConicEffect::GrConicEffect(GrEffectEdgeType edgeType)
|
||||
}
|
||||
|
||||
bool GrConicEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrConicEffect& ce = CastEffect<GrConicEffect>(other);
|
||||
const GrConicEffect& ce = other.cast<GrConicEffect>();
|
||||
return (ce.fEdgeType == fEdgeType);
|
||||
}
|
||||
|
||||
@ -169,19 +169,19 @@ GrEffect* GrConicEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLQuadEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLQuadEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLQuadEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
GrEffectEdgeType fEdgeType;
|
||||
@ -190,14 +190,14 @@ private:
|
||||
};
|
||||
|
||||
GrGLQuadEffect::GrGLQuadEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>();
|
||||
const GrQuadEffect& ce = effect.cast<GrQuadEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -207,7 +207,7 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
builder->addVarying(kVec4f_GrSLType, "HairQuadEdge", &vsName, &fsName);
|
||||
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
const GrShaderVar& inHairQuadEdge = drawEffect.castEffect<GrQuadEffect>().inHairQuadEdge();
|
||||
const GrShaderVar& inHairQuadEdge = effect.cast<GrQuadEffect>().inHairQuadEdge();
|
||||
vsBuilder->codeAppendf("%s = %s;", vsName, inHairQuadEdge.c_str());
|
||||
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
@ -257,9 +257,9 @@ void GrGLQuadEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("edgeAlpha")).c_str());
|
||||
}
|
||||
|
||||
void GrGLQuadEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLQuadEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrQuadEffect& ce = drawEffect.castEffect<GrQuadEffect>();
|
||||
const GrQuadEffect& ce = effect.cast<GrQuadEffect>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -280,7 +280,7 @@ GrQuadEffect::GrQuadEffect(GrEffectEdgeType edgeType)
|
||||
}
|
||||
|
||||
bool GrQuadEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrQuadEffect& ce = CastEffect<GrQuadEffect>(other);
|
||||
const GrQuadEffect& ce = other.cast<GrQuadEffect>();
|
||||
return (ce.fEdgeType == fEdgeType);
|
||||
}
|
||||
|
||||
@ -307,19 +307,19 @@ GrEffect* GrQuadEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GrGLCubicEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLCubicEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLCubicEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
GrEffectEdgeType fEdgeType;
|
||||
@ -328,14 +328,14 @@ private:
|
||||
};
|
||||
|
||||
GrGLCubicEffect::GrGLCubicEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
|
||||
const GrCubicEffect& ce = effect.cast<GrCubicEffect>();
|
||||
fEdgeType = ce.getEdgeType();
|
||||
}
|
||||
|
||||
void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -347,7 +347,7 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
&vsName, &fsName, GrGLShaderVar::kHigh_Precision);
|
||||
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
const GrShaderVar& inCubicCoeffs = drawEffect.castEffect<GrCubicEffect>().inCubicCoeffs();
|
||||
const GrShaderVar& inCubicCoeffs = effect.cast<GrCubicEffect>().inCubicCoeffs();
|
||||
vsBuilder->codeAppendf("%s = %s;", vsName, inCubicCoeffs.c_str());
|
||||
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
@ -437,9 +437,9 @@ void GrGLCubicEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1(edgeAlpha.c_str())).c_str());
|
||||
}
|
||||
|
||||
void GrGLCubicEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLCubicEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrCubicEffect& ce = drawEffect.castEffect<GrCubicEffect>();
|
||||
const GrCubicEffect& ce = effect.cast<GrCubicEffect>();
|
||||
uint32_t key = ce.isAntiAliased() ? (ce.isFilled() ? 0x0 : 0x1) : 0x2;
|
||||
b->add32(key);
|
||||
}
|
||||
@ -460,7 +460,7 @@ GrCubicEffect::GrCubicEffect(GrEffectEdgeType edgeType)
|
||||
}
|
||||
|
||||
bool GrCubicEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrCubicEffect& ce = CastEffect<GrCubicEffect>(other);
|
||||
const GrCubicEffect& ce = other.cast<GrCubicEffect>();
|
||||
return (ce.fEdgeType == fEdgeType);
|
||||
}
|
||||
|
||||
|
@ -22,21 +22,21 @@ const SkScalar GrBicubicEffect::gMitchellCoefficients[16] = {
|
||||
class GrGLBicubicEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLBicubicEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&);
|
||||
const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>().domain();
|
||||
const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
|
||||
b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
|
||||
}
|
||||
|
||||
@ -50,18 +50,18 @@ private:
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLBicubicEffect::GrGLBicubicEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GrGLBicubicEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrTextureDomain& domain = drawEffect.castEffect<GrBicubicEffect>().domain();
|
||||
const GrTextureDomain& domain = effect.cast<GrBicubicEffect>().domain();
|
||||
|
||||
fCoefficientsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kMat44f_GrSLType, "Coefficients");
|
||||
@ -116,15 +116,15 @@ void GrGLBicubicEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLBicubicEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrBicubicEffect& effect = drawEffect.castEffect<GrBicubicEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrBicubicEffect& bicubicEffect = effect.cast<GrBicubicEffect>();
|
||||
const GrTexture& texture = *effect.texture(0);
|
||||
float imageIncrement[2];
|
||||
imageIncrement[0] = 1.0f / texture.width();
|
||||
imageIncrement[1] = 1.0f / texture.height();
|
||||
pdman.set2fv(fImageIncrementUni, 1, imageIncrement);
|
||||
pdman.setMatrix4f(fCoefficientsUni, effect.coefficients());
|
||||
fDomain.setData(pdman, effect.domain(), texture.origin());
|
||||
pdman.setMatrix4f(fCoefficientsUni, bicubicEffect.coefficients());
|
||||
fDomain.setData(pdman, bicubicEffect.domain(), texture.origin());
|
||||
}
|
||||
|
||||
static inline void convert_row_major_scalar_coeffs_to_column_major_floats(float dst[16],
|
||||
@ -163,7 +163,7 @@ const GrBackendEffectFactory& GrBicubicEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrBicubicEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrBicubicEffect& s = CastEffect<GrBicubicEffect>(sBase);
|
||||
const GrBicubicEffect& s = sBase.cast<GrBicubicEffect>();
|
||||
return this->textureAccess(0) == s.textureAccess(0) &&
|
||||
!memcmp(fCoefficients, s.coefficients(), 16) &&
|
||||
fDomain == s.fDomain;
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#include "GrSingleTextureEffect.h"
|
||||
#include "GrTextureDomain.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "gl/GrGLEffect.h"
|
||||
#include "GrTBackendEffectFactory.h"
|
||||
|
||||
|
@ -16,15 +16,15 @@
|
||||
class GrGLConfigConversionEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLConfigConversionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
const GrConfigConversionEffect& effect = drawEffect.castEffect<GrConfigConversionEffect>();
|
||||
fSwapRedAndBlue = effect.swapsRedAndBlue();
|
||||
fPMConversion = effect.pmConversion();
|
||||
const GrConfigConversionEffect& configConversionEffect = effect.cast<GrConfigConversionEffect>();
|
||||
fSwapRedAndBlue = configConversionEffect.swapsRedAndBlue();
|
||||
fPMConversion = configConversionEffect.pmConversion();
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -84,9 +84,9 @@ public:
|
||||
fsBuilder->codeAppend(modulate.c_str());
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrConfigConversionEffect& conv = drawEffect.castEffect<GrConfigConversionEffect>();
|
||||
const GrConfigConversionEffect& conv = effect.cast<GrConfigConversionEffect>();
|
||||
uint32_t key = (conv.swapsRedAndBlue() ? 0 : 1) | (conv.pmConversion() << 1);
|
||||
b->add32(key);
|
||||
}
|
||||
@ -119,7 +119,7 @@ const GrBackendEffectFactory& GrConfigConversionEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrConfigConversionEffect::onIsEqual(const GrEffect& s) const {
|
||||
const GrConfigConversionEffect& other = CastEffect<GrConfigConversionEffect>(s);
|
||||
const GrConfigConversionEffect& other = s.cast<GrConfigConversionEffect>();
|
||||
return this->texture(0) == s.texture(0) &&
|
||||
other.fSwapRedAndBlue == fSwapRedAndBlue &&
|
||||
other.fPMConversion == fPMConversion;
|
||||
|
@ -50,7 +50,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const AARectEffect& aare = CastEffect<AARectEffect>(other);
|
||||
const AARectEffect& aare = other.cast<AARectEffect>();
|
||||
return fRect == aare.fRect;
|
||||
}
|
||||
|
||||
@ -87,19 +87,19 @@ GrEffect* AARectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLAARectEffect : public GrGLEffect {
|
||||
public:
|
||||
GLAARectEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLAARectEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fRectUniform;
|
||||
@ -108,19 +108,19 @@ private:
|
||||
};
|
||||
|
||||
GLAARectEffect::GLAARectEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRect.fLeft = SK_ScalarNaN;
|
||||
}
|
||||
|
||||
void GLAARectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
|
||||
const AARectEffect& aare = effect.cast<AARectEffect>();
|
||||
const char *rectName;
|
||||
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
|
||||
// respectively.
|
||||
@ -157,8 +157,8 @@ void GLAARectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
|
||||
void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const AARectEffect& aare = effect.cast<AARectEffect>();
|
||||
const SkRect& rect = aare.getRect();
|
||||
if (rect != fPrevRect) {
|
||||
pdman.set4f(fRectUniform, rect.fLeft + 0.5f, rect.fTop + 0.5f,
|
||||
@ -167,9 +167,9 @@ void GLAARectEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEf
|
||||
}
|
||||
}
|
||||
|
||||
void GLAARectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLAARectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const AARectEffect& aare = drawEffect.castEffect<AARectEffect>();
|
||||
const AARectEffect& aare = effect.cast<AARectEffect>();
|
||||
b->add32(aare.getEdgeType());
|
||||
}
|
||||
|
||||
@ -181,19 +181,19 @@ const GrBackendEffectFactory& AARectEffect::getFactory() const {
|
||||
|
||||
class GrGLConvexPolyEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLConvexPolyEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLConvexPolyEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fEdgeUniform;
|
||||
@ -202,19 +202,19 @@ private:
|
||||
};
|
||||
|
||||
GrGLConvexPolyEffect::GrGLConvexPolyEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevEdges[0] = SK_ScalarNaN;
|
||||
}
|
||||
|
||||
void GrGLConvexPolyEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
|
||||
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
|
||||
|
||||
const char *edgeArrayName;
|
||||
fEdgeUniform = builder->addUniformArray(GrGLProgramBuilder::kFragment_Visibility,
|
||||
@ -249,8 +249,8 @@ void GrGLConvexPolyEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
|
||||
void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
|
||||
size_t byteSize = 3 * cpe.getEdgeCount() * sizeof(SkScalar);
|
||||
if (0 != memcmp(fPrevEdges, cpe.getEdges(), byteSize)) {
|
||||
pdman.set3fv(fEdgeUniform, cpe.getEdgeCount(), cpe.getEdges());
|
||||
@ -258,9 +258,9 @@ void GrGLConvexPolyEffect::setData(const GrGLProgramDataManager& pdman, const Gr
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLConvexPolyEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLConvexPolyEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrConvexPolyEffect& cpe = drawEffect.castEffect<GrConvexPolyEffect>();
|
||||
const GrConvexPolyEffect& cpe = effect.cast<GrConvexPolyEffect>();
|
||||
GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
|
||||
uint32_t key = (cpe.getEdgeCount() << 3) | cpe.getEdgeType();
|
||||
b->add32(key);
|
||||
@ -351,7 +351,7 @@ GrConvexPolyEffect::GrConvexPolyEffect(GrEffectEdgeType edgeType, int n, const S
|
||||
}
|
||||
|
||||
bool GrConvexPolyEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrConvexPolyEffect& cpe = CastEffect<GrConvexPolyEffect>(other);
|
||||
const GrConvexPolyEffect& cpe = other.cast<GrConvexPolyEffect>();
|
||||
// ignore the fact that 0 == -0 and just use memcmp.
|
||||
return (cpe.fEdgeType == fEdgeType && cpe.fEdgeCount == fEdgeCount &&
|
||||
0 == memcmp(cpe.fEdges, fEdges, 3 * fEdgeCount * sizeof(SkScalar)));
|
||||
|
@ -17,19 +17,19 @@ typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
|
||||
class GrGLConvolutionEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager& pdman, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
private:
|
||||
int width() const { return Gr1DKernelEffect::WidthFromRadius(fRadius); }
|
||||
@ -47,16 +47,16 @@ private:
|
||||
};
|
||||
|
||||
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory) {
|
||||
const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>();
|
||||
const GrConvolutionEffect& c = effect.cast<GrConvolutionEffect>();
|
||||
fRadius = c.radius();
|
||||
fUseBounds = c.useBounds();
|
||||
fDirection = c.direction();
|
||||
}
|
||||
|
||||
void GrGLConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -106,8 +106,8 @@ void GrGLConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrConvolutionEffect& conv = effect.cast<GrConvolutionEffect>();
|
||||
GrTexture& texture = *conv.texture(0);
|
||||
// the code we generated was for a specific kernel radius
|
||||
SkASSERT(conv.radius() == fRadius);
|
||||
@ -136,9 +136,9 @@ void GrGLConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
pdman.set1fv(fKernelUni, this->width(), conv.kernel());
|
||||
}
|
||||
|
||||
void GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLConvolutionEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>();
|
||||
const GrConvolutionEffect& conv = effect.cast<GrConvolutionEffect>();
|
||||
uint32_t key = conv.radius();
|
||||
key <<= 2;
|
||||
if (conv.useBounds()) {
|
||||
@ -201,7 +201,7 @@ const GrBackendEffectFactory& GrConvolutionEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrConvolutionEffect& s = CastEffect<GrConvolutionEffect>(sBase);
|
||||
const GrConvolutionEffect& s = sBase.cast<GrConvolutionEffect>();
|
||||
return (this->texture(0) == s.texture(0) &&
|
||||
this->radius() == s.radius() &&
|
||||
this->direction() == s.direction() &&
|
||||
|
@ -16,18 +16,18 @@
|
||||
|
||||
class GrGLCustomCoordsTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect& drawEffect)
|
||||
GrGLCustomCoordsTextureEffect(const GrBackendEffectFactory& factory, const GrEffect& effect)
|
||||
: INHERITED (factory) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const GrCustomCoordsTextureEffect& customCoordsTextureEffect =
|
||||
drawEffect.castEffect<GrCustomCoordsTextureEffect>();
|
||||
effect.cast<GrCustomCoordsTextureEffect>();
|
||||
SkASSERT(1 == customCoordsTextureEffect.getVertexAttribs().count());
|
||||
|
||||
SkString fsCoordName;
|
||||
@ -50,7 +50,7 @@ public:
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) SK_OVERRIDE {}
|
||||
const GrEffect& effect) SK_OVERRIDE {}
|
||||
|
||||
private:
|
||||
typedef GrGLGeometryProcessor INHERITED;
|
||||
@ -68,7 +68,7 @@ GrCustomCoordsTextureEffect::GrCustomCoordsTextureEffect(GrTexture* texture,
|
||||
}
|
||||
|
||||
bool GrCustomCoordsTextureEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrCustomCoordsTextureEffect& cte = CastEffect<GrCustomCoordsTextureEffect>(other);
|
||||
const GrCustomCoordsTextureEffect& cte = other.cast<GrCustomCoordsTextureEffect>();
|
||||
return fTextureAccess == cte.fTextureAccess;
|
||||
}
|
||||
|
||||
|
@ -478,19 +478,19 @@ private:
|
||||
|
||||
class GLDashingCircleEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingCircleEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLDashingCircleEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fParamUniform;
|
||||
@ -501,7 +501,7 @@ private:
|
||||
};
|
||||
|
||||
GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRadius = SK_ScalarMin;
|
||||
fPrevCenterX = SK_ScalarMin;
|
||||
@ -509,13 +509,13 @@ GLDashingCircleEffect::GLDashingCircleEffect(const GrBackendEffectFactory& facto
|
||||
}
|
||||
|
||||
void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const DashingCircleEffect& dce = drawEffect.castEffect<DashingCircleEffect>();
|
||||
const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
|
||||
const char *paramName;
|
||||
// The param uniforms, xyz, refer to circle radius - 0.5, cicles center x coord, and
|
||||
// the total interval length of the dash.
|
||||
@ -549,8 +549,8 @@ void GLDashingCircleEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const DashingCircleEffect& dce = drawEffect.castEffect<DashingCircleEffect>();
|
||||
void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
|
||||
SkScalar radius = dce.getRadius();
|
||||
SkScalar centerX = dce.getCenterX();
|
||||
SkScalar intervalLength = dce.getIntervalLength();
|
||||
@ -562,9 +562,9 @@ void GLDashingCircleEffect::setData(const GrGLProgramDataManager& pdman, const G
|
||||
}
|
||||
}
|
||||
|
||||
void GLDashingCircleEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLDashingCircleEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const DashingCircleEffect& dce = drawEffect.castEffect<DashingCircleEffect>();
|
||||
const DashingCircleEffect& dce = effect.cast<DashingCircleEffect>();
|
||||
b->add32(dce.getEdgeType());
|
||||
}
|
||||
|
||||
@ -603,7 +603,7 @@ DashingCircleEffect::DashingCircleEffect(GrEffectEdgeType edgeType, const DashIn
|
||||
}
|
||||
|
||||
bool DashingCircleEffect::onIsEqual(const GrEffect& other) const {
|
||||
const DashingCircleEffect& dce = CastEffect<DashingCircleEffect>(other);
|
||||
const DashingCircleEffect& dce = other.cast<DashingCircleEffect>();
|
||||
return (fEdgeType == dce.fEdgeType &&
|
||||
fIntervalLength == dce.fIntervalLength &&
|
||||
fRadius == dce.fRadius &&
|
||||
@ -688,19 +688,19 @@ private:
|
||||
|
||||
class GLDashingLineEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GLDashingLineEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLDashingLineEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fRectUniform;
|
||||
@ -711,20 +711,20 @@ private:
|
||||
};
|
||||
|
||||
GLDashingLineEffect::GLDashingLineEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRect.fLeft = SK_ScalarNaN;
|
||||
fPrevIntervalLength = SK_ScalarMax;
|
||||
}
|
||||
|
||||
void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const DashingLineEffect& de = drawEffect.castEffect<DashingLineEffect>();
|
||||
const DashingLineEffect& de = effect.cast<DashingLineEffect>();
|
||||
const char *rectName;
|
||||
// The rect uniform's xyzw refer to (left + 0.5, top + 0.5, right - 0.5, bottom - 0.5),
|
||||
// respectively.
|
||||
@ -770,8 +770,8 @@ void GLDashingLineEffect::emitCode(GrGLFullProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const DashingLineEffect& de = drawEffect.castEffect<DashingLineEffect>();
|
||||
void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const DashingLineEffect& de = effect.cast<DashingLineEffect>();
|
||||
const SkRect& rect = de.getRect();
|
||||
SkScalar intervalLength = de.getIntervalLength();
|
||||
if (rect != fPrevRect || intervalLength != fPrevIntervalLength) {
|
||||
@ -783,9 +783,9 @@ void GLDashingLineEffect::setData(const GrGLProgramDataManager& pdman, const GrD
|
||||
}
|
||||
}
|
||||
|
||||
void GLDashingLineEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLDashingLineEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const DashingLineEffect& de = drawEffect.castEffect<DashingLineEffect>();
|
||||
const DashingLineEffect& de = effect.cast<DashingLineEffect>();
|
||||
b->add32(de.getEdgeType());
|
||||
}
|
||||
|
||||
@ -825,7 +825,7 @@ DashingLineEffect::DashingLineEffect(GrEffectEdgeType edgeType, const DashInfo&
|
||||
}
|
||||
|
||||
bool DashingLineEffect::onIsEqual(const GrEffect& other) const {
|
||||
const DashingLineEffect& de = CastEffect<DashingLineEffect>(other);
|
||||
const DashingLineEffect& de = other.cast<DashingLineEffect>();
|
||||
return (fEdgeType == de.fEdgeType &&
|
||||
fRect == de.fRect &&
|
||||
fIntervalLength == de.fIntervalLength);
|
||||
|
@ -32,7 +32,7 @@
|
||||
class GrGLDistanceFieldTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldTextureEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory)
|
||||
, fTextureSize(SkISize::Make(-1,-1))
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
@ -41,14 +41,14 @@ public:
|
||||
{}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldTextureEffect>();
|
||||
effect.cast<GrDistanceFieldTextureEffect>();
|
||||
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
|
||||
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
@ -131,10 +131,10 @@ public:
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
SkASSERT(fTextureSizeUni.isValid());
|
||||
|
||||
GrTexture* texture = drawEffect.effect()->texture(0);
|
||||
GrTexture* texture = effect.texture(0);
|
||||
if (texture->width() != fTextureSize.width() ||
|
||||
texture->height() != fTextureSize.height()) {
|
||||
fTextureSize = SkISize::Make(texture->width(), texture->height());
|
||||
@ -144,7 +144,7 @@ public:
|
||||
}
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldTextureEffect>();
|
||||
effect.cast<GrDistanceFieldTextureEffect>();
|
||||
float luminance = dfTexEffect.getLuminance();
|
||||
if (luminance != fLuminance) {
|
||||
pdman.set1f(fLuminanceUni, luminance);
|
||||
@ -153,10 +153,10 @@ public:
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrDistanceFieldTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldTextureEffect>();
|
||||
effect.cast<GrDistanceFieldTextureEffect>();
|
||||
|
||||
b->add32(dfTexEffect.getFlags());
|
||||
}
|
||||
@ -197,7 +197,7 @@ GrDistanceFieldTextureEffect::GrDistanceFieldTextureEffect(GrTexture* texture,
|
||||
}
|
||||
|
||||
bool GrDistanceFieldTextureEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrDistanceFieldTextureEffect& cte = CastEffect<GrDistanceFieldTextureEffect>(other);
|
||||
const GrDistanceFieldTextureEffect& cte = other.cast<GrDistanceFieldTextureEffect>();
|
||||
return fTextureAccess == cte.fTextureAccess &&
|
||||
#ifdef SK_GAMMA_APPLY_TO_A8
|
||||
fGammaTextureAccess == cte.fGammaTextureAccess &&
|
||||
@ -264,20 +264,20 @@ GrEffect* GrDistanceFieldTextureEffect::TestCreate(SkRandom* random,
|
||||
class GrGLDistanceFieldLCDTextureEffect : public GrGLGeometryProcessor {
|
||||
public:
|
||||
GrGLDistanceFieldLCDTextureEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory)
|
||||
, fTextureSize(SkISize::Make(-1,-1))
|
||||
, fTextColor(GrColor_ILLEGAL) {}
|
||||
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldLCDTextureEffect>();
|
||||
effect.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
SkASSERT(1 == dfTexEffect.getVertexAttribs().count());
|
||||
|
||||
SkString fsCoordName;
|
||||
@ -400,13 +400,13 @@ public:
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
SkASSERT(fTextureSizeUni.isValid());
|
||||
SkASSERT(fTextColorUni.isValid());
|
||||
|
||||
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldLCDTextureEffect>();
|
||||
GrTexture* texture = drawEffect.effect()->texture(0);
|
||||
effect.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
GrTexture* texture = effect.texture(0);
|
||||
if (texture->width() != fTextureSize.width() ||
|
||||
texture->height() != fTextureSize.height()) {
|
||||
fTextureSize = SkISize::Make(texture->width(), texture->height());
|
||||
@ -431,10 +431,10 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static inline void GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
static inline void GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrDistanceFieldLCDTextureEffect& dfTexEffect =
|
||||
drawEffect.castEffect<GrDistanceFieldLCDTextureEffect>();
|
||||
effect.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
|
||||
b->add32(dfTexEffect.getFlags());
|
||||
}
|
||||
@ -469,8 +469,7 @@ GrDistanceFieldLCDTextureEffect::GrDistanceFieldLCDTextureEffect(
|
||||
}
|
||||
|
||||
bool GrDistanceFieldLCDTextureEffect::onIsEqual(const GrEffect& other) const {
|
||||
const GrDistanceFieldLCDTextureEffect& cte =
|
||||
CastEffect<GrDistanceFieldLCDTextureEffect>(other);
|
||||
const GrDistanceFieldLCDTextureEffect& cte = other.cast<GrDistanceFieldLCDTextureEffect>();
|
||||
return (fTextureAccess == cte.fTextureAccess &&
|
||||
fGammaTextureAccess == cte.fGammaTextureAccess &&
|
||||
fTextColor == cte.fTextColor &&
|
||||
|
@ -68,10 +68,10 @@ GrEffect* DitherEffect::TestCreate(SkRandom*,
|
||||
|
||||
class GLDitherEffect : public GrGLEffect {
|
||||
public:
|
||||
GLDitherEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLDitherEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -83,12 +83,12 @@ private:
|
||||
};
|
||||
|
||||
GLDitherEffect::GLDitherEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
void GLDitherEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -14,18 +14,18 @@
|
||||
class GrGLMatrixConvolutionEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& effect);
|
||||
const GrEffect& effect);
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
typedef GrGLProgramDataManager::UniformHandle UniformHandle;
|
||||
@ -44,22 +44,22 @@ private:
|
||||
};
|
||||
|
||||
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED(factory) {
|
||||
const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
|
||||
const GrMatrixConvolutionEffect& m = effect.cast<GrMatrixConvolutionEffect>();
|
||||
fKernelSize = m.kernelSize();
|
||||
fConvolveAlpha = m.convolveAlpha();
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
sk_ignore_unused_variable(inputColor);
|
||||
const GrTextureDomain& domain = drawEffect.castEffect<GrMatrixConvolutionEffect>().domain();
|
||||
const GrTextureDomain& domain = effect.cast<GrMatrixConvolutionEffect>().domain();
|
||||
|
||||
fBoundsUni = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
kVec4f_GrSLType, "Bounds");
|
||||
@ -120,9 +120,9 @@ void GrGLMatrixConvolutionEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
fsBuilder->codeAppend(modulate.c_str());
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
void GrGLMatrixConvolutionEffect::GenKey(const GrEffect& effect,
|
||||
const GrGLCaps&, GrEffectKeyBuilder* b) {
|
||||
const GrMatrixConvolutionEffect& m = drawEffect.castEffect<GrMatrixConvolutionEffect>();
|
||||
const GrMatrixConvolutionEffect& m = effect.cast<GrMatrixConvolutionEffect>();
|
||||
SkASSERT(m.kernelSize().width() <= 0x7FFF && m.kernelSize().height() <= 0xFFFF);
|
||||
uint32_t key = m.kernelSize().width() << 16 | m.kernelSize().height();
|
||||
key |= m.convolveAlpha() ? 1 << 31 : 0;
|
||||
@ -131,8 +131,8 @@ void GrGLMatrixConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrMatrixConvolutionEffect& conv = drawEffect.castEffect<GrMatrixConvolutionEffect>();
|
||||
const GrEffect& effect) {
|
||||
const GrMatrixConvolutionEffect& conv = effect.cast<GrMatrixConvolutionEffect>();
|
||||
GrTexture& texture = *conv.texture(0);
|
||||
// the code we generated was for a specific kernel size
|
||||
SkASSERT(conv.kernelSize() == fKernelSize);
|
||||
@ -178,7 +178,7 @@ const GrBackendEffectFactory& GrMatrixConvolutionEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrMatrixConvolutionEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrMatrixConvolutionEffect& s = CastEffect<GrMatrixConvolutionEffect>(sBase);
|
||||
const GrMatrixConvolutionEffect& s = sBase.cast<GrMatrixConvolutionEffect>();
|
||||
return this->texture(0) == s.texture(0) &&
|
||||
fKernelSize == s.kernelSize() &&
|
||||
!memcmp(fKernel, s.kernel(),
|
||||
|
@ -71,7 +71,7 @@ CircleEffect::CircleEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScalar
|
||||
}
|
||||
|
||||
bool CircleEffect::onIsEqual(const GrEffect& other) const {
|
||||
const CircleEffect& ce = CastEffect<CircleEffect>(other);
|
||||
const CircleEffect& ce = other.cast<CircleEffect>();
|
||||
return fEdgeType == ce.fEdgeType && fCenter == ce.fCenter && fRadius == ce.fRadius;
|
||||
}
|
||||
|
||||
@ -98,19 +98,19 @@ GrEffect* CircleEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLCircleEffect : public GrGLEffect {
|
||||
public:
|
||||
GLCircleEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLCircleEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fCircleUniform;
|
||||
@ -121,19 +121,19 @@ private:
|
||||
};
|
||||
|
||||
GLCircleEffect::GLCircleEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRadius = -1.f;
|
||||
}
|
||||
|
||||
void GLCircleEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
|
||||
const CircleEffect& ce = effect.cast<CircleEffect>();
|
||||
const char *circleName;
|
||||
// The circle uniform is (center.x, center.y, radius + 0.5) for regular fills and
|
||||
// (... ,radius - 0.5) for inverse fills.
|
||||
@ -163,14 +163,14 @@ void GLCircleEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("d")).c_str());
|
||||
}
|
||||
|
||||
void GLCircleEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLCircleEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
|
||||
const CircleEffect& ce = effect.cast<CircleEffect>();
|
||||
b->add32(ce.getEdgeType());
|
||||
}
|
||||
|
||||
void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const CircleEffect& ce = drawEffect.castEffect<CircleEffect>();
|
||||
void GLCircleEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const CircleEffect& ce = effect.cast<CircleEffect>();
|
||||
if (ce.getRadius() != fPrevRadius || ce.getCenter() != fPrevCenter) {
|
||||
SkScalar radius = ce.getRadius();
|
||||
if (GrEffectEdgeTypeIsInverseFill(ce.getEdgeType())) {
|
||||
@ -244,7 +244,7 @@ EllipseEffect::EllipseEffect(GrEffectEdgeType edgeType, const SkPoint& c, SkScal
|
||||
}
|
||||
|
||||
bool EllipseEffect::onIsEqual(const GrEffect& other) const {
|
||||
const EllipseEffect& ee = CastEffect<EllipseEffect>(other);
|
||||
const EllipseEffect& ee = other.cast<EllipseEffect>();
|
||||
return fEdgeType == ee.fEdgeType && fCenter == ee.fCenter && fRadii == ee.fRadii;
|
||||
}
|
||||
|
||||
@ -272,19 +272,19 @@ GrEffect* EllipseEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLEllipseEffect : public GrGLEffect {
|
||||
public:
|
||||
GLEllipseEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLEllipseEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fEllipseUniform;
|
||||
@ -295,19 +295,19 @@ private:
|
||||
};
|
||||
|
||||
GLEllipseEffect::GLEllipseEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRadii.fX = -1.f;
|
||||
}
|
||||
|
||||
void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const EllipseEffect& ee = drawEffect.castEffect<EllipseEffect>();
|
||||
const EllipseEffect& ee = effect.cast<EllipseEffect>();
|
||||
const char *ellipseName;
|
||||
// The ellipse uniform is (center.x, center.y, 1 / rx^2, 1 / ry^2)
|
||||
fEllipseUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
@ -350,14 +350,14 @@ void GLEllipseEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLEllipseEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLEllipseEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const EllipseEffect& ee = drawEffect.castEffect<EllipseEffect>();
|
||||
const EllipseEffect& ee = effect.cast<EllipseEffect>();
|
||||
b->add32(ee.getEdgeType());
|
||||
}
|
||||
|
||||
void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrDrawEffect& drawEffect) {
|
||||
const EllipseEffect& ee = drawEffect.castEffect<EllipseEffect>();
|
||||
void GLEllipseEffect::setData(const GrGLProgramDataManager& pdman, const GrEffect& effect) {
|
||||
const EllipseEffect& ee = effect.cast<EllipseEffect>();
|
||||
if (ee.getRadii() != fPrevRadii || ee.getCenter() != fPrevCenter) {
|
||||
SkScalar invRXSqd = 1.f / (ee.getRadii().fX * ee.getRadii().fX);
|
||||
SkScalar invRYSqd = 1.f / (ee.getRadii().fY * ee.getRadii().fY);
|
||||
|
@ -102,7 +102,7 @@ CircularRRectEffect::CircularRRectEffect(GrEffectEdgeType edgeType, uint32_t cir
|
||||
}
|
||||
|
||||
bool CircularRRectEffect::onIsEqual(const GrEffect& other) const {
|
||||
const CircularRRectEffect& crre = CastEffect<CircularRRectEffect>(other);
|
||||
const CircularRRectEffect& crre = other.cast<CircularRRectEffect>();
|
||||
// The corner flags are derived from fRRect, so no need to check them.
|
||||
return fEdgeType == crre.fEdgeType && fRRect == crre.fRRect;
|
||||
}
|
||||
@ -132,19 +132,19 @@ GrEffect* CircularRRectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLCircularRRectEffect : public GrGLEffect {
|
||||
public:
|
||||
GLCircularRRectEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLCircularRRectEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fInnerRectUniform;
|
||||
@ -154,19 +154,19 @@ private:
|
||||
};
|
||||
|
||||
GLCircularRRectEffect::GLCircularRRectEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRRect.setEmpty();
|
||||
}
|
||||
|
||||
void GLCircularRRectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const CircularRRectEffect& crre = drawEffect.castEffect<CircularRRectEffect>();
|
||||
const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
|
||||
const char *rectName;
|
||||
const char *radiusPlusHalfName;
|
||||
// The inner rect is the rrect bounds inset by the radius. Its left, top, right, and bottom
|
||||
@ -293,16 +293,16 @@ void GLCircularRRectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLCircularRRectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLCircularRRectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const CircularRRectEffect& crre = drawEffect.castEffect<CircularRRectEffect>();
|
||||
const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
|
||||
GR_STATIC_ASSERT(kGrEffectEdgeTypeCnt <= 8);
|
||||
b->add32((crre.getCircularCornerFlags() << 3) | crre.getEdgeType());
|
||||
}
|
||||
|
||||
void GLCircularRRectEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const CircularRRectEffect& crre = drawEffect.castEffect<CircularRRectEffect>();
|
||||
const GrEffect& effect) {
|
||||
const CircularRRectEffect& crre = effect.cast<CircularRRectEffect>();
|
||||
const SkRRect& rrect = crre.getRRect();
|
||||
if (rrect != fPrevRRect) {
|
||||
SkRect rect = rrect.getBounds();
|
||||
@ -436,7 +436,7 @@ EllipticalRRectEffect::EllipticalRRectEffect(GrEffectEdgeType edgeType, const Sk
|
||||
}
|
||||
|
||||
bool EllipticalRRectEffect::onIsEqual(const GrEffect& other) const {
|
||||
const EllipticalRRectEffect& erre = CastEffect<EllipticalRRectEffect>(other);
|
||||
const EllipticalRRectEffect& erre = other.cast<EllipticalRRectEffect>();
|
||||
return fEdgeType == erre.fEdgeType && fRRect == erre.fRRect;
|
||||
}
|
||||
|
||||
@ -486,19 +486,19 @@ GrEffect* EllipticalRRectEffect::TestCreate(SkRandom* random,
|
||||
|
||||
class GLEllipticalRRectEffect : public GrGLEffect {
|
||||
public:
|
||||
GLEllipticalRRectEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GLEllipticalRRectEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
private:
|
||||
GrGLProgramDataManager::UniformHandle fInnerRectUniform;
|
||||
@ -508,19 +508,19 @@ private:
|
||||
};
|
||||
|
||||
GLEllipticalRRectEffect::GLEllipticalRRectEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect& drawEffect)
|
||||
const GrEffect& effect)
|
||||
: INHERITED (factory) {
|
||||
fPrevRRect.setEmpty();
|
||||
}
|
||||
|
||||
void GLEllipticalRRectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEffect>();
|
||||
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
|
||||
const char *rectName;
|
||||
// The inner rect is the rrect bounds inset by the x/y radii
|
||||
fInnerRectUniform = builder->addUniform(GrGLProgramBuilder::kFragment_Visibility,
|
||||
@ -590,16 +590,16 @@ void GLEllipticalRRectEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
(GrGLSLExpr4(inputColor) * GrGLSLExpr1("alpha")).c_str());
|
||||
}
|
||||
|
||||
void GLEllipticalRRectEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GLEllipticalRRectEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEffect>();
|
||||
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
|
||||
GR_STATIC_ASSERT(kLast_GrEffectEdgeType < (1 << 3));
|
||||
b->add32(erre.getRRect().getType() | erre.getEdgeType() << 3);
|
||||
}
|
||||
|
||||
void GLEllipticalRRectEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const EllipticalRRectEffect& erre = drawEffect.castEffect<EllipticalRRectEffect>();
|
||||
const GrEffect& effect) {
|
||||
const EllipticalRRectEffect& erre = effect.cast<EllipticalRRectEffect>();
|
||||
const SkRRect& rrect = erre.getRRect();
|
||||
if (rrect != fPrevRRect) {
|
||||
SkRect rect = rrect.getBounds();
|
||||
|
@ -15,12 +15,12 @@
|
||||
|
||||
class GrGLSimpleTextureEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrDrawEffect&)
|
||||
GrGLSimpleTextureEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& other) const SK_OVERRIDE {
|
||||
const GrSimpleTextureEffect& ste = CastEffect<GrSimpleTextureEffect>(other);
|
||||
const GrSimpleTextureEffect& ste = other.cast<GrSimpleTextureEffect>();
|
||||
return this->hasSameTextureParamsMatrixAndSourceCoords(ste);
|
||||
}
|
||||
|
||||
|
@ -167,19 +167,19 @@ void GrTextureDomain::GLDomain::setData(const GrGLProgramDataManager& pdman,
|
||||
|
||||
class GrGLTextureDomainEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
|
||||
GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray&,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) SK_OVERRIDE;
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) SK_OVERRIDE;
|
||||
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
|
||||
private:
|
||||
GrTextureDomain::GLDomain fGLDomain;
|
||||
@ -187,19 +187,19 @@ private:
|
||||
};
|
||||
|
||||
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&)
|
||||
const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TransformedCoordsArray& coords,
|
||||
const TextureSamplerArray& samplers) {
|
||||
const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = effect.textureDomain();
|
||||
const GrTextureDomainEffect& textureDomainEffect = effect.cast<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
|
||||
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
|
||||
@ -207,15 +207,15 @@ void GrGLTextureDomainEffect::emitCode(GrGLProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLTextureDomainEffect::setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) {
|
||||
const GrTextureDomainEffect& effect = drawEffect.castEffect<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = effect.textureDomain();
|
||||
const GrEffect& effect) {
|
||||
const GrTextureDomainEffect& textureDomainEffect = effect.cast<GrTextureDomainEffect>();
|
||||
const GrTextureDomain& domain = textureDomainEffect.textureDomain();
|
||||
fGLDomain.setData(pdman, domain, effect.texture(0)->origin());
|
||||
}
|
||||
|
||||
void GrGLTextureDomainEffect::GenKey(const GrDrawEffect& drawEffect, const GrGLCaps&,
|
||||
void GrGLTextureDomainEffect::GenKey(const GrEffect& effect, const GrGLCaps&,
|
||||
GrEffectKeyBuilder* b) {
|
||||
const GrTextureDomain& domain = drawEffect.castEffect<GrTextureDomainEffect>().textureDomain();
|
||||
const GrTextureDomain& domain = effect.cast<GrTextureDomainEffect>().textureDomain();
|
||||
b->add32(GrTextureDomain::GLDomain::DomainKey(domain));
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ const GrBackendEffectFactory& GrTextureDomainEffect::getFactory() const {
|
||||
}
|
||||
|
||||
bool GrTextureDomainEffect::onIsEqual(const GrEffect& sBase) const {
|
||||
const GrTextureDomainEffect& s = CastEffect<GrTextureDomainEffect>(sBase);
|
||||
const GrTextureDomainEffect& s = sBase.cast<GrTextureDomainEffect>();
|
||||
return this->hasSameTextureParamsMatrixAndSourceCoords(s) &&
|
||||
this->fTextureDomain == s.fTextureDomain;
|
||||
}
|
||||
|
@ -45,15 +45,15 @@ public:
|
||||
static const GrGLfloat kRec601ConversionMatrix[16];
|
||||
|
||||
// this class always generates the same code.
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
|
||||
GLEffect(const GrBackendEffectFactory& factory,
|
||||
const GrDrawEffect&)
|
||||
const GrEffect&)
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect&,
|
||||
const GrEffectKey&,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -75,8 +75,8 @@ public:
|
||||
}
|
||||
|
||||
virtual void setData(const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect) SK_OVERRIDE {
|
||||
const YUVtoRGBEffect& yuvEffect = drawEffect.castEffect<YUVtoRGBEffect>();
|
||||
const GrEffect& effect) SK_OVERRIDE {
|
||||
const YUVtoRGBEffect& yuvEffect = effect.cast<YUVtoRGBEffect>();
|
||||
switch (yuvEffect.getColorSpace()) {
|
||||
case kJPEG_SkYUVColorSpace:
|
||||
pdman.setMatrix4f(fMatrixUni, kJPEGConversionMatrix);
|
||||
@ -110,7 +110,7 @@ private:
|
||||
}
|
||||
|
||||
virtual bool onIsEqual(const GrEffect& sBase) const {
|
||||
const YUVtoRGBEffect& s = CastEffect<YUVtoRGBEffect>(sBase);
|
||||
const YUVtoRGBEffect& s = sBase.cast<YUVtoRGBEffect>();
|
||||
return fYAccess.getTexture() == s.fYAccess.getTexture() &&
|
||||
fUAccess.getTexture() == s.fUAccess.getTexture() &&
|
||||
fVAccess.getTexture() == s.fVAccess.getTexture() &&
|
||||
|
@ -20,19 +20,16 @@ class GrGLShaderBuilder;
|
||||
include/gpu/GrEffect.h. Objects of type GrGLEffect are responsible for emitting the
|
||||
GLSL code that implements a GrEffect and for uploading uniforms at draw time. If they don't
|
||||
always emit the same GLSL code, they must have a function:
|
||||
static inline void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
|
||||
static inline void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*)
|
||||
that is used to implement a program cache. When two GrEffects produce the same key this means
|
||||
that their GrGLEffects would emit the same GLSL code.
|
||||
|
||||
The GrGLEffect subclass must also have a constructor of the form:
|
||||
EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrDrawEffect&)
|
||||
The effect held by the GrDrawEffect is guaranteed to be of the type that generated the
|
||||
GrGLEffect subclass instance.
|
||||
EffectSubclass::EffectSubclass(const GrBackendEffectFactory&, const GrEffect&)
|
||||
|
||||
These objects are created by the factory object returned by the GrEffect::getFactory().
|
||||
*/
|
||||
|
||||
class GrDrawEffect;
|
||||
class GrGLTexture;
|
||||
class GrGLGeometryProcessor;
|
||||
|
||||
@ -55,7 +52,7 @@ public:
|
||||
stages.
|
||||
|
||||
@param builder Interface used to emit code in the shaders.
|
||||
@param drawEffect A wrapper on the effect that generated this program stage.
|
||||
@param effect The effect that generated this program stage.
|
||||
@param key The key that was computed by GenKey() from the generating GrEffect.
|
||||
@param outputColor A predefined vec4 in the FS in which the stage should place its output
|
||||
color (or coverage).
|
||||
@ -69,7 +66,7 @@ public:
|
||||
reads in the generated code.
|
||||
*/
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -78,16 +75,16 @@ public:
|
||||
|
||||
/** A GrGLEffect instance can be reused with any GrEffect that produces the same stage
|
||||
key; this function reads data from a GrEffect and uploads any uniform variables required
|
||||
by the shaders created in emitCode(). The GrEffect installed in the GrDrawEffect is
|
||||
by the shaders created in emitCode(). The GrEffect is
|
||||
guaranteed to be of the same type that created this GrGLEffect and to have an identical
|
||||
effect key as the one that created this GrGLEffect. Effects that use local coords have
|
||||
to consider whether the GrEffectStage's coord change matrix should be used. When explicit
|
||||
local coordinates are used it can be ignored. */
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrDrawEffect&) {}
|
||||
virtual void setData(const GrGLProgramDataManager&, const GrEffect&) {}
|
||||
|
||||
const char* name() const { return fFactory.name(); }
|
||||
|
||||
static void GenKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
static void GenKey(const GrEffect&, const GrGLCaps&, GrEffectKeyBuilder*) {}
|
||||
|
||||
/** Used by the system when generating shader code, to see if this effect can be downcasted to
|
||||
the internal GrGLGeometryProcessor type */
|
||||
|
@ -25,7 +25,7 @@ public:
|
||||
* This allows the effect subclass to emit vertex code.
|
||||
*/
|
||||
virtual void emitCode(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
@ -35,7 +35,7 @@ public:
|
||||
* Provide a default override for base class's emitCode() function.
|
||||
*/
|
||||
virtual void emitCode(GrGLProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffect& effect,
|
||||
const GrEffectKey& key,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "GrAllocator.h"
|
||||
#include "GrEffect.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "GrGLEffect.h"
|
||||
#include "GrGpuGL.h"
|
||||
#include "GrGLPathRendering.h"
|
||||
|
@ -8,7 +8,6 @@
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrGLProgramDesc.h"
|
||||
#include "GrBackendEffectFactory.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "GrEffect.h"
|
||||
#include "GrGpuGL.h"
|
||||
#include "GrOptDrawState.h"
|
||||
@ -24,24 +23,27 @@ bool GrGLProgramDesc::GetEffectKeyAndUpdateStats(const GrEffectStage& stage,
|
||||
bool* setTrueIfReadsPos,
|
||||
bool* setTrueIfRequiresVertexShader) {
|
||||
const GrBackendEffectFactory& factory = stage.getEffect()->getFactory();
|
||||
GrDrawEffect drawEffect(stage, useExplicitLocalCoords);
|
||||
if (stage.getEffect()->willReadDstColor()) {
|
||||
const GrEffect& effect = *stage.getEffect();
|
||||
if (effect.willReadDstColor()) {
|
||||
*setTrueIfReadsDst = true;
|
||||
}
|
||||
if (stage.getEffect()->willReadFragmentPosition()) {
|
||||
if (effect.willReadFragmentPosition()) {
|
||||
*setTrueIfReadsPos = true;
|
||||
}
|
||||
if (stage.getEffect()->requiresVertexShader()) {
|
||||
if (effect.requiresVertexShader()) {
|
||||
*setTrueIfRequiresVertexShader = true;
|
||||
}
|
||||
factory.getGLEffectKey(drawEffect, caps, b);
|
||||
factory.getGLEffectKey(effect, caps, b);
|
||||
size_t size = b->size();
|
||||
if (size > SK_MaxU16) {
|
||||
*effectKeySize = 0; // suppresses a warning.
|
||||
return false;
|
||||
}
|
||||
*effectKeySize = SkToU16(size);
|
||||
if (!GrGLProgramEffects::GenEffectMetaKey(drawEffect, caps, b)) {
|
||||
if (!GrGLProgramEffects::GenEffectMetaKey(stage,
|
||||
useExplicitLocalCoords,
|
||||
caps,
|
||||
b)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
#include "GrGLProgramEffects.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "gl/GrGLEffect.h"
|
||||
#include "gl/GrGLPathRendering.h"
|
||||
#include "gl/builders/GrGLProgramBuilder.h"
|
||||
@ -89,15 +88,17 @@ GrCoordSet get_source_coords(uint32_t transformKey, int transformIdx) {
|
||||
/**
|
||||
* Retrieves the final matrix that a transform needs to apply to its source coords.
|
||||
*/
|
||||
SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx) {
|
||||
const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(transformIdx);
|
||||
SkMatrix get_transform_matrix(const GrEffectStage& effectStage,
|
||||
bool useExplicitLocalCoords,
|
||||
int transformIdx) {
|
||||
const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(transformIdx);
|
||||
SkMatrix combined;
|
||||
|
||||
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
|
||||
// If we have explicit local coords then we shouldn't need a coord change.
|
||||
SkASSERT(!drawEffect.programHasExplicitLocalCoords() ||
|
||||
drawEffect.getCoordChangeMatrix().isIdentity());
|
||||
combined.setConcat(coordTransform.getMatrix(), drawEffect.getCoordChangeMatrix());
|
||||
const SkMatrix& ccm =
|
||||
useExplicitLocalCoords ? SkMatrix::I() : effectStage.getCoordChangeMatrix();
|
||||
combined.setConcat(coordTransform.getMatrix(), ccm);
|
||||
} else {
|
||||
combined = coordTransform.getMatrix();
|
||||
}
|
||||
@ -113,18 +114,19 @@ SkMatrix get_transform_matrix(const GrDrawEffect& drawEffect, int transformIdx)
|
||||
}
|
||||
return combined;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps,
|
||||
bool GrGLProgramEffects::GenEffectMetaKey(const GrEffectStage& effectStage,
|
||||
bool useExplicitLocalCoords,
|
||||
const GrGLCaps& caps,
|
||||
GrEffectKeyBuilder* b) {
|
||||
|
||||
uint32_t textureKey = GrGLProgramEffects::GenTextureKey(drawEffect, caps);
|
||||
uint32_t transformKey = GrGLProgramEffects::GenTransformKey(drawEffect);
|
||||
uint32_t attribKey = GrGLProgramEffects::GenAttribKey(drawEffect.castEffect<GrEffect>());
|
||||
uint32_t classID = drawEffect.effect()->getFactory().effectClassID();
|
||||
uint32_t textureKey = GrGLProgramEffects::GenTextureKey(effectStage.getEffect(), caps);
|
||||
uint32_t transformKey = GrGLProgramEffects::GenTransformKey(effectStage,useExplicitLocalCoords);
|
||||
uint32_t attribKey = GrGLProgramEffects::GenAttribKey(effectStage.getEffect());
|
||||
uint32_t classID = effectStage.getEffect()->getFactory().effectClassID();
|
||||
|
||||
// Currently we allow 16 bits for each of the above portions of the meta-key. Fail if they
|
||||
// don't fit.
|
||||
@ -139,10 +141,10 @@ bool GrGLProgramEffects::GenEffectMetaKey(const GrDrawEffect& drawEffect, const
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect& effect) {
|
||||
uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect* effect) {
|
||||
uint32_t key = 0;
|
||||
|
||||
const GrEffect::VertexAttribArray& vars = effect.getVertexAttribs();
|
||||
const GrEffect::VertexAttribArray& vars = effect->getVertexAttribs();
|
||||
int numAttributes = vars.count();
|
||||
SkASSERT(numAttributes <= 2);
|
||||
for (int a = 0; a < numAttributes; ++a) {
|
||||
@ -152,25 +154,23 @@ uint32_t GrGLProgramEffects::GenAttribKey(const GrEffect& effect) {
|
||||
return key;
|
||||
}
|
||||
|
||||
uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
|
||||
uint32_t GrGLProgramEffects::GenTransformKey(const GrEffectStage& effectStage,
|
||||
bool useExplicitLocalCoords) {
|
||||
uint32_t totalKey = 0;
|
||||
int numTransforms = drawEffect.effect()->numTransforms();
|
||||
int numTransforms = effectStage.getEffect()->numTransforms();
|
||||
for (int t = 0; t < numTransforms; ++t) {
|
||||
uint32_t key = 0;
|
||||
const GrCoordTransform& coordTransform = drawEffect.effect()->coordTransform(t);
|
||||
const GrCoordTransform& coordTransform = effectStage.getEffect()->coordTransform(t);
|
||||
SkMatrix::TypeMask type0 = coordTransform.getMatrix().getType();
|
||||
SkMatrix::TypeMask type1;
|
||||
if (kLocal_GrCoordSet == coordTransform.sourceCoords()) {
|
||||
type1 = drawEffect.getCoordChangeMatrix().getType();
|
||||
} else {
|
||||
if (drawEffect.programHasExplicitLocalCoords()) {
|
||||
SkMatrix::TypeMask type1 = SkMatrix::kIdentity_Mask;
|
||||
if (kLocal_GrCoordSet == coordTransform.sourceCoords() && !useExplicitLocalCoords) {
|
||||
type1 = effectStage.getCoordChangeMatrix().getType();
|
||||
} else if (kPosition_GrCoordSet == coordTransform.sourceCoords() && useExplicitLocalCoords) {
|
||||
// We only make the key indicate that device coords are referenced when the local coords
|
||||
// are not actually determined by positions. Otherwise the local coords var and position
|
||||
// var are identical.
|
||||
key |= kPositionCoords_Flag;
|
||||
}
|
||||
type1 = SkMatrix::kIdentity_Mask;
|
||||
}
|
||||
|
||||
int combinedTypes = type0 | type1;
|
||||
|
||||
@ -186,11 +186,11 @@ uint32_t GrGLProgramEffects::GenTransformKey(const GrDrawEffect& drawEffect) {
|
||||
return totalKey;
|
||||
}
|
||||
|
||||
uint32_t GrGLProgramEffects::GenTextureKey(const GrDrawEffect& drawEffect, const GrGLCaps& caps) {
|
||||
uint32_t GrGLProgramEffects::GenTextureKey(const GrEffect* effect, const GrGLCaps& caps) {
|
||||
uint32_t key = 0;
|
||||
int numTextures = drawEffect.effect()->numTextures();
|
||||
int numTextures = effect->numTextures();
|
||||
for (int t = 0; t < numTextures; ++t) {
|
||||
const GrTextureAccess& access = drawEffect.effect()->textureAccess(t);
|
||||
const GrTextureAccess& access = effect->textureAccess(t);
|
||||
uint32_t configComponentMask = GrPixelConfigComponentMask(access.getTexture()->config());
|
||||
if (swizzle_requires_alpha_remapping(caps, configComponentMask, access.swizzleMask())) {
|
||||
key |= 1 << t;
|
||||
@ -207,10 +207,10 @@ GrGLProgramEffects::~GrGLProgramEffects() {
|
||||
}
|
||||
|
||||
void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder,
|
||||
const GrEffect* effect,
|
||||
const GrEffect& effect,
|
||||
TextureSamplerArray* outSamplers) {
|
||||
SkTArray<Sampler, true>& samplers = fSamplers.push_back();
|
||||
int numTextures = effect->numTextures();
|
||||
int numTextures = effect.numTextures();
|
||||
samplers.push_back_n(numTextures);
|
||||
SkString name;
|
||||
for (int t = 0; t < numTextures; ++t) {
|
||||
@ -219,7 +219,7 @@ void GrGLProgramEffects::emitSamplers(GrGLProgramBuilder* builder,
|
||||
kSampler2D_GrSLType,
|
||||
name.c_str());
|
||||
SkNEW_APPEND_TO_TARRAY(outSamplers, TextureSampler,
|
||||
(samplers[t].fUniform, effect->textureAccess(t)));
|
||||
(samplers[t].fUniform, effect.textureAccess(t)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -237,13 +237,13 @@ void GrGLProgramEffects::initSamplers(const GrGLProgramDataManager& programResou
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect* effect, int effectIdx) {
|
||||
void GrGLProgramEffects::bindTextures(GrGpuGL* gpu, const GrEffect& effect, int effectIdx) {
|
||||
const SkTArray<Sampler, true>& samplers = fSamplers[effectIdx];
|
||||
int numSamplers = samplers.count();
|
||||
SkASSERT(numSamplers == effect->numTextures());
|
||||
SkASSERT(numSamplers == effect.numTextures());
|
||||
for (int s = 0; s < numSamplers; ++s) {
|
||||
SkASSERT(samplers[s].fTextureUnit >= 0);
|
||||
const GrTextureAccess& textureAccess = effect->textureAccess(s);
|
||||
const GrTextureAccess& textureAccess = effect.textureAccess(s);
|
||||
gpu->bindTexture(samplers[s].fTextureUnit,
|
||||
textureAccess.getParams(),
|
||||
static_cast<GrGLTexture*>(textureAccess.getTexture()));
|
||||
@ -258,18 +258,17 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
|
||||
const char* outColor,
|
||||
const char* inColor,
|
||||
int stageIndex) {
|
||||
GrDrawEffect drawEffect(stage, fHasExplicitLocalCoords);
|
||||
const GrEffect* effect = stage.getEffect();
|
||||
SkSTArray<2, TransformedCoords> coords(effect->numTransforms());
|
||||
SkSTArray<4, TextureSampler> samplers(effect->numTextures());
|
||||
const GrEffect& effect = *stage.getEffect();
|
||||
SkSTArray<2, TransformedCoords> coords(effect.numTransforms());
|
||||
SkSTArray<4, TextureSampler> samplers(effect.numTextures());
|
||||
|
||||
GrGLVertexShaderBuilder* vsBuilder = builder->getVertexShaderBuilder();
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
vsBuilder->emitAttributes(stage);
|
||||
this->emitTransforms(builder, drawEffect, &coords);
|
||||
this->emitTransforms(builder, stage, &coords);
|
||||
this->emitSamplers(builder, effect, &samplers);
|
||||
|
||||
GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect);
|
||||
GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
|
||||
fGLEffects.push_back(glEffect);
|
||||
|
||||
// Enclose custom code in a block to avoid namespace conflicts
|
||||
@ -280,9 +279,9 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
|
||||
|
||||
if (glEffect->isVertexEffect()) {
|
||||
GrGLGeometryProcessor* vertexEffect = static_cast<GrGLGeometryProcessor*>(glEffect);
|
||||
vertexEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
|
||||
vertexEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
|
||||
} else {
|
||||
glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
|
||||
glEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
|
||||
}
|
||||
|
||||
vsBuilder->codeAppend("\t}\n");
|
||||
@ -290,11 +289,11 @@ void GrGLVertexProgramEffects::emitEffect(GrGLFullProgramBuilder* builder,
|
||||
}
|
||||
|
||||
void GrGLVertexProgramEffects::emitTransforms(GrGLFullProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffectStage& effectStage,
|
||||
TransformedCoordsArray* outCoords) {
|
||||
SkTArray<Transform, true>& transforms = fTransforms.push_back();
|
||||
uint32_t totalKey = GenTransformKey(drawEffect);
|
||||
int numTransforms = drawEffect.effect()->numTransforms();
|
||||
uint32_t totalKey = GenTransformKey(effectStage, fHasExplicitLocalCoords);
|
||||
int numTransforms = effectStage.getEffect()->numTransforms();
|
||||
transforms.push_back_n(numTransforms);
|
||||
|
||||
SkTArray<PathTransform, true>* pathTransforms = NULL;
|
||||
@ -375,15 +374,16 @@ void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
|
||||
SkASSERT(numEffects == fTransforms.count());
|
||||
SkASSERT(numEffects == fSamplers.count());
|
||||
for (int e = 0; e < numEffects; ++e) {
|
||||
GrDrawEffect drawEffect(*effectStages[e], fHasExplicitLocalCoords);
|
||||
fGLEffects[e]->setData(programDataManager, drawEffect);
|
||||
const GrEffectStage& effectStage = *effectStages[e];
|
||||
const GrEffect& effect = *effectStage.getEffect();
|
||||
fGLEffects[e]->setData(programDataManager, effect);
|
||||
if (GrGpu::IsPathRenderingDrawType(drawType)) {
|
||||
this->setPathTransformData(gpu, programDataManager, drawEffect, e);
|
||||
this->setPathTransformData(gpu, programDataManager, effectStage, e);
|
||||
} else {
|
||||
this->setTransformData(gpu, programDataManager, drawEffect, e);
|
||||
this->setTransformData(gpu, programDataManager, effectStage, e);
|
||||
}
|
||||
|
||||
this->bindTextures(gpu, drawEffect.effect(), e);
|
||||
this->bindTextures(gpu, effect, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -394,27 +394,27 @@ void GrGLVertexProgramEffects::setData(GrGpuGL* gpu,
|
||||
SkASSERT(1 == fTransforms.count());
|
||||
SkASSERT(1 == fSamplers.count());
|
||||
SkASSERT(1 == fGLEffects.count());
|
||||
GrDrawEffect drawEffect(*effectStage, fHasExplicitLocalCoords);
|
||||
fGLEffects[0]->setData(programDataManager, drawEffect);
|
||||
const GrEffect& effect = *effectStage->getEffect();
|
||||
fGLEffects[0]->setData(programDataManager, effect);
|
||||
if (GrGpu::IsPathRenderingDrawType(drawType)) {
|
||||
this->setPathTransformData(gpu, programDataManager, drawEffect, 0);
|
||||
this->setPathTransformData(gpu, programDataManager, *effectStage, 0);
|
||||
} else {
|
||||
this->setTransformData(gpu, programDataManager, drawEffect, 0);
|
||||
this->setTransformData(gpu, programDataManager, *effectStage, 0);
|
||||
}
|
||||
|
||||
this->bindTextures(gpu, drawEffect.effect(), 0);
|
||||
this->bindTextures(gpu, effect, 0);
|
||||
}
|
||||
|
||||
void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
|
||||
const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffectStage& effectStage,
|
||||
int effectIdx) {
|
||||
SkTArray<Transform, true>& transforms = fTransforms[effectIdx];
|
||||
int numTransforms = transforms.count();
|
||||
SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
|
||||
SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
|
||||
for (int t = 0; t < numTransforms; ++t) {
|
||||
SkASSERT(transforms[t].fHandle.isValid());
|
||||
const SkMatrix& matrix = get_transform_matrix(drawEffect, t);
|
||||
const SkMatrix& matrix = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
|
||||
if (!transforms[t].fCurrentValue.cheapEqualTo(matrix)) {
|
||||
pdman.setSkMatrix(transforms[t].fHandle, matrix);
|
||||
transforms[t].fCurrentValue = matrix;
|
||||
@ -424,14 +424,14 @@ void GrGLVertexProgramEffects::setTransformData(GrGpuGL* gpu,
|
||||
|
||||
void GrGLVertexProgramEffects::setPathTransformData(GrGpuGL* gpu,
|
||||
const GrGLProgramDataManager& pdman,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffectStage& effectStage,
|
||||
int effectIdx) {
|
||||
SkTArray<PathTransform, true>& transforms = fPathTransforms[effectIdx];
|
||||
int numTransforms = transforms.count();
|
||||
SkASSERT(numTransforms == drawEffect.effect()->numTransforms());
|
||||
SkASSERT(numTransforms == effectStage.getEffect()->numTransforms());
|
||||
for (int t = 0; t < numTransforms; ++t) {
|
||||
SkASSERT(transforms[t].fHandle.isValid());
|
||||
const SkMatrix& transform = get_transform_matrix(drawEffect, t);
|
||||
const SkMatrix& transform = get_transform_matrix(effectStage, fHasExplicitLocalCoords, t);
|
||||
if (transforms[t].fCurrentValue.cheapEqualTo(transform)) {
|
||||
continue;
|
||||
}
|
||||
@ -473,16 +473,15 @@ void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyProgramBuilder* bu
|
||||
const char* outColor,
|
||||
const char* inColor,
|
||||
int stageIndex) {
|
||||
GrDrawEffect drawEffect(stage, false);
|
||||
const GrEffect* effect = stage.getEffect();
|
||||
SkSTArray<2, TransformedCoords> coords(effect->numTransforms());
|
||||
SkSTArray<4, TextureSampler> samplers(effect->numTextures());
|
||||
const GrEffect& effect = *stage.getEffect();
|
||||
SkSTArray<2, TransformedCoords> coords(effect.numTransforms());
|
||||
SkSTArray<4, TextureSampler> samplers(effect.numTextures());
|
||||
|
||||
SkASSERT(0 == effect->getVertexAttribs().count());
|
||||
this->setupPathTexGen(builder, drawEffect, &coords);
|
||||
SkASSERT(0 == effect.getVertexAttribs().count());
|
||||
this->setupPathTexGen(builder, stage, &coords);
|
||||
this->emitSamplers(builder, effect, &samplers);
|
||||
|
||||
GrGLEffect* glEffect = effect->getFactory().createGLInstance(drawEffect);
|
||||
GrGLEffect* glEffect = effect.getFactory().createGLInstance(effect);
|
||||
fGLEffects.push_back(glEffect);
|
||||
|
||||
GrGLFragmentShaderBuilder* fsBuilder = builder->getFragmentShaderBuilder();
|
||||
@ -492,16 +491,16 @@ void GrGLPathTexGenProgramEffects::emitEffect(GrGLFragmentOnlyProgramBuilder* bu
|
||||
fsBuilder->codeAppend(openBrace.c_str());
|
||||
|
||||
SkASSERT(!glEffect->isVertexEffect());
|
||||
glEffect->emitCode(builder, drawEffect, key, outColor, inColor, coords, samplers);
|
||||
glEffect->emitCode(builder, effect, key, outColor, inColor, coords, samplers);
|
||||
|
||||
fsBuilder->codeAppend("\t}\n");
|
||||
}
|
||||
|
||||
void GrGLPathTexGenProgramEffects::setupPathTexGen(GrGLFragmentOnlyProgramBuilder* builder,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffectStage& effectStage,
|
||||
TransformedCoordsArray* outCoords) {
|
||||
int numTransforms = drawEffect.effect()->numTransforms();
|
||||
uint32_t totalKey = GenTransformKey(drawEffect);
|
||||
int numTransforms = effectStage.getEffect()->numTransforms();
|
||||
uint32_t totalKey = GenTransformKey(effectStage, false);
|
||||
int texCoordIndex = builder->addTexCoordSets(numTransforms);
|
||||
SkNEW_APPEND_TO_TARRAY(&fTransforms, Transforms, (totalKey, texCoordIndex));
|
||||
SkString name;
|
||||
@ -522,23 +521,24 @@ void GrGLPathTexGenProgramEffects::setData(GrGpuGL* gpu,
|
||||
SkASSERT(numEffects == fTransforms.count());
|
||||
SkASSERT(numEffects == fSamplers.count());
|
||||
for (int e = 0; e < numEffects; ++e) {
|
||||
GrDrawEffect drawEffect(*effectStages[e], false);
|
||||
fGLEffects[e]->setData(pdman, drawEffect);
|
||||
this->setPathTexGenState(gpu, drawEffect, e);
|
||||
this->bindTextures(gpu, drawEffect.effect(), e);
|
||||
const GrEffectStage& effectStage = *effectStages[e];
|
||||
const GrEffect& effect = *effectStage.getEffect();
|
||||
fGLEffects[e]->setData(pdman, effect);
|
||||
this->setPathTexGenState(gpu, effectStage, e);
|
||||
this->bindTextures(gpu, effect, e);
|
||||
}
|
||||
}
|
||||
|
||||
void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
|
||||
const GrDrawEffect& drawEffect,
|
||||
const GrEffectStage& effectStage,
|
||||
int effectIdx) {
|
||||
uint32_t totalKey = fTransforms[effectIdx].fTransformKey;
|
||||
int texCoordIndex = fTransforms[effectIdx].fTexCoordIndex;
|
||||
int numTransforms = drawEffect.effect()->numTransforms();
|
||||
int numTransforms = effectStage.getEffect()->numTransforms();
|
||||
for (int t = 0; t < numTransforms; ++t) {
|
||||
switch (get_matrix_type(totalKey, t)) {
|
||||
case kNoPersp_MatrixType: {
|
||||
const SkMatrix& transform = get_transform_matrix(drawEffect, t);
|
||||
const SkMatrix& transform = get_transform_matrix(effectStage, false, t);
|
||||
gpu->glPathRendering()->enablePathTexGen(
|
||||
texCoordIndex++,
|
||||
GrGLPathRendering::kST_PathTexGenComponents,
|
||||
@ -546,7 +546,7 @@ void GrGLPathTexGenProgramEffects::setPathTexGenState(GrGpuGL* gpu,
|
||||
break;
|
||||
}
|
||||
case kGeneral_MatrixType: {
|
||||
const SkMatrix& transform = get_transform_matrix(drawEffect, t);
|
||||
const SkMatrix& transform = get_transform_matrix(effectStage, false, t);
|
||||
gpu->glPathRendering()->enablePathTexGen(
|
||||
texCoordIndex++,
|
||||
GrGLPathRendering::kSTR_PathTexGenComponents,
|
||||
|
@ -39,7 +39,10 @@ public:
|
||||
* which must be different for every GrEffect subclass. It can fail if an effect uses too many
|
||||
* textures, attributes, etc for the space allotted in the meta-key.
|
||||
*/
|
||||
static bool GenEffectMetaKey(const GrDrawEffect&, const GrGLCaps&, GrEffectKeyBuilder*);
|
||||
static bool GenEffectMetaKey(const GrEffectStage&,
|
||||
bool,
|
||||
const GrGLCaps&,
|
||||
GrEffectKeyBuilder*);
|
||||
|
||||
virtual ~GrGLProgramEffects();
|
||||
|
||||
@ -114,9 +117,9 @@ protected:
|
||||
/**
|
||||
* Helpers for GenEffectMetaKey.
|
||||
*/
|
||||
static uint32_t GenAttribKey(const GrEffect&);
|
||||
static uint32_t GenTransformKey(const GrDrawEffect&);
|
||||
static uint32_t GenTextureKey(const GrDrawEffect&, const GrGLCaps&);
|
||||
static uint32_t GenAttribKey(const GrEffect*);
|
||||
static uint32_t GenTransformKey(const GrEffectStage&, bool useExplicitLocalCoords);
|
||||
static uint32_t GenTextureKey(const GrEffect*, const GrGLCaps&);
|
||||
|
||||
GrGLProgramEffects(int reserveCount)
|
||||
: fGLEffects(reserveCount)
|
||||
@ -128,12 +131,12 @@ protected:
|
||||
* appends the necessary data to the TextureSamplerArray* object so effects can add texture
|
||||
* lookups to their code. This method is only meant to be called during the construction phase.
|
||||
*/
|
||||
void emitSamplers(GrGLProgramBuilder*, const GrEffect*, TextureSamplerArray*);
|
||||
void emitSamplers(GrGLProgramBuilder*, const GrEffect&, TextureSamplerArray*);
|
||||
|
||||
/**
|
||||
* Helper for setData(). Binds all the textures for an effect.
|
||||
*/
|
||||
void bindTextures(GrGpuGL*, const GrEffect*, int effectIdx);
|
||||
void bindTextures(GrGpuGL*, const GrEffect&, int effectIdx);
|
||||
|
||||
struct Sampler {
|
||||
SkDEBUGCODE(Sampler() : fTextureUnit(-1) {})
|
||||
@ -212,14 +215,15 @@ private:
|
||||
* TransformedCoordsArray* object, which is in turn passed to the effect's emitCode() function.
|
||||
*/
|
||||
void emitTransforms(GrGLFullProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffectStage&,
|
||||
TransformedCoordsArray*);
|
||||
|
||||
/**
|
||||
* Helper for setData(). Sets all the transform matrices for an effect.
|
||||
*/
|
||||
void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrDrawEffect&, int effectIdx);
|
||||
void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrDrawEffect&,
|
||||
void setTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
|
||||
int effectIdx);
|
||||
void setPathTransformData(GrGpuGL* gpu, const GrGLProgramDataManager&, const GrEffectStage&,
|
||||
int effectIdx);
|
||||
|
||||
struct Transform {
|
||||
@ -307,13 +311,13 @@ private:
|
||||
* effect's emitCode() function.
|
||||
*/
|
||||
void setupPathTexGen(GrGLFragmentOnlyProgramBuilder*,
|
||||
const GrDrawEffect&,
|
||||
const GrEffectStage&,
|
||||
TransformedCoordsArray*);
|
||||
|
||||
/**
|
||||
* Helper for setData(). Sets the PathTexGen state for each transform in an effect.
|
||||
*/
|
||||
void setPathTexGenState(GrGpuGL*, const GrDrawEffect&, int effectIdx);
|
||||
void setPathTexGenState(GrGpuGL*, const GrEffectStage&, int effectIdx);
|
||||
|
||||
struct Transforms {
|
||||
Transforms(uint32_t transformKey, int texCoordIndex)
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "gl/GrGLSLPrettyPrint.h"
|
||||
#include "gl/GrGLUniformHandle.h"
|
||||
#include "GrCoordTransform.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "../GrGpuGL.h"
|
||||
#include "GrGLFragmentShaderBuilder.h"
|
||||
#include "GrGLProgramBuilder.h"
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include "GrBackendEffectFactory.h"
|
||||
#include "GrContextFactory.h"
|
||||
#include "GrDrawEffect.h"
|
||||
#include "effects/GrConfigConversionEffect.h"
|
||||
#include "gl/GrGLPathRendering.h"
|
||||
#include "gl/GrGpuGL.h"
|
||||
@ -56,7 +55,6 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
|
||||
fKey.reset();
|
||||
return false;
|
||||
}
|
||||
GrDrawEffect drawEffect(*stage, useLocalCoords);
|
||||
GrEffectKeyBuilder b(&fKey);
|
||||
uint16_t effectKeySize;
|
||||
if (!GetEffectKeyAndUpdateStats(*stage, gpu->glCaps(), useLocalCoords, &b,
|
||||
@ -79,7 +77,6 @@ bool GrGLProgramDesc::setRandom(SkRandom* random,
|
||||
fKey.reset();
|
||||
return false;
|
||||
}
|
||||
GrDrawEffect drawEffect(*stage, useLocalCoords);
|
||||
GrEffectKeyBuilder b(&fKey);
|
||||
uint16_t effectKeySize;
|
||||
if (!GetEffectKeyAndUpdateStats(*stage, gpu->glCaps(), useLocalCoords, &b,
|
||||
|
Loading…
Reference in New Issue
Block a user