summaryrefslogtreecommitdiffstats
path: root/graphics/java/android/graphics/Picture.java
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/java/android/graphics/Picture.java')
-rw-r--r--graphics/java/android/graphics/Picture.java35
1 files changed, 27 insertions, 8 deletions
diff --git a/graphics/java/android/graphics/Picture.java b/graphics/java/android/graphics/Picture.java
index bbb2dbf..997141d 100644
--- a/graphics/java/android/graphics/Picture.java
+++ b/graphics/java/android/graphics/Picture.java
@@ -32,10 +32,15 @@ public class Picture {
private Canvas mRecordingCanvas;
private final int mNativePicture;
+ /**
+ * @hide
+ */
+ public final boolean createdFromStream;
+
private static final int WORKING_STREAM_STORAGE = 16 * 1024;
public Picture() {
- this(nativeConstructor(0));
+ this(nativeConstructor(0), false);
}
/**
@@ -44,7 +49,7 @@ public class Picture {
* changes will not be reflected in this picture.
*/
public Picture(Picture src) {
- this(nativeConstructor(src != null ? src.mNativePicture : 0));
+ this(nativeConstructor(src != null ? src.mNativePicture : 0), false);
}
/**
@@ -101,15 +106,24 @@ public class Picture {
/**
* Create a new picture (already recorded) from the data in the stream. This
* data was generated by a previous call to writeToStream().
+ *
+ * <strong>Note:</strong> a picture created from an input stream cannot be
+ * replayed on a hardware accelerated canvas.
+ *
+ * @see #writeToStream(java.io.OutputStream)
*/
public static Picture createFromStream(InputStream stream) {
- return new Picture(
- nativeCreateFromStream(stream, new byte[WORKING_STREAM_STORAGE]));
+ return new Picture(nativeCreateFromStream(stream, new byte[WORKING_STREAM_STORAGE]), true);
}
/**
* Write the picture contents to a stream. The data can be used to recreate
* the picture in this or another process by calling createFromStream.
+ *
+ * <strong>Note:</strong> a picture created from an input stream cannot be
+ * replayed on a hardware accelerated canvas.
+ *
+ * @see #createFromStream(java.io.InputStream)
*/
public void writeToStream(OutputStream stream) {
// do explicit check before calling the native method
@@ -123,18 +137,23 @@ public class Picture {
}
protected void finalize() throws Throwable {
- nativeDestructor(mNativePicture);
+ try {
+ nativeDestructor(mNativePicture);
+ } finally {
+ super.finalize();
+ }
}
-
- /*package*/ final int ni() {
+
+ final int ni() {
return mNativePicture;
}
- private Picture(int nativePicture) {
+ private Picture(int nativePicture, boolean fromStream) {
if (nativePicture == 0) {
throw new RuntimeException();
}
mNativePicture = nativePicture;
+ createdFromStream = fromStream;
}
// return empty picture if src is 0, or a copy of the native src