Introduces new SingleTextureEffect base class for GrCustomStage objects.
This class tracks the texture that the object uses. A future commit will get rid of the
GrTexture pointer currenty stored in the GrDrawState, allowing us to have CustomStages
*without* textures.
Requires gyp change on next roll.
http://codereview.appspot.com/6306097/
git-svn-id: http://skia.googlecode.com/svn/trunk@4576 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 42dc2b4..4970d62 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -28,7 +28,6 @@
virtual void initUniforms(const GrGLInterface*, int programID) SK_OVERRIDE;
virtual void setData(const GrGLInterface*,
- const GrGLTexture&,
const GrCustomStage&,
int stageNum) SK_OVERRIDE;
@@ -118,11 +117,11 @@
}
void GrGLConvolutionEffect::setData(const GrGLInterface* gl,
- const GrGLTexture& texture,
const GrCustomStage& data,
int stageNum) {
const GrConvolutionEffect& conv =
static_cast<const GrConvolutionEffect&>(data);
+ GrTexture& texture = *data.texture(0);
// the code we generated was for a specific kernel radius
GrAssert(conv.radius() == fRadius);
float imageIncrement[2] = { 0 };
@@ -148,10 +147,11 @@
///////////////////////////////////////////////////////////////////////////////
-GrConvolutionEffect::GrConvolutionEffect(Direction direction,
+GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
+ Direction direction,
int radius,
const float* kernel)
- : Gr1DKernelEffect(direction, radius) {
+ : Gr1DKernelEffect(texture, direction, radius) {
GrAssert(radius <= kMaxKernelRadius);
int width = this->width();
if (NULL != kernel) {
@@ -171,9 +171,10 @@
bool GrConvolutionEffect::isEqual(const GrCustomStage& sBase) const {
const GrConvolutionEffect& s =
static_cast<const GrConvolutionEffect&>(sBase);
- return (this->radius() == s.radius() &&
- this->direction() == s.direction() &&
- 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float)));
+ return (INHERITED::isEqual(sBase) &&
+ this->radius() == s.radius() &&
+ this->direction() == s.direction() &&
+ 0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float)));
}
void GrConvolutionEffect::setGaussianKernel(float sigma) {