| 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 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 getGenerationID(). | 466 getGenerationID(). |
| 467 */ | 467 */ |
| 468 void notifyPixelsChanged() const; | 468 void notifyPixelsChanged() const; |
| 469 | 469 |
| 470 /** | 470 /** |
| 471 * Fill the entire bitmap with the specified color. | 471 * Fill the entire bitmap with the specified color. |
| 472 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha | 472 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha |
| 473 * of the color is ignored (treated as opaque). If the colortype only suppo
rts | 473 * of the color is ignored (treated as opaque). If the colortype only suppo
rts |
| 474 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 474 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
| 475 */ | 475 */ |
| 476 void eraseColor(SkColor c) const; | 476 void eraseColor(SkColor c) const { |
| 477 this->eraseARGB(SkColorGetA(c), SkColorGetR(c), SkColorGetG(c), |
| 478 SkColorGetB(c)); |
| 479 } |
| 477 | 480 |
| 478 /** | 481 /** |
| 479 * Fill the entire bitmap with the specified color. | 482 * Fill the entire bitmap with the specified color. |
| 480 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha | 483 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha |
| 481 * of the color is ignored (treated as opaque). If the colortype only suppo
rts | 484 * of the color is ignored (treated as opaque). If the colortype only suppo
rts |
| 482 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 485 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
| 483 */ | 486 */ |
| 484 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const { | 487 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const; |
| 485 this->eraseColor(SkColorSetARGB(a, r, g, b)); | |
| 486 } | |
| 487 | 488 |
| 488 SK_ATTR_DEPRECATED("use eraseARGB or eraseColor") | 489 SK_ATTR_DEPRECATED("use eraseARGB or eraseColor") |
| 489 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { | 490 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { |
| 490 this->eraseARGB(0xFF, r, g, b); | 491 this->eraseARGB(0xFF, r, g, b); |
| 491 } | 492 } |
| 492 | 493 |
| 493 /** | 494 /** |
| 494 * Fill the specified area of this bitmap with the specified color. | 495 * Fill the specified area of this bitmap with the specified color. |
| 495 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha | 496 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha |
| 496 * of the color is ignored (treated as opaque). If the colortype only suppo
rts | 497 * of the color is ignored (treated as opaque). If the colortype only suppo
rts |
| 497 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 498 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
| 498 */ | 499 */ |
| 499 void erase(SkColor c, const SkIRect& area) const; | 500 void eraseArea(const SkIRect& area, SkColor c) const; |
| 500 | |
| 501 // DEPRECATED | |
| 502 void eraseArea(const SkIRect& area, SkColor c) const { | |
| 503 this->erase(c, area); | |
| 504 } | |
| 505 | 501 |
| 506 /** | 502 /** |
| 507 * Return the SkColor of the specified pixel. In most cases this will | 503 * Return the SkColor of the specified pixel. In most cases this will |
| 508 * require un-premultiplying the color. Alpha only colortypes (e.g. kAlpha
_8_SkColorType) | 504 * require un-premultiplying the color. Alpha only colortypes (e.g. kAlpha
_8_SkColorType) |
| 509 * return black with the appropriate alpha set. The value is undefined | 505 * return black with the appropriate alpha set. The value is undefined |
| 510 * for kUnknown_SkColorType or if x or y are out of bounds, or if the bitma
p | 506 * for kUnknown_SkColorType or if x or y are out of bounds, or if the bitma
p |
| 511 * does not have any pixels (or has not be locked with lockPixels()). | 507 * does not have any pixels (or has not be locked with lockPixels()). |
| 512 */ | 508 */ |
| 513 SkColor getColor(int x, int y) const; | 509 SkColor getColor(int x, int y) const; |
| 514 | 510 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 #ifdef SK_BUILD_FOR_ANDROID | 729 #ifdef SK_BUILD_FOR_ANDROID |
| 734 /* A hint for the renderer responsible for drawing this bitmap | 730 /* A hint for the renderer responsible for drawing this bitmap |
| 735 * indicating that it should attempt to use mipmaps when this bitmap | 731 * indicating that it should attempt to use mipmaps when this bitmap |
| 736 * is drawn scaled down. | 732 * is drawn scaled down. |
| 737 */ | 733 */ |
| 738 kHasHardwareMipMap_Flag = 0x08, | 734 kHasHardwareMipMap_Flag = 0x08, |
| 739 #endif | 735 #endif |
| 740 }; | 736 }; |
| 741 | 737 |
| 742 SkImageInfo fInfo; | 738 SkImageInfo fInfo; |
| 739 |
| 743 uint32_t fRowBytes; | 740 uint32_t fRowBytes; |
| 741 |
| 744 uint8_t fFlags; | 742 uint8_t fFlags; |
| 745 | 743 |
| 744 void internalErase(const SkIRect&, U8CPU a, U8CPU r, U8CPU g, U8CPU b)const; |
| 745 |
| 746 /* Unreference any pixelrefs or colortables | 746 /* Unreference any pixelrefs or colortables |
| 747 */ | 747 */ |
| 748 void freePixels(); | 748 void freePixels(); |
| 749 void updatePixelsFromRef() const; | 749 void updatePixelsFromRef() const; |
| 750 | 750 |
| 751 static void WriteRawPixels(SkWriteBuffer*, const SkBitmap&); | 751 static void WriteRawPixels(SkWriteBuffer*, const SkBitmap&); |
| 752 static bool ReadRawPixels(SkReadBuffer*, SkBitmap*); | 752 static bool ReadRawPixels(SkReadBuffer*, SkBitmap*); |
| 753 | 753 |
| 754 friend class SkBitmapSource; // unflatten | 754 friend class SkBitmapSource; // unflatten |
| 755 friend class SkReadBuffer; // unflatten, rawpixels | 755 friend class SkReadBuffer; // unflatten, rawpixels |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 803 | 803 |
| 804 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { | 804 inline SkPMColor SkBitmap::getIndex8Color(int x, int y) const { |
| 805 SkASSERT(fPixels); | 805 SkASSERT(fPixels); |
| 806 SkASSERT(kIndex_8_SkColorType == this->colorType()); | 806 SkASSERT(kIndex_8_SkColorType == this->colorType()); |
| 807 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); | 807 SkASSERT((unsigned)x < (unsigned)this->width() && (unsigned)y < (unsigned)th
is->height()); |
| 808 SkASSERT(fColorTable); | 808 SkASSERT(fColorTable); |
| 809 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; | 809 return (*fColorTable)[*((const uint8_t*)fPixels + y * fRowBytes + x)]; |
| 810 } | 810 } |
| 811 | 811 |
| 812 #endif | 812 #endif |
| OLD | NEW |