| 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 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con
st { | 15 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con
st { |
| 16 SkImageFilter* outer = getInput(0); | 16 SkImageFilter* outer = getInput(0); |
| 17 SkImageFilter* inner = getInput(1); | 17 SkImageFilter* inner = getInput(1); |
| 18 | 18 |
| 19 SkRect tmp; | 19 SkRect tmp; |
| 20 inner->computeFastBounds(src, &tmp); | 20 inner->computeFastBounds(src, &tmp); |
| 21 outer->computeFastBounds(tmp, dst); | 21 outer->computeFastBounds(tmp, dst); |
| 22 } | 22 } |
| 23 | 23 |
| 24 SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons
t Context& ctx, | 24 SkSpecialImage* SkComposeImageFilter::onFilterImage(SkSpecialImage* source, cons
t Context& ctx, |
| 25 SkIPoint* offset) const { | 25 SkIPoint* offset) const { |
| 26 // The bounds passed to the inner filter must be filtered by the outer |
| 27 // filter, so that the inner filter produces the pixels that the outer |
| 28 // filter requires as input. This matters if the outer filter moves pixels. |
| 29 SkIRect innerClipBounds; |
| 30 getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(), &innerClipBounds); |
| 31 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); |
| 26 SkIPoint innerOffset = SkIPoint::Make(0, 0); | 32 SkIPoint innerOffset = SkIPoint::Make(0, 0); |
| 27 SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, ctx, &innerO
ffset)); | 33 SkAutoTUnref<SkSpecialImage> inner(this->filterInput(1, source, innerContext
, &innerOffset)); |
| 28 if (!inner) { | 34 if (!inner) { |
| 29 return nullptr; | 35 return nullptr; |
| 30 } | 36 } |
| 31 | 37 |
| 32 SkMatrix outerMatrix(ctx.ctm()); | 38 SkMatrix outerMatrix(ctx.ctm()); |
| 33 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); | 39 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); |
| 34 SkIRect clipBounds = ctx.clipBounds(); | 40 SkIRect clipBounds = ctx.clipBounds(); |
| 35 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); | 41 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); |
| 36 Context outerContext(outerMatrix, clipBounds, ctx.cache()); | 42 Context outerContext(outerMatrix, clipBounds, ctx.cache()); |
| 37 | 43 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 | 77 |
| 72 str->appendf("outer: "); | 78 str->appendf("outer: "); |
| 73 outer->toString(str); | 79 outer->toString(str); |
| 74 | 80 |
| 75 str->appendf("inner: "); | 81 str->appendf("inner: "); |
| 76 inner->toString(str); | 82 inner->toString(str); |
| 77 | 83 |
| 78 str->appendf(")"); | 84 str->appendf(")"); |
| 79 } | 85 } |
| 80 #endif | 86 #endif |
| OLD | NEW |