Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(184)

Unified Diff: src/gpu/effects/GrConvolutionEffect.cpp

Issue 23018003: Rename GrGLUniformManager to GrGLUniform and ref GrGLUniforms directly Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/effects/GrConvolutionEffect.cpp
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index e7fb8e5403d9c6bc60c6f2a923d252c83e757b6d..7c06c063e3dea602c0a7bcb5ae6cb09b5f8184dd 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -12,10 +12,6 @@
#include "gl/GrGLTexture.h"
#include "GrTBackendEffectFactory.h"
-// For brevity
-typedef GrGLUniformManager::UniformHandle UniformHandle;
-static const UniformHandle kInvalidUniformHandle = GrGLUniformManager::kInvalidUniformHandle;
-
class GrGLConvolutionEffect : public GrGLEffect {
public:
GrGLConvolutionEffect(const GrBackendEffectFactory&, const GrDrawEffect&);
@@ -27,7 +23,7 @@ public:
const char* inputColor,
const TextureSamplerArray&) SK_OVERRIDE;
- virtual void setData(const GrGLUniformManager& uman, const GrDrawEffect&) SK_OVERRIDE;
+ virtual void setData(const GrGLContext& context, const GrDrawEffect&) SK_OVERRIDE;
static inline EffectKey GenKey(const GrDrawEffect&, const GrGLCaps&);
@@ -39,9 +35,9 @@ private:
int fRadius;
bool fUseBounds;
Gr1DKernelEffect::Direction fDirection;
- UniformHandle fKernelUni;
- UniformHandle fImageIncrementUni;
- UniformHandle fBoundsUni;
+ GrGLUniform* fKernelUni;
+ GrGLUniform* fImageIncrementUni;
+ GrGLUniform* fBoundsUni;
GrGLEffectMatrix fEffectMatrix;
typedef GrGLEffect INHERITED;
@@ -50,9 +46,9 @@ private:
GrGLConvolutionEffect::GrGLConvolutionEffect(const GrBackendEffectFactory& factory,
const GrDrawEffect& drawEffect)
: INHERITED(factory)
- , fKernelUni(kInvalidUniformHandle)
- , fImageIncrementUni(kInvalidUniformHandle)
- , fBoundsUni(kInvalidUniformHandle)
+ , fKernelUni(NULL)
+ , fImageIncrementUni(NULL)
+ , fBoundsUni(NULL)
, fEffectMatrix(drawEffect.castEffect<GrConvolutionEffect>().coordsType()) {
const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>();
fRadius = c.radius();
@@ -68,39 +64,46 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
const TextureSamplerArray& samplers) {
const char* coords;
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
- fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
- kVec2f_GrSLType, "ImageIncrement");
+ GrGLShaderBuilder::Uniform* imageIncrementUni =
+ builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
+ kVec2f_GrSLType, "ImageIncrement");
+ fImageIncrementUni = imageIncrementUni->glUniform();
+
+ GrGLShaderBuilder::Uniform* boundsUni = NULL;
+
if (this->useBounds()) {
- fBoundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
- kVec2f_GrSLType, "Bounds");
+ boundsUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
+ kVec2f_GrSLType, "Bounds");
+ fBoundsUni = boundsUni->glUniform();
}
- fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
- kFloat_GrSLType, "Kernel", this->width());
+
+ GrGLShaderBuilder::Uniform* kernelUni =
+ builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
+ kFloat_GrSLType, "Kernel", this->width());
+ fKernelUni = kernelUni->glUniform();
builder->fsCodeAppendf("\t\t%s = vec4(0, 0, 0, 0);\n", outputColor);
int width = this->width();
- const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
- const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
- builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imgInc);
+ builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imageIncrementUni->c_str());
// Manually unroll loop because some drivers don't; yields 20-30% speedup.
for (int i = 0; i < width; i++) {
SkString index;
SkString kernelIndex;
index.appendS32(i);
- kernel.appendArrayAccess(index.c_str(), &kernelIndex);
+ kernelUni->appendArrayAccess(index.c_str(), &kernelIndex);
builder->fsCodeAppendf("\t\t%s += ", outputColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "coord");
if (this->useBounds()) {
- const char* bounds = builder->getUniformCStr(fBoundsUni);
+ const char* bounds = boundsUni->c_str();
const char* component = this->direction() == Gr1DKernelEffect::kY_Direction ? "y" : "x";
builder->fsCodeAppendf(" * float(coord.%s >= %s.x && coord.%s <= %s.y)",
component, bounds, component, bounds);
}
builder->fsCodeAppendf(" * %s;\n", kernelIndex.c_str());
- builder->fsCodeAppendf("\t\tcoord += %s;\n", imgInc);
+ builder->fsCodeAppendf("\t\tcoord += %s;\n", imageIncrementUni->c_str());
}
SkString modulate;
@@ -108,7 +111,7 @@ void GrGLConvolutionEffect::emitCode(GrGLShaderBuilder* builder,
builder->fsCodeAppend(modulate.c_str());
}
-void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
+void GrGLConvolutionEffect::setData(const GrGLContext& context,
const GrDrawEffect& drawEffect) {
const GrConvolutionEffect& conv = drawEffect.castEffect<GrConvolutionEffect>();
GrTexture& texture = *conv.texture(0);
@@ -126,18 +129,18 @@ void GrGLConvolutionEffect::setData(const GrGLUniformManager& uman,
default:
GrCrash("Unknown filter direction.");
}
- uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
+ fImageIncrementUni->set2fv(context, 0, 1, imageIncrement);
if (conv.useBounds()) {
const float* bounds = conv.bounds();
if (Gr1DKernelEffect::kY_Direction == conv.direction() &&
texture.origin() != kTopLeft_GrSurfaceOrigin) {
- uman.set2f(fBoundsUni, 1.0f - bounds[1], 1.0f - bounds[0]);
+ fBoundsUni->set2f(context, 1.0f - bounds[1], 1.0f - bounds[0]);
} else {
- uman.set2f(fBoundsUni, bounds[0], bounds[1]);
+ fBoundsUni->set2f(context, bounds[0], bounds[1]);
}
}
- uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
- fEffectMatrix.setData(uman, conv.getMatrix(), drawEffect, conv.texture(0));
+ fKernelUni->set1fv(context, 0, this->width(), conv.kernel());
+ fEffectMatrix.setData(context, conv.getMatrix(), drawEffect, conv.texture(0));
}
GrGLEffect::EffectKey GrGLConvolutionEffect::GenKey(const GrDrawEffect& drawEffect,
« no previous file with comments | « src/gpu/effects/GrConfigConversionEffect.cpp ('k') | src/gpu/effects/GrSimpleTextureEffect.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698