| 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;
|
| }
|
|
|