OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2008 The Android Open Source Project | 2 * Copyright 2008 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 "SkAtomics.h" | 8 #include "SkAtomics.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1138 for (int y = height - 1; y >= 1; --y) { | 1138 for (int y = height - 1; y >= 1; --y) { |
1139 memmove(dstRow, srcRow, snugRB); | 1139 memmove(dstRow, srcRow, snugRB); |
1140 srcRow -= snugRB; | 1140 srcRow -= snugRB; |
1141 dstRow -= ramRB; | 1141 dstRow -= ramRB; |
1142 } | 1142 } |
1143 SkASSERT(srcRow == dstRow); // first row does not need to be moved | 1143 SkASSERT(srcRow == dstRow); // first row does not need to be moved |
1144 } | 1144 } |
1145 | 1145 |
1146 SkAutoTUnref<SkColorTable> ctable; | 1146 SkAutoTUnref<SkColorTable> ctable; |
1147 if (buffer->readBool()) { | 1147 if (buffer->readBool()) { |
1148 ctable.reset(new SkColorTable(*buffer)); | 1148 ctable.reset(SkColorTable::Create(*buffer)); |
1149 if (!ctable) { | |
1150 return false; | |
1151 } | |
1152 // only permit an empty table if we have no pixels | |
robertphillips
2015/08/28 15:58:53
seems some guard is missing here
reed1
2015/08/28 16:01:08
Done.
| |
1153 if (ctable->count() == 0 && info.width() > 0 && info.height() > 0) { | |
1154 return false; | |
1155 } | |
1149 | 1156 |
1150 unsigned char maxIndex = ctable->count() ? ctable->count()-1 : 0; | 1157 unsigned char maxIndex = ctable->count() - 1; |
1151 for (uint64_t i = 0; i < ramSize; ++i) { | 1158 for (uint64_t i = 0; i < ramSize; ++i) { |
1152 dst[i] = SkTMin(dst[i], maxIndex); | 1159 dst[i] = SkTMin(dst[i], maxIndex); |
1153 } | 1160 } |
1154 } | 1161 } |
1155 | 1162 |
1156 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowB ytes(), | 1163 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowB ytes(), |
1157 ctable.get(), data .get())); | 1164 ctable.get(), data .get())); |
1158 if (!pr.get()) { | 1165 if (!pr.get()) { |
1159 return false; | 1166 return false; |
1160 } | 1167 } |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1300 /////////////////////////////////////////////////////////////////////////////// | 1307 /////////////////////////////////////////////////////////////////////////////// |
1301 | 1308 |
1302 #ifdef SK_DEBUG | 1309 #ifdef SK_DEBUG |
1303 void SkImageInfo::validate() const { | 1310 void SkImageInfo::validate() const { |
1304 SkASSERT(fWidth >= 0); | 1311 SkASSERT(fWidth >= 0); |
1305 SkASSERT(fHeight >= 0); | 1312 SkASSERT(fHeight >= 0); |
1306 SkASSERT(SkColorTypeIsValid(fColorType)); | 1313 SkASSERT(SkColorTypeIsValid(fColorType)); |
1307 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1314 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1308 } | 1315 } |
1309 #endif | 1316 #endif |
OLD | NEW |