588 Commits

Author SHA1 Message Date
Narayan Kamath
5a7468f598 DO NOT MERGE Fix several bad function definitions.
We claim these functions want jlong as input (8 bytes wide)
but the definitions use pointer types or jints
(4 bytes wide for 32 bit).

bug: 12890271

(cherry picked from 047b938f7188c21c07669108c5c68b2358f6b158)

Change-Id: I6ce506131780d7cdeb05df9a7b8322f5494eeab2
2014-04-04 15:01:06 -07:00
Victoria Lease
ca58036dd8 am cfd46dc4: am 610d401c: am e9c7fd2f: am 55371beb: am 754bf6ab: am c8868db2: am 737d3e5d: am 6b96ecca: am 32753f4f: am 31912122: am 6eb28103: am 183f97b7: am 1c12f9e7: malloc some advances
* commit 'cfd46dc4847d5ef1ed14484717cf857ae5f67cae':
  malloc some advances
2014-03-19 22:36:38 +00:00
Victoria Lease
610d401cb5 am e9c7fd2f: am 55371beb: am 754bf6ab: am c8868db2: am 737d3e5d: am 6b96ecca: am 32753f4f: am 31912122: am 6eb28103: am 183f97b7: am 1c12f9e7: malloc some advances
* commit 'e9c7fd2f2ee7840c61dc66ead3737e437f4e8c10':
  malloc some advances
2014-03-19 22:27:06 +00:00
Victoria Lease
754bf6abc0 am c8868db2: am 737d3e5d: am 6b96ecca: am 32753f4f: am 31912122: am 6eb28103: am 183f97b7: am 1c12f9e7: malloc some advances
* commit 'c8868db2a025a97e439f8a9adde565c9c83f2204':
  malloc some advances
2014-03-19 15:08:32 -07:00
Victoria Lease
6eb2810318 am 183f97b7: am 1c12f9e7: malloc some advances
* commit '183f97b72faf7a0f45ad66e1b3fd9a4343cc7482':
  malloc some advances
2014-03-19 14:32:15 -07:00
Victoria Lease
183f97b72f am 1c12f9e7: malloc some advances
* commit '1c12f9e76298c757423155ad812890d27effafe8':
  malloc some advances
2014-03-19 14:27:19 -07:00
Victoria Lease
1c12f9e762 malloc some advances
Bug: 13506939
Change-Id: I87ad616960c4f16bc55d8b906049dbd4f001d6a5
(cherry picked from commit 3af2a37e057b31617b8f4eeb22ac3ef85c3fd5aa)
2014-03-18 16:22:20 +00:00
Leon Scroggins III
2fd045c092 DO NOT MERGE - merge nativeDecodeFileDescriptor fixes into KLP-MR2
BUG:13191516

Original CLs below:

In nativeDecodeFileDescriptor, use fdopen.

Instead of attempting to mmap the entire file, create an
SkFILEStream from a FILE.

BUG:11669944
BUG:11028218
Cherry-pick from: If67da91484acc79f9f3dde6d05201409c0c75e41

-------------------------------------------------------------------------

Decode file descriptor from the correct offset.

Fix a few bugs in nativeDecodeFileDescriptor:
1. Restore the FD's offset when exiting the function.
2. Copy the data when potentially using an SkImageRef.
   The old behavior would have continued to modify the
   file descriptor's offset each time a new decode was
   required. The copy ensures that the file descriptor
   remains unchanged.
3. Buffer the file stream.
   Prior to this change, if the image was not a PNG,
   the stream would be rewound to the beginning of the
   file, even if the file descriptor was passed in with
   an offset. Thanks to the buffer, the stream is only
   rewound to the original offset.

Depends on https://googleplex-android-review.googlesource.com/#/c/415821/1
in external/skia

BUG:12807677
BUG:12895876
Cherry-pick from: I38b8cf5d210dbbc0107e6562e3884867de57fc4b
2014-03-17 14:18:53 +00:00
Leon Scroggins III
f8d8777ddd Update framework to use M33 Skia. DO NOT MERGE
(These CLs are already in master.)

Bug: 13246311

This cherry-picks 7 CLs:

-----------------------------------------------------------------------

Remove calls to deprecated SkBitmap::setIsOpaque()

setIsOpaque() has been removed from ToT Skia.

Update setters for mIsPremultiplied and hasAlpha to take the
other into consideration.

cherry-pick from: I1b36b0b0ce7126031eb7b769b563c17dcd4b306a

-----------------------------------------------------------------------

Merge AssetStream with AssetStreamAdaptor.

Add enums to the constructor for AssetStreamAdaptor to choose the
different behaviors used by the (former) two different classes.

The old clients of AssetStream now get the following features of
AssetStreamAdaptor
- Debugging statements on error.
- The stream is an SkStreamRewindable.
- getLength() returns the correct value, and the old way of getting
  the length (read(NULL, 0)) is no longer implemented, since it is
  no longer used.
- isAtEnd() returns the correct value. ToT Skia makes it pure virtual,
  so some implementation is necessary.

cherry-pick from: I2a5395914e4f53830aaefee396556459083a1c56

-----------------------------------------------------------------------

Deprecate Android-specific SkPaint functions.

The following functions were problematic:
 const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*);
 const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*);
 const void* findImage(const SkGlyph&, const SkMatrix*);

Replacing them with calls through SkGlyphCache solved a nasty crash
bug, so they have all been deprecated.

Bug: 11968757
cherry-pick from: Id746315d41aec5b211b78b172a883c2061130f08

-----------------------------------------------------------------------

pass SkGlyphCache into updateGlyphCache()

Doing so prevents us from double-locking the glyph cache, thereby
effectively locking ourselves out of reusing work that we'd just done.

Bug: 11968757
cherry-pick from: I5c552f2d0bbe30af2ce9054ba684e7da756a0d89

-----------------------------------------------------------------------

Updates to the Skia API needed to merge the WebView m33 version of Skia.

cherry-pick from: I0f63b53f2aae58871413b132742fc84138f069a3

Bugfix for screenshots (recent apps) due to incorrect rowBytes computation

bug: 12915192
cherry-pick from: I4d5fe2a2f75baf66099e0970fb646686a1992714

-----------------------------------------------------------------------

Fix bug in AndroidPixelRef where we did not store the correct imageInfo for a recycled bitmap.

cherry-pick from: I882483b78886e2f19fa4e43a86e69f5a82b3b7e5

-----------------------------------------------------------------------

Change-Id: Ie2b731a9f0795802418cfecddb4b684c92c64d33

Conflicts:
	core/jni/android/graphics/Bitmap.cpp
	core/jni/android/graphics/Graphics.cpp
	core/jni/android/graphics/Typeface.cpp
	graphics/java/android/graphics/Bitmap.java
2014-03-17 13:57:18 +00:00
Leon Scroggins III
278250dafb DO NOT MERGE - merge nativeDecodeFileDescriptor fixes into KLP-MR2
BUG:13191516

Original CLs below:

In nativeDecodeFileDescriptor, use fdopen.

Instead of attempting to mmap the entire file, create an
SkFILEStream from a FILE.

BUG:11669944
BUG:11028218
Cherry-pick from: If67da91484acc79f9f3dde6d05201409c0c75e41

-------------------------------------------------------------------------

Decode file descriptor from the correct offset.

Fix a few bugs in nativeDecodeFileDescriptor:
1. Restore the FD's offset when exiting the function.
2. Copy the data when potentially using an SkImageRef.
   The old behavior would have continued to modify the
   file descriptor's offset each time a new decode was
   required. The copy ensures that the file descriptor
   remains unchanged.
3. Buffer the file stream.
   Prior to this change, if the image was not a PNG,
   the stream would be rewound to the beginning of the
   file, even if the file descriptor was passed in with
   an offset. Thanks to the buffer, the stream is only
   rewound to the original offset.

Depends on https://googleplex-android-review.googlesource.com/#/c/415821/1
in external/skia

BUG:12807677
BUG:12895876
Cherry-pick from: I38b8cf5d210dbbc0107e6562e3884867de57fc4b
2014-03-07 11:28:44 -05:00
Leon Scroggins III
5e49b497ae Update framework to use M33 Skia. DO NOT MERGE
(These CLs are already in master.)

Bug: 13246311

This cherry-picks 7 CLs:

-----------------------------------------------------------------------

Remove calls to deprecated SkBitmap::setIsOpaque()

setIsOpaque() has been removed from ToT Skia.

Update setters for mIsPremultiplied and hasAlpha to take the
other into consideration.

cherry-pick from: I1b36b0b0ce7126031eb7b769b563c17dcd4b306a

-----------------------------------------------------------------------

Merge AssetStream with AssetStreamAdaptor.

Add enums to the constructor for AssetStreamAdaptor to choose the
different behaviors used by the (former) two different classes.

The old clients of AssetStream now get the following features of
AssetStreamAdaptor
- Debugging statements on error.
- The stream is an SkStreamRewindable.
- getLength() returns the correct value, and the old way of getting
  the length (read(NULL, 0)) is no longer implemented, since it is
  no longer used.
- isAtEnd() returns the correct value. ToT Skia makes it pure virtual,
  so some implementation is necessary.

cherry-pick from: I2a5395914e4f53830aaefee396556459083a1c56

-----------------------------------------------------------------------

Deprecate Android-specific SkPaint functions.

The following functions were problematic:
 const SkGlyph& getUnicharMetrics(SkUnichar, const SkMatrix*);
 const SkGlyph& getGlyphMetrics(uint16_t, const SkMatrix*);
 const void* findImage(const SkGlyph&, const SkMatrix*);

Replacing them with calls through SkGlyphCache solved a nasty crash
bug, so they have all been deprecated.

Bug: 11968757
cherry-pick from: Id746315d41aec5b211b78b172a883c2061130f08

-----------------------------------------------------------------------

pass SkGlyphCache into updateGlyphCache()

Doing so prevents us from double-locking the glyph cache, thereby
effectively locking ourselves out of reusing work that we'd just done.

Bug: 11968757
cherry-pick from: I5c552f2d0bbe30af2ce9054ba684e7da756a0d89

-----------------------------------------------------------------------

Updates to the Skia API needed to merge the WebView m33 version of Skia.

cherry-pick from: I0f63b53f2aae58871413b132742fc84138f069a3

Bugfix for screenshots (recent apps) due to incorrect rowBytes computation

bug: 12915192
cherry-pick from: I4d5fe2a2f75baf66099e0970fb646686a1992714

-----------------------------------------------------------------------

Fix bug in AndroidPixelRef where we did not store the correct imageInfo for a recycled bitmap.

cherry-pick from: I882483b78886e2f19fa4e43a86e69f5a82b3b7e5

-----------------------------------------------------------------------

Change-Id: Ie2b731a9f0795802418cfecddb4b684c92c64d33
2014-03-06 12:14:47 -05:00
Narayan Kamath
d4ccffd3ba Merge "AArch64: Use long for pointers in graphics/Interpolator" 2014-01-29 12:12:27 +00:00
Narayan Kamath
887b1ca879 Merge "AArch64: Use long for pointers in SurfaceTexture" 2014-01-29 12:12:17 +00:00
Ashok Bhat
5753b45516 AArch64: Use long for pointers in graphics/Camera
For storing pointers, long is used in
android/graphics/Camera class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use of
jint instead of int in JNI function prototypes)

Change-Id: Ic05ebf2051a225a1638a43f476bab6176c0b5c38
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-28 17:53:30 +00:00
Ashok Bhat
a0398430fc AArch64: Make graphics classes 64-bit compatible
Changes in this patch include

[x] Long is used to store native pointers as they can
    be 64-bit.

[x] Some minor changes have been done to conform with
    standard JNI practice (e.g. use of jint instead of int
    in JNI function prototypes)

[x] AssetAtlasManager is not completely 64-bit compatible
    yet. Specifically mAtlasMap member has to be converted
    to hold native pointer using long. Added a TODO to
    AssetAtlasManager.java to indicate the change required.

Change-Id: I940433f601c6db998c1a8ffff338f5361200d5ed
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Craig Barber <craig.barber@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-28 17:40:38 +00:00
Mathieu Chartier
768480c245 Fix dest == src bugs in Matrix.cpp.
The main bug was that the AutoJavaFloatArray autoSrc was not passing in
read only. This meant that the destructor overwrote the data which
the autoDst AutoJavaFloatArray had written in it's destructor.
This case only happened if src == dest and the arrays were copies.
Also improved performance by passing in read only a few other places.

Bug: 12570144

Change-Id: Idc8764087dc165433c584b87a0f9d4ed0ec795e8
2014-01-25 17:54:22 -08:00
Ashok Bhat
a2f9042f4e AArch64: Use long for pointers in graphics/Interpolator
For storing pointers, long is used in
android/graphics/Interpolator class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I1e181476a4fe5273ff190cf34c4a7487aa1aecf4
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-01-16 13:23:53 +00:00
Ashok Bhat
72aa313ff4 AArch64: Use long for pointers in SurfaceTexture
Long is used in SurfaceTexture class to store
pointers as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I771aa62c42bc865e644c63fd48f309782dd03e73
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Kévin PETIT <kevin.petit@arm.com>
2014-01-16 12:55:13 +00:00
Narayan Kamath
98002dfb60 Merge "AArch64: Use long for pointers in graphics/PathMeasure" 2014-01-16 12:12:11 +00:00
Narayan Kamath
1b0f0be097 Merge "Make YuvToJpegEncoder more JNI compliant" 2014-01-16 12:12:01 +00:00
Ashok Bhat
b091d47a2e AArch64: Use long for pointers in BitmapRegionDecoder
For storing pointers, long is used in BitmapRegionDecoder
class, as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

In addition, Graphics.cpp has been changed to work
with modified BitmapRegionDecoder.

Change-Id: Id54087dd3bfb29577e8b762e70946793369dc701
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-15 14:23:22 +00:00
Ashok Bhat
dcaf5593dd AArch64: Use long for pointers in Movie class
For storing pointers, long is used in Movie class,
as native pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I946325e4af6cb9282012bebdaee89e1117d8797b
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-15 14:22:56 +00:00
Ashok Bhat
39029b2990 Make YuvToJpegEncoder more JNI compliant
Minor changes have been done to conform with standard
JNI practice (e.g. use of jint instead of int in JNI
function prototypes)

Change-Id: I4015138921cc18ecae52daaa6710b3c9efd68e87
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-13 15:14:05 +00:00
Ashok Bhat
0c10cc6052 AArch64: Use long for pointers in graphics/PathMeasure
For storing pointers, long is used in
android/graphics/PathMeasure class, as native
pointers can be 64-bit.

In addition, some minor changes have been done
to conform with standard JNI practice (e.g. use
of jint instead of int in JNI function prototypes)

Change-Id: I4599a9d5f7dcf9c39838db96d9033059114d3a49
Signed-off-by: Ashok Bhat <ashok.bhat@arm.com>
Signed-off-by: Marcus Oakland <marcus.oakland@arm.com>
2014-01-13 14:50:50 +00:00
The Android Open Source Project
ebcb32f58a Merge commit 'bac61807d3bcfff957b358cb9ad77850bd373689' into HEAD
Change-Id: I29374270c8e0c2f2859efaf1d55af9f73da0f8d7
2013-12-05 13:10:46 -08:00
Mathieu Chartier
a1a19d28d0 Use exceptionCheck after VMRuntime.newNonMovableArray/addressOf.
Since VMRuntime.newNonMovableArray and VMRuntime.addressOf are java
methods implemented in Native, they don't necessarily return NULL
when an exception is thrown. Checking the exception instead of the
return value fixes errors which may occur if the runtime returns
garbage when an exception is pending.

Bug: 11971220
Change-Id: I70478834c9f14cc5d9e666e1e174d3fd09269719
2013-12-04 17:58:37 -08:00
The Android Open Source Project
dbccd44a63 Merge commit 'b873a17ce7be0a9771c24999adca6964431728f6' into HEAD
Change-Id: I938755073e70602cc8f51ce9bd420fdcf870cecd
2013-11-22 11:18:57 -08:00
Svetoslav
ebd616e88d am 134631b9: am 90242fe5: Merge "Switch to the new Skia PDF generation APIs." into klp-dev
* commit '134631b9078df0b9277fb3b8319bf3b85f690727':
  Switch to the new Skia PDF generation APIs.
2013-11-07 16:25:32 -08:00
Svetoslav
35aacf2eb3 Switch to the new Skia PDF generation APIs.
The new Skia PDF generation APIs are a small extension to
the code that converts drawing commands to PDF (SkPDFDevice)
and this new functionality is exposed via new APIs. This
change switches to using these new APIs allowing us to
capitalize on the new perspective support for PDF
generation.

bug:11561776

Change-Id: Ief61f7ff6a5a22c27d3acbe99a48910cb679f594
2013-11-07 14:15:19 -08:00
Victoria Lease
dd3776d673 am 30a3ef6c: am c89eaf91: Merge "Fix for Typeface.create(Typeface, style) semantics changed in KK" into klp-dev
* commit '30a3ef6c85011ba82a777e6eef7f026323019f35':
  Fix for Typeface.create(Typeface, style) semantics changed in KK
2013-11-06 11:37:15 -08:00
Raph Levien
4f0064fa34 Fix for Typeface.create(Typeface, style) semantics changed in KK
This is a fix for bug 11553661. The "closest match" heuristic for
resolving a typeface when an exact match was not found changed between
JB MR2 and KK, resulting in loss of custom typeface when StyleSpan was
applied. This patch reinstates the logic that had been present. Also
reported externally as:
https://code.google.com/p/android/issues/detail?id=61771

Change-Id: Ia432fca07c4bf3b830ee2487cd8f5267a9cfb7ff
2013-11-06 11:16:01 -08:00
Victoria Lease
ed82a64828 am 54b7e3e8: am a80d6424: Merge "Implement language-specific GSUB processing" into klp-dev
* commit '54b7e3e81c39a5e94fd3dcd67cc4eba0f56351f2':
  Implement language-specific GSUB processing
2013-10-21 09:01:18 -07:00
Elliott Hughes
9f13a608a7 am 2ec939ba: am cf4c7bdd: Merge "Fix whitespace issues after casts."
* commit '2ec939bac6263fefee2605d2b50136955cfcba6d':
  Fix whitespace issues after casts.
2013-10-18 12:11:42 -07:00
Elliott Hughes
f585655b4e am 4a5b3f0a: am ac6e036a: Merge "Remove dependency on jniGetNonMovableArrayElements."
* commit '4a5b3f0ad0b742fbdce154236b15185aaff87ffb':
  Remove dependency on jniGetNonMovableArrayElements.
2013-10-18 12:11:38 -07:00
Mathieu Chartier
6ecb7a9a27 Fix whitespace issues after casts.
Change-Id: Ief3e50fbedd193e22509aac783f16ba1288908de
2013-10-18 11:04:31 -07:00
Mathieu Chartier
7384b428c4 Remove dependency on jniGetNonMovableArrayElements.
jniGetNonMovableArrayElements is not safe and is going to be deleted.

Change-Id: I6daae1e4ac9e01ca593cda522fdbeb774eef1eff
(cherry picked from commit 75a5038849cecf38aba72721272ff07cca09501f)
2013-10-18 10:58:25 -07:00
Raph Levien
677726b376 Implement language-specific GSUB processing
This patch allows HarfBuzz to select language-specific features based
on the language. It is a fix for bug 7004056.

Change-Id: I63f01b9580250728b900f19f357cefdeb9d36c72
2013-10-08 15:47:42 +02:00
Leon Scroggins III
80a058b303 Merge "Do not attempt to decode NULL SkData." into klp-dev 2013-10-08 13:33:05 +00:00
Leon Scroggins III
f65183fd76 Do not attempt to decode NULL SkData.
NewFromFD fails if mmap fails. In that case, it returns a NULL
SkData. SkMemoryStream handles NULL input by calling SkData::NewEmpty,
which is not threadsafe. If the SkMemoryStream were to get some
busted SkData, its call to read might fail. Sidestep this problem
by not creating the SkMemoryStream if the SkData is NULL, skipping
the call to SkData::NewEmpty.

BUG:11028218
Change-Id: Id70299bef1c85ffb5d17102fdb5ea071b0bee68a
2013-10-07 17:30:47 -04:00
Victoria Lease
8450a6ef8b reset mShapingPaint's SkTypeface before we use it
Harfbuzz works in TTF glyph-space, but most of Skia works in
fallback glyph-space. shapeFontRun() helpfully calculates the
baseGlyphCount needed to convert between the two, but leaves
mShapingPaint's SkTypeface set to the specific TTF being shaped
rather than the original SkTypeface that was requested. Needless
to say, this causes all manner of horrific malady when glyph
indices are calculated in one glyph-index-space and then applied
to another.

To fix this issue, I reset mShapingPaint's SkTypeface when done
with the Harfbuzz shaping operation so that the baseGlyphCount only
gets applied once.

Change-Id: Ia886f89d667634e15e5fc8d7af443c9d1ba89622
2013-10-04 17:33:35 -07:00
Derek Sollenberger
fe8e21fd80 Fix Java API error where requesting another style for a provided family fails
Internally the API uses the same code path as SkTypeface::CreateFromName which
returns NULL if the requested style is not supported by the existing family.
However, the existing Java API expects that we return the default font in the
requested style so this CL ensures that we do.

bug: 10860066
Change-Id: Ide3a0cc24015e97fa35aef283b42e7d7d11edd9c
2013-09-23 09:22:56 -04:00
Svetoslav
facc08c775 Merge "Move PdfDocument to android.graphics.pdf" into klp-dev 2013-09-20 01:14:02 +00:00
Svetoslav
6811f4e92c Move PdfDocument to android.graphics.pdf
1. Move PdfDocument to android.graphics.pdf.

2. Changed the PdfDocument as per API concil request.

3. Updated the documentation.

bug:10461180
bug:10552565
bug:10681585
bug:10552336

Change-Id: I08e15b34cf37bb064248c887e6f59808019cafe8
2013-09-19 17:12:47 -07:00
Leon Scroggins III
57989c0e04 Merge "Skip writing zeroes to java allocated memory." into klp-dev 2013-09-19 23:19:13 +00:00
Leon Scroggins III
1ffe727c06 Skip writing zeroes to java allocated memory.
If pixel memory was just allocated by Java, tell our decoders not
to write 0s, since the memory was initialized to 0. Likewise,
when drawing to a bitmap with memory just allocated by Java, do
not erase to 0.

Depends on a change to external/skia to add the new option on
image decoders:
https://googleplex-android-review.git.corp.google.com/362663

BUG:10016979
Change-Id: I9a3dc969870f8516e7d8495fe96d0a6b8225eda2
2013-09-19 16:22:57 -04:00
Derek Sollenberger
89ec829908 Update SkTypeface::CreateFromName to handle NULL if familyName does not match
This is a multi-project change with a dependency on external/skia

bug: 10730965
Change-Id: Ida880a86ebd182a221333bbd85eaa30d047a1618
2013-09-19 08:14:53 -04:00
Leon Scroggins III
7315f1baee 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
2013-09-18 12:01:20 -04:00
Leon Scroggins III
37b82e3232 Do not allocate so much memory on the stack.
Instead, allocate a smaller amount and grow as necessary.

BUG:10697851
Change-Id: Iec57a8a374a4a76a3770e241cf561d58f3c8e1dc
2013-09-12 20:00:46 -04:00
Igor Murashkin
2cad64c0fb Merge "Surface: Change OutOfResourcesException to be a runtime exception" into klp-dev 2013-09-11 18:28:07 +00:00
Chris Craik
68fbe16ba0 Merge "Avoid ref-ing AndroidPixelRefs that wrap others in globalRef/Unref" into klp-dev 2013-09-11 17:40:39 +00:00