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

Commit 460a39bd authored by Shai Barack's avatar Shai Barack
Browse files

Bitmap::writeBlob should respect bitmap_parcel_ashmem_as_immutable

Bug: 400807118
Flag: com.android.graphics.hwui.flags.bitmap_parcel_ashmem_as_immutable
Change-Id: I9a04504c9ebaf9b49cbe2429a6962ef82c148e4c
parent 0fc21121
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -679,10 +679,10 @@ static binder_status_t writeBlobFromFd(AParcel* parcel, int32_t size, int fd) {
    return STATUS_OK;
}

static binder_status_t writeBlob(AParcel* parcel, uint64_t bitmapId, const SkBitmap& bitmap) {
static binder_status_t writeBlob(AParcel* parcel, uint64_t bitmapId, const SkBitmap& bitmap,
                                 bool immutable) {
    const size_t size = bitmap.computeByteSize();
    const void* data = bitmap.getPixels();
    const bool immutable = bitmap.isImmutable();

    if (size <= 0 || data == nullptr) {
        return STATUS_NOT_ENOUGH_DATA;
@@ -910,7 +910,8 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, jlong bitmapHandle, j
    bitmapWrapper->getSkBitmap(&bitmap);
    uint64_t id = bitmapWrapper->bitmap().getId();

    p.writeInt32(shouldParcelAsMutable(bitmap, p.get()));
    const bool asMutable = shouldParcelAsMutable(bitmap, p.get());
    p.writeInt32(asMutable);
    p.writeInt32(bitmap.colorType());
    p.writeInt32(bitmap.alphaType());
    SkColorSpace* colorSpace = bitmap.colorSpace();
@@ -948,7 +949,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject, jlong bitmapHandle, j
    ALOGD("Bitmap.writeToParcel: copying bitmap into new blob (fds %s)",
          p.allowFds() ? "allowed" : "forbidden");
#endif
    status = writeBlob(p.get(), id, bitmap);
    status = writeBlob(p.get(), id, bitmap, !asMutable);
    if (status) {
        doThrowRE(env, "Could not copy bitmap to parcel blob.");
        return JNI_FALSE;