| 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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 return true; | 337 return true; |
| 338 } | 338 } |
| 339 | 339 |
| 340 bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, siz
e_t rb, | 340 bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, siz
e_t rb, |
| 341 SkColorTable* ct, void (*releaseProc)(void* addr, v
oid* context), | 341 SkColorTable* ct, void (*releaseProc)(void* addr, v
oid* context), |
| 342 void* context) { | 342 void* context) { |
| 343 if (!this->setInfo(requestedInfo, rb)) { | 343 if (!this->setInfo(requestedInfo, rb)) { |
| 344 this->reset(); | 344 this->reset(); |
| 345 return false; | 345 return false; |
| 346 } | 346 } |
| 347 if (NULL == pixels) { |
| 348 return true; // we behaved as if they called setInfo() |
| 349 } |
| 347 | 350 |
| 348 // setInfo may have corrected info (e.g. 565 is always opaque). | 351 // setInfo may have corrected info (e.g. 565 is always opaque). |
| 349 const SkImageInfo& correctedInfo = this->info(); | 352 const SkImageInfo& correctedInfo = this->info(); |
| 350 | 353 |
| 351 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(correctedInfo, rb, ct, pixels
, releaseProc, | 354 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(correctedInfo, rb, ct, pixels
, releaseProc, |
| 352 context); | 355 context); |
| 353 if (!pr) { | 356 if (!pr) { |
| 354 this->reset(); | 357 this->reset(); |
| 355 return false; | 358 return false; |
| 356 } | 359 } |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 /////////////////////////////////////////////////////////////////////////////// | 1383 /////////////////////////////////////////////////////////////////////////////// |
| 1381 | 1384 |
| 1382 #ifdef SK_DEBUG | 1385 #ifdef SK_DEBUG |
| 1383 void SkImageInfo::validate() const { | 1386 void SkImageInfo::validate() const { |
| 1384 SkASSERT(fWidth >= 0); | 1387 SkASSERT(fWidth >= 0); |
| 1385 SkASSERT(fHeight >= 0); | 1388 SkASSERT(fHeight >= 0); |
| 1386 SkASSERT(SkColorTypeIsValid(fColorType)); | 1389 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1390 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1388 } | 1391 } |
| 1389 #endif | 1392 #endif |
| OLD | NEW |