Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9fce8535 authored by Narayan Kamath's avatar Narayan Kamath Committed by Gerrit Code Review
Browse files

Merge "AArch64: Make AssetAtlasService 64-bit compatible"

parents 2b3c14bf 4de3f481
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -392,11 +392,11 @@ class GLES20Canvas extends HardwareCanvas {
    // Atlas
    ///////////////////////////////////////////////////////////////////////////

    static void initAtlas(GraphicBuffer buffer, int[] map) {
    static void initAtlas(GraphicBuffer buffer, long[] map) {
        nInitAtlas(buffer, map, map.length);
    }

    private static native void nInitAtlas(GraphicBuffer buffer, int[] map, int count);
    private static native void nInitAtlas(GraphicBuffer buffer, long[] map, int count);

    ///////////////////////////////////////////////////////////////////////////
    // Display list
+1 −1
Original line number Diff line number Diff line
@@ -1981,7 +1981,7 @@ public abstract class HardwareRenderer {
                if (atlas.isCompatible(android.os.Process.myPpid())) {
                    GraphicBuffer buffer = atlas.getBuffer();
                    if (buffer != null) {
                        int[] map = atlas.getMap();
                        long[] map = atlas.getMap();
                        if (map != null) {
                            GLES20Canvas.initAtlas(buffer, map);
                        }
+5 −5
Original line number Diff line number Diff line
@@ -45,10 +45,10 @@ interface IAssetAtlas {
     * if the atlas is not available yet.
     *
     * Each bitmap is represented by several entries in the array:
     * int0: SkBitmap*, the native bitmap object
     * int1: x position
     * int2: y position
     * int3: rotated, 1 if the bitmap must be rotated, 0 otherwise
     * long0: SkBitmap*, the native bitmap object
     * long1: x position
     * long2: y position
     * long3: rotated, 1 if the bitmap must be rotated, 0 otherwise
     */
    int[] getMap();
    long[] getMap();
}
+5 −7
Original line number Diff line number Diff line
@@ -118,14 +118,12 @@ static void android_view_GLES20Canvas_terminateCaches(JNIEnv* env, jobject clazz
// ----------------------------------------------------------------------------

static void android_view_GLES20Canvas_initAtlas(JNIEnv* env, jobject clazz,
        jobject graphicBuffer, jintArray atlasMapArray, jint count) {
        jobject graphicBuffer, jlongArray atlasMapArray, jint count) {

    sp<GraphicBuffer> buffer = graphicBufferForJavaObject(env, graphicBuffer);
    jint* atlasMap = env->GetIntArrayElements(atlasMapArray, NULL);

    Caches::getInstance().assetAtlas.init(buffer, atlasMap, count);

    env->ReleaseIntArrayElements(atlasMapArray, atlasMap, 0);
    jlong* jAtlasMap = env->GetLongArrayElements(atlasMapArray, NULL);
    Caches::getInstance().assetAtlas.init(buffer, jAtlasMap, count);
    env->ReleaseLongArrayElements(atlasMapArray, jAtlasMap, 0);
}

// ----------------------------------------------------------------------------
@@ -1163,7 +1161,7 @@ static JNINativeMethod gMethods[] = {
    { "nInitCaches",        "()Z",             (void*) android_view_GLES20Canvas_initCaches },
    { "nTerminateCaches",   "()V",             (void*) android_view_GLES20Canvas_terminateCaches },

    { "nInitAtlas",         "(Landroid/view/GraphicBuffer;[II)V",
    { "nInitAtlas",         "(Landroid/view/GraphicBuffer;[JI)V",
            (void*) android_view_GLES20Canvas_initAtlas },

    { "nCreateRenderer",    "()J",             (void*) android_view_GLES20Canvas_createRenderer },
+10 −5
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@ namespace uirenderer {
// Lifecycle
///////////////////////////////////////////////////////////////////////////////

void AssetAtlas::init(sp<GraphicBuffer> buffer, int* map, int count) {
void AssetAtlas::init(sp<GraphicBuffer> 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<SkBitmap*>(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<int>(map[i++]);
        const int y = static_cast<int>(map[i++]);
        bool rotated = map[i++] > 0;

        // Bitmaps should never be null, we're just extra paranoid
Loading