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 "SkCanvas.h" | 10 #include "SkCanvas.h" |
11 #include "SkDevice.h" | 11 #include "SkDevice.h" |
12 #include "SkReadBuffer.h" | 12 #include "SkReadBuffer.h" |
13 #include "SkWriteBuffer.h" | 13 #include "SkWriteBuffer.h" |
14 #include "SkMatrix.h" | 14 #include "SkMatrix.h" |
15 #include "SkPaint.h" | 15 #include "SkPaint.h" |
16 | 16 |
17 bool SkOffsetImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& source, | 17 bool SkOffsetImageFilter::onFilterImageDeprecated(Proxy* proxy, const SkBitmap&
source, |
18 const Context& ctx, | 18 const Context& ctx, |
19 SkBitmap* result, | 19 SkBitmap* result, |
20 SkIPoint* offset) const { | 20 SkIPoint* offset) const { |
21 SkBitmap src = source; | 21 SkBitmap src = source; |
22 SkIPoint srcOffset = SkIPoint::Make(0, 0); | 22 SkIPoint srcOffset = SkIPoint::Make(0, 0); |
23 if (!cropRectIsSet()) { | 23 if (!cropRectIsSet()) { |
24 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 24 if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset
)) { |
25 return false; | 25 return false; |
26 } | 26 } |
27 | 27 |
28 SkVector vec; | 28 SkVector vec; |
29 ctx.ctm().mapVectors(&vec, &fOffset, 1); | 29 ctx.ctm().mapVectors(&vec, &fOffset, 1); |
30 | 30 |
31 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX); | 31 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX); |
32 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); | 32 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); |
33 *result = src; | 33 *result = src; |
34 } else { | 34 } else { |
35 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 35 if (!this->filterInputDeprecated(0, proxy, source, ctx, &src, &srcOffset
)) { |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 SkIRect bounds; | 39 SkIRect bounds; |
40 SkIRect srcBounds = src.bounds(); | 40 SkIRect srcBounds = src.bounds(); |
41 srcBounds.offset(srcOffset); | 41 srcBounds.offset(srcOffset); |
42 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { | 42 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
43 return false; | 43 return false; |
44 } | 44 } |
45 | 45 |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 void SkOffsetImageFilter::toString(SkString* str) const { | 105 void SkOffsetImageFilter::toString(SkString* str) const { |
106 str->appendf("SkOffsetImageFilter: ("); | 106 str->appendf("SkOffsetImageFilter: ("); |
107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); |
108 str->append("input: ("); | 108 str->append("input: ("); |
109 if (this->getInput(0)) { | 109 if (this->getInput(0)) { |
110 this->getInput(0)->toString(str); | 110 this->getInput(0)->toString(str); |
111 } | 111 } |
112 str->append("))"); | 112 str->append("))"); |
113 } | 113 } |
114 #endif | 114 #endif |
OLD | NEW |