| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 89 |
| 90 /** Return true iff the bitmap has empty dimensions. | 90 /** Return true iff the bitmap has empty dimensions. |
| 91 */ | 91 */ |
| 92 bool empty() const { return 0 == fWidth || 0 == fHeight; } | 92 bool empty() const { return 0 == fWidth || 0 == fHeight; } |
| 93 | 93 |
| 94 /** Return true iff the bitmap has no pixelref. Note: this can return true e
ven if the | 94 /** Return true iff the bitmap has no pixelref. Note: this can return true e
ven if the |
| 95 dimensions of the bitmap are > 0 (see empty()). | 95 dimensions of the bitmap are > 0 (see empty()). |
| 96 */ | 96 */ |
| 97 bool isNull() const { return NULL == fPixelRef; } | 97 bool isNull() const { return NULL == fPixelRef; } |
| 98 | 98 |
| 99 /** Return the config for the bitmap. | 99 /** Return the config for the bitmap. */ |
| 100 */ | |
| 101 Config config() const { return (Config)fConfig; } | 100 Config config() const { return (Config)fConfig; } |
| 102 /** DEPRECATED, use config() | 101 |
| 103 */ | 102 SK_ATTR_DEPRECATED("use config()") |
| 104 Config getConfig() const { return this->config(); } | 103 Config getConfig() const { return this->config(); } |
| 105 /** Return the bitmap's width, in pixels. | 104 |
| 106 */ | 105 /** Return the bitmap's width, in pixels. */ |
| 107 int width() const { return fWidth; } | 106 int width() const { return fWidth; } |
| 108 /** Return the bitmap's height, in pixels. | 107 |
| 109 */ | 108 /** Return the bitmap's height, in pixels. */ |
| 110 int height() const { return fHeight; } | 109 int height() const { return fHeight; } |
| 111 /** Return the number of bytes between subsequent rows of the bitmap. | 110 |
| 112 */ | 111 /** Return the number of bytes between subsequent rows of the bitmap. */ |
| 113 size_t rowBytes() const { return fRowBytes; } | 112 size_t rowBytes() const { return fRowBytes; } |
| 114 | 113 |
| 115 /** Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for | 114 /** Return the shift amount per pixel (i.e. 0 for 1-byte per pixel, 1 for |
| 116 2-bytes per pixel configs, 2 for 4-bytes per pixel configs). Return 0 | 115 2-bytes per pixel configs, 2 for 4-bytes per pixel configs). Return 0 |
| 117 for configs that are not at least 1-byte per pixel (e.g. kA1_Config | 116 for configs that are not at least 1-byte per pixel (e.g. kA1_Config |
| 118 or kNo_Config) | 117 or kNo_Config) |
| 119 */ | 118 */ |
| 120 int shiftPerPixel() const { return fBytesPerPixel >> 1; } | 119 int shiftPerPixel() const { return fBytesPerPixel >> 1; } |
| 121 | 120 |
| 122 /** Return the number of bytes per pixel based on the config. If the config | 121 /** Return the number of bytes per pixel based on the config. If the config |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 that share the same pixelref. | 181 that share the same pixelref. |
| 183 */ | 182 */ |
| 184 void setImmutable(); | 183 void setImmutable(); |
| 185 | 184 |
| 186 /** Returns true if the bitmap is opaque (has no translucent/transparent pix
els). | 185 /** Returns true if the bitmap is opaque (has no translucent/transparent pix
els). |
| 187 */ | 186 */ |
| 188 bool isOpaque() const { | 187 bool isOpaque() const { |
| 189 return SkAlphaTypeIsOpaque(this->alphaType()); | 188 return SkAlphaTypeIsOpaque(this->alphaType()); |
| 190 } | 189 } |
| 191 | 190 |
| 192 /** | 191 SK_ATTR_DEPRECATED("use setAlphaType") |
| 193 * DEPRECATED: use setAlpahType() instead. | |
| 194 */ | |
| 195 void setIsOpaque(bool opaque) { | 192 void setIsOpaque(bool opaque) { |
| 196 this->setAlphaType(opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); | 193 this->setAlphaType(opaque ? kOpaque_SkAlphaType : kPremul_SkAlphaType); |
| 197 } | 194 } |
| 198 | 195 |
| 199 /** Returns true if the bitmap is volatile (i.e. should not be cached by dev
ices.) | 196 /** Returns true if the bitmap is volatile (i.e. should not be cached by dev
ices.) |
| 200 */ | 197 */ |
| 201 bool isVolatile() const; | 198 bool isVolatile() const; |
| 202 | 199 |
| 203 /** Specify whether this bitmap is volatile. Bitmaps are not volatile by | 200 /** Specify whether this bitmap is volatile. Bitmaps are not volatile by |
| 204 default. Temporary bitmaps that are discarded after use should be | 201 default. Temporary bitmaps that are discarded after use should be |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 412 } | 409 } |
| 413 | 410 |
| 414 /** | 411 /** |
| 415 * Fill the entire bitmap with the specified color. | 412 * Fill the entire bitmap with the specified color. |
| 416 * If the bitmap's config does not support alpha (e.g. 565) then the alpha | 413 * If the bitmap's config does not support alpha (e.g. 565) then the alpha |
| 417 * of the color is ignored (treated as opaque). If the config only supports | 414 * of the color is ignored (treated as opaque). If the config only supports |
| 418 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 415 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
| 419 */ | 416 */ |
| 420 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const; | 417 void eraseARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) const; |
| 421 | 418 |
| 422 // DEPRECATED -- call eraseColor or eraseARGB | 419 SK_ATTR_DEPRECATED("use eraseARGB or eraseColor") |
| 423 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { | 420 void eraseRGB(U8CPU r, U8CPU g, U8CPU b) const { |
| 424 this->eraseARGB(0xFF, r, g, b); | 421 this->eraseARGB(0xFF, r, g, b); |
| 425 } | 422 } |
| 426 | 423 |
| 427 /** | 424 /** |
| 428 * Fill the specified area of this bitmap with the specified color. | 425 * Fill the specified area of this bitmap with the specified color. |
| 429 * If the bitmap's config does not support alpha (e.g. 565) then the alpha | 426 * If the bitmap's config does not support alpha (e.g. 565) then the alpha |
| 430 * of the color is ignored (treated as opaque). If the config only supports | 427 * of the color is ignored (treated as opaque). If the config only supports |
| 431 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. | 428 * alpha (e.g. A1 or A8) then the color's r,g,b components are ignored. |
| 432 */ | 429 */ |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 * gpu (typically as a texture), the it will do the same for the dst. | 543 * gpu (typically as a texture), the it will do the same for the dst. |
| 547 * If the request cannot be fulfilled, returns false and dst is unmodified. | 544 * If the request cannot be fulfilled, returns false and dst is unmodified. |
| 548 */ | 545 */ |
| 549 bool deepCopyTo(SkBitmap* dst, Config c) const; | 546 bool deepCopyTo(SkBitmap* dst, Config c) const; |
| 550 | 547 |
| 551 /** Returns true if this bitmap can be deep copied into the requested config | 548 /** Returns true if this bitmap can be deep copied into the requested config |
| 552 by calling copyTo(). | 549 by calling copyTo(). |
| 553 */ | 550 */ |
| 554 bool canCopyTo(Config newConfig) const; | 551 bool canCopyTo(Config newConfig) const; |
| 555 | 552 |
| 556 /** | 553 SK_ATTR_DEPRECATED("use setFilterLevel on SkPaint") |
| 557 * DEPRECATED -- will be replaced with API on SkPaint | |
| 558 */ | |
| 559 void buildMipMap(bool forceRebuild = false); | 554 void buildMipMap(bool forceRebuild = false); |
| 560 | 555 |
| 561 #ifdef SK_BUILD_FOR_ANDROID | 556 #ifdef SK_BUILD_FOR_ANDROID |
| 562 bool hasHardwareMipMap() const { | 557 bool hasHardwareMipMap() const { |
| 563 return (fFlags & kHasHardwareMipMap_Flag) != 0; | 558 return (fFlags & kHasHardwareMipMap_Flag) != 0; |
| 564 } | 559 } |
| 565 | 560 |
| 566 void setHasHardwareMipMap(bool hasHardwareMipMap) { | 561 void setHasHardwareMipMap(bool hasHardwareMipMap) { |
| 567 if (hasHardwareMipMap) { | 562 if (hasHardwareMipMap) { |
| 568 fFlags |= kHasHardwareMipMap_Flag; | 563 fFlags |= kHasHardwareMipMap_Flag; |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 | 821 |
| 827 // returns the address of the byte that contains the x coordinate | 822 // returns the address of the byte that contains the x coordinate |
| 828 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { | 823 inline uint8_t* SkBitmap::getAddr1(int x, int y) const { |
| 829 SkASSERT(fPixels); | 824 SkASSERT(fPixels); |
| 830 SkASSERT(fConfig == kA1_Config); | 825 SkASSERT(fConfig == kA1_Config); |
| 831 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); | 826 SkASSERT((unsigned)x < fWidth && (unsigned)y < fHeight); |
| 832 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); | 827 return (uint8_t*)fPixels + y * fRowBytes + (x >> 3); |
| 833 } | 828 } |
| 834 | 829 |
| 835 #endif | 830 #endif |
| OLD | NEW |