576 Commits

Author SHA1 Message Date
Elliott Hughes
b1ce729fd0 am 9f13a608: am 2ec939ba: am cf4c7bdd: Merge "Fix whitespace issues after casts."
* commit '9f13a608a703d4d12bbfc65472de766ece0037da':
  Fix whitespace issues after casts.
2013-10-18 12:16:53 -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
Mathieu Chartier
75a5038849 Remove dependency on jniGetNonMovableArrayElements.
jniGetNonMovableArrayElements is not compaction safe and is going
to be deleted.

Change-Id: I6daae1e4ac9e01ca593cda522fdbeb774eef1eff
2013-10-18 09:53:45 -07:00
Leon Scroggins III
6034ee95a0 am 25c4e987: am 97b707d5: am 80a058b3: Merge "Do not attempt to decode NULL SkData." into klp-dev
* commit '25c4e98711d29a69db96526e3c72604f7dbb1005':
  Do not attempt to decode  NULL SkData.
2013-10-08 06:41:06 -07: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
28ff40405d am e8200873: am 0d5a719d: am b088c9e0: Merge "reset mShapingPaint\'s SkTypeface before we use it" into klp-dev
* commit 'e8200873598cf872062126b86edd933620f594aa':
  reset mShapingPaint's SkTypeface before we use it
2013-10-04 18:04:57 -07: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
5380709c78 am fad41c8f: am 5db1f5aa: Merge "Fix Java API error where requesting another style for a provided family fails" into klp-dev
* commit 'fad41c8fd1024a8257bdced18dbcbc9cd67e407a':
  Fix Java API error where requesting another style for a provided family fails
2013-09-24 10:22:29 -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
6e1e8b17c5 am c0e1ae01: am facc08c7: Merge "Move PdfDocument to android.graphics.pdf" into klp-dev
* commit 'c0e1ae0176b2ce23ea1b19883507cd920712289a':
  Move PdfDocument to android.graphics.pdf
2013-09-20 11:21:05 -07:00
Leon Scroggins III
29baa03ba5 am 2360ada9: am 57989c0e: Merge "Skip writing zeroes to java allocated memory." into klp-dev
* commit '2360ada939b0abd4a6cca794288ff06701219f19':
  Skip writing zeroes to java allocated memory.
2013-09-20 11:20:22 -07:00
Derek Sollenberger
8fa4e29f16 am 23b7bc1b: am a2c6209f: Merge "Update SkTypeface::CreateFromName to handle NULL if familyName does not match" into klp-dev
* commit '23b7bc1b4409ca5844db5f17992b906aa3e63927':
  Update SkTypeface::CreateFromName to handle NULL if familyName does not match
2013-09-20 09:57:42 -07: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
44f65cb5fd am 2e4e9889: am 3490228e: Merge "Use a native buffer for decoding images." into klp-dev
* commit '2e4e98895b17ef248f5071202a3610ac715eaf0e':
  Use a native buffer for decoding images.
2013-09-18 10:58:27 -07: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
5387aa5029 am 3b8a7a04: am b693ef60: Merge "Do not allocate so much memory on the stack." into klp-dev
* commit '3b8a7a0402fbc2cb34e59a5757b8134c8bdadedc':
  Do not allocate so much memory on the stack.
2013-09-16 10:45:01 -07: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
33069f40e5 am 47869404: am 2cad64c0: Merge "Surface: Change OutOfResourcesException to be a runtime exception" into klp-dev
* commit '47869404cb8233c536a0a5d2c5ce4d0089e39882':
  Surface: Change OutOfResourcesException to be a runtime exception
2013-09-11 17:22:40 -07: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
27569f2447 am a180fd6d: am 68fbe16b: Merge "Avoid ref-ing AndroidPixelRefs that wrap others in globalRef/Unref" into klp-dev
* commit 'a180fd6d67819a45bafc052581d43c0ecc1faccf':
  Avoid ref-ing AndroidPixelRefs that wrap others in globalRef/Unref
2013-09-11 10:45:28 -07: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
ce526bde4c am 47e6c4be: am 932e59fc: Merge "Create a pixelref wrapper for reused bitmaps" into klp-dev
* commit '47e6c4be1e1ef0f377aed7be773a070f3bfa4a13':
  Create a pixelref wrapper for reused bitmaps
2013-09-09 16:06:16 -07:00
Chris Craik
932e59fc2a Merge "Create a pixelref wrapper for reused bitmaps" into klp-dev 2013-09-09 23:00:49 +00:00
Leon Scroggins III
fe3b9727ba am a818f0fa: am 91c8111d: Merge "Register jni objs in CreateJavaOutputStreamAdaptor" into klp-dev
* commit 'a818f0face6eeee24795c80f8c3b66169e75ffba':
  Register jni objs in CreateJavaOutputStreamAdaptor
2013-09-09 14:14:49 -07: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
ed59cbb2d8 am 22f36b1a: am 4c92f7ce: Merge "Revert workaround for Skia bug now that Skia has been fixed." into klp-dev
* commit '22f36b1a8d9b6b4ecb27e3e35a79579fd9e9cff8':
  Revert workaround for Skia bug now that Skia has been fixed.
2013-09-04 10:40:09 -07: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
9f5da6ff42 am 050129b4: am 3f8da091: Merge "Change name back to CreateJavaInputStreamAdaptor." into klp-dev
* commit '050129b44ada6c105c317092056803b2a60cef74':
  Change name back to CreateJavaInputStreamAdaptor.
2013-09-03 10:53:21 -07: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
f7142e3e8b am af172519: am 4b299312: Merge "Replace stream wrap-function w/ more specific ones" into klp-dev
* commit 'af1725190fbb8dd7c29726f8b7c072f3af734aed':
  Replace stream wrap-function w/ more specific ones
2013-08-29 10:24:21 -07: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
Mike Klein
f5b43bdc62 SkTScopedPtr -> SkAutoTDelete in Android
Change-Id: I8f0312f34e112d302b05852c31308a43967e7a3f
2013-08-29 11:15:06 -04: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
c6ad1f4384 am 8f564fbe: am 3871fdb9: Merge "Fix unpremul setting in BitmapRegionDecoder." into klp-dev
* commit '8f564fbef3f8d1916662ededb33cb541802953d0':
  Fix unpremul setting in BitmapRegionDecoder.
2013-08-26 15:11:53 -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
Chris Craik
ed2515e853 am 908d9bfa: am dc70afae: Merge "Add inPremutiplied option to BitmapFactory.Options, functionality in Bitmap" into klp-dev
* commit '908d9bfafd576755d06f0566fc4cac3831476f63':
  Add inPremutiplied option to BitmapFactory.Options, functionality in Bitmap
2013-08-21 10:26:23 -07:00
Chris Craik
1abf5d6242 Add inPremutiplied option to BitmapFactory.Options, functionality in Bitmap
bug:2248948

Change-Id: I8fdd649332667598504a1076d5a447572bd53086
2013-08-20 18:29:33 -07:00
Romain Guy
13656743cc Make color filters mutable
Change-Id: I3d035d24a75e09db13d136a22bd7dbd326d0ce36
2013-08-19 18:18:00 -07:00