| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkComposeImageFilter.h" | 8 #include "SkComposeImageFilter.h" |
| 9 | 9 |
| 10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
| 11 #include "SkSpecialImage.h" | 11 #include "SkSpecialImage.h" |
| 12 #include "SkWriteBuffer.h" | 12 #include "SkWriteBuffer.h" |
| 13 | 13 |
| 14 | 14 |
| 15 SkRect SkComposeImageFilter::computeFastBounds(const SkRect& src) const { | 15 SkRect SkComposeImageFilter::computeFastBounds(const SkRect& src) const { |
| 16 SkImageFilter* outer = getInput(0); | 16 SkImageFilter* outer = this->getInput(0); |
| 17 SkImageFilter* inner = getInput(1); | 17 SkImageFilter* inner = this->getInput(1); |
| 18 | 18 |
| 19 return outer->computeFastBounds(inner->computeFastBounds(src)); | 19 return outer->computeFastBounds(inner->computeFastBounds(src)); |
| 20 } | 20 } |
| 21 | 21 |
| 22 sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source
, | 22 sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source
, |
| 23 const Context& ctx, | 23 const Context& ctx, |
| 24 SkIPoint* offset) cons
t { | 24 SkIPoint* offset) cons
t { |
| 25 // The bounds passed to the inner filter must be filtered by the outer | 25 // The bounds passed to the inner filter must be filtered by the outer |
| 26 // filter, so that the inner filter produces the pixels that the outer | 26 // filter, so that the inner filter produces the pixels that the outer |
| 27 // filter requires as input. This matters if the outer filter moves pixels. | 27 // filter requires as input. This matters if the outer filter moves pixels. |
| 28 SkIRect innerClipBounds; | 28 SkIRect innerClipBounds; |
| 29 innerClipBounds = getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm()); | 29 innerClipBounds = this->getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(
)); |
| 30 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); | 30 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); |
| 31 SkIPoint innerOffset = SkIPoint::Make(0, 0); | 31 SkIPoint innerOffset = SkIPoint::Make(0, 0); |
| 32 sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &inne
rOffset)); | 32 sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &inne
rOffset)); |
| 33 if (!inner) { | 33 if (!inner) { |
| 34 return nullptr; | 34 return nullptr; |
| 35 } | 35 } |
| 36 | 36 |
| 37 SkMatrix outerMatrix(ctx.ctm()); | 37 SkMatrix outerMatrix(ctx.ctm()); |
| 38 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); | 38 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); |
| 39 SkIRect clipBounds = ctx.clipBounds(); | 39 SkIRect clipBounds = ctx.clipBounds(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 53 SkIRect SkComposeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, | 53 SkIRect SkComposeImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix&
ctm, |
| 54 MapDirection direction) const { | 54 MapDirection direction) const { |
| 55 SkImageFilter* outer = this->getInput(0); | 55 SkImageFilter* outer = this->getInput(0); |
| 56 SkImageFilter* inner = this->getInput(1); | 56 SkImageFilter* inner = this->getInput(1); |
| 57 | 57 |
| 58 return outer->filterBounds(inner->filterBounds(src, ctm, direction), ctm, di
rection); | 58 return outer->filterBounds(inner->filterBounds(src, ctm, direction), ctm, di
rection); |
| 59 } | 59 } |
| 60 | 60 |
| 61 SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) { | 61 SkFlattenable* SkComposeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 62 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); | 62 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 2); |
| 63 return SkComposeImageFilter::Create(common.getInput(0), common.getInput(1)); | 63 return SkComposeImageFilter::Make(sk_ref_sp<SkImageFilter>(common.getInput(0
)), |
| 64 sk_ref_sp<SkImageFilter>(common.getInput(1
))).release(); |
| 64 } | 65 } |
| 65 | 66 |
| 66 #ifndef SK_IGNORE_TO_STRING | 67 #ifndef SK_IGNORE_TO_STRING |
| 67 void SkComposeImageFilter::toString(SkString* str) const { | 68 void SkComposeImageFilter::toString(SkString* str) const { |
| 68 SkImageFilter* outer = getInput(0); | 69 SkImageFilter* outer = getInput(0); |
| 69 SkImageFilter* inner = getInput(1); | 70 SkImageFilter* inner = getInput(1); |
| 70 | 71 |
| 71 str->appendf("SkComposeImageFilter: ("); | 72 str->appendf("SkComposeImageFilter: ("); |
| 72 | 73 |
| 73 str->appendf("outer: "); | 74 str->appendf("outer: "); |
| 74 outer->toString(str); | 75 outer->toString(str); |
| 75 | 76 |
| 76 str->appendf("inner: "); | 77 str->appendf("inner: "); |
| 77 inner->toString(str); | 78 inner->toString(str); |
| 78 | 79 |
| 79 str->appendf(")"); | 80 str->appendf(")"); |
| 80 } | 81 } |
| 81 #endif | 82 #endif |
| OLD | NEW |