577 Commits

Author SHA1 Message Date
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
Chris Craik
28a1222baf Avoid ref-ing AndroidPixelRefs that wrap others in globalRef/Unref
bug:10691404

Only ref the wrapped pixel refs, so that they are the single source of
correct refcount, since the wrapping pixel ref can change out from
underneath an SkBitmap.

Change-Id: I253b8737d2afdcc567a26725fa40b1d9ef0e6a92
2013-09-10 18:13:48 -07:00
Igor Murashkin
a86ab640f7 Surface: Change OutOfResourcesException to be a runtime exception
- Deprecates SurfaceTexture.OutOfResourcesException, it wasn't used
- Make all JNI code throw only Surface.OutOfResourcesException
- Get rid of redundant SurfaceControl.OutOfResourcesException

Bug: 10566539
Change-Id: I58126260771b9ccff6a69c672ce7719b9f98138d
2013-09-09 21:53:59 -07:00
Chris Craik
932e59fc2a Merge "Create a pixelref wrapper for reused bitmaps" into klp-dev 2013-09-09 23:00:49 +00:00
Chris Craik
cd0ba71aa9 Create a pixelref wrapper for reused bitmaps
Reused bitmaps may gain a color table when reused, so we wrap a new
AndroidPixelRef that holds the color table around the old.

bug:10608305
Change-Id: I35288edf3158cfda21c500360ad1abdf5654af8d
2013-09-09 14:08:11 -07:00
Leon Scroggins III
d0d7eaf129 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
2013-09-06 18:27:16 -04:00
Derek Sollenberger
2696797939 Revert workaround for Skia bug now that Skia has been fixed.
bug: 7170836
Change-Id: If357767a5f66d539f775bce766e963b3d0df38bf
2013-09-04 10:50:06 -04:00
Leon Scroggins III
c779752508 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
2013-09-03 11:35:00 -04:00
Leon Scroggins III
4b2993123b Merge "Replace stream wrap-function w/ more specific ones" into klp-dev 2013-08-29 17:12:01 +00:00
Leon Scroggins III
ca32021b43 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
2013-08-27 15:28:58 -04:00
Chris Craik
28fe1ee579 Forward compatibility fix
Change-Id: Ib031372d43881a9bb7af1e51fb2c7cf55e03a326
2013-08-27 10:55:44 -07:00
Leon Scroggins III
2cc409ae52 Fix unpremul setting in BitmapRegionDecoder.
requireUnpremultiplied should be the opposite of BitmapOptions.
inPremultiplied, as in BitmapFactory.

Fixes CTS tests.

BUG=10490308

Change-Id: I21b8c057ccdc9b35c69730a7fe8c3b6802ee6dd8
2013-08-26 14:41:58 -04:00