diff options
author | Xin Li <delphij@google.com> | 2020-08-31 21:21:38 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2020-08-31 21:21:38 -0700 |
commit | 628590d7ec80e10a3fc24b1c18a1afb55cca10a8 (patch) | |
tree | 4b1c3f52d86d7fb53afbe9e9438468588fa489f8 /libs/input/SpriteIcon.h | |
parent | b11b8ec3aec8bb42f2c07e1c5ac7942da293baa8 (diff) | |
parent | d2d3a20624d968199353ccf6ddbae6f3ac39c9af (diff) |
Merge Android R (rvc-dev-plus-aosp-without-vendor@6692709)
Bug: 166295507
Merged-In: I3d92a6de21a938f6b352ec26dc23420c0fe02b27
Change-Id: Ifdb80563ef042738778ebb8a7581a97c4e3d96e2
Diffstat (limited to 'libs/input/SpriteIcon.h')
-rw-r--r-- | libs/input/SpriteIcon.h | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/libs/input/SpriteIcon.h b/libs/input/SpriteIcon.h index c535faf624f7..a257d7e89ebc 100644 --- a/libs/input/SpriteIcon.h +++ b/libs/input/SpriteIcon.h @@ -17,7 +17,7 @@ #ifndef _UI_SPRITE_ICON_H #define _UI_SPRITE_ICON_H -#include <SkBitmap.h> +#include <android/graphics/bitmap.h> #include <gui/Surface.h> namespace android { @@ -26,22 +26,17 @@ namespace android { * Icon that a sprite displays, including its hotspot. */ struct SpriteIcon { - inline SpriteIcon() : style(0), hotSpotX(0), hotSpotY(0) { } - inline SpriteIcon(const SkBitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) : - bitmap(bitmap), style(style), hotSpotX(hotSpotX), hotSpotY(hotSpotY) { } + inline SpriteIcon() : style(0), hotSpotX(0), hotSpotY(0) {} + inline SpriteIcon(const graphics::Bitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) + : bitmap(bitmap), style(style), hotSpotX(hotSpotX), hotSpotY(hotSpotY) {} - SkBitmap bitmap; + graphics::Bitmap bitmap; int32_t style; float hotSpotX; float hotSpotY; inline SpriteIcon copy() const { - SkBitmap bitmapCopy; - if (bitmapCopy.tryAllocPixels(bitmap.info().makeColorType(kN32_SkColorType))) { - bitmap.readPixels(bitmapCopy.info(), bitmapCopy.getPixels(), bitmapCopy.rowBytes(), - 0, 0); - } - return SpriteIcon(bitmapCopy, style, hotSpotX, hotSpotY); + return SpriteIcon(bitmap.copy(ANDROID_BITMAP_FORMAT_RGBA_8888), style, hotSpotX, hotSpotY); } inline void reset() { @@ -51,17 +46,16 @@ struct SpriteIcon { hotSpotY = 0; } - inline bool isValid() const { return !bitmap.isNull() && !bitmap.empty(); } + inline bool isValid() const { return bitmap.isValid() && !bitmap.isEmpty(); } - inline int32_t width() const { return bitmap.width(); } - inline int32_t height() const { return bitmap.height(); } + inline int32_t width() const { return bitmap.getInfo().width; } + inline int32_t height() const { return bitmap.getInfo().height; } // Draw the bitmap onto the given surface. Returns true if it's successful, or false otherwise. // Note it doesn't set any metadata to the surface. bool draw(const sp<Surface> surface) const; }; - } // namespace android #endif // _UI_SPRITE_ICON_H |