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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
479 } | 479 } |
480 | 480 |
481 return true; | 481 return true; |
482 } | 482 } |
483 } | 483 } |
484 } | 484 } |
485 | 485 |
486 /////////////////////////////////////////////////////////////////////////////// | 486 /////////////////////////////////////////////////////////////////////////////// |
487 | 487 |
488 bool SkBitmap::isImmutable() const { | 488 bool SkBitmap::isImmutable() const { |
489 return fPixelRef ? fPixelRef->isImmutable() : | 489 return fPixelRef ? fPixelRef->isImmutable() : false; |
490 fFlags & kImageIsImmutable_Flag; | |
491 } | 490 } |
492 | 491 |
493 void SkBitmap::setImmutable() { | 492 void SkBitmap::setImmutable() { |
494 if (fPixelRef) { | 493 if (fPixelRef) { |
495 fPixelRef->setImmutable(); | 494 fPixelRef->setImmutable(); |
496 } else { | |
497 fFlags |= kImageIsImmutable_Flag; | |
498 } | 495 } |
499 } | 496 } |
500 | 497 |
501 bool SkBitmap::isVolatile() const { | 498 bool SkBitmap::isVolatile() const { |
502 return (fFlags & kImageIsVolatile_Flag) != 0; | 499 return (fFlags & kImageIsVolatile_Flag) != 0; |
503 } | 500 } |
504 | 501 |
505 void SkBitmap::setIsVolatile(bool isVolatile) { | 502 void SkBitmap::setIsVolatile(bool isVolatile) { |
506 if (isVolatile) { | 503 if (isVolatile) { |
507 fFlags |= kImageIsVolatile_Flag; | 504 fFlags |= kImageIsVolatile_Flag; |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1310 void SkBitmap::validate() const { | 1307 void SkBitmap::validate() const { |
1311 fInfo.validate(); | 1308 fInfo.validate(); |
1312 | 1309 |
1313 // ImageInfo may not require this, but Bitmap ensures that opaque-only | 1310 // ImageInfo may not require this, but Bitmap ensures that opaque-only |
1314 // colorTypes report opaque for their alphatype | 1311 // colorTypes report opaque for their alphatype |
1315 if (kRGB_565_SkColorType == fInfo.colorType()) { | 1312 if (kRGB_565_SkColorType == fInfo.colorType()) { |
1316 SkASSERT(kOpaque_SkAlphaType == fInfo.alphaType()); | 1313 SkASSERT(kOpaque_SkAlphaType == fInfo.alphaType()); |
1317 } | 1314 } |
1318 | 1315 |
1319 SkASSERT(fInfo.validRowBytes(fRowBytes)); | 1316 SkASSERT(fInfo.validRowBytes(fRowBytes)); |
1320 uint8_t allFlags = kImageIsOpaque_Flag | kImageIsVolatile_Flag | kImageIsImm utable_Flag; | 1317 uint8_t allFlags = kImageIsOpaque_Flag | kImageIsVolatile_Flag; |
1321 #ifdef SK_BUILD_FOR_ANDROID | 1318 #ifdef SK_BUILD_FOR_ANDROID |
1322 allFlags |= kHasHardwareMipMap_Flag; | 1319 allFlags |= kHasHardwareMipMap_Flag; |
1323 #endif | 1320 #endif |
1324 SkASSERT(fFlags <= allFlags); | 1321 SkASSERT(fFlags <= allFlags); |
scroggo
2014/07/11 20:48:47
We may want to update this to instead do a mask of
scroggo
2014/07/14 21:03:49
Done.
| |
1325 SkASSERT(fPixelLockCount >= 0); | 1322 SkASSERT(fPixelLockCount >= 0); |
1326 | 1323 |
1327 if (fPixels) { | 1324 if (fPixels) { |
1328 SkASSERT(fPixelRef); | 1325 SkASSERT(fPixelRef); |
1329 SkASSERT(fPixelLockCount > 0); | 1326 SkASSERT(fPixelLockCount > 0); |
1330 SkASSERT(fPixelRef->isLocked()); | 1327 SkASSERT(fPixelRef->isLocked()); |
1331 SkASSERT(fPixelRef->rowBytes() == fRowBytes); | 1328 SkASSERT(fPixelRef->rowBytes() == fRowBytes); |
1332 SkASSERT(fPixelRefOrigin.fX >= 0); | 1329 SkASSERT(fPixelRefOrigin.fX >= 0); |
1333 SkASSERT(fPixelRefOrigin.fY >= 0); | 1330 SkASSERT(fPixelRefOrigin.fY >= 0); |
1334 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig in.fX); | 1331 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig in.fX); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1383 /////////////////////////////////////////////////////////////////////////////// | 1380 /////////////////////////////////////////////////////////////////////////////// |
1384 | 1381 |
1385 #ifdef SK_DEBUG | 1382 #ifdef SK_DEBUG |
1386 void SkImageInfo::validate() const { | 1383 void SkImageInfo::validate() const { |
1387 SkASSERT(fWidth >= 0); | 1384 SkASSERT(fWidth >= 0); |
1388 SkASSERT(fHeight >= 0); | 1385 SkASSERT(fHeight >= 0); |
1389 SkASSERT(SkColorTypeIsValid(fColorType)); | 1386 SkASSERT(SkColorTypeIsValid(fColorType)); |
1390 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
1391 } | 1388 } |
1392 #endif | 1389 #endif |
OLD | NEW |