Reverting r10251 (Implement crop rect for SkImageFilter) due to Chromium-side unit test failures
git-svn-id: http://skia.googlecode.com/svn/trunk@10304 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp
index 4456f51..eaac5ab 100644
--- a/src/gpu/SkGpuDevice.cpp
+++ b/src/gpu/SkGpuDevice.cpp
@@ -1387,7 +1387,7 @@
SkAutoCachedTexture act(this, bitmap, NULL, &texture);
SkImageFilter* filter = paint.getImageFilter();
- SkIPoint offset = SkIPoint::Make(left, top);
+ SkIPoint offset = SkIPoint::Make(0, 0);
// This bitmap will own the filtered result as a texture.
SkBitmap filteredBitmap;
@@ -1396,8 +1396,6 @@
texture = (GrTexture*) filteredBitmap.getTexture();
w = filteredBitmap.width();
h = filteredBitmap.height();
- } else {
- return;
}
}
@@ -1409,12 +1407,12 @@
}
fContext->drawRectToRect(grPaint,
- SkRect::MakeXYWH(SkIntToScalar(offset.fX),
- SkIntToScalar(offset.fY),
+ SkRect::MakeXYWH(SkIntToScalar(left),
+ SkIntToScalar(top),
SkIntToScalar(w),
SkIntToScalar(h)),
- SkRect::MakeXYWH(0,
- 0,
+ SkRect::MakeXYWH(SkIntToScalar(offset.fX),
+ SkIntToScalar(offset.fY),
SK_Scalar1 * w / texture->width(),
SK_Scalar1 * h / texture->height()));
}
@@ -1483,8 +1481,6 @@
h = filteredBitmap.height();
x += offset.fX;
y += offset.fY;
- } else {
- return;
}
}
diff --git a/src/gpu/effects/GrConvolutionEffect.cpp b/src/gpu/effects/GrConvolutionEffect.cpp
index 5682b9c..380581f 100644
--- a/src/gpu/effects/GrConvolutionEffect.cpp
+++ b/src/gpu/effects/GrConvolutionEffect.cpp
@@ -37,7 +37,6 @@
int fRadius;
UniformHandle fKernelUni;
UniformHandle fImageIncrementUni;
- UniformHandle fCropRectUni;
GrGLEffectMatrix fEffectMatrix;
typedef GrGLEffect INHERITED;
@@ -48,7 +47,6 @@
: INHERITED(factory)
, fKernelUni(kInvalidUniformHandle)
, fImageIncrementUni(kInvalidUniformHandle)
- , fCropRectUni(kInvalidUniformHandle)
, fEffectMatrix(drawEffect.castEffect<GrConvolutionEffect>().coordsType()) {
const GrConvolutionEffect& c = drawEffect.castEffect<GrConvolutionEffect>();
fRadius = c.radius();
@@ -64,8 +62,6 @@
fEffectMatrix.emitCodeMakeFSCoords2D(builder, key, &coords);
fImageIncrementUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
kVec2f_GrSLType, "ImageIncrement");
- fCropRectUni = builder->addUniform(GrGLShaderBuilder::kFragment_ShaderType,
- kVec4f_GrSLType, "CropRect");
fKernelUni = builder->addUniformArray(GrGLShaderBuilder::kFragment_ShaderType,
kFloat_GrSLType, "Kernel", this->width());
@@ -74,7 +70,6 @@
int width = this ->width();
const GrGLShaderVar& kernel = builder->getUniformVariable(fKernelUni);
const char* imgInc = builder->getUniformCStr(fImageIncrementUni);
- const char* cropRect = builder->getUniformCStr(fCropRectUni);
builder->fsCodeAppendf("\t\tvec2 coord = %s - %d.0 * %s;\n", coords, fRadius, imgInc);
@@ -86,11 +81,9 @@
kernel.appendArrayAccess(index.c_str(), &kernelIndex);
builder->fsCodeAppendf("\t\t%s += ", outputColor);
builder->appendTextureLookup(GrGLShaderBuilder::kFragment_ShaderType, samplers[0], "coord");
- builder->fsCodeAppendf(" * float(coord.x >= %s.x && coord.x <= %s.y && coord.y >= %s.z && coord.y <= %s.w) * %s;\n",
- cropRect, cropRect, cropRect, cropRect, kernelIndex.c_str());
+ builder->fsCodeAppendf(" * %s;\n", kernelIndex.c_str());
builder->fsCodeAppendf("\t\tcoord += %s;\n", imgInc);
}
-
SkString modulate;
GrGLSLMulVarBy4f(&modulate, 2, outputColor, inputColor);
builder->fsCodeAppend(modulate.c_str());
@@ -103,26 +96,17 @@
// the code we generated was for a specific kernel radius
GrAssert(conv.radius() == fRadius);
float imageIncrement[2] = { 0 };
- float ySign = texture.origin() != kTopLeft_GrSurfaceOrigin ? 1.0f : -1.0f;
switch (conv.direction()) {
case Gr1DKernelEffect::kX_Direction:
imageIncrement[0] = 1.0f / texture.width();
break;
case Gr1DKernelEffect::kY_Direction:
- imageIncrement[1] = ySign / texture.height();
+ imageIncrement[1] = 1.0f / texture.height();
break;
default:
GrCrash("Unknown filter direction.");
}
uman.set2fv(fImageIncrementUni, 0, 1, imageIncrement);
- float c[4];
- memcpy(c, conv.cropRect(), sizeof(c));
- if (texture.origin() != kTopLeft_GrSurfaceOrigin) {
- float tmp = 1.0f - c[2];
- c[2] = 1.0f - c[3];
- c[3] = tmp;
- }
- uman.set4fv(fCropRectUni, 0, 1, c);
uman.set1fv(fKernelUni, 0, this->width(), conv.kernel());
fEffectMatrix.setData(uman, conv.getMatrix(), drawEffect, conv.texture(0));
}
@@ -144,8 +128,7 @@
GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
Direction direction,
int radius,
- const float* kernel,
- float cropRect[4])
+ const float* kernel)
: Gr1DKernelEffect(texture, direction, radius) {
GrAssert(radius <= kMaxKernelRadius);
GrAssert(NULL != kernel);
@@ -153,14 +136,12 @@
for (int i = 0; i < width; i++) {
fKernel[i] = kernel[i];
}
- memcpy(fCropRect, cropRect, sizeof(fCropRect));
}
GrConvolutionEffect::GrConvolutionEffect(GrTexture* texture,
Direction direction,
int radius,
- float gaussianSigma,
- float cropRect[4])
+ float gaussianSigma)
: Gr1DKernelEffect(texture, direction, radius) {
GrAssert(radius <= kMaxKernelRadius);
int width = this->width();
@@ -179,7 +160,6 @@
for (int i = 0; i < width; ++i) {
fKernel[i] *= scale;
}
- memcpy(fCropRect, cropRect, sizeof(fCropRect));
}
GrConvolutionEffect::~GrConvolutionEffect() {
@@ -194,7 +174,6 @@
return (this->texture(0) == s.texture(0) &&
this->radius() == s.radius() &&
this->direction() == s.direction() &&
- 0 == memcmp(fCropRect, s.fCropRect, sizeof(fCropRect)) &&
0 == memcmp(fKernel, s.fKernel, this->width() * sizeof(float)));
}
@@ -211,13 +190,9 @@
Direction dir = random->nextBool() ? kX_Direction : kY_Direction;
int radius = random->nextRangeU(1, kMaxKernelRadius);
float kernel[kMaxKernelRadius];
- float cropRect[4];
for (int i = 0; i < kMaxKernelRadius; ++i) {
kernel[i] = random->nextSScalar1();
}
- for (int i = 0; i < 4; ++i) {
- cropRect[i] = random->nextF();
- }
- return GrConvolutionEffect::Create(textures[texIdx], dir, radius, kernel, cropRect);
+ return GrConvolutionEffect::Create(textures[texIdx], dir, radius,kernel);
}
diff --git a/src/gpu/effects/GrConvolutionEffect.h b/src/gpu/effects/GrConvolutionEffect.h
index f75cfe9..e4faa94 100644
--- a/src/gpu/effects/GrConvolutionEffect.h
+++ b/src/gpu/effects/GrConvolutionEffect.h
@@ -22,16 +22,11 @@
public:
/// Convolve with an arbitrary user-specified kernel
- static GrEffectRef* Create(GrTexture* tex,
- Direction dir,
- int halfWidth,
- const float* kernel,
- float cropRect[4]) {
+ static GrEffectRef* Create(GrTexture* tex, Direction dir, int halfWidth, const float* kernel) {
AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
- kernel,
- cropRect)));
+ kernel)));
return CreateEffectRef(effect);
}
@@ -39,13 +34,11 @@
static GrEffectRef* CreateGaussian(GrTexture* tex,
Direction dir,
int halfWidth,
- float gaussianSigma,
- float cropRect[4]) {
+ float gaussianSigma) {
AutoEffectUnref effect(SkNEW_ARGS(GrConvolutionEffect, (tex,
dir,
halfWidth,
- gaussianSigma,
- cropRect)));
+ gaussianSigma)));
return CreateEffectRef(effect);
}
@@ -53,8 +46,6 @@
const float* kernel() const { return fKernel; }
- const float* cropRect() const { return fCropRect; }
-
static const char* Name() { return "Convolution"; }
typedef GrGLConvolutionEffect GLEffect;
@@ -81,17 +72,15 @@
protected:
float fKernel[kMaxKernelWidth];
- float fCropRect[4];
private:
GrConvolutionEffect(GrTexture*, Direction,
- int halfWidth, const float* kernel, float cropRect[4]);
+ int halfWidth, const float* kernel);
/// Convolve with a Gaussian kernel
GrConvolutionEffect(GrTexture*, Direction,
int halfWidth,
- float gaussianSigma,
- float cropRect[4]);
+ float gaussianSigma);
virtual bool onIsEqual(const GrEffect&) const SK_OVERRIDE;