Make a bunch of GrGLEffects derive directly from GrGLEffect rather than GrGLLegacyEffect.
Review URL: https://codereview.appspot.com/6783053 git-svn-id: http://skia.googlecode.com/svn/branches/gpu_dev@6150 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
parent
4d3f8b40e3
commit
22a800a257
@ -110,24 +110,24 @@ bool SkBlendImageFilter::onFilterImage(Proxy* proxy,
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if SK_SUPPORT_GPU
|
||||
class GrGLBlendEffect : public GrGLLegacyEffect {
|
||||
class GrGLBlendEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLBlendEffect(const GrBackendEffectFactory& factory,
|
||||
const GrEffect& effect);
|
||||
virtual ~GrGLBlendEffect();
|
||||
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
const char* vertexCoords) SK_OVERRIDE {}
|
||||
virtual void emitCode(GrGLShaderBuilder*,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps&);
|
||||
|
||||
private:
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
SkBlendImageFilter::Mode fMode;
|
||||
};
|
||||
|
||||
@ -245,10 +245,13 @@ GrGLBlendEffect::GrGLBlendEffect(const GrBackendEffectFactory& factory,
|
||||
GrGLBlendEffect::~GrGLBlendEffect() {
|
||||
}
|
||||
|
||||
void GrGLBlendEffect::emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
void GrGLBlendEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
SkString* code = &builder->fFSCode;
|
||||
const char* bgColor = inputColor;
|
||||
const char* fgColor = "fgColor";
|
||||
|
@ -339,7 +339,7 @@ public:
|
||||
|
||||
GR_DECLARE_EFFECT_TEST;
|
||||
|
||||
class GLEffect : public GrGLLegacyEffect {
|
||||
class GLEffect : public GrGLEffect {
|
||||
public:
|
||||
// this class always generates the same code.
|
||||
static EffectKey GenKey(const GrEffect& s, const GrGLCaps&) { return 0; }
|
||||
@ -351,22 +351,20 @@ public:
|
||||
, fVectorHandle(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
}
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE {
|
||||
virtual void emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE {
|
||||
fMatrixHandle = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kMat44f_GrSLType,
|
||||
"ColorMatrix");
|
||||
fVectorHandle = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec4f_GrSLType,
|
||||
"ColorMatrixVector");
|
||||
}
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder, const char* vertexCoords) SK_OVERRIDE {
|
||||
}
|
||||
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE {
|
||||
if (NULL == inputColor) {
|
||||
// could optimize this case, but we aren't for now.
|
||||
inputColor = GrGLSLOnesVecf(4);
|
||||
@ -410,7 +408,7 @@ public:
|
||||
private:
|
||||
SkColorMatrix fMatrix;
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GR_DEFINE_EFFECT_TEST(ColorMatrixEffect);
|
||||
|
@ -279,17 +279,17 @@ private:
|
||||
typedef GrSingleTextureEffect INHERITED;
|
||||
};
|
||||
|
||||
class GrGLMatrixConvolutionEffect : public GrGLLegacyEffect {
|
||||
class GrGLMatrixConvolutionEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrEffect& effect);
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) SK_OVERRIDE {}
|
||||
virtual void emitFS(GrGLShaderBuilder* state,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void emitCode(GrGLShaderBuilder*,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
static inline EffectKey GenKey(const GrEffect& s, const GrGLCaps& caps);
|
||||
|
||||
@ -308,7 +308,7 @@ private:
|
||||
UniformHandle fGainUni;
|
||||
UniformHandle fBiasUni;
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFactory& factory,
|
||||
@ -325,19 +325,6 @@ GrGLMatrixConvolutionEffect::GrGLMatrixConvolutionEffect(const GrBackendEffectFa
|
||||
fConvolveAlpha = m.convolveAlpha();
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::setupVariables(GrGLShaderBuilder* builder) {
|
||||
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec2f_GrSLType, "ImageIncrement");
|
||||
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Kernel", fKernelSize.width() * fKernelSize.height());
|
||||
fTargetUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec2f_GrSLType, "Target");
|
||||
fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Gain");
|
||||
fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Bias");
|
||||
}
|
||||
|
||||
static void appendTextureLookup(GrGLShaderBuilder* builder,
|
||||
const GrGLShaderBuilder::TextureSampler& sampler,
|
||||
const char* coord,
|
||||
@ -360,10 +347,25 @@ static void appendTextureLookup(GrGLShaderBuilder* builder,
|
||||
builder->appendTextureLookup(code, sampler, coord);
|
||||
}
|
||||
|
||||
void GrGLMatrixConvolutionEffect::emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
void GrGLMatrixConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
|
||||
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec2f_GrSLType, "ImageIncrement");
|
||||
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Kernel", fKernelSize.width() * fKernelSize.height());
|
||||
fTargetUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec2f_GrSLType, "Target");
|
||||
fGainUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Gain");
|
||||
fBiasUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kFloat_GrSLType, "Bias");
|
||||
|
||||
SkString* code = &builder->fFSCode;
|
||||
|
||||
const char* target = builder->getUniformCStr(fTargetUni);
|
||||
|
@ -244,18 +244,18 @@ private:
|
||||
typedef GrEffect INHERITED;
|
||||
};
|
||||
|
||||
class GLColorTableEffect : public GrGLLegacyEffect {
|
||||
class GLColorTableEffect : public GrGLEffect {
|
||||
public:
|
||||
GLColorTableEffect(const GrBackendEffectFactory& factory,
|
||||
const GrEffect& effect);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* state) SK_OVERRIDE {}
|
||||
virtual void emitVS(GrGLShaderBuilder* state,
|
||||
const char* vertexCoords) SK_OVERRIDE {}
|
||||
virtual void emitFS(GrGLShaderBuilder* state,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void emitCode(GrGLShaderBuilder*,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE {}
|
||||
|
||||
@ -263,7 +263,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GLColorTableEffect::GLColorTableEffect(
|
||||
@ -271,10 +271,14 @@ GLColorTableEffect::GLColorTableEffect(
|
||||
: INHERITED(factory) {
|
||||
}
|
||||
|
||||
void GLColorTableEffect::emitFS(GrGLShaderBuilder* builder,
|
||||
void GLColorTableEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
|
||||
static const float kColorScaleFactor = 255.0f / 256.0f;
|
||||
static const float kColorOffsetFactor = 1.0f / 512.0f;
|
||||
SkString* code = &builder->fFSCode;
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "GrConfigConversionEffect.h"
|
||||
#include "gl/GrGLEffect.h"
|
||||
|
||||
class GrGLConfigConversionEffect : public GrGLLegacyEffect {
|
||||
class GrGLConfigConversionEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLConfigConversionEffect(const GrBackendEffectFactory& factory,
|
||||
const GrEffect& s) : INHERITED (factory) {
|
||||
@ -17,12 +17,13 @@ public:
|
||||
fPMConversion = effect.pmConversion();
|
||||
}
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
const char* vertexCoords) SK_OVERRIDE { }
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
virtual void emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
builder->fFSCode.appendf("\t\t%s = ", outputColor);
|
||||
builder->appendTextureLookup(&builder->fFSCode, samplers[0]);
|
||||
builder->fFSCode.append(";\n");
|
||||
@ -67,7 +68,7 @@ private:
|
||||
bool fSwapRedAndBlue;
|
||||
GrConfigConversionEffect::PMConversion fPMConversion;
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
|
||||
};
|
||||
|
||||
|
@ -12,18 +12,20 @@
|
||||
#include "GrBackendEffectFactory.h"
|
||||
#include "GrTexture.h"
|
||||
|
||||
class GrGLSingleTextureEffect : public GrGLLegacyEffect {
|
||||
class GrGLSingleTextureEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLSingleTextureEffect(const GrBackendEffectFactory& factory, const GrEffect&)
|
||||
: INHERITED (factory) {
|
||||
}
|
||||
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
const char* vertexCoords) SK_OVERRIDE { }
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
virtual void emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) SK_OVERRIDE {
|
||||
|
||||
builder->fFSCode.appendf("\t%s = ", outputColor);
|
||||
builder->appendTextureLookupAndModulate(&builder->fFSCode, inputColor, samplers[0]);
|
||||
builder->fFSCode.append(";\n");
|
||||
@ -33,7 +35,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -9,17 +9,17 @@
|
||||
#include "gl/GrGLEffect.h"
|
||||
#include "GrBackendEffectFactory.h"
|
||||
|
||||
class GrGLTextureDomainEffect : public GrGLLegacyEffect {
|
||||
class GrGLTextureDomainEffect : public GrGLEffect {
|
||||
public:
|
||||
GrGLTextureDomainEffect(const GrBackendEffectFactory&, const GrEffect&);
|
||||
|
||||
virtual void setupVariables(GrGLShaderBuilder* builder) SK_OVERRIDE;
|
||||
virtual void emitVS(GrGLShaderBuilder* builder,
|
||||
const char* vertexCoords) SK_OVERRIDE { }
|
||||
virtual void emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
virtual void emitCode(GrGLShaderBuilder*,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray&) SK_OVERRIDE;
|
||||
|
||||
virtual void setData(const GrGLUniformManager&, const GrEffectStage&) SK_OVERRIDE;
|
||||
|
||||
@ -28,7 +28,7 @@ public:
|
||||
private:
|
||||
GrGLUniformManager::UniformHandle fNameUni;
|
||||
|
||||
typedef GrGLLegacyEffect INHERITED;
|
||||
typedef GrGLEffect INHERITED;
|
||||
};
|
||||
|
||||
GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& factory,
|
||||
@ -37,15 +37,17 @@ GrGLTextureDomainEffect::GrGLTextureDomainEffect(const GrBackendEffectFactory& f
|
||||
, fNameUni(GrGLUniformManager::kInvalidUniformHandle) {
|
||||
}
|
||||
|
||||
void GrGLTextureDomainEffect::setupVariables(GrGLShaderBuilder* builder) {
|
||||
void GrGLTextureDomainEffect::emitCode(GrGLShaderBuilder* builder,
|
||||
const GrEffect&,
|
||||
EffectKey,
|
||||
const char* vertexCoords,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
|
||||
fNameUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
|
||||
kVec4f_GrSLType, "TexDom");
|
||||
};
|
||||
|
||||
void GrGLTextureDomainEffect::emitFS(GrGLShaderBuilder* builder,
|
||||
const char* outputColor,
|
||||
const char* inputColor,
|
||||
const TextureSamplerArray& samplers) {
|
||||
builder->fFSCode.appendf("\tvec2 clampCoord = clamp(%s, %s.xy, %s.zw);\n",
|
||||
builder->defaultTexCoordsName(),
|
||||
builder->getUniformCStr(fNameUni),
|
||||
|
Loading…
Reference in New Issue
Block a user