OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkOffsetImageFilter.h" | 8 #include "SkOffsetImageFilter.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkMatrix.h" | 10 #include "SkMatrix.h" |
11 #include "SkFlattenableBuffers.h" | 11 #include "SkFlattenableBuffers.h" |
12 | 12 |
13 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, | 13 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, |
14 const SkMatrix& matrix, | 14 const SkMatrix& matrix, |
15 SkBitmap* result, | 15 SkBitmap* result, |
16 SkIPoint* loc) { | 16 SkIPoint* loc) { |
17 SkBitmap src = this->getInputResult(0, proxy, source, matrix, loc); | 17 SkBitmap src = source; |
| 18 if (getInput(0) && !getInput(0)->filterImage(proxy, source, matrix, &src, lo
c)) { |
| 19 return false; |
| 20 } |
| 21 |
18 SkVector vec; | 22 SkVector vec; |
19 matrix.mapVectors(&vec, &fOffset, 1); | 23 matrix.mapVectors(&vec, &fOffset, 1); |
20 | 24 |
21 loc->fX += SkScalarRoundToInt(vec.fX); | 25 loc->fX += SkScalarRoundToInt(vec.fX); |
22 loc->fY += SkScalarRoundToInt(vec.fY); | 26 loc->fY += SkScalarRoundToInt(vec.fY); |
23 *result = src; | 27 *result = src; |
24 return true; | 28 return true; |
25 } | 29 } |
26 | 30 |
27 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
, | 31 bool SkOffsetImageFilter::onFilterBounds(const SkIRect& src, const SkMatrix& ctm
, |
(...skipping 12 matching lines...) Expand all Loading... |
40 } | 44 } |
41 | 45 |
42 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, | 46 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, |
43 SkImageFilter* input) : INHERITED(input
) { | 47 SkImageFilter* input) : INHERITED(input
) { |
44 fOffset.set(dx, dy); | 48 fOffset.set(dx, dy); |
45 } | 49 } |
46 | 50 |
47 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) : INHE
RITED(buffer) { | 51 SkOffsetImageFilter::SkOffsetImageFilter(SkFlattenableReadBuffer& buffer) : INHE
RITED(buffer) { |
48 buffer.readPoint(&fOffset); | 52 buffer.readPoint(&fOffset); |
49 } | 53 } |
OLD | NEW |