| 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 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |