| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
#ifndef _UI_SPRITE_ICON_H |
| 18 |
#define _UI_SPRITE_ICON_H |
| 19 |
|
| 20 |
#include <android/graphics/bitmap.h> |
| 21 |
#include <gui/Surface.h> |
| 22 |
|
| 23 |
namespace android { |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
struct SpriteIcon { |
| 29 |
inline SpriteIcon() : style(0), hotSpotX(0), hotSpotY(0) {} |
| 30 |
inline SpriteIcon(const graphics::Bitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) |
| 31 |
: bitmap(bitmap), style(style), hotSpotX(hotSpotX), hotSpotY(hotSpotY) {} |
| 32 |
|
| 33 |
graphics::Bitmap bitmap; |
| 34 |
int32_t style; |
| 35 |
float hotSpotX; |
| 36 |
float hotSpotY; |
| 37 |
|
| 38 |
inline SpriteIcon copy() const { |
| 39 |
return SpriteIcon(bitmap.copy(ANDROID_BITMAP_FORMAT_RGBA_8888), style, hotSpotX, hotSpotY); |
| 40 |
} |
| 41 |
|
| 42 |
inline void reset() { |
| 43 |
bitmap.reset(); |
| 44 |
style = 0; |
| 45 |
hotSpotX = 0; |
| 46 |
hotSpotY = 0; |
| 47 |
} |
| 48 |
|
| 49 |
inline bool isValid() const { return bitmap.isValid() && !bitmap.isEmpty(); } |
| 50 |
|
| 51 |
inline int32_t width() const { return bitmap.getInfo().width; } |
| 52 |
inline int32_t height() const { return bitmap.getInfo().height; } |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
bool draw(const sp<Surface> surface) const; |
| 57 |
}; |
| 58 |
|
| 59 |
} |
| 60 |
|
| 61 |
#endif |