From 17ab38f8a87bc90eab11373f878f220ce3031de6 Mon Sep 17 00:00:00 2001 From: Ashok Bhat Date: Mon, 27 Jan 2014 16:00:23 +0000 Subject: AArch64: Make AssetAtlasService 64-bit compatible Changes in this patch include [x] Long(64-bit) is used to store native pointers in AssetAtlasService and related classes as they can be 64-bit. [x] Some minor changes have been done to conform with standard JNI practice (e.g. use of jint instead of int in JNI function prototypes) Signed-off-by: Ashok Bhat (cherry-picked from 4de3f481bc59ab4b766dc027e41aff7cda9d62f7) Change-Id: If22daf40eef46f8df9f94d65ddcc52c45b3acf2a --- libs/hwui/AssetAtlas.cpp | 15 ++++++++++----- libs/hwui/AssetAtlas.h | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) (limited to 'libs') diff --git a/libs/hwui/AssetAtlas.cpp b/libs/hwui/AssetAtlas.cpp index fddfe90..fc86e4f 100644 --- a/libs/hwui/AssetAtlas.cpp +++ b/libs/hwui/AssetAtlas.cpp @@ -28,7 +28,7 @@ namespace uirenderer { // Lifecycle /////////////////////////////////////////////////////////////////////////////// -void AssetAtlas::init(sp buffer, int* map, int count) { +void AssetAtlas::init(sp buffer, int64_t* map, int count) { if (mImage) { return; } @@ -108,14 +108,19 @@ private: /** * TODO: This method does not take the rotation flag into account */ -void AssetAtlas::createEntries(Caches& caches, int* map, int count) { +void AssetAtlas::createEntries(Caches& caches, int64_t* map, int count) { const float width = float(mTexture->width); const float height = float(mTexture->height); for (int i = 0; i < count; ) { - SkBitmap* bitmap = (SkBitmap*) map[i++]; - int x = map[i++]; - int y = map[i++]; + SkBitmap* bitmap = reinterpret_cast(map[i++]); + // NOTE: We're converting from 64 bit signed values to 32 bit + // signed values. This is guaranteed to be safe because the "x" + // and "y" coordinate values are guaranteed to be representable + // with 32 bits. The array is 64 bits wide so that it can carry + // pointers on 64 bit architectures. + const int x = static_cast(map[i++]); + const int y = static_cast(map[i++]); bool rotated = map[i++] > 0; // Bitmaps should never be null, we're just extra paranoid diff --git a/libs/hwui/AssetAtlas.h b/libs/hwui/AssetAtlas.h index 57c8a60..2ec556e 100644 --- a/libs/hwui/AssetAtlas.h +++ b/libs/hwui/AssetAtlas.h @@ -121,7 +121,7 @@ public: * initialized. To re-initialize the atlas, you must * first call terminate(). */ - ANDROID_API void init(sp buffer, int* map, int count); + ANDROID_API void init(sp buffer, int64_t* map, int count); /** * Destroys the atlas texture. This object can be @@ -176,7 +176,7 @@ public: } private: - void createEntries(Caches& caches, int* map, int count); + void createEntries(Caches& caches, int64_t* map, int count); Texture* mTexture; Image* mImage; -- cgit v1.1