From f0656c140aa3dcbfb250433045e803b2b99f4cab Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Wed, 22 May 2013 23:56:49 +0000 Subject: [PATCH] Reverting r9245 due to Chrome breakage git-svn-id: http://skia.googlecode.com/svn/trunk@9250 2bbb7eff-a529-9590-31e7-b0007b416f81 --- include/core/SkImageFilter.h | 5 +++++ src/core/SkImageFilter.cpp | 14 ++++++++++++++ src/effects/SkBicubicImageFilter.cpp | 6 +----- src/effects/SkBlurImageFilter.cpp | 6 +----- src/effects/SkColorFilterImageFilter.cpp | 6 +----- src/effects/SkMatrixConvolutionImageFilter.cpp | 6 +----- src/effects/SkMorphologyImageFilter.cpp | 11 ++--------- src/effects/SkOffsetImageFilter.cpp | 6 +----- 8 files changed, 26 insertions(+), 34 deletions(-) diff --git a/include/core/SkImageFilter.h b/include/core/SkImageFilter.h index 78e321a7b5..7eefaf5c16 100644 --- a/include/core/SkImageFilter.h +++ b/include/core/SkImageFilter.h @@ -159,6 +159,11 @@ protected: // Default impl copies src into dst and returns true virtual bool onFilterBounds(const SkIRect&, const SkMatrix&, SkIRect*); + // Return the result of processing the given input, or the source bitmap + // if we have no connected input at that index. + SkBitmap getInputResult(int index, Proxy*, const SkBitmap& src, const SkMatrix&, + SkIPoint*); + private: typedef SkFlattenable INHERITED; int fInputCount; diff --git a/src/core/SkImageFilter.cpp b/src/core/SkImageFilter.cpp index 37d1f44fd4..2d81026a56 100644 --- a/src/core/SkImageFilter.cpp +++ b/src/core/SkImageFilter.cpp @@ -69,6 +69,20 @@ void SkImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { } } +SkBitmap SkImageFilter::getInputResult(int index, Proxy* proxy, + const SkBitmap& src, const SkMatrix& ctm, + SkIPoint* loc) { + SkASSERT(index < fInputCount); + SkImageFilter* input = getInput(index); + SkBitmap result; + if (input && input->filterImage(proxy, src, ctm, &result, loc)) { + return result; + } else { + return src; + } +} + + bool SkImageFilter::filterImage(Proxy* proxy, const SkBitmap& src, const SkMatrix& ctm, SkBitmap* result, SkIPoint* loc) { diff --git a/src/effects/SkBicubicImageFilter.cpp b/src/effects/SkBicubicImageFilter.cpp index daa59484fa..c10937eaea 100644 --- a/src/effects/SkBicubicImageFilter.cpp +++ b/src/effects/SkBicubicImageFilter.cpp @@ -81,11 +81,7 @@ bool SkBicubicImageFilter::onFilterImage(Proxy* proxy, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); if (src.config() != SkBitmap::kARGB_8888_Config) { return false; } diff --git a/src/effects/SkBlurImageFilter.cpp b/src/effects/SkBlurImageFilter.cpp index 7b68ea0214..4885070264 100644 --- a/src/effects/SkBlurImageFilter.cpp +++ b/src/effects/SkBlurImageFilter.cpp @@ -137,11 +137,7 @@ static void getBox3Params(SkScalar s, int *kernelSize, int* kernelSize3, int *lo bool SkBlurImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& ctm, SkBitmap* dst, SkIPoint* offset) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offset)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, ctm, offset); if (src.config() != SkBitmap::kARGB_8888_Config) { return false; } diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp index 1d3cfee1c3..b5ab255ce7 100755 --- a/src/effects/SkColorFilterImageFilter.cpp +++ b/src/effects/SkColorFilterImageFilter.cpp @@ -98,11 +98,7 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); SkAutoTUnref device(proxy->createDevice(src.width(), src.height())); SkCanvas canvas(device.get()); SkPaint paint; diff --git a/src/effects/SkMatrixConvolutionImageFilter.cpp b/src/effects/SkMatrixConvolutionImageFilter.cpp index 99e8368e7d..6368096fbc 100644 --- a/src/effects/SkMatrixConvolutionImageFilter.cpp +++ b/src/effects/SkMatrixConvolutionImageFilter.cpp @@ -203,11 +203,7 @@ bool SkMatrixConvolutionImageFilter::onFilterImage(Proxy* proxy, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); if (src.config() != SkBitmap::kARGB_8888_Config) { return false; } diff --git a/src/effects/SkMorphologyImageFilter.cpp b/src/effects/SkMorphologyImageFilter.cpp index be63d15b10..77299e4f78 100644 --- a/src/effects/SkMorphologyImageFilter.cpp +++ b/src/effects/SkMorphologyImageFilter.cpp @@ -136,11 +136,7 @@ static void dilateY(const SkBitmap& src, SkBitmap* dst, int radiusY) bool SkErodeImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& ctm, SkBitmap* dst, SkIPoint* offset) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offset)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, ctm, offset); if (src.config() != SkBitmap::kARGB_8888_Config) { return false; } @@ -185,10 +181,7 @@ bool SkErodeImageFilter::onFilterImage(Proxy* proxy, bool SkDilateImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& ctm, SkBitmap* dst, SkIPoint* offset) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, ctm, &src, offset)) { - return false; - } + SkBitmap src = this->getInputResult(0, proxy, source, ctm, offset); if (src.config() != SkBitmap::kARGB_8888_Config) { return false; } diff --git a/src/effects/SkOffsetImageFilter.cpp b/src/effects/SkOffsetImageFilter.cpp index ad5e49d776..2a4f71c0b2 100644 --- a/src/effects/SkOffsetImageFilter.cpp +++ b/src/effects/SkOffsetImageFilter.cpp @@ -14,11 +14,7 @@ bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, const SkMatrix& matrix, SkBitmap* result, SkIPoint* loc) { - SkBitmap src = source; - if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, loc)) { - return false; - } - + SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); SkVector vec; matrix.mapVectors(&vec, &fOffset, 1);