| 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 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 inputs[i]->draw(canvas, | 124 inputs[i]->draw(canvas, |
| 125 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset
s[i].y() - y0), | 125 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset
s[i].y() - y0), |
| 126 &paint); | 126 &paint); |
| 127 } | 127 } |
| 128 | 128 |
| 129 offset->fX = bounds.left(); | 129 offset->fX = bounds.left(); |
| 130 offset->fY = bounds.top(); | 130 offset->fY = bounds.top(); |
| 131 return surf->makeImageSnapshot(); | 131 return surf->makeImageSnapshot(); |
| 132 } | 132 } |
| 133 | 133 |
| 134 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { | 134 sk_sp<SkFlattenable> SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 135 Common common; | 135 Common common; |
| 136 if (!common.unflatten(buffer, -1)) { | 136 if (!common.unflatten(buffer, -1)) { |
| 137 return nullptr; | 137 return nullptr; |
| 138 } | 138 } |
| 139 | 139 |
| 140 const int count = common.inputCount(); | 140 const int count = common.inputCount(); |
| 141 bool hasModes = buffer.readBool(); | 141 bool hasModes = buffer.readBool(); |
| 142 if (hasModes) { | 142 if (hasModes) { |
| 143 SkAutoSTArray<4, SkXfermode::Mode> modes(count); | 143 SkAutoSTArray<4, SkXfermode::Mode> modes(count); |
| 144 SkAutoSTArray<4, uint8_t> modes8(count); | 144 SkAutoSTArray<4, uint8_t> modes8(count); |
| 145 if (!buffer.readByteArray(modes8.get(), count)) { | 145 if (!buffer.readByteArray(modes8.get(), count)) { |
| 146 return nullptr; | 146 return nullptr; |
| 147 } | 147 } |
| 148 for (int i = 0; i < count; ++i) { | 148 for (int i = 0; i < count; ++i) { |
| 149 modes[i] = (SkXfermode::Mode)modes8[i]; | 149 modes[i] = (SkXfermode::Mode)modes8[i]; |
| 150 buffer.validate(SkIsValidMode(modes[i])); | 150 buffer.validate(SkIsValidMode(modes[i])); |
| 151 } | 151 } |
| 152 if (!buffer.isValid()) { | 152 if (!buffer.isValid()) { |
| 153 return nullptr; | 153 return nullptr; |
| 154 } | 154 } |
| 155 return Make(common.inputs(), count, modes.get(), &common.cropRect()).rel
ease(); | 155 return Make(common.inputs(), count, modes.get(), &common.cropRect()); |
| 156 } | 156 } |
| 157 return Make(common.inputs(), count, nullptr, &common.cropRect()).release(); | 157 return Make(common.inputs(), count, nullptr, &common.cropRect()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { | 160 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 161 this->INHERITED::flatten(buffer); | 161 this->INHERITED::flatten(buffer); |
| 162 buffer.writeBool(fModes != nullptr); | 162 buffer.writeBool(fModes != nullptr); |
| 163 if (fModes) { | 163 if (fModes) { |
| 164 buffer.writeByteArray(fModes, this->countInputs() * sizeof(fModes[0])); | 164 buffer.writeByteArray(fModes, this->countInputs() * sizeof(fModes[0])); |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 #ifndef SK_IGNORE_TO_STRING | 168 #ifndef SK_IGNORE_TO_STRING |
| 169 void SkMergeImageFilter::toString(SkString* str) const { | 169 void SkMergeImageFilter::toString(SkString* str) const { |
| 170 str->appendf("SkMergeImageFilter: ("); | 170 str->appendf("SkMergeImageFilter: ("); |
| 171 | 171 |
| 172 for (int i = 0; i < this->countInputs(); ++i) { | 172 for (int i = 0; i < this->countInputs(); ++i) { |
| 173 SkImageFilter* filter = this->getInput(i); | 173 SkImageFilter* filter = this->getInput(i); |
| 174 str->appendf("%d: (", i); | 174 str->appendf("%d: (", i); |
| 175 filter->toString(str); | 175 filter->toString(str); |
| 176 str->appendf(")"); | 176 str->appendf(")"); |
| 177 } | 177 } |
| 178 | 178 |
| 179 str->append(")"); | 179 str->append(")"); |
| 180 } | 180 } |
| 181 #endif | 181 #endif |
| OLD | NEW |