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

Unified Diff: src/effects/SkColorFilterImageFilter.cpp

Issue 19775006: Implement crop rect for SkImageFilter (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Fix comments 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 | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkGpuBlurUtils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkColorFilterImageFilter.cpp
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index 1d3cfee1c398fd413f9399f805ee92a82162330f..9c2c54eb56a72a4a9fcea24e461e6d4f95103e63 100755
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -57,7 +57,7 @@ bool matrix_needs_clamping(SkScalar matrix[20]) {
};
SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
- SkImageFilter* input) {
+ SkImageFilter* input, const SkIRect* cropRect) {
SkASSERT(cf);
SkScalar colorMatrix[20], inputMatrix[20];
SkColorFilter* inputColorFilter;
@@ -69,13 +69,15 @@ SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
SkScalar combinedMatrix[20];
mult_color_matrix(inputMatrix, colorMatrix, combinedMatrix);
SkAutoTUnref<SkColorFilter> newCF(SkNEW_ARGS(SkColorMatrixFilter, (combinedMatrix)));
- return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0)));
+ return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect));
}
}
- return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input));
+ return SkNEW_ARGS(SkColorFilterImageFilter, (cf, input, cropRect));
}
-SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf, SkImageFilter* input) : INHERITED(input), fColorFilter(cf) {
+SkColorFilterImageFilter::SkColorFilterImageFilter(SkColorFilter* cf,
+ SkImageFilter* input, const SkIRect* cropRect)
+ : INHERITED(input, cropRect), fColorFilter(cf) {
SkASSERT(cf);
SkSafeRef(cf);
}
@@ -103,22 +105,33 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
return false;
}
- SkAutoTUnref<SkDevice> device(proxy->createDevice(src.width(), src.height()));
+ SkIRect bounds;
+ src.getBounds(&bounds);
+ if (!this->applyCropRect(&bounds)) {
+ return false;
+ }
+
+ SkAutoTUnref<SkDevice> device(proxy->createDevice(bounds.width(), bounds.height()));
SkCanvas canvas(device.get());
SkPaint paint;
paint.setXfermodeMode(SkXfermode::kSrc_Mode);
paint.setColorFilter(fColorFilter);
- canvas.drawSprite(src, 0, 0, &paint);
+ canvas.drawSprite(src, -bounds.fLeft, -bounds.fTop, &paint);
*result = device.get()->accessBitmap(false);
+ loc->fX += bounds.fLeft;
+ loc->fY += bounds.fTop;
return true;
}
bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const {
- if (filter) {
- *filter = fColorFilter;
- fColorFilter->ref();
+ if (cropRect().isLargest()) {
+ if (filter) {
+ *filter = fColorFilter;
+ fColorFilter->ref();
+ }
+ return true;
}
- return true;
+ return false;
}
« no previous file with comments | « src/effects/SkBlurMaskFilter.cpp ('k') | src/effects/SkGpuBlurUtils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698