summaryrefslogtreecommitdiff
path: root/libs/input/SpriteController.h
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2019-08-14 15:50:59 -0400
committerDerek Sollenberger <djsollen@google.com>2019-09-10 14:50:02 -0400
commit9ca5bbe39f54547dbe585c39459208719a9728b4 (patch)
tree945a0e0a7e58c128d31619e5034a9e104ca06766 /libs/input/SpriteController.h
parent00f6e5d22db205765eeadbe6500f3f5500fb3d6a (diff)
Create C API for accessing android.graphics.Bitmap in native code.
Restrict access to SkBitmap for libandroid_runtime.so to be only within the boundaries of the graphics module. Test: CtsUiRenderingTestCases Bug: 137655431 Change-Id: I4d0ea227e91d22068966513c4e3a55021b9e924f
Diffstat (limited to 'libs/input/SpriteController.h')
-rw-r--r--libs/input/SpriteController.h18
1 files changed, 6 insertions, 12 deletions
diff --git a/libs/input/SpriteController.h b/libs/input/SpriteController.h
index 79a904f5fe65..2513544d4bdf 100644
--- a/libs/input/SpriteController.h
+++ b/libs/input/SpriteController.h
@@ -20,10 +20,9 @@
#include <utils/RefBase.h>
#include <utils/Looper.h>
+#include <android/graphics/bitmap.h>
#include <gui/SurfaceComposerClient.h>
-#include <SkBitmap.h>
-
namespace android {
/*
@@ -56,21 +55,16 @@ struct SpriteTransformationMatrix {
*/
struct SpriteIcon {
inline SpriteIcon() : style(0), hotSpotX(0), hotSpotY(0) { }
- inline SpriteIcon(const SkBitmap& bitmap, int32_t style, float hotSpotX, float hotSpotY) :
+ 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() {
@@ -81,7 +75,7 @@ struct SpriteIcon {
}
inline bool isValid() const {
- return !bitmap.isNull() && !bitmap.empty();
+ return bitmap.isValid() && !bitmap.isEmpty();
}
};
@@ -183,7 +177,7 @@ private:
* This structure is designed so that it can be copied during updates so that
* surfaces can be resized and redrawn without blocking the client by holding a lock
* on the sprites for a long time.
- * Note that the SkBitmap holds a reference to a shared (and immutable) pixel ref. */
+ * Note that the SpriteIcon holds a reference to a shared (and immutable) bitmap. */
struct SpriteState {
inline SpriteState() :
dirty(0), visible(false),