| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Copyright 2006 The Android Open Source Project | 3 * Copyright 2006 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 #ifndef SkBitmap_DEFINED | 10 #ifndef SkBitmap_DEFINED |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 ~SkAutoLockPixels() { | 723 ~SkAutoLockPixels() { |
| 724 if (fDidLock) { | 724 if (fDidLock) { |
| 725 fBitmap.unlockPixels(); | 725 fBitmap.unlockPixels(); |
| 726 } | 726 } |
| 727 } | 727 } |
| 728 | 728 |
| 729 private: | 729 private: |
| 730 const SkBitmap& fBitmap; | 730 const SkBitmap& fBitmap; |
| 731 bool fDidLock; | 731 bool fDidLock; |
| 732 }; | 732 }; |
| 733 #define SkAutoLockPixels(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockPixels) |
| 733 | 734 |
| 734 /** Helper class that performs the lock/unlockColors calls on a colortable. | 735 /** Helper class that performs the lock/unlockColors calls on a colortable. |
| 735 The destructor will call unlockColors(false) if it has a bitmap's colortable | 736 The destructor will call unlockColors(false) if it has a bitmap's colortable |
| 736 */ | 737 */ |
| 737 class SkAutoLockColors : public SkNoncopyable { | 738 class SkAutoLockColors : public SkNoncopyable { |
| 738 public: | 739 public: |
| 739 /** Initialize with no bitmap. Call lockColors(bitmap) to lock bitmap's | 740 /** Initialize with no bitmap. Call lockColors(bitmap) to lock bitmap's |
| 740 colortable | 741 colortable |
| 741 */ | 742 */ |
| 742 SkAutoLockColors() : fCTable(NULL), fColors(NULL) {} | 743 SkAutoLockColors() : fCTable(NULL), fColors(NULL) {} |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 776 } | 777 } |
| 777 | 778 |
| 778 const SkPMColor* lockColors(const SkBitmap& bm) { | 779 const SkPMColor* lockColors(const SkBitmap& bm) { |
| 779 return this->lockColors(bm.getColorTable()); | 780 return this->lockColors(bm.getColorTable()); |
| 780 } | 781 } |
| 781 | 782 |
| 782 private: | 783 private: |
| 783 SkColorTable* fCTable; | 784 SkColorTable* fCTable; |
| 784 const SkPMColor* fColors; | 785 const SkPMColor* fColors; |
| 785 }; | 786 }; |
| 787 #define SkAutoLockColors(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockColors) |
| 786 | 788 |
| 787 /////////////////////////////////////////////////////////////////////////////// | 789 /////////////////////////////////////////////////////////////////////////////// |
| 788 | 790 |
| 789 inline uint32_t* SkBitmap::getAddr32(int x, int y) const { | 791 inline uint32_t* SkBitmap::getAddr32(int x, int y) const { |
| 790 SkASSERT(fPixels); | 792 SkASSERT(fPixels); |
| 791 SkASSERT(fConfig == kARGB_8888_Config); | 793 SkASSERT(fConfig == kARGB_8888_Config); |
| 792 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 794 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
| 793 return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2)); | 795 return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2)); |
| 794 } | 796 } |
| 795 | 797 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 817 | 819 |
| 818 // returns the address of the byte that contains the x coordinate | 820 // returns the address of the byte that contains the x coordinate |
| 819 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { | 821 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { |
| 820 SkASSERT(fPixels); | 822 SkASSERT(fPixels); |
| 821 SkASSERT(fConfig == kA1_Config); | 823 SkASSERT(fConfig == kA1_Config); |
| 822 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 824 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
| 823 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); | 825 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); |
| 824 } | 826 } |
| 825 | 827 |
| 826 #endif | 828 #endif |
| OLD | NEW |