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

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

Issue 172603002: revert to previous behavior in installPixels, allowing for NULL address (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 } 496 }
497 497
498 bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb, 498 bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb,
499 void (*releaseProc)(void* addr, void* context), 499 void (*releaseProc)(void* addr, void* context),
500 void* context) { 500 void* context) {
501 if (!this->setConfig(info, rb)) { 501 if (!this->setConfig(info, rb)) {
502 this->reset(); 502 this->reset();
503 return false; 503 return false;
504 } 504 }
505 505
506 // No pixels means just behave like setConfig()
507 if (NULL == pixels) {
508 return true;
509 }
510
511 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels, 506 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels,
512 releaseProc, context); 507 releaseProc, context);
513 if (!pr) { 508 if (!pr) {
514 this->reset(); 509 this->reset();
515 return false; 510 return false;
516 } 511 }
517 512
518 this->setPixelRef(pr)->unref(); 513 this->setPixelRef(pr)->unref();
519 514
520 // since we're already allocated, we lockPixels right away 515 // since we're already allocated, we lockPixels right away
521 this->lockPixels(); 516 this->lockPixels();
522 SkASSERT(this->getPixels());
523 SkDEBUGCODE(this->validate();) 517 SkDEBUGCODE(this->validate();)
524 return true; 518 return true;
525 } 519 }
526 520
527 bool SkBitmap::installMaskPixels(const SkMask& mask) { 521 bool SkBitmap::installMaskPixels(const SkMask& mask) {
528 if (SkMask::kA8_Format != mask.fFormat) { 522 if (SkMask::kA8_Format != mask.fFormat) {
529 this->reset(); 523 this->reset();
530 return false; 524 return false;
531 } 525 }
532 return this->installPixels(SkImageInfo::MakeA8(mask.fBounds.width(), 526 return this->installPixels(SkImageInfo::MakeA8(mask.fBounds.width(),
(...skipping 1187 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 /////////////////////////////////////////////////////////////////////////////// 1714 ///////////////////////////////////////////////////////////////////////////////
1721 1715
1722 #ifdef SK_DEBUG 1716 #ifdef SK_DEBUG
1723 void SkImageInfo::validate() const { 1717 void SkImageInfo::validate() const {
1724 SkASSERT(fWidth >= 0); 1718 SkASSERT(fWidth >= 0);
1725 SkASSERT(fHeight >= 0); 1719 SkASSERT(fHeight >= 0);
1726 SkASSERT(SkColorTypeIsValid(fColorType)); 1720 SkASSERT(SkColorTypeIsValid(fColorType));
1727 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1721 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1728 } 1722 }
1729 #endif 1723 #endif
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698