Chromium Code Reviews| 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkDevice.h" | 10 #include "SkDevice.h" |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 34 int inputCount = countInputs(); | 34 int inputCount = countInputs(); |
| 35 for (int i = 0; i < inputCount; ++i) { | 35 for (int i = 0; i < inputCount; ++i) { |
| 36 fModes[i] = SkToU8(modes[i]); | 36 fModes[i] = SkToU8(modes[i]); |
| 37 } | 37 } |
| 38 } else { | 38 } else { |
| 39 fModes = NULL; | 39 fModes = NULL; |
| 40 } | 40 } |
| 41 } | 41 } |
| 42 | 42 |
| 43 SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count, | 43 SkMergeImageFilter::SkMergeImageFilter(SkImageFilter* filters[], int count, |
| 44 const SkXfermode::Mode modes[], | 44 const SkXfermode::Mode modes[], |
|
robertphillips
2015/03/18 16:51:43
overlength ?
Stephen White
2015/03/18 16:55:29
Fixed.
| |
| 45 const CropRect* cropRect, | 45 const CropRect* cropRect) : INHERITED(cou nt, filters, cropRect) { |
| 46 uint32_t uniqueID) | |
| 47 : INHERITED(count, filters, cropRect, uniqueID) { | |
| 48 SkASSERT(count >= 0); | 46 SkASSERT(count >= 0); |
| 49 this->initModes(modes); | 47 this->initModes(modes); |
| 50 } | 48 } |
| 51 | 49 |
| 52 SkMergeImageFilter::~SkMergeImageFilter() { | 50 SkMergeImageFilter::~SkMergeImageFilter() { |
| 53 | 51 |
| 54 if (fModes != SkTCast<uint8_t*>(fStorage)) { | 52 if (fModes != SkTCast<uint8_t*>(fStorage)) { |
| 55 sk_free(fModes); | 53 sk_free(fModes); |
| 56 } | 54 } |
| 57 } | 55 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 121 if (!buffer.readByteArray(modes8.get(), count)) { | 119 if (!buffer.readByteArray(modes8.get(), count)) { |
| 122 return NULL; | 120 return NULL; |
| 123 } | 121 } |
| 124 for (int i = 0; i < count; ++i) { | 122 for (int i = 0; i < count; ++i) { |
| 125 modes[i] = (SkXfermode::Mode)modes8[i]; | 123 modes[i] = (SkXfermode::Mode)modes8[i]; |
| 126 buffer.validate(SkIsValidMode(modes[i])); | 124 buffer.validate(SkIsValidMode(modes[i])); |
| 127 } | 125 } |
| 128 if (!buffer.isValid()) { | 126 if (!buffer.isValid()) { |
| 129 return NULL; | 127 return NULL; |
| 130 } | 128 } |
| 131 return Create(common.inputs(), count, modes.get(), &common.cropRect(), c ommon.uniqueID()); | 129 return Create(common.inputs(), count, modes.get(), &common.cropRect()); |
| 132 } | 130 } |
| 133 return Create(common.inputs(), count, NULL, &common.cropRect(), common.uniqu eID()); | 131 return Create(common.inputs(), count, NULL, &common.cropRect()); |
| 134 } | 132 } |
| 135 | 133 |
| 136 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { | 134 void SkMergeImageFilter::flatten(SkWriteBuffer& buffer) const { |
| 137 this->INHERITED::flatten(buffer); | 135 this->INHERITED::flatten(buffer); |
| 138 buffer.writeBool(fModes != NULL); | 136 buffer.writeBool(fModes != NULL); |
| 139 if (fModes) { | 137 if (fModes) { |
| 140 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); | 138 buffer.writeByteArray(fModes, countInputs() * sizeof(fModes[0])); |
| 141 } | 139 } |
| 142 } | 140 } |
| 143 | 141 |
| 144 #ifndef SK_IGNORE_TO_STRING | 142 #ifndef SK_IGNORE_TO_STRING |
| 145 void SkMergeImageFilter::toString(SkString* str) const { | 143 void SkMergeImageFilter::toString(SkString* str) const { |
| 146 str->appendf("SkMergeImageFilter: ("); | 144 str->appendf("SkMergeImageFilter: ("); |
| 147 | 145 |
| 148 for (int i = 0; i < this->countInputs(); ++i) { | 146 for (int i = 0; i < this->countInputs(); ++i) { |
| 149 SkImageFilter* filter = this->getInput(i); | 147 SkImageFilter* filter = this->getInput(i); |
| 150 str->appendf("%d: (", i); | 148 str->appendf("%d: (", i); |
| 151 filter->toString(str); | 149 filter->toString(str); |
| 152 str->appendf(")"); | 150 str->appendf(")"); |
| 153 } | 151 } |
| 154 | 152 |
| 155 str->append(")"); | 153 str->append(")"); |
| 156 } | 154 } |
| 157 #endif | 155 #endif |
| OLD | NEW |