Merge change 4737 into donut

* changes:
  Add prepareToDraw() to Bitmap for fixing http://b/issue?id=1907995.
This commit is contained in:
Android (Google) Code Review
2009-06-22 03:48:29 -07:00
3 changed files with 103 additions and 68 deletions

View File

@@ -47001,6 +47001,17 @@
visibility="public" visibility="public"
> >
</method> </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" <method name="recycle"
return="void" return="void"
abstract="false" abstract="false"

View File

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

View File

@@ -16,14 +16,14 @@
package android.graphics; package android.graphics;
import android.os.Parcelable;
import android.os.Parcel; import android.os.Parcel;
import android.os.Parcelable;
import java.io.OutputStream;
import java.nio.Buffer; import java.nio.Buffer;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.ShortBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
import java.io.OutputStream; import java.nio.ShortBuffer;
public final class Bitmap implements Parcelable { public final class Bitmap implements Parcelable {
/** /**
@@ -917,6 +917,22 @@ public final class Bitmap implements Parcelable {
return bm; 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 { protected void finalize() throws Throwable {
try { try {
nativeDestructor(mNativeBitmap); nativeDestructor(mNativeBitmap);
@@ -969,6 +985,8 @@ public final class Bitmap implements Parcelable {
int nativePaint, int nativePaint,
int[] offsetXY); int[] offsetXY);
private static native void nativePrepareToDraw(int nativeBitmap);
/* package */ final int ni() { /* package */ final int ni() {
return mNativeBitmap; return mNativeBitmap;
} }