559 Commits

Author SHA1 Message Date
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
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
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
Romain Guy
3ed72781a0 Convert 4444 bitmaps to 8888
Bug #10206452

Change-Id: I928c9189b0d80741490b01a739959d8c2d5312a7
(cherry picked from commit a2cdb59b186d0ee51f110c1a7d358911573d48bf)
2013-08-15 19:56:05 +00:00
Mathias Agopian
5893a97cbf Merge "fix-up dependencies to gl headers" into klp-dev 2013-08-09 04:39:55 +00:00
Mathias Agopian
e3eae73abb fix-up dependencies to gl headers
Change-Id: I9f176847587db1f9ccee2bc425106d277ffceee6
2013-08-08 21:09:16 -07:00
Jonathan Dixon
667fe1039f Refactor Canvas.drawPicture() to delegate to Picture
Bug: 9814370

To allow WebView.capturePicture() to return a subclass, we need to
ensure the subclass is always consulted when being drawn into a canvas.

Change-Id: Ia0357f95b6fafb3ac81e6bcfaef05739e619897a
2013-08-08 17:22:48 -07:00
Mathias Agopian
52a9a10b6b Clearly separate consumer and producer interfaces
Bug: 9265647
Change-Id: Ic68e91788d0a05251e1d2fb9f9d4de403c7099bf
2013-08-06 13:07:42 -07:00
Derek Sollenberger
5827cb5059 Changes needed to support Skia at r10377.
Change-Id: Id1e1c8c5938ee1a33c6fa3caabd2c28e89243eb4
2013-08-01 12:52:21 -04:00
Romain Guy
8018c8db82 Add path ops API
Path ops can be used to combine two paths instances in a single path
object. The following operations can be used:

- Difference
- Reverse difference
- Union
- XOR
- Intersection

To use the API:

Path p1 = createCircle();
Path p2 = createRect();

Path result = new Path();
result.op(p1, p2, Path.Op.DIFFERENCE);

This code will subtract the rectangle from the circle and generate
the resulting path in "result."

Change-Id: Ic25244665b6691a7df0b0002a09da73d937b553b
2013-07-30 10:51:24 -07:00
Mathias Agopian
e591b49de0 single buffer mode for SurfaceTexture
Bug: 9891035
Change-Id: Ib9cc2b64f7ff3c084ef1d7db442db8e7a24a923d
2013-07-26 19:33:54 -07:00
Alex Ray
aff14e7008 libandroid_runtime: android_print needs NELEM def
NELEM is defined many places in the framework, so this gives
android_print_PdfDocument.cpp one of them (JNIHelp.h).  Without this
updating an upstream library (libskia) to remove an NELEM definition
causes this file to break.

Change-Id: Ifd033f9bd92b8902b6035ec5a8381cb9debd87ce
2013-07-25 14:35:27 -07:00
Mathias Agopian
d84feebba4 Merge "update to new Consumer APIs" 2013-07-20 01:03:22 +00:00
Chris Craik
ef5498edf6 Merge "Add reconfigure method to Bitmap" 2013-07-18 22:55:44 +00:00
Chris Craik
c84d203da2 Add reconfigure method to Bitmap
bug:9797004

Grants a means to reuse a bitmap's allocation for different
width/height/Config without going through
BitmapFactoryOptions.inBitmap

Change-Id: Ib62319f3bd96c451fc1636288adf06a8275b4e3d
2013-07-17 12:08:01 -07:00
Mathias Agopian
e32632682c update to new Consumer APIs
Change-Id: I8649f3add40e0aeeeb0396b98e2cb93312e8e990
2013-07-16 23:14:24 -07:00
Mathias Agopian
377d7bd543 Merge "always pass the BufferQueue explicitely to consumers" 2013-07-16 02:17:56 +00:00
Chris Craik
d63ee75652 Merge "Add webp to BitmapFactory.Options outMimetype" 2013-07-15 19:29:10 +00:00
Mathias Agopian
b550929b7a always pass the BufferQueue explicitely to consumers
Change-Id: I32e380979a3f4c6b1dfb440cc5b5c3d30d7607db
2013-07-12 22:06:31 -07:00
Chris Craik
95587f9045 Add webp to BitmapFactory.Options outMimetype
Change-Id: Id0d5b4d6c2c5b21fa0b31f1a5ada6275fdc38f44
2013-07-12 19:46:19 -07:00