OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2006 The Android Open Source Project | 2 * Copyright 2006 The Android Open Source Project |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #ifndef SkBitmap_DEFINED | 8 #ifndef SkBitmap_DEFINED |
9 #define SkBitmap_DEFINED | 9 #define SkBitmap_DEFINED |
10 | 10 |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
346 the bitmap will be unchanged. | 346 the bitmap will be unchanged. |
347 */ | 347 */ |
348 bool allocPixels(Allocator* allocator, SkColorTable* ctable); | 348 bool allocPixels(Allocator* allocator, SkColorTable* ctable); |
349 | 349 |
350 /** Return the current pixelref object, if any | 350 /** Return the current pixelref object, if any |
351 */ | 351 */ |
352 SkPixelRef* pixelRef() const { return fPixelRef; } | 352 SkPixelRef* pixelRef() const { return fPixelRef; } |
353 /** Return the offset into the pixelref, if any. Will return 0 if there is | 353 /** Return the offset into the pixelref, if any. Will return 0 if there is |
354 no pixelref installed. | 354 no pixelref installed. |
355 */ | 355 */ |
356 size_t pixelRefOffset() const { return fPixelRefOffset; } | 356 // size_t pixelRefOffset() const { return fPixelRefOffset; } |
scroggo
2014/01/07 22:11:33
Any reason not to delete this outright?
reed1
2014/01/07 22:37:59
Done.
| |
357 | |
358 SkIPoint pixelRefOrigin() const { return fPixelRefOrigin; } | |
359 | |
357 /** Assign a pixelref and optional offset. Pixelrefs are reference counted, | 360 /** Assign a pixelref and optional offset. Pixelrefs are reference counted, |
358 so the existing one (if any) will be unref'd and the new one will be | 361 so the existing one (if any) will be unref'd and the new one will be |
359 ref'd. | 362 ref'd. |
360 */ | 363 */ |
361 SkPixelRef* setPixelRef(SkPixelRef* pr, size_t offset = 0); | 364 SkPixelRef* setPixelRef(SkPixelRef* pr, int dx, int dy); |
365 SkPixelRef* setPixelRef(SkPixelRef* pr) { | |
366 return this->setPixelRef(pr, 0, 0); | |
367 } | |
368 SkPixelRef* setPixelRef(SkPixelRef* pr, const SkIPoint& origin) { | |
369 return this->setPixelRef(pr, origin.fX, origin.fY); | |
370 } | |
362 | 371 |
363 /** Call this to ensure that the bitmap points to the current pixel address | 372 /** Call this to ensure that the bitmap points to the current pixel address |
364 in the pixelref. Balance it with a call to unlockPixels(). These calls | 373 in the pixelref. Balance it with a call to unlockPixels(). These calls |
365 are harmless if there is no pixelref. | 374 are harmless if there is no pixelref. |
366 */ | 375 */ |
367 void lockPixels() const; | 376 void lockPixels() const; |
368 /** When you are finished access the pixel memory, call this to balance a | 377 /** When you are finished access the pixel memory, call this to balance a |
369 previous call to lockPixels(). This allows pixelrefs that implement | 378 previous call to lockPixels(). This allows pixelrefs that implement |
370 cached/deferred image decoding to know when there are active clients of | 379 cached/deferred image decoding to know when there are active clients of |
371 a given image. | 380 a given image. |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
658 int fHeight; | 667 int fHeight; |
659 }; | 668 }; |
660 | 669 |
661 SkDEVCODE(void toString(SkString* str) const;) | 670 SkDEVCODE(void toString(SkString* str) const;) |
662 | 671 |
663 private: | 672 private: |
664 struct MipMap; | 673 struct MipMap; |
665 mutable MipMap* fMipMap; | 674 mutable MipMap* fMipMap; |
666 | 675 |
667 mutable SkPixelRef* fPixelRef; | 676 mutable SkPixelRef* fPixelRef; |
668 mutable size_t fPixelRefOffset; | |
669 mutable int fPixelLockCount; | 677 mutable int fPixelLockCount; |
670 // either user-specified (in which case it is not treated as mutable) | 678 // either user-specified (in which case it is not treated as mutable) |
671 // or a cache of the returned value from fPixelRef->lockPixels() | 679 // or a cache of the returned value from fPixelRef->lockPixels() |
672 mutable void* fPixels; | 680 mutable void* fPixels; |
673 mutable SkColorTable* fColorTable; // only meaningful for kIndex8 | 681 mutable SkColorTable* fColorTable; // only meaningful for kIndex8 |
674 | 682 |
683 SkIPoint fPixelRefOrigin; | |
scroggo
2014/01/07 22:11:33
Why was the old one mutable, and this one not? (My
| |
684 | |
675 enum Flags { | 685 enum Flags { |
676 kImageIsOpaque_Flag = 0x01, | 686 kImageIsOpaque_Flag = 0x01, |
677 kImageIsVolatile_Flag = 0x02, | 687 kImageIsVolatile_Flag = 0x02, |
678 kImageIsImmutable_Flag = 0x04, | 688 kImageIsImmutable_Flag = 0x04, |
679 #ifdef SK_BUILD_FOR_ANDROID | 689 #ifdef SK_BUILD_FOR_ANDROID |
680 /* A hint for the renderer responsible for drawing this bitmap | 690 /* A hint for the renderer responsible for drawing this bitmap |
681 * indicating that it should attempt to use mipmaps when this bitmap | 691 * indicating that it should attempt to use mipmaps when this bitmap |
682 * is drawn scaled down. | 692 * is drawn scaled down. |
683 */ | 693 */ |
684 kHasHardwareMipMap_Flag = 0x08, | 694 kHasHardwareMipMap_Flag = 0x08, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
824 | 834 |
825 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 835 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
826 SkASSERT(fPixels); | 836 SkASSERT(fPixels); |
827 SkASSERT(fConfig == kIndex8_Config); | 837 SkASSERT(fConfig == kIndex8_Config); |
828 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 838 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
829 SkASSERT(fColorTable); | 839 SkASSERT(fColorTable); |
830 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 840 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
831 } | 841 } |
832 | 842 |
833 #endif | 843 #endif |
OLD | NEW |