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

Unified Diff: src/effects/SkMagnifierImageFilter.cpp

Issue 1048583002: Revert "Implement approx-match support in image filter saveLayer() offscreen." (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/core/SkCanvas.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkMagnifierImageFilter.cpp
diff --git a/src/effects/SkMagnifierImageFilter.cpp b/src/effects/SkMagnifierImageFilter.cpp
index d8e21cf29a2610be1b869875fa1d6c61cbbf3149..622713d796f1f0be7cc240ffdff51ddfcf13ac7f 100644
--- a/src/effects/SkMagnifierImageFilter.cpp
+++ b/src/effects/SkMagnifierImageFilter.cpp
@@ -25,7 +25,6 @@ class GrMagnifierEffect : public GrSingleTextureEffect {
public:
static GrFragmentProcessor* Create(GrTexture* texture,
- const SkRect& bounds,
float xOffset,
float yOffset,
float xInvZoom,
@@ -33,7 +32,6 @@ public:
float xInvInset,
float yInvInset) {
return SkNEW_ARGS(GrMagnifierEffect, (texture,
- bounds,
xOffset,
yOffset,
xInvZoom,
@@ -50,7 +48,6 @@ public:
GrGLFragmentProcessor* createGLInstance() const override;
- const SkRect& bounds() const { return fBounds; }
float x_offset() const { return fXOffset; }
float y_offset() const { return fYOffset; }
float x_inv_zoom() const { return fXInvZoom; }
@@ -60,7 +57,6 @@ public:
private:
GrMagnifierEffect(GrTexture* texture,
- const SkRect& bounds,
float xOffset,
float yOffset,
float xInvZoom,
@@ -68,7 +64,6 @@ private:
float xInvInset,
float yInvInset)
: GrSingleTextureEffect(texture, GrCoordTransform::MakeDivByTextureWHMatrix(texture))
- , fBounds(bounds)
, fXOffset(xOffset)
, fYOffset(yOffset)
, fXInvZoom(xInvZoom)
@@ -84,7 +79,6 @@ private:
GR_DECLARE_FRAGMENT_PROCESSOR_TEST;
- SkRect fBounds;
float fXOffset;
float fYOffset;
float fXInvZoom;
@@ -115,7 +109,6 @@ private:
UniformHandle fOffsetVar;
UniformHandle fInvZoomVar;
UniformHandle fInvInsetVar;
- UniformHandle fBoundsVar;
typedef GrGLFragmentProcessor INHERITED;
};
@@ -141,10 +134,6 @@ void GrGLMagnifierEffect::emitCode(GrGLFPBuilder* builder,
GrGLProgramBuilder::kFragment_Visibility |
GrGLProgramBuilder::kVertex_Visibility,
kVec2f_GrSLType, kDefault_GrSLPrecision, "InvInset");
- fBoundsVar = builder->addUniform(
- GrGLProgramBuilder::kFragment_Visibility |
- GrGLProgramBuilder::kVertex_Visibility,
- kVec4f_GrSLType, kDefault_GrSLPrecision, "Bounds");
GrGLFPFragmentBuilder* fsBuilder = builder->getFragmentShaderBuilder();
SkString coords2D = fsBuilder->ensureFSCoords2D(coords, 0);
@@ -153,9 +142,9 @@ void GrGLMagnifierEffect::emitCode(GrGLFPBuilder* builder,
builder->getUniformCStr(fOffsetVar),
coords2D.c_str(),
builder->getUniformCStr(fInvZoomVar));
- const char* bounds = builder->getUniformCStr(fBoundsVar);
- fsBuilder->codeAppendf("\t\tvec2 delta = (coord - %s.xy) * %s.zw;\n", bounds, bounds);
- fsBuilder->codeAppendf("\t\tdelta = min(delta, vec2(1.0, 1.0) - delta);\n");
+
+ fsBuilder->codeAppend("\t\tvec2 delta = min(coord, vec2(1.0, 1.0) - coord);\n");
+
fsBuilder->codeAppendf("\t\tdelta = delta * %s;\n", builder->getUniformCStr(fInvInsetVar));
fsBuilder->codeAppend("\t\tfloat weight = 0.0;\n");
@@ -186,8 +175,6 @@ void GrGLMagnifierEffect::setData(const GrGLProgramDataManager& pdman,
pdman.set2f(fOffsetVar, zoom.x_offset(), zoom.y_offset());
pdman.set2f(fInvZoomVar, zoom.x_inv_zoom(), zoom.y_inv_zoom());
pdman.set2f(fInvInsetVar, zoom.x_inv_inset(), zoom.y_inv_inset());
- pdman.set4f(fBoundsVar, zoom.bounds().x(), zoom.bounds().y(),
- zoom.bounds().width(), zoom.bounds().height());
}
/////////////////////////////////////////////////////////////////////
@@ -219,7 +206,6 @@ GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random,
GrFragmentProcessor* effect = GrMagnifierEffect::Create(
texture,
- SkRect::MakeWH(SkIntToScalar(kMaxWidth), SkIntToScalar(kMaxHeight)),
(float) width / texture->width(),
(float) height / texture->height(),
texture->width() / (float) x,
@@ -234,8 +220,7 @@ GrFragmentProcessor* GrMagnifierEffect::TestCreate(SkRandom* random,
bool GrMagnifierEffect::onIsEqual(const GrFragmentProcessor& sBase) const {
const GrMagnifierEffect& s = sBase.cast<GrMagnifierEffect>();
- return (this->fBounds == s.fBounds &&
- this->fXOffset == s.fXOffset &&
+ return (this->fXOffset == s.fXOffset &&
this->fYOffset == s.fYOffset &&
this->fXInvZoom == s.fXInvZoom &&
this->fYInvZoom == s.fYInvZoom &&
@@ -273,27 +258,18 @@ SkMagnifierImageFilter::SkMagnifierImageFilter(const SkRect& srcRect, SkScalar i
#if SK_SUPPORT_GPU
bool SkMagnifierImageFilter::asFragmentProcessor(GrFragmentProcessor** fp, GrTexture* texture,
- const SkMatrix&, const SkIRect&bounds) const {
+ const SkMatrix&, const SkIRect&) const {
if (fp) {
- SkScalar yOffset = texture->origin() == kTopLeft_GrSurfaceOrigin ? fSrcRect.y() :
- texture->height() - fSrcRect.height() * texture->height() / bounds.height()
- - fSrcRect.y();
- int boundsY = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? bounds.y() :
- (texture->height() - bounds.height());
- SkRect effectBounds = SkRect::MakeXYWH(
- SkIntToScalar(bounds.x()) / texture->width(),
- SkIntToScalar(boundsY) / texture->height(),
- SkIntToScalar(texture->width()) / bounds.width(),
- SkIntToScalar(texture->height()) / bounds.height());
+ SkScalar yOffset = (texture->origin() == kTopLeft_GrSurfaceOrigin) ? fSrcRect.y() :
+ (texture->height() - (fSrcRect.y() + fSrcRect.height()));
SkScalar invInset = fInset > 0 ? SkScalarInvert(fInset) : SK_Scalar1;
*fp = GrMagnifierEffect::Create(texture,
- effectBounds,
fSrcRect.x() / texture->width(),
yOffset / texture->height(),
- fSrcRect.width() / bounds.width(),
- fSrcRect.height() / bounds.height(),
- bounds.width() * invInset,
- bounds.height() * invInset);
+ fSrcRect.width() / texture->width(),
+ fSrcRect.height() / texture->height(),
+ texture->width() * invInset,
+ texture->height() * invInset);
}
return true;
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698