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

Unified Diff: src/core/SkImageFilter.cpp

Issue 23295017: In image filters, apply the CTM and offset to the crop rect. This is necessary to compensate for bo… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix documentation comment. 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/core/SkCanvas.cpp ('k') | src/effects/SkBlurImageFilter.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 222a02999715b658862474098a2cf0216665ab57..502613bb68835caf66d4dcb4d893b90b6697a1ad 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, SkIPoint::Make(0, 0));
+ return this->asNewEffect(NULL, NULL, SkMatrix::I());
}
bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm,
@@ -116,7 +116,7 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
GrTexture* srcTexture = input.getTexture();
SkIRect bounds;
src.getBounds(&bounds);
- if (!this->applyCropRect(&bounds)) {
+ if (!this->applyCropRect(&bounds, ctm)) {
return false;
}
SkRect srcRect = SkRect::Make(bounds);
@@ -135,7 +135,9 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
GrContext::AutoClip acs(context, dstRect);
GrEffectRef* effect;
- this->asNewEffect(&effect, srcTexture, SkIPoint::Make(bounds.left(), bounds.top()));
+ SkMatrix matrix(ctm);
+ matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.top()));
+ this->asNewEffect(&effect, srcTexture, matrix);
SkASSERT(effect);
SkAutoUnref effectRef(effect);
GrPaint paint;
@@ -152,8 +154,17 @@ bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const SkMa
#endif
}
-bool SkImageFilter::applyCropRect(SkIRect* rect) const {
- return rect->intersect(fCropRect);
+bool SkImageFilter::applyCropRect(SkIRect* rect, const SkMatrix& matrix) const {
+ SkRect cropRect;
+ matrix.mapRect(&cropRect, SkRect::Make(fCropRect));
+ SkIRect cropRectI;
+ cropRect.roundOut(&cropRectI);
+ // If the original crop rect edges were unset, max out the new crop edges
+ if (fCropRect.fLeft == SK_MinS32) cropRectI.fLeft = SK_MinS32;
+ if (fCropRect.fTop == SK_MinS32) cropRectI.fTop = SK_MinS32;
+ if (fCropRect.fRight == SK_MaxS32) cropRectI.fRight = SK_MaxS32;
+ if (fCropRect.fBottom == SK_MaxS32) cropRectI.fBottom = SK_MaxS32;
+ return rect->intersect(cropRectI);
}
bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
@@ -162,7 +173,7 @@ bool SkImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm,
return true;
}
-bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkIPoint& offset) const {
+bool SkImageFilter::asNewEffect(GrEffectRef**, GrTexture*, const SkMatrix&) const {
return false;
}
« no previous file with comments | « src/core/SkCanvas.cpp ('k') | src/effects/SkBlurImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698