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

Commit 7569de0f authored by Mike Reed's avatar Mike Reed
Browse files

switch to new API for compute image size

Test: make

Change-Id: Ie3a5d068bef1c2a1790ab227f6398695aee11cf7
parent 771f811c
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -1051,7 +1051,7 @@ static jobject Bitmap_createFromParcel(JNIEnv* env, jobject, jobject parcel) {
    }
    }


    // Read the bitmap blob.
    // Read the bitmap blob.
    size_t size = bitmap->getSize();
    size_t size = bitmap->computeByteSize();
    android::Parcel::ReadableBlob blob;
    android::Parcel::ReadableBlob blob;
    android::status_t status = p->readBlob(size, &blob);
    android::status_t status = p->readBlob(size, &blob);
    if (status) {
    if (status) {
@@ -1188,7 +1188,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,
            p->allowFds() ? "allowed" : "forbidden");
            p->allowFds() ? "allowed" : "forbidden");
#endif
#endif


    size_t size = bitmap.getSize();
    size_t size = bitmap.computeByteSize();
    android::Parcel::WritableBlob blob;
    android::Parcel::WritableBlob blob;
    status = p->writeBlob(size, mutableCopy, &blob);
    status = p->writeBlob(size, mutableCopy, &blob);
    if (status) {
    if (status) {
@@ -1411,7 +1411,7 @@ static void Bitmap_copyPixelsToBuffer(JNIEnv* env, jobject,
        android::AutoBufferPointer abp(env, jbuffer, JNI_TRUE);
        android::AutoBufferPointer abp(env, jbuffer, JNI_TRUE);


        // the java side has already checked that buffer is large enough
        // the java side has already checked that buffer is large enough
        memcpy(abp.pointer(), src, bitmap.getSize());
        memcpy(abp.pointer(), src, bitmap.computeByteSize());
    }
    }
}
}


@@ -1424,7 +1424,7 @@ static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject,
    if (NULL != dst) {
    if (NULL != dst) {
        android::AutoBufferPointer abp(env, jbuffer, JNI_FALSE);
        android::AutoBufferPointer abp(env, jbuffer, JNI_FALSE);
        // the java side has already checked that buffer is large enough
        // the java side has already checked that buffer is large enough
        memcpy(dst, abp.pointer(), bitmap.getSize());
        memcpy(dst, abp.pointer(), bitmap.computeByteSize());
        bitmap.notifyPixelsChanged();
        bitmap.notifyPixelsChanged();
    }
    }
}
}
+2 −3
Original line number Original line Diff line number Diff line
@@ -174,13 +174,12 @@ public:
            return false;
            return false;
        }
        }


        const int64_t size64 = info.getSafeSize64(bitmap->rowBytes());
        const size_t size = info.computeByteSize(bitmap->rowBytes());
        if (!sk_64_isS32(size64)) {
        if (size > SK_MaxS32) {
            ALOGW("bitmap is too large");
            ALOGW("bitmap is too large");
            return false;
            return false;
        }
        }


        const size_t size = sk_64_asS32(size64);
        if (size > mSize) {
        if (size > mSize) {
            ALOGW("bitmap marked for reuse (%u bytes) can't fit new bitmap "
            ALOGW("bitmap marked for reuse (%u bytes) can't fit new bitmap "
                  "(%zu bytes)", mSize, size);
                  "(%zu bytes)", mSize, size);
+1 −1
Original line number Original line Diff line number Diff line
@@ -645,7 +645,7 @@ bool RecyclingClippingPixelAllocator::allocPixelRef(SkBitmap* bitmap) {
    const int maxHeight = SkTMax(bitmap->height(), mRecycledBitmap->info().height());
    const int maxHeight = SkTMax(bitmap->height(), mRecycledBitmap->info().height());
    const SkImageInfo maxInfo = bitmap->info().makeWH(maxWidth, maxHeight);
    const SkImageInfo maxInfo = bitmap->info().makeWH(maxWidth, maxHeight);
    const size_t rowBytes = maxInfo.minRowBytes();
    const size_t rowBytes = maxInfo.minRowBytes();
    const size_t bytesNeeded = maxInfo.getSafeSize(rowBytes);
    const size_t bytesNeeded = maxInfo.computeByteSize(rowBytes);
    if (bytesNeeded <= mRecycledBytes) {
    if (bytesNeeded <= mRecycledBytes) {
        // Here we take advantage of reconfigure() to reset the rowBytes
        // Here we take advantage of reconfigure() to reset the rowBytes
        // of mRecycledBitmap.  It is very important that we pass in
        // of mRecycledBitmap.  It is very important that we pass in
+4 −4
Original line number Original line Diff line number Diff line
@@ -1328,7 +1328,7 @@ nAllocationCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong type,
    const void* ptr = bitmap.getPixels();
    const void* ptr = bitmap.getPixels();
    jlong id = (jlong)(uintptr_t)rsAllocationCreateFromBitmap((RsContext)con,
    jlong id = (jlong)(uintptr_t)rsAllocationCreateFromBitmap((RsContext)con,
                                                  (RsType)type, (RsAllocationMipmapControl)mip,
                                                  (RsType)type, (RsAllocationMipmapControl)mip,
                                                  ptr, bitmap.getSize(), usage);
                                                  ptr, bitmap.computeByteSize(), usage);
    return id;
    return id;
}
}


@@ -1356,7 +1356,7 @@ nAllocationCubeCreateFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong ty
    const void* ptr = bitmap.getPixels();
    const void* ptr = bitmap.getPixels();
    jlong id = (jlong)(uintptr_t)rsAllocationCubeCreateFromBitmap((RsContext)con,
    jlong id = (jlong)(uintptr_t)rsAllocationCubeCreateFromBitmap((RsContext)con,
                                                      (RsType)type, (RsAllocationMipmapControl)mip,
                                                      (RsType)type, (RsAllocationMipmapControl)mip,
                                                      ptr, bitmap.getSize(), usage);
                                                      ptr, bitmap.computeByteSize(), usage);
    return id;
    return id;
}
}


@@ -1371,7 +1371,7 @@ nAllocationCopyFromBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, j
    const void* ptr = bitmap.getPixels();
    const void* ptr = bitmap.getPixels();
    rsAllocation2DData((RsContext)con, (RsAllocation)alloc, 0, 0,
    rsAllocation2DData((RsContext)con, (RsAllocation)alloc, 0, 0,
                       0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
                       0, RS_ALLOCATION_CUBEMAP_FACE_POSITIVE_X,
                       w, h, ptr, bitmap.getSize(), 0);
                       w, h, ptr, bitmap.computeByteSize(), 0);
}
}


static void
static void
@@ -1381,7 +1381,7 @@ nAllocationCopyToBitmap(JNIEnv *_env, jobject _this, jlong con, jlong alloc, job
    GraphicsJNI::getSkBitmap(_env, jbitmap, &bitmap);
    GraphicsJNI::getSkBitmap(_env, jbitmap, &bitmap);


    void* ptr = bitmap.getPixels();
    void* ptr = bitmap.getPixels();
    rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.getSize());
    rsAllocationCopyToBitmap((RsContext)con, (RsAllocation)alloc, ptr, bitmap.computeByteSize());
    bitmap.notifyPixelsChanged();
    bitmap.notifyPixelsChanged();
}
}