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" |
(...skipping 19 matching lines...) Expand all Loading... |
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->filterInput(0, proxy, source, ctx, &src, &srcOffset)) { |
36 return false; | 36 return false; |
37 } | 37 } |
38 | 38 |
39 SkIRect bounds; | 39 SkIRect bounds; |
40 if (!this->applyCropRect(ctx, src, srcOffset, &bounds)) { | 40 SkIRect srcBounds = src.bounds(); |
| 41 srcBounds.offset(srcOffset); |
| 42 if (!this->applyCropRect(ctx, srcBounds, &bounds)) { |
41 return false; | 43 return false; |
42 } | 44 } |
43 | 45 |
44 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo
unds.height())); | 46 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), bo
unds.height())); |
45 if (nullptr == device.get()) { | 47 if (nullptr == device.get()) { |
46 return false; | 48 return false; |
47 } | 49 } |
48 SkCanvas canvas(device); | 50 SkCanvas canvas(device); |
49 SkPaint paint; | 51 SkPaint paint; |
50 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 52 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void SkOffsetImageFilter::toString(SkString* str) const { | 105 void SkOffsetImageFilter::toString(SkString* str) const { |
104 str->appendf("SkOffsetImageFilter: ("); | 106 str->appendf("SkOffsetImageFilter: ("); |
105 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); |
106 str->append("input: ("); | 108 str->append("input: ("); |
107 if (this->getInput(0)) { | 109 if (this->getInput(0)) { |
108 this->getInput(0)->toString(str); | 110 this->getInput(0)->toString(str); |
109 } | 111 } |
110 str->append("))"); | 112 str->append("))"); |
111 } | 113 } |
112 #endif | 114 #endif |
OLD | NEW |