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

Commit 766d7236 authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 4737 into donut

* changes:
  Add prepareToDraw() to Bitmap for fixing http://b/issue?id=1907995.
parents 8570e5fc 8cdcb127
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -47001,6 +47001,17 @@
 visibility="public"
>
</method>
<method name="prepareToDraw"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="recycle"
 return="void"
 abstract="false"
+30 −24
Original line number Diff line number Diff line
@@ -519,6 +519,11 @@ static void Bitmap_copyPixelsFromBuffer(JNIEnv* env, jobject,
    }
}

static void Bitmap_prepareToDraw(JNIEnv* env, jobject, SkBitmap* bitmap) {
    bitmap->lockPixels();
    bitmap->unlockPixels();
}

///////////////////////////////////////////////////////////////////////////////

#include <android_runtime/AndroidRuntime.h>
@@ -552,7 +557,8 @@ static JNINativeMethod gBitmapMethods[] = {
    {   "nativeCopyPixelsToBuffer", "(ILjava/nio/Buffer;)V",
                                            (void*)Bitmap_copyPixelsToBuffer },
    {   "nativeCopyPixelsFromBuffer", "(ILjava/nio/Buffer;)V",
                                            (void*)Bitmap_copyPixelsFromBuffer }
                                            (void*)Bitmap_copyPixelsFromBuffer },
    {   "nativePrepareToDraw",      "(I)V", (void*)Bitmap_prepareToDraw }
};

#define kClassPathName  "android/graphics/Bitmap"
+62 −44
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@

package android.graphics;

import android.os.Parcelable;
import android.os.Parcel;
import android.os.Parcelable;

import java.io.OutputStream;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.IntBuffer;
import java.io.OutputStream;
import java.nio.ShortBuffer;

public final class Bitmap implements Parcelable {
    /**
@@ -917,6 +917,22 @@ public final class Bitmap implements Parcelable {
        return bm;
    }

    /**
     * Rebuilds any caches associated with the bitmap that are used for
     * drawing it. In the case of purgeable bitmaps, this call will attempt to
     * ensure that the pixels have been decoded.
     * If this is called on more than one bitmap in sequence, the priority is
     * given in LRU order (i.e. the last bitmap called will be given highest
     * priority).
     *
     * For bitmaps with no associated caches, this call is effectively a no-op,
     * and therefore is harmless.
     */
    public void prepareToDraw() {
        nativePrepareToDraw(mNativeBitmap);
    }

    @Override
    protected void finalize() throws Throwable {
        try {
            nativeDestructor(mNativeBitmap);
@@ -969,6 +985,8 @@ public final class Bitmap implements Parcelable {
                                                    int nativePaint,
                                                    int[] offsetXY);

    private static native void nativePrepareToDraw(int nativeBitmap);

    /* package */ final int ni() {
        return mNativeBitmap;
    }