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 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 * modifications will be lost when unlockPixels() is called.) | 464 * modifications will be lost when unlockPixels() is called.) |
465 */ | 465 */ |
466 bool lockPixelsAreWritable() const; | 466 bool lockPixelsAreWritable() const; |
467 | 467 |
468 /** Call this to be sure that the bitmap is valid enough to be drawn (i.e. | 468 /** Call this to be sure that the bitmap is valid enough to be drawn (i.e. |
469 it has non-null pixels, and if required by its config, it has a | 469 it has non-null pixels, and if required by its config, it has a |
470 non-null colortable. Returns true if all of the above are met. | 470 non-null colortable. Returns true if all of the above are met. |
471 */ | 471 */ |
472 bool readyToDraw() const { | 472 bool readyToDraw() const { |
473 return this->getPixels() != NULL && | 473 return this->getPixels() != NULL && |
474 (this->config() != kIndex8_Config || NULL != fColorTable); | 474 (this->colorType() != kIndex_8_SkColorType || NULL != fColorTable
); |
475 } | 475 } |
476 | 476 |
477 /** Returns the pixelRef's texture, or NULL | 477 /** Returns the pixelRef's texture, or NULL |
478 */ | 478 */ |
479 GrTexture* getTexture() const; | 479 GrTexture* getTexture() const; |
480 | 480 |
481 /** Return the bitmap's colortable, if it uses one (i.e. colorType is | 481 /** Return the bitmap's colortable, if it uses one (i.e. colorType is |
482 Index_8) and the pixels are locked. | 482 Index_8) and the pixels are locked. |
483 Otherwise returns NULL. Does not affect the colortable's | 483 Otherwise returns NULL. Does not affect the colortable's |
484 reference count. | 484 reference count. |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 private: | 883 private: |
884 SkColorTable* fCTable; | 884 SkColorTable* fCTable; |
885 const SkPMColor* fColors; | 885 const SkPMColor* fColors; |
886 }; | 886 }; |
887 #define SkAutoLockColors(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockColors) | 887 #define SkAutoLockColors(...) SK_REQUIRE_LOCAL_VAR(SkAutoLockColors) |
888 | 888 |
889 /////////////////////////////////////////////////////////////////////////////// | 889 /////////////////////////////////////////////////////////////////////////////// |
890 | 890 |
891 inline uint32_t* SkBitmap::getAddr32(int x, int y) const { | 891 inline uint32_t* SkBitmap::getAddr32(int x, int y) const { |
892 SkASSERT(fPixels); | 892 SkASSERT(fPixels); |
893 SkASSERT(this->config() == kARGB_8888_Config); | 893 SkASSERT(4 == this->bytesPerPixel()); |
894 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 894 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
895 return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2)); | 895 return (uint32_t*)((char*)fPixels + y * fRowBytes + (x << 2)); |
896 } | 896 } |
897 | 897 |
898 inline uint16_t* SkBitmap::getAddr16(int x, int y) const { | 898 inline uint16_t* SkBitmap::getAddr16(int x, int y) const { |
899 SkASSERT(fPixels); | 899 SkASSERT(fPixels); |
900 SkASSERT(this->config() == kRGB_565_Config || this->config() == kARGB_4444_C
onfig); | 900 SkASSERT(2 == this->bytesPerPixel()); |
901 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 901 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
902 return (uint16_t*)((char*)fPixels + y * fRowBytes + (x << 1)); | 902 return (uint16_t*)((char*)fPixels + y * fRowBytes + (x << 1)); |
903 } | 903 } |
904 | 904 |
905 inline uint8_t* SkBitmap::getAddr8(int x, int y) const { | 905 inline uint8_t* SkBitmap::getAddr8(int x, int y) const { |
906 SkASSERT(fPixels); | 906 SkASSERT(fPixels); |
907 SkASSERT(this->config() == kA8_Config || this->config() == kIndex8_Config); | 907 SkASSERT(1 == this->bytesPerPixel()); |
908 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 908 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
909 return (uint8_t*)fPixels + y * fRowBytes + x; | 909 return (uint8_t*)fPixels + y * fRowBytes + x; |
910 } | 910 } |
911 | 911 |
912 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 912 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
913 SkASSERT(fPixels); | 913 SkASSERT(fPixels); |
914 SkASSERT(this->config() == kIndex8_Config); | 914 SkASSERT(kIndex_8_SkColorType == this->colorType()); |
915 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 915 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
916 SkASSERT(fColorTable); | 916 SkASSERT(fColorTable); |
917 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 917 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
918 } | 918 } |
919 | 919 |
920 /////////////////////////////////////////////////////////////////////////////// | 920 /////////////////////////////////////////////////////////////////////////////// |
921 // | 921 // |
922 // Helpers until we can fully deprecate SkBitmap::Config | 922 // Helpers until we can fully deprecate SkBitmap::Config |
923 // | 923 // |
924 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); | 924 extern SkBitmap::Config SkColorTypeToBitmapConfig(SkColorType); |
925 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); | 925 extern SkColorType SkBitmapConfigToColorType(SkBitmap::Config); |
926 | 926 |
927 #endif | 927 #endif |
OLD | NEW |