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

Commit aed7f58f authored by sergeyv's avatar sergeyv
Browse files

Pass Bitmap instead of SkBitmap in canvas.drawBitmap(Bitmap, float,float,Paint)

Test: refactoring cl.
bug:32216791

Change-Id: If9f9fbc19e683b14cce6c3c268258bd832d495d2
parent c1c54062
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -55,7 +55,10 @@ public:
        return !!mBitmap;
    }

    Bitmap* bitmap() { return mBitmap.get(); }
    Bitmap& bitmap() {
        assertValid();
        return *mBitmap;
    }

    void assertValid() {
        LOG_ALWAYS_FATAL_IF(!valid(), "Error, cannot access an invalid/free'd bitmap here!");
@@ -134,7 +137,7 @@ public:
    }

    void* pixels() {
        return mBitmapWrapper->bitmap()->pixels();
        return mBitmapWrapper->bitmap().pixels();
    }

    bool valid() {
@@ -200,13 +203,12 @@ void toSkBitmap(jlong bitmapHandle, SkBitmap* outBitmap) {
    bitmap->getSkBitmap(outBitmap);
}

Bitmap* toBitmap(JNIEnv* env, jobject bitmap) {
Bitmap& toBitmap(JNIEnv* env, jobject bitmap) {
    SkASSERT(env);
    SkASSERT(bitmap);
    SkASSERT(env->IsInstanceOf(bitmap, gBitmap_class));
    jlong bitmapHandle = env->GetLongField(bitmap, gBitmap_nativePtr);
    LocalScopedBitmap localBitmap(bitmapHandle);
    localBitmap->assertValid();
    return localBitmap->bitmap();
}

@@ -646,7 +648,7 @@ static void Bitmap_reconfigure(JNIEnv* env, jobject clazz, jlong bitmapHandle,
        // Otherwise respect the premultiplied request.
        alphaType = requestPremul ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
    }
    bitmap->bitmap()->reconfigure(SkImageInfo::Make(width, height, colorType, alphaType,
    bitmap->bitmap().reconfigure(SkImageInfo::Make(width, height, colorType, alphaType,
            sk_sp<SkColorSpace>(bitmap->info().colorSpace())));
}

@@ -941,7 +943,7 @@ static jboolean Bitmap_writeToParcel(JNIEnv* env, jobject,

    // Transfer the underlying ashmem region if we have one and it's immutable.
    android::status_t status;
    int fd = bitmapWrapper->bitmap()->getAshmemFd();
    int fd = bitmapWrapper->bitmap().getAshmemFd();
    if (fd >= 0 && !isMutable && p->allowFds()) {
#if DEBUG_PARCEL
        ALOGD("Bitmap.writeToParcel: transferring immutable bitmap's ashmem fd as "
@@ -1189,9 +1191,9 @@ static jboolean Bitmap_sameAs(JNIEnv* env, jobject, jlong bm0Handle,

static jlong Bitmap_refPixelRef(JNIEnv* env, jobject, jlong bitmapHandle) {
    LocalScopedBitmap bitmap(bitmapHandle);
    SkPixelRef* pixelRef = bitmap->bitmap();
    SkSafeRef(pixelRef);
    return reinterpret_cast<jlong>(pixelRef);
    SkPixelRef& pixelRef = bitmap->bitmap();
    pixelRef.ref();
    return reinterpret_cast<jlong>(&pixelRef);
}

static void Bitmap_prepareToDraw(JNIEnv* env, jobject, jlong bitmapPtr) {
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ jobject createBitmap(JNIEnv* env, Bitmap* bitmap,

void toSkBitmap(jlong bitmapHandle, SkBitmap* outBitmap);

Bitmap* toBitmap(JNIEnv* env, jobject bitmap);
Bitmap& toBitmap(JNIEnv* env, jobject bitmap);

/** Reinitialize a bitmap. bitmap must already have its SkAlphaType set in
    sync with isPremultiplied
+1 −1
Original line number Diff line number Diff line
@@ -330,7 +330,7 @@ static jobject doDecode(JNIEnv* env, SkStreamRewindable* stream, jobject padding
    android::Bitmap* reuseBitmap = nullptr;
    unsigned int existingBufferSize = 0;
    if (javaBitmap != NULL) {
        reuseBitmap = bitmap::toBitmap(env, javaBitmap);
        reuseBitmap = &bitmap::toBitmap(env, javaBitmap);
        if (reuseBitmap->isImmutable()) {
            ALOGW("Unable to reuse an immutable bitmap as an image decoder target.");
            javaBitmap = NULL;
+1 −1
Original line number Diff line number Diff line
@@ -151,7 +151,7 @@ static jobject nativeDecodeRegion(JNIEnv* env, jobject, jlong brdHandle, jint in
    android::Bitmap* recycledBitmap = nullptr;
    size_t recycledBytes = 0;
    if (javaBitmap) {
        recycledBitmap = bitmap::toBitmap(env, javaBitmap);
        recycledBitmap = &bitmap::toBitmap(env, javaBitmap);
        if (recycledBitmap->isImmutable()) {
            ALOGW("Warning: Reusing an immutable bitmap as an image decoder target.");
        }
+5 −5
Original line number Diff line number Diff line
@@ -337,13 +337,13 @@ SkColorType GraphicsJNI::legacyBitmapConfigToColorType(jint legacyConfig) {
}

void GraphicsJNI::getSkBitmap(JNIEnv* env, jobject bitmap, SkBitmap* outBitmap) {
    android::bitmap::toBitmap(env, bitmap)->getSkBitmap(outBitmap);
    android::bitmap::toBitmap(env, bitmap).getSkBitmap(outBitmap);
}

SkPixelRef* GraphicsJNI::refSkPixelRef(JNIEnv* env, jobject bitmap) {
    SkPixelRef* pixelRef = android::bitmap::toBitmap(env, bitmap);
    pixelRef->ref();
    return pixelRef;
SkPixelRef* GraphicsJNI::refSkPixelRef(JNIEnv* env, jobject jbitmap) {
    android::Bitmap& bitmap = android::bitmap::toBitmap(env, jbitmap);
    bitmap.ref();
    return &bitmap;
}
SkColorType GraphicsJNI::getNativeBitmapColorType(JNIEnv* env, jobject jconfig) {
    SkASSERT(env);
Loading