summaryrefslogtreecommitdiffstats
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/java/android/graphics/BitmapFactory.java74
-rw-r--r--graphics/java/android/graphics/BitmapRegionDecoder.java7
-rw-r--r--graphics/java/android/renderscript/Allocation.java14
-rw-r--r--graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java4
-rw-r--r--graphics/java/android/renderscript/ScriptIntrinsicHistogram.java4
5 files changed, 55 insertions, 48 deletions
diff --git a/graphics/java/android/graphics/BitmapFactory.java b/graphics/java/android/graphics/BitmapFactory.java
index 1c426fd..1721bee 100644
--- a/graphics/java/android/graphics/BitmapFactory.java
+++ b/graphics/java/android/graphics/BitmapFactory.java
@@ -23,7 +23,6 @@ import android.util.DisplayMetrics;
import android.util.Log;
import android.util.TypedValue;
-import java.io.BufferedInputStream;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
@@ -545,28 +544,28 @@ public class BitmapFactory {
return null;
}
- Bitmap bm;
+ Bitmap bm = null;
Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeBitmap");
try {
- // we need mark/reset to work properly
- if (!is.markSupported()) {
- is = new BufferedInputStream(is, DECODE_BUFFER_SIZE);
- }
-
- // so we can call reset() if a given codec gives up after reading up to
- // this many bytes. FIXME: need to find out from the codecs what this
- // value should be.
- is.mark(1024);
-
+ boolean decodeGenericStream = true;
if (is instanceof AssetManager.AssetInputStream) {
final int asset = ((AssetManager.AssetInputStream) is).getAssetInt();
bm = nativeDecodeAsset(asset, outPadding, opts);
- } else {
- // pass some temp storage down to the native code. 1024 is made up,
- // but should be large enough to avoid too many small calls back
- // into is.read(...) This number is not related to the value passed
- // to mark(...) above.
+ // Do not follow the normal case.
+ decodeGenericStream = false;
+ } else if (is instanceof FileInputStream) {
+ try {
+ FileDescriptor fd = ((FileInputStream) is).getFD();
+ // decodeFileDescriptor will take care of throwing the IAE and
+ // calling setDensityFromOptions.
+ return decodeFileDescriptor(fd, outPadding, opts);
+ } catch (IOException e) {
+ // Fall through to nativeDecodeStream.
+ }
+ }
+
+ if (decodeGenericStream) {
byte [] tempStorage = null;
if (opts != null) tempStorage = opts.inTempStorage;
if (tempStorage == null) tempStorage = new byte[DECODE_BUFFER_SIZE];
@@ -610,26 +609,41 @@ public class BitmapFactory {
* no bitmap is returned (null) then padding is
* unchanged.
* @param opts null-ok; Options that control downsampling and whether the
- * image should be completely decoded, or just is size returned.
+ * image should be completely decoded, or just its size returned.
* @return the decoded bitmap, or null
*/
public static Bitmap decodeFileDescriptor(FileDescriptor fd, Rect outPadding, Options opts) {
- if (nativeIsSeekable(fd)) {
- Bitmap bm = nativeDecodeFileDescriptor(fd, outPadding, opts);
+ Bitmap bm;
+
+ Trace.traceBegin(Trace.TRACE_TAG_GRAPHICS, "decodeFileDescriptor");
+ try {
+ if (nativeIsSeekable(fd)) {
+ bm = nativeDecodeFileDescriptor(fd, outPadding, opts);
+ } else {
+ FileInputStream fis = new FileInputStream(fd);
+ // FIXME: If nativeDecodeStream grabbed the pointer to tempStorage
+ // from Options, this code would not need to be duplicated.
+ byte [] tempStorage = null;
+ if (opts != null) tempStorage = opts.inTempStorage;
+ if (tempStorage == null) tempStorage = new byte[DECODE_BUFFER_SIZE];
+ try {
+ bm = nativeDecodeStream(fis, tempStorage, outPadding, opts);
+ } finally {
+ try {
+ fis.close();
+ } catch (Throwable t) {/* ignore */}
+ }
+ }
+
if (bm == null && opts != null && opts.inBitmap != null) {
throw new IllegalArgumentException("Problem decoding into existing bitmap");
}
- return bm;
- } else {
- FileInputStream fis = new FileInputStream(fd);
- try {
- return decodeStream(fis, outPadding, opts);
- } finally {
- try {
- fis.close();
- } catch (Throwable t) {/* ignore */}
- }
+
+ setDensityFromOptions(bm, opts);
+ } finally {
+ Trace.traceEnd(Trace.TRACE_TAG_GRAPHICS);
}
+ return bm;
}
/**
diff --git a/graphics/java/android/graphics/BitmapRegionDecoder.java b/graphics/java/android/graphics/BitmapRegionDecoder.java
index b38d107..3524b25 100644
--- a/graphics/java/android/graphics/BitmapRegionDecoder.java
+++ b/graphics/java/android/graphics/BitmapRegionDecoder.java
@@ -17,7 +17,6 @@ package android.graphics;
import android.content.res.AssetManager;
-import java.io.BufferedInputStream;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.IOException;
@@ -108,12 +107,6 @@ public final class BitmapRegionDecoder {
*/
public static BitmapRegionDecoder newInstance(InputStream is,
boolean isShareable) throws IOException {
- // we need mark/reset to work properly in JNI
-
- if (!is.markSupported()) {
- is = new BufferedInputStream(is, 16 * 1024);
- }
-
if (is instanceof AssetManager.AssetInputStream) {
return nativeNewInstance(
((AssetManager.AssetInputStream) is).getAssetInt(),
diff --git a/graphics/java/android/renderscript/Allocation.java b/graphics/java/android/renderscript/Allocation.java
index 7d05a74..ca72c25 100644
--- a/graphics/java/android/renderscript/Allocation.java
+++ b/graphics/java/android/renderscript/Allocation.java
@@ -80,7 +80,7 @@ public class Allocation extends BaseObj {
int mCurrentCount;
static HashMap<Integer, Allocation> mAllocationMap =
new HashMap<Integer, Allocation>();
- IoInputNotifier mBufferNotifier;
+ OnBufferAvailableListener mBufferNotifier;
/**
* The usage of the Allocation. These signal to RenderScript where to place
@@ -1838,26 +1838,22 @@ public class Allocation extends BaseObj {
}
/**
- * @hide
- *
* Interface to handle notification when new buffers are available via
* {@link #USAGE_IO_INPUT}. An application will receive one notification
* when a buffer is available. Additional buffers will not trigger new
* notifications until a buffer is processed.
*/
- public interface IoInputNotifier {
+ public interface OnBufferAvailableListener {
public void onBufferAvailable(Allocation a);
}
/**
- * @hide
- *
* Set a notification handler for {@link #USAGE_IO_INPUT}.
*
- * @param callback instance of the IoInputNotifier class to be called
- * when buffer arrive.
+ * @param callback instance of the OnBufferAvailableListener
+ * class to be called when buffer arrive.
*/
- public void setIoInputNotificationHandler(IoInputNotifier callback) {
+ public void setOnBufferAvailableListener(OnBufferAvailableListener callback) {
synchronized(mAllocationMap) {
mAllocationMap.put(new Integer(getID(mRS)), this);
mBufferNotifier = callback;
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
index 6881627..32c3d15 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicColorMatrix.java
@@ -56,8 +56,12 @@ public final class ScriptIntrinsicColorMatrix extends ScriptIntrinsic {
* this parameter is ignored. The Element type check is
* performed in the kernel launch.
*
+ * @deprecated Use the single argument version as Element is now
+ * ignored.
+ *
* @return ScriptIntrinsicColorMatrix
*/
+ @Deprecated
public static ScriptIntrinsicColorMatrix create(RenderScript rs, Element e) {
return create(rs);
}
diff --git a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java b/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java
index f143326..adc2d95 100644
--- a/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java
+++ b/graphics/java/android/renderscript/ScriptIntrinsicHistogram.java
@@ -151,7 +151,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic {
*
* @param ain The input image
*/
- public void forEach_dot(Allocation ain) {
+ public void forEach_Dot(Allocation ain) {
if (mOut.getType().getElement().getVectorSize() != 1) {
throw new RSIllegalArgumentException("Output vector size must be one.");
}
@@ -170,7 +170,7 @@ public final class ScriptIntrinsicHistogram extends ScriptIntrinsic {
*
* @return Script.KernelID The KernelID object.
*/
- public Script.KernelID getKernelID_seperate() {
+ public Script.KernelID getKernelID_Separate() {
return createKernelID(0, 3, null, null);
}