// For brevity
typedef GrGLUniformManager::UniformHandle UniformHandle;
-class GrGLMagnifierEffect : public GrGLLegacyEffect {
+class GrGLMagnifierEffect : public GrGLEffect {
public:
GrGLMagnifierEffect(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& uman, const GrEffectStage& stage) SK_OVERRIDE;
UniformHandle fZoomVar;
UniformHandle fInsetVar;
- typedef GrGLLegacyEffect INHERITED;
+ typedef GrGLEffect INHERITED;
};
GrGLMagnifierEffect::GrGLMagnifierEffect(const GrBackendEffectFactory& factory,
, fInsetVar(GrGLUniformManager::kInvalidUniformHandle) {
}
-void GrGLMagnifierEffect::setupVariables(GrGLShaderBuilder* state) {
- fOffsetVar = state->addUniform(
+void GrGLMagnifierEffect::emitCode(GrGLShaderBuilder* builder,
+ const GrEffect&,
+ EffectKey,
+ const char* vertexCoords,
+ const char* outputColor,
+ const char* inputColor,
+ const TextureSamplerArray& samplers) {
+ fOffsetVar = builder->addUniform(
GrGLShaderBuilder::kFragment_ShaderType |
GrGLShaderBuilder::kVertex_ShaderType,
kVec2f_GrSLType, "uOffset");
- fZoomVar = state->addUniform(
+ fZoomVar = builder->addUniform(
GrGLShaderBuilder::kFragment_ShaderType |
GrGLShaderBuilder::kVertex_ShaderType,
kVec2f_GrSLType, "uZoom");
- fInsetVar = state->addUniform(
+ fInsetVar = builder->addUniform(
GrGLShaderBuilder::kFragment_ShaderType |
GrGLShaderBuilder::kVertex_ShaderType,
kVec2f_GrSLType, "uInset");
-}
-
-void GrGLMagnifierEffect::emitVS(GrGLShaderBuilder* state,
- const char* vertexCoords) {
-}
-void GrGLMagnifierEffect::emitFS(GrGLShaderBuilder* state,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) {
- SkString* code = &state->fFSCode;
+ SkString* code = &builder->fFSCode;
- code->appendf("\t\tvec2 coord = %s;\n", state->defaultTexCoordsName());
+ code->appendf("\t\tvec2 coord = %s;\n", builder->defaultTexCoordsName());
code->appendf("\t\tvec2 zoom_coord = %s + %s / %s;\n",
- state->getUniformCStr(fOffsetVar),
- state->defaultTexCoordsName(),
- state->getUniformCStr(fZoomVar));
+ builder->getUniformCStr(fOffsetVar),
+ builder->defaultTexCoordsName(),
+ builder->getUniformCStr(fZoomVar));
code->appendf("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n");
- code->appendf(
- "\t\tdelta = delta / %s;\n", state->getUniformCStr(fInsetVar));
+ code->appendf("\t\tdelta = delta / %s;\n", builder->getUniformCStr(fInsetVar));
code->appendf("\t\tfloat weight = 0.0;\n");
code->appendf("\t\tif (delta.s < 2.0 && delta.t < 2.0) {\n");
code->appendf("\t\t\tweight = min(dist * dist, 1.0);\n");
code->appendf("\t\t} else {\n");
code->appendf("\t\t\tvec2 delta_squared = delta * delta;\n");
- code->appendf(
- "\t\t\tweight = min(min(delta_squared.s, delta_squared.y), 1.0);\n");
+ code->appendf("\t\t\tweight = min(min(delta_squared.s, delta_squared.y), 1.0);\n");
code->appendf("\t\t}\n");
code->appendf("\t\tvec2 mix_coord = mix(coord, zoom_coord, weight);\n");
code->appendf("\t\tvec4 output_color = ");
- state->appendTextureLookup(code, samplers[0], "mix_coord");
+ builder->appendTextureLookup(code, samplers[0], "mix_coord");
code->append(";\n");
code->appendf("\t\t%s = output_color;", outputColor);
///////////////////////////////////////////////////////////////////////////////
-class GrGLMorphologyEffect : public GrGLLegacyEffect {
+class GrGLMorphologyEffect : public GrGLEffect {
public:
GrGLMorphologyEffect (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);
GrMorphologyEffect::MorphologyType fType;
GrGLUniformManager::UniformHandle fImageIncrementUni;
- typedef GrGLLegacyEffect INHERITED;
+ typedef GrGLEffect INHERITED;
};
GrGLMorphologyEffect::GrGLMorphologyEffect(const GrBackendEffectFactory& factory,
fType = m.type();
}
-void GrGLMorphologyEffect::setupVariables(GrGLShaderBuilder* builder) {
+void GrGLMorphologyEffect::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");
-}
-void GrGLMorphologyEffect::emitFS(GrGLShaderBuilder* builder,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) {
SkString* code = &builder->fFSCode;
const char* func;
typedef GrGLUniformManager::UniformHandle UniformHandle;
static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle;
-class GrGLConvolutionEffect : public GrGLLegacyEffect {
+class GrGLConvolutionEffect : public GrGLEffect {
public:
GrGLConvolutionEffect(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& uman, const GrEffectStage&) SK_OVERRIDE;
UniformHandle fKernelUni;
UniformHandle fImageIncrementUni;
- typedef GrGLLegacyEffect INHERITED;
+ typedef GrGLEffect INHERITED;
};
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& factory,
fRadius = c.radius();
}
-void GrGLConvolutionEffect::setupVariables(GrGLShaderBuilder* builder) {
+void GrGLConvolutionEffect::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", this->width());
-}
-
-void GrGLConvolutionEffect::emitFS(GrGLShaderBuilder* builder,
- const char* outputColor,
- const char* inputColor,
- const TextureSamplerArray& samplers) {
SkString* code = &builder->fFSCode;
code->appendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);