aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar reed <reed@google.com>2015-03-05 14:47:29 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-03-05 14:47:29 -0800
commit5c518a862264225f0a378e4728e037966ddf4cc2 (patch)
treee3981640e6e603424f670a421bfb959455154ab1
parent4b31de8328bbf3ee789157ae1dc6fe7cc74c796a (diff)
Revert of check for inputs before reporting asColorFilter (patchset #7 id:110001 of https://codereview.chromium.org/967833003/)
Reason for revert: Need to suppress these for rebaselining, so reverting for now. Regressions: Unexpected image-only failures (5) css3/filters/effect-brightness-clamping-hw.html [ ImageOnlyFailure ] css3/filters/effect-combined-hw.html [ ImageOnlyFailure ] virtual/slimmingpaint/css3/filters/effect-brightness-clamping-hw.html [ ImageOnlyFailure ] virtual/slimmingpaint/css3/filters/effect-combined-hw.html [ ImageOnlyFailure ] Original issue's description: > Use ComposeColorFilter in factory to collapse consecutive filters (when possible). > Change asColorFilter to reflect its reliance on the new factory behavior. > > patch from issue 967143002 at patchset 80001 (http://crrev.com/967143002#ps80001) > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/dac843bf046c2cd79fd955cb177aee241d7a4b0c TBR=senorblanco@chromium.org,robertphillips@google.com,bsalomon@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true BUG=skia: Review URL: https://codereview.chromium.org/978923005
-rwxr-xr-xsrc/effects/SkColorFilterImageFilter.cpp19
-rw-r--r--tests/ImageFilterTest.cpp35
2 files changed, 13 insertions, 41 deletions
diff --git a/src/effects/SkColorFilterImageFilter.cpp b/src/effects/SkColorFilterImageFilter.cpp
index 908f814b94..fdf6de7b76 100755
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -21,12 +21,10 @@ SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
return NULL;
}
- SkColorFilter* inputCF;
- if (input && input->asColorFilter(&inputCF)) {
- // This is an optimization, as it collapses the hierarchy by just combining the two
- // colorfilters into a single one, which the new imagefilter will wrap.
- SkAutoUnref autoUnref(inputCF);
- SkAutoTUnref<SkColorFilter> newCF(SkColorFilter::CreateComposeFilter(cf, inputCF));
+ SkColorFilter* inputColorFilter;
+ if (input && input->asColorFilter(&inputColorFilter)) {
+ SkAutoUnref autoUnref(inputColorFilter);
+ SkAutoTUnref<SkColorFilter> newCF(cf->newComposed(inputColorFilter));
if (newCF) {
return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect, 0));
}
@@ -88,13 +86,10 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
}
bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const {
- if (!this->cropRectIsSet()) {
- SkASSERT(1 == this->countInputs());
- // Since our factory has already performed the collapse optimization, we can assert that
- // if we have an input, it is *not* also a colorfilter.
- SkASSERT(!this->getInput(0) || !this->getInput(0)->asColorFilter(NULL));
+ if (!cropRectIsSet()) {
if (filter) {
- *filter = SkRef(fColorFilter);
+ *filter = fColorFilter;
+ fColorFilter->ref();
}
return true;
}
diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp
index da663bcfc0..2798ea0b18 100644
--- a/tests/ImageFilterTest.cpp
+++ b/tests/ImageFilterTest.cpp
@@ -133,7 +133,7 @@ static SkImageFilter* make_scale(float amount, SkImageFilter* input = NULL) {
return SkColorFilterImageFilter::Create(filter, input);
}
-static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) {
+static SkImageFilter* make_grayscale(SkImageFilter* input = NULL, const SkImageFilter::CropRect* cropRect = NULL) {
SkScalar matrix[20];
memset(matrix, 0, 20 * sizeof(SkScalar));
matrix[0] = matrix[5] = matrix[10] = 0.2126f;
@@ -144,51 +144,28 @@ static SkImageFilter* make_grayscale(SkImageFilter* input, const SkImageFilter::
return SkColorFilterImageFilter::Create(filter, input, cropRect);
}
-static SkImageFilter* make_blue(SkImageFilter* input, const SkImageFilter::CropRect* cropRect) {
- SkAutoTUnref<SkColorFilter> filter(SkColorFilter::CreateModeFilter(SK_ColorBLUE,
- SkXfermode::kSrcIn_Mode));
- return SkColorFilterImageFilter::Create(filter, input, cropRect);
-}
-
DEF_TEST(ImageFilter, reporter) {
{
- // Check that two non-clipping color-matrice-filters concatenate into a single filter.
+ // Check that two non-clipping color matrices concatenate into a single filter.
SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f));
SkAutoTUnref<SkImageFilter> quarterBrightness(make_scale(0.5f, halfBrightness));
REPORTER_ASSERT(reporter, NULL == quarterBrightness->getInput(0));
- SkColorFilter* cf;
- REPORTER_ASSERT(reporter, quarterBrightness->asColorFilter(&cf));
- REPORTER_ASSERT(reporter, cf->asColorMatrix(NULL));
- cf->unref();
}
{
- // Check that a clipping color-matrice-filter followed by a color-matrice-filters
- // concatenates into a single filter, but not a matrixfilter (due to clamping).
+ // Check that a clipping color matrix followed by a grayscale does not concatenate into a single filter.
SkAutoTUnref<SkImageFilter> doubleBrightness(make_scale(2.0f));
SkAutoTUnref<SkImageFilter> halfBrightness(make_scale(0.5f, doubleBrightness));
- REPORTER_ASSERT(reporter, NULL == halfBrightness->getInput(0));
- SkColorFilter* cf;
- REPORTER_ASSERT(reporter, halfBrightness->asColorFilter(&cf));
- REPORTER_ASSERT(reporter, !cf->asColorMatrix(NULL));
- cf->unref();
+ REPORTER_ASSERT(reporter, halfBrightness->getInput(0));
}
{
// Check that a color filter image filter without a crop rect can be
// expressed as a color filter.
- SkAutoTUnref<SkImageFilter> gray(make_grayscale(NULL, NULL));
+ SkAutoTUnref<SkImageFilter> gray(make_grayscale());
REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL));
}
-
- {
- // Check that a colorfilterimage filter without a crop rect but with an input
- // that is another colorfilterimage can be expressed as a colorfilter (composed).
- SkAutoTUnref<SkImageFilter> mode(make_blue(NULL, NULL));
- SkAutoTUnref<SkImageFilter> gray(make_grayscale(mode, NULL));
- REPORTER_ASSERT(reporter, true == gray->asColorFilter(NULL));
- }
-
+
{
// Check that a color filter image filter with a crop rect cannot
// be expressed as a color filter.