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

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

Issue 387083002: Remove kImageIsImmutable_Flag. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase + better validation for Flags. Created 6 years, 5 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 468 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 void SkBitmap::validate() const { 1322 void SkBitmap::validate() const {
1326 fInfo.validate(); 1323 fInfo.validate();
1327 1324
1328 // ImageInfo may not require this, but Bitmap ensures that opaque-only 1325 // ImageInfo may not require this, but Bitmap ensures that opaque-only
1329 // colorTypes report opaque for their alphatype 1326 // colorTypes report opaque for their alphatype
1330 if (kRGB_565_SkColorType == fInfo.colorType()) { 1327 if (kRGB_565_SkColorType == fInfo.colorType()) {
1331 SkASSERT(kOpaque_SkAlphaType == fInfo.alphaType()); 1328 SkASSERT(kOpaque_SkAlphaType == fInfo.alphaType());
1332 } 1329 }
1333 1330
1334 SkASSERT(fInfo.validRowBytes(fRowBytes)); 1331 SkASSERT(fInfo.validRowBytes(fRowBytes));
1335 uint8_t allFlags = kImageIsVolatile_Flag | kImageIsImmutable_Flag; 1332 uint8_t allFlags = kImageIsVolatile_Flag;
1336 #ifdef SK_BUILD_FOR_ANDROID 1333 #ifdef SK_BUILD_FOR_ANDROID
1337 allFlags |= kHasHardwareMipMap_Flag; 1334 allFlags |= kHasHardwareMipMap_Flag;
1338 #endif 1335 #endif
1339 SkASSERT(fFlags <= allFlags); 1336 SkASSERT((~allFlags & fFlags) == 0);
1340 SkASSERT(fPixelLockCount >= 0); 1337 SkASSERT(fPixelLockCount >= 0);
1341 1338
1342 if (fPixels) { 1339 if (fPixels) {
1343 SkASSERT(fPixelRef); 1340 SkASSERT(fPixelRef);
1344 SkASSERT(fPixelLockCount > 0); 1341 SkASSERT(fPixelLockCount > 0);
1345 SkASSERT(fPixelRef->isLocked()); 1342 SkASSERT(fPixelRef->isLocked());
1346 SkASSERT(fPixelRef->rowBytes() == fRowBytes); 1343 SkASSERT(fPixelRef->rowBytes() == fRowBytes);
1347 SkASSERT(fPixelRefOrigin.fX >= 0); 1344 SkASSERT(fPixelRefOrigin.fX >= 0);
1348 SkASSERT(fPixelRefOrigin.fY >= 0); 1345 SkASSERT(fPixelRefOrigin.fY >= 0);
1349 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig in.fX); 1346 SkASSERT(fPixelRef->info().width() >= (int)this->width() + fPixelRefOrig in.fX);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
1398 /////////////////////////////////////////////////////////////////////////////// 1395 ///////////////////////////////////////////////////////////////////////////////
1399 1396
1400 #ifdef SK_DEBUG 1397 #ifdef SK_DEBUG
1401 void SkImageInfo::validate() const { 1398 void SkImageInfo::validate() const {
1402 SkASSERT(fWidth >= 0); 1399 SkASSERT(fWidth >= 0);
1403 SkASSERT(fHeight >= 0); 1400 SkASSERT(fHeight >= 0);
1404 SkASSERT(SkColorTypeIsValid(fColorType)); 1401 SkASSERT(SkColorTypeIsValid(fColorType));
1405 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1402 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1406 } 1403 }
1407 #endif 1404 #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