| 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 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 this->setPixelRef(pr)->unref(); | 330 this->setPixelRef(pr)->unref(); |
| 331 | 331 |
| 332 // TODO: lockPixels could/should return bool or void*/NULL | 332 // TODO: lockPixels could/should return bool or void*/NULL |
| 333 this->lockPixels(); | 333 this->lockPixels(); |
| 334 if (NULL == this->getPixels()) { | 334 if (NULL == this->getPixels()) { |
| 335 return reset_return_false(this); | 335 return reset_return_false(this); |
| 336 } | 336 } |
| 337 return true; | 337 return true; |
| 338 } | 338 } |
| 339 | 339 |
| 340 static void invoke_release_proc(void (*proc)(void* pixels, void* ctx), void* pix
els, void* ctx) { |
| 341 if (proc) { |
| 342 proc(pixels, ctx); |
| 343 } |
| 344 } |
| 345 |
| 340 bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, siz
e_t rb, | 346 bool SkBitmap::installPixels(const SkImageInfo& requestedInfo, void* pixels, siz
e_t rb, |
| 341 SkColorTable* ct, void (*releaseProc)(void* addr, v
oid* context), | 347 SkColorTable* ct, void (*releaseProc)(void* addr, v
oid* context), |
| 342 void* context) { | 348 void* context) { |
| 343 if (!this->setInfo(requestedInfo, rb)) { | 349 if (!this->setInfo(requestedInfo, rb)) { |
| 350 invoke_release_proc(releaseProc, pixels, context); |
| 344 this->reset(); | 351 this->reset(); |
| 345 return false; | 352 return false; |
| 346 } | 353 } |
| 354 if (NULL == pixels) { |
| 355 invoke_release_proc(releaseProc, pixels, context); |
| 356 return true; // we behaved as if they called setInfo() |
| 357 } |
| 347 | 358 |
| 348 // setInfo may have corrected info (e.g. 565 is always opaque). | 359 // setInfo may have corrected info (e.g. 565 is always opaque). |
| 349 const SkImageInfo& correctedInfo = this->info(); | 360 const SkImageInfo& correctedInfo = this->info(); |
| 350 | 361 |
| 351 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(correctedInfo, rb, ct, pixels
, releaseProc, | 362 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(correctedInfo, rb, ct, pixels
, releaseProc, |
| 352 context); | 363 context); |
| 353 if (!pr) { | 364 if (!pr) { |
| 354 this->reset(); | 365 this->reset(); |
| 355 return false; | 366 return false; |
| 356 } | 367 } |
| (...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1380 /////////////////////////////////////////////////////////////////////////////// | 1391 /////////////////////////////////////////////////////////////////////////////// |
| 1381 | 1392 |
| 1382 #ifdef SK_DEBUG | 1393 #ifdef SK_DEBUG |
| 1383 void SkImageInfo::validate() const { | 1394 void SkImageInfo::validate() const { |
| 1384 SkASSERT(fWidth >= 0); | 1395 SkASSERT(fWidth >= 0); |
| 1385 SkASSERT(fHeight >= 0); | 1396 SkASSERT(fHeight >= 0); |
| 1386 SkASSERT(SkColorTypeIsValid(fColorType)); | 1397 SkASSERT(SkColorTypeIsValid(fColorType)); |
| 1387 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); | 1398 SkASSERT(SkAlphaTypeIsValid(fAlphaType)); |
| 1388 } | 1399 } |
| 1389 #endif | 1400 #endif |
| OLD | NEW |