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 } | |
480 | 477 |
481 /** | 478 /** |
482 * Fill the entire bitmap with the specified color. | 479 * Fill the entire bitmap with the specified color. |
483 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha | 480 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha |
484 * of the color is ignored (treated as opaque). If the colortype only suppo
rts | 481 * of the color is ignored (treated as opaque). If the colortype only suppo
rts |
485 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 482 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
486 */ | 483 */ |
487 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const; | 484 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const { |
| 485 this->eraseColor(SkColorSetARGB(a, r, g, b)); |
| 486 } |
488 | 487 |
489 SK_ATTR_DEPRECATED("use eraseARGB or eraseColor") | 488 SK_ATTR_DEPRECATED("use eraseARGB or eraseColor") |
490 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { | 489 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { |
491 this->eraseARGB(0xFF, r, g, b); | 490 this->eraseARGB(0xFF, r, g, b); |
492 } | 491 } |
493 | 492 |
494 /** | 493 /** |
495 * Fill the specified area of this bitmap with the specified color. | 494 * Fill the specified area of this bitmap with the specified color. |
496 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha | 495 * If the bitmap's colortype does not support alpha (e.g. 565) then the alp
ha |
497 * of the color is ignored (treated as opaque). If the colortype only suppo
rts | 496 * of the color is ignored (treated as opaque). If the colortype only suppo
rts |
498 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 497 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
499 */ | 498 */ |
500 void eraseArea(const SkIRect& area, SkColor c) const; | 499 void erase(SkColor c, const SkIRect& area) const; |
| 500 |
| 501 // DEPRECATED |
| 502 void eraseArea(const SkIRect& area, SkColor c) const { |
| 503 this->erase(c, area); |
| 504 } |
501 | 505 |
502 /** | 506 /** |
503 * Return the SkColor of the specified pixel. In most cases this will | 507 * Return the SkColor of the specified pixel. In most cases this will |
504 * require un-premultiplying the color. Alpha only colortypes (e.g. kAlpha
_8_SkColorType) | 508 * require un-premultiplying the color. Alpha only colortypes (e.g. kAlpha
_8_SkColorType) |
505 * return black with the appropriate alpha set. The value is undefined | 509 * return black with the appropriate alpha set. The value is undefined |
506 * for kUnknown_SkColorType or if x or y are out of bounds, or if the bitma
p | 510 * for kUnknown_SkColorType or if x or y are out of bounds, or if the bitma
p |
507 * does not have any pixels (or has not be locked with lockPixels()). | 511 * does not have any pixels (or has not be locked with lockPixels()). |
508 */ | 512 */ |
509 SkColor getColor(int x, int y) const; | 513 SkColor getColor(int x, int y) const; |
510 | 514 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 #ifdef SK_BUILD_FOR_ANDROID | 733 #ifdef SK_BUILD_FOR_ANDROID |
730 /* A hint for the renderer responsible for drawing this bitmap | 734 /* A hint for the renderer responsible for drawing this bitmap |
731 * indicating that it should attempt to use mipmaps when this bitmap | 735 * indicating that it should attempt to use mipmaps when this bitmap |
732 * is drawn scaled down. | 736 * is drawn scaled down. |
733 */ | 737 */ |
734 kHasHardwareMipMap_Flag = 0x08, | 738 kHasHardwareMipMap_Flag = 0x08, |
735 #endif | 739 #endif |
736 }; | 740 }; |
737 | 741 |
738 SkImageInfo fInfo; | 742 SkImageInfo fInfo; |
739 | |
740 uint32_t fRowBytes; | 743 uint32_t fRowBytes; |
741 | |
742 uint8_t fFlags; | 744 uint8_t fFlags; |
743 | 745 |
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 |