| 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 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 488 |
| 489 bool SkBitmap::allocPixels(Allocator* allocator, SkColorTable* ctable) { | 489 bool SkBitmap::allocPixels(Allocator* allocator, SkColorTable* ctable) { |
| 490 HeapAllocator stdalloc; | 490 HeapAllocator stdalloc; |
| 491 | 491 |
| 492 if (NULL == allocator) { | 492 if (NULL == allocator) { |
| 493 allocator = &stdalloc; | 493 allocator = &stdalloc; |
| 494 } | 494 } |
| 495 return allocator->allocPixelRef(this, ctable); | 495 return allocator->allocPixelRef(this, ctable); |
| 496 } | 496 } |
| 497 | 497 |
| 498 bool SkBitmap::allocPixels(const SkImageInfo& info, SkColorTable* ctable) { |
| 499 if (!this->setConfig(info) && !this->allocPixels(ctable)) { |
| 500 this->reset(); |
| 501 return false; |
| 502 } |
| 503 return true; |
| 504 } |
| 505 |
| 506 bool SkBitmap::installPixels(const SkImageInfo& info, void* pixels, size_t rb, |
| 507 void (*releaseProc)(void* addr, void* context), |
| 508 void* context) { |
| 509 if (!this->setConfig(info)) { |
| 510 this->reset(); |
| 511 return false; |
| 512 } |
| 513 |
| 514 SkPixelRef* pr = SkMallocPixelRef::NewWithProc(info, rb, NULL, pixels, |
| 515 releaseProc, context); |
| 516 if (!pr) { |
| 517 this->reset(); |
| 518 return false; |
| 519 } |
| 520 |
| 521 this->setPixelRef(pr)->unref(); |
| 522 return true; |
| 523 } |
| 524 |
| 498 void SkBitmap::freePixels() { | 525 void SkBitmap::freePixels() { |
| 499 // if we're gonna free the pixels, we certainly need to free the mipmap | 526 // if we're gonna free the pixels, we certainly need to free the mipmap |
| 500 this->freeMipMap(); | 527 this->freeMipMap(); |
| 501 | 528 |
| 502 if (NULL != fPixelRef) { | 529 if (NULL != fPixelRef) { |
| 503 if (fPixelLockCount > 0) { | 530 if (fPixelLockCount > 0) { |
| 504 fPixelRef->unlockPixels(); | 531 fPixelRef->unlockPixels(); |
| 505 } | 532 } |
| 506 fPixelRef->unref(); | 533 fPixelRef->unref(); |
| 507 fPixelRef = NULL; | 534 fPixelRef = NULL; |
| (...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 if (NULL != uri) { | 1676 if (NULL != uri) { |
| 1650 str->appendf(" uri:\"%s\"", uri); | 1677 str->appendf(" uri:\"%s\"", uri); |
| 1651 } else { | 1678 } else { |
| 1652 str->appendf(" pixelref:%p", pr); | 1679 str->appendf(" pixelref:%p", pr); |
| 1653 } | 1680 } |
| 1654 } | 1681 } |
| 1655 | 1682 |
| 1656 str->append(")"); | 1683 str->append(")"); |
| 1657 } | 1684 } |
| 1658 #endif | 1685 #endif |
| OLD | NEW |