Chromium Code Reviews| 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 395 info->fColorType = ct; | 395 info->fColorType = ct; |
| 396 } | 396 } |
| 397 return true; | 397 return true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) { | 400 SkPixelRef* SkBitmap::setPixelRef(SkPixelRef* pr, size_t offset) { |
| 401 // do this first, we that we never have a non-zero offset with a null ref | 401 // do this first, we that we never have a non-zero offset with a null ref |
| 402 if (NULL == pr) { | 402 if (NULL == pr) { |
| 403 offset = 0; | 403 offset = 0; |
| 404 } | 404 } |
| 405 #ifdef SK_DEBUG | |
| 406 else { | |
| 407 SkImageInfo info; | |
| 408 if (this->asImageInfo(&info)) { | |
| 409 const SkImageInfo& prInfo = pr->info(); | |
| 410 SkASSERT(info.fWidth <= prInfo.fWidth); | |
| 411 SkASSERT(info.fHeight <= prInfo.fHeight); | |
| 412 SkASSERT(info.fColorType == prInfo.fColorType); | |
| 413 switch (prInfo.fAlphaType) { | |
| 414 case kIgnore_SkAlphaType: | |
| 415 SkASSERT(fAlphaType == kIgnore_SkAlphaType); | |
| 416 break; | |
| 417 case kOpaque_SkAlphaType: | |
| 418 case kPremul_SkAlphaType: | |
|
hal.canary
2014/01/02 22:36:01
Under what circumstances will the alphatypes be !=
| |
| 419 SkASSERT(info.fAlphaType == kOpaque_SkAlphaType || | |
| 420 info.fAlphaType == kPremul_SkAlphaType); | |
| 421 break; | |
| 422 case kUnpremul_SkAlphaType: | |
| 423 SkASSERT(info.fAlphaType == kOpaque_SkAlphaType || | |
| 424 info.fAlphaType == kUnpremul_SkAlphaType); | |
| 425 break; | |
| 426 } | |
| 427 } | |
| 428 } | |
| 429 #endif | |
| 405 | 430 |
| 406 if (fPixelRef != pr || fPixelRefOffset != offset) { | 431 if (fPixelRef != pr || fPixelRefOffset != offset) { |
| 407 if (fPixelRef != pr) { | 432 if (fPixelRef != pr) { |
| 408 this->freePixels(); | 433 this->freePixels(); |
| 409 SkASSERT(NULL == fPixelRef); | 434 SkASSERT(NULL == fPixelRef); |
| 410 | 435 |
| 411 SkSafeRef(pr); | 436 SkSafeRef(pr); |
| 412 fPixelRef = pr; | 437 fPixelRef = pr; |
| 413 } | 438 } |
| 414 fPixelRefOffset = offset; | 439 fPixelRefOffset = offset; |
| (...skipping 1286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1701 if (NULL != uri) { | 1726 if (NULL != uri) { |
| 1702 str->appendf(" uri:\"%s\"", uri); | 1727 str->appendf(" uri:\"%s\"", uri); |
| 1703 } else { | 1728 } else { |
| 1704 str->appendf(" pixelref:%p", pr); | 1729 str->appendf(" pixelref:%p", pr); |
| 1705 } | 1730 } |
| 1706 } | 1731 } |
| 1707 | 1732 |
| 1708 str->append(")"); | 1733 str->append(")"); |
| 1709 } | 1734 } |
| 1710 #endif | 1735 #endif |
| OLD | NEW |