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" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source
, | 33 sk_sp<SkSpecialImage> SkComposeImageFilter::onFilterImage(SkSpecialImage* source
, |
34 const Context& ctx, | 34 const Context& ctx, |
35 SkIPoint* offset) cons
t { | 35 SkIPoint* offset) cons
t { |
36 // The bounds passed to the inner filter must be filtered by the outer | 36 // The bounds passed to the inner filter must be filtered by the outer |
37 // filter, so that the inner filter produces the pixels that the outer | 37 // filter, so that the inner filter produces the pixels that the outer |
38 // filter requires as input. This matters if the outer filter moves pixels. | 38 // filter requires as input. This matters if the outer filter moves pixels. |
39 SkIRect innerClipBounds; | 39 SkIRect innerClipBounds; |
40 innerClipBounds = this->getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(
)); | 40 innerClipBounds = this->getInput(0)->filterBounds(ctx.clipBounds(), ctx.ctm(
)); |
41 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache()); | 41 Context innerContext(ctx.ctm(), innerClipBounds, ctx.cache(), ctx.outputProp
erties()); |
42 SkIPoint innerOffset = SkIPoint::Make(0, 0); | 42 SkIPoint innerOffset = SkIPoint::Make(0, 0); |
43 sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &inne
rOffset)); | 43 sk_sp<SkSpecialImage> inner(this->filterInput(1, source, innerContext, &inne
rOffset)); |
44 if (!inner) { | 44 if (!inner) { |
45 return nullptr; | 45 return nullptr; |
46 } | 46 } |
47 | 47 |
48 SkMatrix outerMatrix(ctx.ctm()); | 48 SkMatrix outerMatrix(ctx.ctm()); |
49 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); | 49 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in
nerOffset.y())); |
50 SkIRect clipBounds = ctx.clipBounds(); | 50 SkIRect clipBounds = ctx.clipBounds(); |
51 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); | 51 clipBounds.offset(-innerOffset.x(), -innerOffset.y()); |
52 Context outerContext(outerMatrix, clipBounds, ctx.cache()); | 52 Context outerContext(outerMatrix, clipBounds, ctx.cache(), ctx.outputPropert
ies()); |
53 | 53 |
54 SkIPoint outerOffset = SkIPoint::Make(0, 0); | 54 SkIPoint outerOffset = SkIPoint::Make(0, 0); |
55 sk_sp<SkSpecialImage> outer(this->filterInput(0, inner.get(), outerContext,
&outerOffset)); | 55 sk_sp<SkSpecialImage> outer(this->filterInput(0, inner.get(), outerContext,
&outerOffset)); |
56 if (!outer) { | 56 if (!outer) { |
57 return nullptr; | 57 return nullptr; |
58 } | 58 } |
59 | 59 |
60 *offset = innerOffset + outerOffset; | 60 *offset = innerOffset + outerOffset; |
61 return outer; | 61 return outer; |
62 } | 62 } |
(...skipping 20 matching lines...) Expand all Loading... |
83 | 83 |
84 str->appendf("outer: "); | 84 str->appendf("outer: "); |
85 outer->toString(str); | 85 outer->toString(str); |
86 | 86 |
87 str->appendf("inner: "); | 87 str->appendf("inner: "); |
88 inner->toString(str); | 88 inner->toString(str); |
89 | 89 |
90 str->appendf(")"); | 90 str->appendf(")"); |
91 } | 91 } |
92 #endif | 92 #endif |
OLD | NEW |