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 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 bool hasMipMap() const; | 535 bool hasMipMap() const; |
536 void buildMipMap(bool forceRebuild = false); | 536 void buildMipMap(bool forceRebuild = false); |
537 void freeMipMap(); | 537 void freeMipMap(); |
538 | 538 |
539 /** Given scale factors sx, sy, determine the miplevel available in the | 539 /** Given scale factors sx, sy, determine the miplevel available in the |
540 bitmap, and return it (this is the amount to shift matrix iterators | 540 bitmap, and return it (this is the amount to shift matrix iterators |
541 by). If dst is not null, it is set to the correct level. | 541 by). If dst is not null, it is set to the correct level. |
542 */ | 542 */ |
543 int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy); | 543 int extractMipLevel(SkBitmap* dst, SkFixed sx, SkFixed sy); |
544 | 544 |
| 545 #ifdef SK_BUILD_FOR_ANDROID |
| 546 bool hasHardwareMipMap() const { |
| 547 return (fFlags & kHasHardwareMipMap_Flag) != 0; |
| 548 } |
| 549 |
| 550 void setHasHardwareMipMap(bool hasHardwareMipMap) { |
| 551 if (hasHardwareMipMap) { |
| 552 fFlags |= kHasHardwareMipMap_Flag; |
| 553 } else { |
| 554 fFlags &= ~kHasHardwareMipMap_Flag; |
| 555 } |
| 556 } |
| 557 #endif |
| 558 |
545 bool extractAlpha(SkBitmap* dst) const { | 559 bool extractAlpha(SkBitmap* dst) const { |
546 return this->extractAlpha(dst, NULL, NULL, NULL); | 560 return this->extractAlpha(dst, NULL, NULL, NULL); |
547 } | 561 } |
548 | 562 |
549 bool extractAlpha(SkBitmap* dst, const SkPaint* paint, | 563 bool extractAlpha(SkBitmap* dst, const SkPaint* paint, |
550 SkIPoint* offset) const { | 564 SkIPoint* offset) const { |
551 return this->extractAlpha(dst, paint, NULL, offset); | 565 return this->extractAlpha(dst, paint, NULL, offset); |
552 } | 566 } |
553 | 567 |
554 /** Set dst to contain alpha layer of this bitmap. If destination bitmap | 568 /** Set dst to contain alpha layer of this bitmap. If destination bitmap |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 mutable size_t fPixelRefOffset; | 649 mutable size_t fPixelRefOffset; |
636 mutable int fPixelLockCount; | 650 mutable int fPixelLockCount; |
637 // either user-specified (in which case it is not treated as mutable) | 651 // either user-specified (in which case it is not treated as mutable) |
638 // or a cache of the returned value from fPixelRef->lockPixels() | 652 // or a cache of the returned value from fPixelRef->lockPixels() |
639 mutable void* fPixels; | 653 mutable void* fPixels; |
640 mutable SkColorTable* fColorTable; // only meaningful for kIndex8 | 654 mutable SkColorTable* fColorTable; // only meaningful for kIndex8 |
641 | 655 |
642 enum Flags { | 656 enum Flags { |
643 kImageIsOpaque_Flag = 0x01, | 657 kImageIsOpaque_Flag = 0x01, |
644 kImageIsVolatile_Flag = 0x02, | 658 kImageIsVolatile_Flag = 0x02, |
645 kImageIsImmutable_Flag = 0x04 | 659 kImageIsImmutable_Flag = 0x04, |
| 660 #ifdef SK_BUILD_FOR_ANDROID |
| 661 /* A hint for the renderer responsible for drawing this bitmap |
| 662 * indicating that it should attempt to use mipmaps when this bitmap |
| 663 * is drawn scaled down. |
| 664 */ |
| 665 kHasHardwareMipMap_Flag = 0x08, |
| 666 #endif |
646 }; | 667 }; |
647 | 668 |
648 uint32_t fRowBytes; | 669 uint32_t fRowBytes; |
649 uint32_t fWidth; | 670 uint32_t fWidth; |
650 uint32_t fHeight; | 671 uint32_t fHeight; |
651 uint8_t fConfig; | 672 uint8_t fConfig; |
652 uint8_t fFlags; | 673 uint8_t fFlags; |
653 uint8_t fBytesPerPixel; // based on config | 674 uint8_t fBytesPerPixel; // based on config |
654 | 675 |
655 /* Internal computations for safe size. | 676 /* Internal computations for safe size. |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
776 | 797 |
777 // returns the address of the byte that contains the x coordinate | 798 // returns the address of the byte that contains the x coordinate |
778 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { | 799 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { |
779 SkASSERT(fPixels); | 800 SkASSERT(fPixels); |
780 SkASSERT(fConfig == kA1_Config); | 801 SkASSERT(fConfig == kA1_Config); |
781 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 802 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
782 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); | 803 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); |
783 } | 804 } |
784 | 805 |
785 #endif | 806 #endif |
OLD | NEW |