Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/core/SkBitmap.cpp

Issue 1307023004: change colortable to use factory for reinflating, check for empty (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/core/SkColorTable.h ('k') | src/core/SkColorTable.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
1149 1152
1150 unsigned char maxIndex = ctable->count() ? ctable->count()-1 : 0; 1153 if (info.isEmpty()) {
1151 for (uint64_t i = 0; i < ramSize; ++i) { 1154 // require an empty ctable
robertphillips 2015/08/28 16:31:43 '!=' instead of '!'...'==' ?
reed1 2015/08/28 17:00:36 Done.
1152 dst[i] = SkTMin(dst[i], maxIndex); 1155 if (!buffer->validate(ctable->count() == 0)) {
1156 return false;
1157 }
1158 } else {
1159 // require a non-empty ctable
robertphillips 2015/08/28 16:31:43 '<=' instead of '!'...'>' ?
reed1 2015/08/28 17:00:36 Done.
1160 if (!buffer->validate(ctable->count() > 0)) {
1161 return false;
1162 }
1163 unsigned char maxIndex = ctable->count() - 1;
1164 for (uint64_t i = 0; i < ramSize; ++i) {
1165 dst[i] = SkTMin(dst[i], maxIndex);
1166 }
1153 } 1167 }
1154 } 1168 }
1155 1169
1156 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowB ytes(), 1170 SkAutoTUnref<SkPixelRef> pr(SkMallocPixelRef::NewWithData(info, info.minRowB ytes(),
1157 ctable.get(), data .get())); 1171 ctable.get(), data .get()));
1158 if (!pr.get()) { 1172 if (!pr.get()) {
1159 return false; 1173 return false;
1160 } 1174 }
1161 bitmap->setInfo(pr->info()); 1175 bitmap->setInfo(pr->info());
1162 bitmap->setPixelRef(pr, 0, 0); 1176 bitmap->setPixelRef(pr, 0, 0);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 /////////////////////////////////////////////////////////////////////////////// 1314 ///////////////////////////////////////////////////////////////////////////////
1301 1315
1302 #ifdef SK_DEBUG 1316 #ifdef SK_DEBUG
1303 void SkImageInfo::validate() const { 1317 void SkImageInfo::validate() const {
1304 SkASSERT(fWidth >= 0); 1318 SkASSERT(fWidth >= 0);
1305 SkASSERT(fHeight >= 0); 1319 SkASSERT(fHeight >= 0);
1306 SkASSERT(SkColorTypeIsValid(fColorType)); 1320 SkASSERT(SkColorTypeIsValid(fColorType));
1307 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1321 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1308 } 1322 }
1309 #endif 1323 #endif
OLDNEW
« no previous file with comments | « include/core/SkColorTable.h ('k') | src/core/SkColorTable.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698