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

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

Issue 120063003: assert in setPixelRef that the pr matches the bitmap's config (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/SerializationTest.cpp » ('j') | 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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW
« no previous file with comments | « no previous file | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698