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 170713006: installPixels returns true if null-pixels -- devolving to setConfig (Closed) Base URL: https://skia.googlesource.com/skia.git@master
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
« 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
506 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels, 511 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels,
507 releaseProc, context); 512 releaseProc, context);
508 if (!pr) { 513 if (!pr) {
509 this->reset(); 514 this->reset();
510 return false; 515 return false;
511 } 516 }
512 517
513 this->setPixelRef(pr)->unref(); 518 this->setPixelRef(pr)->unref();
514 519
515 // since we're already allocated, we lockPixels right away 520 // since we're already allocated, we lockPixels right away
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 /////////////////////////////////////////////////////////////////////////////// 1720 ///////////////////////////////////////////////////////////////////////////////
1716 1721
1717 #ifdef SK_DEBUG 1722 #ifdef SK_DEBUG
1718 void SkImageInfo::validate() const { 1723 void SkImageInfo::validate() const {
1719 SkASSERT(fWidth >= 0); 1724 SkASSERT(fWidth >= 0);
1720 SkASSERT(fHeight >= 0); 1725 SkASSERT(fHeight >= 0);
1721 SkASSERT(SkColorTypeIsValid(fColorType)); 1726 SkASSERT(SkColorTypeIsValid(fColorType));
1722 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); 1727 SkASSERT(SkAlphaTypeIsValid(fAlphaType));
1723 } 1728 }
1724 #endif 1729 #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