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::onFilterImage(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 #ifdef SK_DISABLE_OFFSETIMAGEFILTER_OPTIMIZATION | |
24 if (false) { | |
25 #else | |
26 if (!cropRectIsSet()) { | 23 if (!cropRectIsSet()) { |
27 #endif | |
28 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { | 24 if (!this->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { |
29 return false; | 25 return false; |
30 } | 26 } |
31 | 27 |
32 SkVector vec; | 28 SkVector vec; |
33 ctx.ctm().mapVectors(&vec, &fOffset, 1); | 29 ctx.ctm().mapVectors(&vec, &fOffset, 1); |
34 | 30 |
35 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX); | 31 offset->fX = srcOffset.fX + SkScalarRoundToInt(vec.fX); |
36 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); | 32 offset->fY = srcOffset.fY + SkScalarRoundToInt(vec.fY); |
37 *result = src; | 33 *result = src; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 void SkOffsetImageFilter::toString(SkString* str) const { | 112 void SkOffsetImageFilter::toString(SkString* str) const { |
117 str->appendf("SkOffsetImageFilter: ("); | 113 str->appendf("SkOffsetImageFilter: ("); |
118 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 114 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); |
119 str->append("input: ("); | 115 str->append("input: ("); |
120 if (this->getInput(0)) { | 116 if (this->getInput(0)) { |
121 this->getInput(0)->toString(str); | 117 this->getInput(0)->toString(str); |
122 } | 118 } |
123 str->append("))"); | 119 str->append("))"); |
124 } | 120 } |
125 #endif | 121 #endif |
OLD | NEW |