OLD | NEW |
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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1340 bitmap->setConfig(pr->info()); | 1340 bitmap->setConfig(pr->info()); |
1341 bitmap->setPixelRef(pr, 0, 0); | 1341 bitmap->setPixelRef(pr, 0, 0); |
1342 return true; | 1342 return true; |
1343 } | 1343 } |
1344 | 1344 |
1345 enum { | 1345 enum { |
1346 SERIALIZE_PIXELTYPE_NONE, | 1346 SERIALIZE_PIXELTYPE_NONE, |
1347 SERIALIZE_PIXELTYPE_REF_DATA | 1347 SERIALIZE_PIXELTYPE_REF_DATA |
1348 }; | 1348 }; |
1349 | 1349 |
1350 #ifdef SK_SUPPORT_LEGACY_BITMAPFLATTEN | 1350 void SkBitmap::legacyUnflatten(SkReadBuffer& buffer) { |
1351 void SkBitmap::flatten(SkWriteBuffer& buffer) const { | |
1352 fInfo.flatten(buffer); | |
1353 buffer.writeInt(fRowBytes); | |
1354 | |
1355 if (fPixelRef) { | |
1356 if (fPixelRef->getFactory()) { | |
1357 buffer.writeInt(SERIALIZE_PIXELTYPE_REF_DATA); | |
1358 buffer.writeInt(fPixelRefOrigin.fX); | |
1359 buffer.writeInt(fPixelRefOrigin.fY); | |
1360 buffer.writeFlattenable(fPixelRef); | |
1361 return; | |
1362 } | |
1363 // if we get here, we can't record the pixels | |
1364 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); | |
1365 } else { | |
1366 buffer.writeInt(SERIALIZE_PIXELTYPE_NONE); | |
1367 } | |
1368 } | |
1369 #endif | |
1370 | |
1371 void SkBitmap::unflatten(SkReadBuffer& buffer) { | |
1372 this->reset(); | 1351 this->reset(); |
1373 | 1352 |
1374 SkImageInfo info; | 1353 SkImageInfo info; |
1375 info.unflatten(buffer); | 1354 info.unflatten(buffer); |
1376 size_t rowBytes = buffer.readInt(); | 1355 size_t rowBytes = buffer.readInt(); |
1377 if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) && | 1356 if (!buffer.validate((info.width() >= 0) && (info.height() >= 0) && |
1378 SkColorTypeIsValid(info.fColorType) && | 1357 SkColorTypeIsValid(info.fColorType) && |
1379 SkAlphaTypeIsValid(info.fAlphaType) && | 1358 SkAlphaTypeIsValid(info.fAlphaType) && |
1380 validate_alphaType(info.fColorType, info.fAlphaType) && | 1359 validate_alphaType(info.fColorType, info.fAlphaType) && |
1381 info.validRowBytes(rowBytes))) { | 1360 info.validRowBytes(rowBytes))) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1501 /////////////////////////////////////////////////////////////////////////////// | 1480 /////////////////////////////////////////////////////////////////////////////// |
1502 | 1481 |
1503 #ifdef SK_DEBUG | 1482 #ifdef SK_DEBUG |
1504 void SkImageInfo::validate() const { | 1483 void SkImageInfo::validate() const { |
1505 SkASSERT(fWidth >= 0); | 1484 SkASSERT(fWidth >= 0); |
1506 SkASSERT(fHeight >= 0); | 1485 SkASSERT(fHeight >= 0); |
1507 SkASSERT(SkColorTypeIsValid(fColorType)); | 1486 SkASSERT(SkColorTypeIsValid(fColorType)); |
1508 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1487 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1509 } | 1488 } |
1510 #endif | 1489 #endif |
OLD | NEW |