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 "SkMergeImageFilter.h" | 8 #include "SkMergeImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 this->initAllocModes(); | 35 this->initAllocModes(); |
36 int inputCount = this->countInputs(); | 36 int inputCount = this->countInputs(); |
37 for (int i = 0; i < inputCount; ++i) { | 37 for (int i = 0; i < inputCount; ++i) { |
38 fModes[i] = SkToU8(modes[i]); | 38 fModes[i] = SkToU8(modes[i]); |
39 } | 39 } |
40 } else { | 40 } else { |
41 fModes = nullptr; | 41 fModes = nullptr; |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count, | 45 SkMergeImageFilter::SkMergeImageFilter(sk_sp<SkImageFilter> filters[], int count
, |
46 const SkXfermode::Mode modes[], | 46 const SkXfermode::Mode modes[], |
47 const CropRect* cropRect) | 47 const CropRect* cropRect) |
48 : INHERITED(count, filters, cropRect) { | 48 : INHERITED(filters, count, cropRect) { |
49 SkASSERT(count >= 0); | 49 SkASSERT(count >= 0); |
50 this->initModes(modes); | 50 this->initModes(modes); |
51 } | 51 } |
52 | 52 |
53 SkMergeImageFilter::~SkMergeImageFilter() { | 53 SkMergeImageFilter::~SkMergeImageFilter() { |
54 | 54 |
55 if (fModes != SkTCast<uint8_t*>(fStorage)) { | 55 if (fModes != SkTCast<uint8_t*>(fStorage)) { |
56 sk_free(fModes); | 56 sk_free(fModes); |
57 } | 57 } |
58 } | 58 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 if (!buffer.readByteArray(modes8.get(), count)) { | 142 if (!buffer.readByteArray(modes8.get(), count)) { |
143 return nullptr; | 143 return nullptr; |
144 } | 144 } |
145 for (int i = 0; i < count; ++i) { | 145 for (int i = 0; i < count; ++i) { |
146 modes[i] = (SkXfermode::Mode)modes8[i]; | 146 modes[i] = (SkXfermode::Mode)modes8[i]; |
147 buffer.validate(SkIsValidMode(modes[i])); | 147 buffer.validate(SkIsValidMode(modes[i])); |
148 } | 148 } |
149 if (!buffer.isValid()) { | 149 if (!buffer.isValid()) { |
150 return nullptr; | 150 return nullptr; |
151 } | 151 } |
152 return Create(common.inputs(), count, modes.get(), &common.cropRect()); | 152 return Make(common.inputs(), count, modes.get(), &common.cropRect()).rel
ease(); |
153 } | 153 } |
154 return Create(common.inputs(), count, nullptr, &common.cropRect()); | 154 return Make(common.inputs(), count, nullptr, &common.cropRect()).release(); |
155 } | 155 } |
156 | 156 |
157 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { | 157 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { |
158 this->INHERITED::flatten(buffer); | 158 this->INHERITED::flatten(buffer); |
159 buffer.writeBool(fModes != nullptr); | 159 buffer.writeBool(fModes != nullptr); |
160 if (fModes) { | 160 if (fModes) { |
161 buffer.writeByteArray(fModes, this->countInputs() * sizeof(fModes[0])); | 161 buffer.writeByteArray(fModes, this->countInputs() * sizeof(fModes[0])); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 #ifndef SK_IGNORE_TO_STRING | 165 #ifndef SK_IGNORE_TO_STRING |
166 void SkMergeImageFilter::toString(SkString* str) const { | 166 void SkMergeImageFilter::toString(SkString* str) const { |
167 str->appendf("SkMergeImageFilter: ("); | 167 str->appendf("SkMergeImageFilter: ("); |
168 | 168 |
169 for (int i = 0; i < this->countInputs(); ++i) { | 169 for (int i = 0; i < this->countInputs(); ++i) { |
170 SkImageFilter* filter = this->getInput(i); | 170 SkImageFilter* filter = this->getInput(i); |
171 str->appendf("%d: (", i); | 171 str->appendf("%d: (", i); |
172 filter->toString(str); | 172 filter->toString(str); |
173 str->appendf(")"); | 173 str->appendf(")"); |
174 } | 174 } |
175 | 175 |
176 str->append(")"); | 176 str->append(")"); |
177 } | 177 } |
178 #endif | 178 #endif |
OLD | NEW |