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

Unified Diff: src/core/SkImageFilter.cpp

Issue 20426002: Implement crop rect for lighting image filters. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Bugfix: set the bitmap's width and height to the bounds's width and height, Created 7 years, 5 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 | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/core/SkImageFilter.cpp
diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp
index ff060a1a52cb8e764905959f62d06af9617e53ee..f37a220a39d4dee12db4608ccc143d72a145dc2d 100644
--- a/src/core/SkImageFilter.cpp
+++ b/src/core/SkImageFilter.cpp
@@ -102,7 +102,7 @@ bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const SkMatrix&,
}
bool SkImageFilter::canFilterImageGPU() const {
- return this->asNewEffect(NULL, NULL);
+ return this->asNewEffect(NULL, NULL, SkIPoint::Make(0, 0));
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap* result,
@@ -114,30 +114,38 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, SkBitmap*
return false;
}
GrTexture* srcTexture = input.getTexture();
- SkRect rect;
- src.getBounds(&rect);
+ SkIRect bounds;
+ src.getBounds(&bounds);
+ if (!this->applyCropRect(&bounds)) {
+ return false;
+ }
+ SkRect srcRect = SkRect::Make(bounds);
+ SkRect dstRect = SkRect::MakeWH(srcRect.width(), srcRect.height());
GrContext* context = srcTexture->getContext();
GrTextureDesc desc;
desc.fFlags = kRenderTarget_GrTextureFlagBit,
- desc.fWidth = input.width();
- desc.fHeight = input.height();
+ desc.fWidth = bounds.width();
+ desc.fHeight = bounds.height();
desc.fConfig = kRGBA_8888_GrPixelConfig;
GrAutoScratchTexture dst(context, desc);
GrContext::AutoMatrix am;
am.setIdentity(context);
GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
- GrContext::AutoClip acs(context, rect);
+ GrContext::AutoClip acs(context, dstRect);
GrEffectRef* effect;
- this->asNewEffect(&effect, srcTexture);
+ this->asNewEffect(&effect, srcTexture, SkIPoint::Make(bounds.left(), bounds.top()));
SkASSERT(effect);
SkAutoUnref effectRef(effect);
GrPaint paint;
paint.addColorEffect(effect);
- context->drawRect(paint, rect);
+ context->drawRectToRect(paint, dstRect, srcRect);
+
SkAutoTUnref<GrTexture> resultTex(dst.detach());
- SkImageFilterUtils::WrapTexture(resultTex, input.width(), input.height(), result);
+ SkImageFilterUtils::WrapTexture(resultTex, bounds.width(), bounds.height(), result);
+ offset->fX += bounds.left();
+ offset->fY += bounds.top();
return true;
#else
return false;
@@ -154,7 +162,7 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
return true;
}
-bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*) const {
+bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkIPoint& offset) const {
return false;
}
« no previous file with comments | « include/effects/SkMatrixConvolutionImageFilter.h ('k') | src/effects/SkLightingImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698