7315f1baee19476363235127bc1438e2a291fa15 |
|
11-Sep-2013 |
Leon Scroggins III <scroggo@google.com> |
Use a native buffer for decoding images. Fixes BUG:10725383 Depends on https://googleplex-android-review.git.corp.google.com/#/c/357300/ in external/skia. In the previous fix for BUG:8432093 and BUG:6493544 (https://googleplex-android-review.googlesource.com/#/c/346191/), instead of calling mark on the provided input stream, we copied the entire stream in native code (except in one case; more details below), allowing rewind no matter how much of the stream had been read. This was because two decoders may rewind after reading an arbitrary amount of the stream: SkImageDecoder_wbmp and SkImageDecoder_libjpeg. It turns out that the jpeg decoder does not need this rewind after arbitrary length (it is a failure recovery case, and libjpeg has a default recovery we can use - the above referenced CL in Skia uses the default). Although the wbmp decoder could read any amount given a stream with the "right" data, and then return false, such a stream would not be a valid stream of another format, so it is okay for this rewind to fail. Further, the previous fix was inefficient in the common case where the caller decodes just the bounds, resets, then decodes the entire image (since we have copied the entire stream twice). The copy also resulted in the crashes seen in BUG:10725383. In this CL, buffer only the amount of input needed by SkImageDecoder::Factory to determine the type of image decoder needed. Do not mark the input stream provided by the caller, so their mark (if any) can remain in tact. The new Skia class SkFrontBufferedStream allows buffering just the beginning of the stream. core/jni/android/graphics/BitmapFactory.cpp: Instead of calling GetRewindableStream (which has been removed), call CreateJavaInputStreamAdaptor. Then wrap it in an SkFrontBufferedStream, with a large enough buffer to determine which type of image is used. core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h: core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp: Remove mark, markSupported, and rewind. CreateJavaInputStreamAdaptor now turns an SkStream which is not rewindable. If the caller needs rewind that needs to be handled differently (for example, by using SkFrontBufferedStream, as is done in BitmapFactory and Movie. Remove RewindableJavaStream and GetRewindableStream. Remove code specific to ByteArrayInputStream, which makes slow JNI calls. Instead, depend on the caller to buffer the input in the general case. There is no reason to special case this stream (especially since we already have decodeByteArray). Remove CheckForAssetStream, which is now always special cased in Java. core/jni/android/graphics/Movie.cpp: Call CreateJavaInputStreamAdaptor and use an SkFrontBufferedStream. Add a native function for decoding an Asset, and remove old call to CheckForAssetStream. graphics/java/android/graphics/BitmapFactory.java: Write a helper function for decoding a stream to consolidate common code. Buffer enough of the input so that SkImageDecoder::Factory can rewind after having read enough to determine the type. Unlike the old code, do NOT mark the caller's stream. This is handled in native code. The caller's mark (if any) is left alone. graphics/java/android/graphics/Movie.java: Check for an Asset stream before passing to native, and call a native function for handling the asset directly. BUG:6493544 BUG:8432093 BUG:10725383 Change-Id: Ide74d3606ff4bb2a8c6cdbf11bae3f96696f331a
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
37b82e32324d0911aba897880c28b2fdedc3ec9a |
|
13-Sep-2013 |
Leon Scroggins III <scroggo@google.com> |
Do not allocate so much memory on the stack. Instead, allocate a smaller amount and grow as necessary. BUG:10697851 Change-Id: Iec57a8a374a4a76a3770e241cf561d58f3c8e1dc
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
d0d7eaf129b48ea04c06902a11c2a4f74056d76c |
|
06-Sep-2013 |
Leon Scroggins III <scroggo@google.com> |
Register jni objs in CreateJavaOutputStreamAdaptor Write a registration function and call it in AndroidRuntime, which calls FindClass/GetFieldID only once per class/method. Use NewGlobalRef for classes that will be checked against later. BUG:10612755 Change-Id: I25541da1b7bb1cd53a1579ea84c4620e1901310f
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
c7797525084ba0ea441e394aa0a2ba35d6ff3320 |
|
03-Sep-2013 |
Leon Scroggins III <scroggo@google.com> |
Change name back to CreateJavaInputStreamAdaptor. In order to fix open source builds, change WrapJavaInputStream's name back to CreateJavaInputStreamAdaptor. Remove FIXME in CopyJavaInputStream, and return a more generic type, since the more specific type was only needed by a change in external/webkit, which is being reverted since it depends on unreleased code. Change-Id: I89b0431e357b509a2a0c17a624b31bd49d29070f
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
ca32021b43f326af7d3f4ae041f8db297f98a518 |
|
20-Aug-2013 |
Leon Scroggins III <scroggo@google.com> |
Replace stream wrap-function w/ more specific ones The current stream wrapper returns a potentially incorrect value for a call to getLength(), is typically copied into another stream (not always in the same way), and doesn't always take advantage of its underlying data (like when it is an Asset). The overall goal of this CL is to provide the caller with something that is ready to use, depending on what is asked for. If a copy is desired, the copy is made before being returned to the caller. core/jni/android/graphics/Bitmap.cpp: Include SkStream.h, since it is no longer included by CreateJavaOutputStreamAdaptor's header file. core/jni/android/graphics/BitmapFactory.cpp: Pass an SkStreamRewindable to decoding functions, as Skia decoders will be updated to only take an SkStreamRewindable (which makes more sense because they require rewinding). Call the more specific GetRewindableStream to get a rewindable stream. Remove copyAssetToStream which has been moved to Utils. In nativeDecodeAsset, pass forcePurgeable as allowPurgeable in doDecode. Technically the old code worked, but it checked the BitmapOptions again. Remove getFDSize, which is no longer used. core/jni/android/graphics/BitmapRegionDecoder.cpp: Remove redundant buildSkMemoryStream. nativeNewInstanceFromStream now calls CopyJavaInputStream, which handles the copy. Copy the Asset directly, using common code, rather than creating an AssetStreamAdaptor to copy. core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp: core/jni/android/graphics/CreateJavaOutputStreamAdaptor.h: Provide new interfaces to access data from a Java InputStream. The new interfaces are more specific about what type of stream is desired. Use forward declarations where possible. Remove doSize, which gives a misleading answer to the question of how long the entire stream is. TODO: Only call FindClass etc once. core/jni/android/graphics/Movie.cpp: Check for an asset stream, and use it if possible. Then call GetRewindableStream if there is not an asset. Remove the memory leak. Call DeleteLocalRef to delete the allocated memory. core/jni/android/graphics/Picture.cpp: Call the new interface. core/jni/android/graphics/Utils.cpp: core/jni/android/graphics/Utils.h: Make AssetStreamAdaptor inherit from SkStreamRewindable so it can be passed to Skia decoding functions once they require it. Add CopyAssetToStream (moved from BitmapFactory.cpp) so it can be used by multiple files. graphics/java/android/graphics/BitmapFactory.java: Remove the call to mark, which is now done natively. Remove the BufferedInputStream. Mark/reset is now handled by native code. Allow decodeStream to handle a FileInputStream by using the FileDescriptor, if it is seekable. In decodeFileDescriptor, call nativeDecodeStream instead of decodeStream so this new functionality will not loop. Call setDensityFromOptions in decodeFileDescriptor. graphics/java/android/graphics/BitmapRegionDecoder.java: Remove the BufferedInputStream. Mark/reset is now handled by native code. TODO: ADD TESTS! Requires https://googleplex-android-review.googlesource.com/#/c/344317/ BUG=https://b.corp.google.com/issue?id=8432093 Change-Id: I4419b70b3482325c98ecc673dbfc4613f1b18581
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
8ac41bb79e96e240e0e774ff2dff2654cb10669c |
|
03-May-2011 |
Edward Savage-Jones <edward.savage-jones@sonyericsson.com> |
Corrected typo when checking InputStream methods Corrected a small typo where Java InputStream methods are incorrectly checked when creating a JNI InputStream adaptor. Change-Id: I5f14897e0d5ddceb4b2af6be46769713f0487624
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
dd66bcbf9d6ef0c50a18d9c4b1b39ce7ef7afcc4 |
|
12-Apr-2011 |
Elliott Hughes <enh@google.com> |
More native code cleanup. Don't keep unused global references to classes, don't throw exceptions when an exception is already pending, and fix a (harmless) misunderstanding about how GetStringChars works. Change-Id: Ie445036f057daa8a1c76aceb7bad2a84fb81d820
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
f1f48bc7f200f54c76b22d845d8ba8419879b375 |
|
19-Jul-2010 |
Joseph Wen <josephwen@google.com> |
Do JPEG tile-based decoding. Change-Id: I5c1b4ac3c02eb4350ef0ba9a7877b22cfd730cfb
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
8cd48574a755bea86243e9f9eabaee341ecf9c60 |
|
16-Jul-2010 |
Gilles Debunne <debunne@google.com> |
Fixed bug in BitmapFactory.decodeStream Downloading images over a slow connection could result in errors and null images. The JavaInputStreamAdaptor::do_skip method was correctly called in a loop (to handle the EOF case using read()), but the amount that was skipped at each time was not decreased by the amount already skipped. Bug http://code.google.com/p/android/issues/detail?id=6066 Cherry picked from master CL57808 Change-Id: Ie6856898b21ba31de1209e1f995b4ae784c919b9
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
9066cfe9886ac131c34d59ed0e2d287b0e3c0087 |
|
04-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@135843
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
d83a98f4ce9cfa908f5c54bbd70f03eec07e7553 |
|
04-Mar-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //depot/cupcake/@135843
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
d24b8183b93e781080b2c16c487e60d51c12da31 |
|
11-Feb-2009 |
The Android Open Source Project <initial-contribution@android.com> |
auto import from //branches/cupcake/...@130745
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
f013e1afd1e68af5e3b868c26a653bbfb39538f8 |
|
18-Dec-2008 |
The Android Open Source Project <initial-contribution@android.com> |
Code drop from //branches/cupcake/...@124589
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|
54b6cfa9a9e5b861a9930af873580d6dc20f773c |
|
21-Oct-2008 |
The Android Open Source Project <initial-contribution@android.com> |
Initial Contribution
/frameworks/base/core/jni/android/graphics/CreateJavaOutputStreamAdaptor.cpp
|