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

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

Issue 1020403002: remove SK_SUPPORT_LEGACY_PIXELREF_UNFLATTENABLE code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 9 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/SkBitmap.h ('k') | no next file » | 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 /* 2 /*
3 * Copyright 2008 The Android Open Source Project 3 * Copyright 2008 The Android Open Source Project
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 1257 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 bitmap->setInfo(pr->info()); 1268 bitmap->setInfo(pr->info());
1269 bitmap->setPixelRef(pr, 0, 0); 1269 bitmap->setPixelRef(pr, 0, 0);
1270 return true; 1270 return true;
1271 } 1271 }
1272 1272
1273 enum { 1273 enum {
1274 SERIALIZE_PIXELTYPE_NONE, 1274 SERIALIZE_PIXELTYPE_NONE,
1275 SERIALIZE_PIXELTYPE_REF_DATA 1275 SERIALIZE_PIXELTYPE_REF_DATA
1276 }; 1276 };
1277 1277
1278 void SkBitmap::legacyUnflatten(SkReadBuffer& buffer) {
1279 #ifdef SK_SUPPORT_LEGACY_PIXELREF_UNFLATTENABLE
1280 this->reset();
1281
1282 SkImageInfo info;
1283 info.unflatten(buffer);
1284 size_t rowBytes = buffer.readInt();
1285 if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) &&
1286 SkColorTypeIsValid(info.fColorType) &&
1287 SkAlphaTypeIsValid(info.fAlphaType) &&
1288 SkColorTypeValidateAlphaType(info.fColorType, info.fAlp haType) &&
1289 info.validRowBytes(rowBytes))) {
1290 return;
1291 }
1292
1293 bool configIsValid = this->setInfo(info, rowBytes);
1294 buffer.validate(configIsValid);
1295
1296 int reftype = buffer.readInt();
1297 if (buffer.validate((SERIALIZE_PIXELTYPE_REF_DATA == reftype) ||
1298 (SERIALIZE_PIXELTYPE_NONE == reftype))) {
1299 switch (reftype) {
1300 case SERIALIZE_PIXELTYPE_REF_DATA: {
1301 SkIPoint origin;
1302 origin.fX = buffer.readInt();
1303 origin.fY = buffer.readInt();
1304 size_t offset = origin.fY * rowBytes + origin.fX * info.bytesPer Pixel();
1305 SkPixelRef* pr = buffer.readFlattenable<SkPixelRef>();
1306 if (!buffer.validate((NULL == pr) ||
1307 (pr->getAllocatedSizeInBytes() >= (offset + this->getSafe Size())))) {
1308 origin.setZero();
1309 }
1310 SkSafeUnref(this->setPixelRef(pr, origin));
1311 break;
1312 }
1313 case SERIALIZE_PIXELTYPE_NONE:
1314 break;
1315 default:
1316 SkDEBUGFAIL("unrecognized pixeltype in serialized data");
1317 sk_throw();
1318 }
1319 }
1320 #else
1321 sk_throw();
1322 #endif
1323 }
1324
1325 /////////////////////////////////////////////////////////////////////////////// 1278 ///////////////////////////////////////////////////////////////////////////////
1326 1279
1327 SkBitmap::RLEPixels::RLEPixels(int width, int height) { 1280 SkBitmap::RLEPixels::RLEPixels(int width, int height) {
1328 fHeight = height; 1281 fHeight = height;
1329 fYPtrs = (uint8_t**)sk_calloc_throw(height * sizeof(uint8_t*)); 1282 fYPtrs = (uint8_t**)sk_calloc_throw(height * sizeof(uint8_t*));
1330 } 1283 }
1331 1284
1332 SkBitmap::RLEPixels::~RLEPixels() { 1285 SkBitmap::RLEPixels::~RLEPixels() {
1333 sk_free(fYPtrs); 1286 sk_free(fYPtrs);
1334 } 1287 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 /////////////////////////////////////////////////////////////////////////////// 1365 ///////////////////////////////////////////////////////////////////////////////
1413 1366
1414 #ifdef SK_DEBUG 1367 #ifdef SK_DEBUG
1415 void SkImageInfo::validate() const { 1368 void SkImageInfo::validate() const {
1416 SkASSERT(fWidth >= 0); 1369 SkASSERT(fWidth >= 0);
1417 SkASSERT(fHeight >= 0); 1370 SkASSERT(fHeight >= 0);
1418 SkASSERT(SkColorTypeIsValid(fColorType)); 1371 SkASSERT(SkColorTypeIsValid(fColorType));
1419 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1372 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1420 } 1373 }
1421 #endif 1374 #endif
OLDNEW
« no previous file with comments | « include/core/SkBitmap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698