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 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 vec.negate(); | 79 vec.negate(); |
80 } | 80 } |
81 | 81 |
82 return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); | 82 return src.makeOffset(SkScalarCeilToInt(vec.fX), SkScalarCeilToInt(vec.fY)); |
83 } | 83 } |
84 | 84 |
85 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { | 85 SkFlattenable* SkOffsetImageFilter::CreateProc(SkReadBuffer& buffer) { |
86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 86 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
87 SkPoint offset; | 87 SkPoint offset; |
88 buffer.readPoint(&offset); | 88 buffer.readPoint(&offset); |
89 return Create(offset.x(), offset.y(), common.getInput(0).get(), &common.crop
Rect()); | 89 return Make(offset.x(), offset.y(), common.getInput(0), &common.cropRect()).
release(); |
90 } | 90 } |
91 | 91 |
92 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { | 92 void SkOffsetImageFilter::flatten(SkWriteBuffer& buffer) const { |
93 this->INHERITED::flatten(buffer); | 93 this->INHERITED::flatten(buffer); |
94 buffer.writePoint(fOffset); | 94 buffer.writePoint(fOffset); |
95 } | 95 } |
96 | 96 |
97 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, SkImageFilter
* input, | 97 SkOffsetImageFilter::SkOffsetImageFilter(SkScalar dx, SkScalar dy, |
| 98 sk_sp<SkImageFilter> input, |
98 const CropRect* cropRect) | 99 const CropRect* cropRect) |
99 : INHERITED(1, &input, cropRect) { | 100 : INHERITED(&input, 1, cropRect) { |
100 fOffset.set(dx, dy); | 101 fOffset.set(dx, dy); |
101 } | 102 } |
102 | 103 |
103 #ifndef SK_IGNORE_TO_STRING | 104 #ifndef SK_IGNORE_TO_STRING |
104 void SkOffsetImageFilter::toString(SkString* str) const { | 105 void SkOffsetImageFilter::toString(SkString* str) const { |
105 str->appendf("SkOffsetImageFilter: ("); | 106 str->appendf("SkOffsetImageFilter: ("); |
106 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); | 107 str->appendf("offset: (%f, %f) ", fOffset.fX, fOffset.fY); |
107 str->append("input: ("); | 108 str->append("input: ("); |
108 if (this->getInput(0)) { | 109 if (this->getInput(0)) { |
109 this->getInput(0)->toString(str); | 110 this->getInput(0)->toString(str); |
110 } | 111 } |
111 str->append("))"); | 112 str->append("))"); |
112 } | 113 } |
113 #endif | 114 #endif |
OLD | NEW |