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 "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkComposeImageFilter.h" | 9 #include "SkComposeImageFilter.h" |
10 #include "SkReadBuffer.h" | 10 #include "SkReadBuffer.h" |
11 #include "SkWriteBuffer.h" | 11 #include "SkWriteBuffer.h" |
12 | 12 |
13 SkComposeImageFilter::~SkComposeImageFilter() { | 13 SkComposeImageFilter::~SkComposeImageFilter() { |
14 } | 14 } |
15 | 15 |
16 void SkComposeImageFilter::computeFastBounds(const SkRect& src, SkRect* dst) con st { | |
17 SkImageFilter* outer = getInput(0); | |
18 SkImageFilter* inner = getInput(1); | |
19 | |
20 SkRect tmp; | |
21 inner->computeFastBounds(src, &tmp); | |
22 outer->computeFastBounds(tmp, dst); | |
23 } | |
24 | |
16 bool SkComposeImageFilter::onFilterImage(Proxy* proxy, | 25 bool SkComposeImageFilter::onFilterImage(Proxy* proxy, |
17 const SkBitmap& src, | 26 const SkBitmap& src, |
18 const Context& ctx, | 27 const Context& ctx, |
19 SkBitmap* result, | 28 SkBitmap* result, |
20 SkIPoint* offset) const { | 29 SkIPoint* offset) const { |
21 SkImageFilter* outer = getInput(0); | 30 SkImageFilter* outer = getInput(0); |
22 SkImageFilter* inner = getInput(1); | 31 SkImageFilter* inner = getInput(1); |
23 | 32 |
24 SkBitmap tmp; | 33 SkBitmap tmp; |
25 return inner->filterImage(proxy, src, ctx, &tmp, offset) && | 34 SkIPoint innerOffset = SkIPoint::Make(0, 0); |
26 outer->filterImage(proxy, tmp, ctx, result, offset); | 35 SkIPoint outerOffset = SkIPoint::Make(0, 0); |
36 if (!inner->filterImage(proxy, src, ctx, &tmp, &innerOffset)) | |
37 return false; | |
38 | |
39 SkMatrix outerMatrix(ctx.ctm()); | |
40 outerMatrix.postTranslate(SkIntToScalar(-innerOffset.x()), SkIntToScalar(-in nerOffset.y())); | |
41 Context outerContext(outerMatrix, ctx.clipBounds(), ctx.cache()); | |
42 if (!outer->filterImage(proxy, tmp, outerContext, result, &outerOffset)) | |
reed1
2015/02/12 21:01:19
nit: Skia style always uses { }
ajuma
2015/02/13 16:02:24
Done.
| |
43 return false; | |
44 | |
45 *offset = innerOffset + outerOffset; | |
46 return true; | |
27 } | 47 } |
28 | 48 |
29 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, | 49 bool SkComposeImageFilter::onFilterBounds(const SkIRect& src, |
30 const SkMatrix& ctm, | 50 const SkMatrix& ctm, |
31 SkIRect* dst) const { | 51 SkIRect* dst) const { |
32 SkImageFilter* outer = getInput(0); | 52 SkImageFilter* outer = getInput(0); |
33 SkImageFilter* inner = getInput(1); | 53 SkImageFilter* inner = getInput(1); |
34 | 54 |
35 SkIRect tmp; | 55 SkIRect tmp; |
36 return inner->filterBounds(src, ctm, &tmp) && outer->filterBounds(tmp, ctm, dst); | 56 return inner->filterBounds(src, ctm, &tmp) && outer->filterBounds(tmp, ctm, dst); |
(...skipping 13 matching lines...) Expand all Loading... | |
50 | 70 |
51 str->appendf("outer: "); | 71 str->appendf("outer: "); |
52 outer->toString(str); | 72 outer->toString(str); |
53 | 73 |
54 str->appendf("inner: "); | 74 str->appendf("inner: "); |
55 inner->toString(str); | 75 inner->toString(str); |
56 | 76 |
57 str->appendf(")"); | 77 str->appendf(")"); |
58 } | 78 } |
59 #endif | 79 #endif |
OLD | NEW |