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

Unified Diff: src/effects/SkColorFilterImageFilter.cpp

Issue 982933002: Use ComposColorFilter to collaps hierarchy (when possible). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix unused parameter warning Created 5 years, 9 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/SkImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('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 fdf6de7b76daf755f2fea5d49c87a753374e3cb7..210fb57b98fd6a3fa0534581bee4c25dc05d9a37 100755
--- a/src/effects/SkColorFilterImageFilter.cpp
+++ b/src/effects/SkColorFilterImageFilter.cpp
@@ -21,10 +21,12 @@ SkColorFilterImageFilter* SkColorFilterImageFilter::Create(SkColorFilter* cf,
return NULL;
}
- SkColorFilter* inputColorFilter;
- if (input && input->asColorFilter(&inputColorFilter)) {
- SkAutoUnref autoUnref(inputColorFilter);
- SkAutoTUnref<SkColorFilter> newCF(cf->newComposed(inputColorFilter));
+ SkColorFilter* inputCF;
+ if (input && input->isColorFilterNode(&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));
if (newCF) {
return SkNEW_ARGS(SkColorFilterImageFilter, (newCF, input->getInput(0), cropRect, 0));
}
@@ -85,11 +87,11 @@ bool SkColorFilterImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& sourc
return true;
}
-bool SkColorFilterImageFilter::asColorFilter(SkColorFilter** filter) const {
- if (!cropRectIsSet()) {
+bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const {
+ SkASSERT(1 == this->countInputs());
+ if (!this->cropRectIsSet()) {
if (filter) {
- *filter = fColorFilter;
- fColorFilter->ref();
+ *filter = SkRef(fColorFilter);
}
return true;
}
« no previous file with comments | « src/core/SkImageFilter.cpp ('k') | tests/ImageFilterTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698