1325 Commits

Author SHA1 Message Date
Victoria Lease
a4eb894a55 Merge "clarify Paint flag docs" into klp-dev 2013-09-26 21:40:55 +00:00
Victoria Lease
8dc7d5ea26 clarify Paint flag docs
Bug: 10460797
Change-Id: Iae622b302cad3dc788f512b472e3a59ec227a8d7
2013-09-26 13:40:47 -07:00
Leon Scroggins III
321bc46b3c Update docs to state that mark is no longer called.
BUG:6493544

Change-Id: I97a4d90ce2efcd12f8f1cc5b545f822f8e5a5ab0
2013-09-25 18:02:32 -04: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
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
Igor Murashkin
2cad64c0fb Merge "Surface: Change OutOfResourcesException to be a runtime exception" into klp-dev 2013-09-11 18:28:07 +00:00
John Reck
1d2daa7809 Merge "Remove FD optimization case for decodeStream" into klp-dev 2013-09-10 16:25:14 +00:00
Stephen Hines
e3d0f02282 Merge "Don't set Allocation mSize when we have no Type." into klp-dev 2013-09-10 05:23:15 +00: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
Stephen Hines
88990da58d Don't set Allocation mSize when we have no Type.
Bug: 10667740

A3D creates Allocations before knowing the underlying Type (and thus size).
Moving the mSize calculation to be conditional for concrete Allocations
eliminates the bug. In the future, we could let A3D dynamically update the
Allocation size if it is necessary to improve heap behavior.

Change-Id: I520246806b6ead0387a1a41372dade1a6e7c2271
2013-09-09 17:56:07 -07:00
John Reck
5835157d76 Remove FD optimization case for decodeStream
Bug: 10677727
 The problem is that the FileInputStream may be wrapping a pipe or
 AssetFileDescriptor which fails if handed to decodeFileDescriptor.
 The problem is that AFDs can start in the middle of a file, whereas
 decodeFileDescriptor assumes it can mmap() the FD and start at
 the beginning.

Change-Id: I98a3c5f789865145e25a99b32d205e290808c1cf
2013-09-09 23:41:20 +00:00
Andy McFadden
440f4dfac8 Merge "Fix pixel test" into klp-dev 2013-09-09 22:55:35 +00:00
Andy McFadden
5d2cace4c5 Fix pixel test
A deprecated format was dropped entirely.

Bug 10666734

Change-Id: I6b64bd27db8965a1696d72387232b7de4bce6574
2013-09-09 10:19:44 -07:00
Chris Craik
352919efd0 Update doc for BitmapFactory.Options to include BitmapRegionDecoder
bug:9987022
Change-Id: I1a4e187e1c35a7758b70f69a0a25914597920e8f
2013-09-06 18:52:22 -07:00
Chet Haase
e8222dddaf Change build version from KEY_LIME_PIE to KITKAT
Issue #10631619 Change build version to KitKat

Change-Id: I6ad13f6169ad74204078d36929479998b498ad8b
2013-09-05 08:44:33 -07:00
Tim Murray
d2676f9bd9 Merge "Add YUV element convenience function." into klp-dev 2013-09-05 07:36:43 +00:00
Tim Murray
932e78e990 Add YUV element convenience function.
Change-Id: Ie67dfba6a4c4f1913875ad9817c53e45d56809ae
2013-09-04 16:15:45 -07:00
Romain Guy
e182bfd4dc Merge "Prevent NPE when cloning gradients Bug #10436856" into klp-dev 2013-09-03 23:32:33 +00:00
Romain Guy
9622adf6e8 Prevent NPE when cloning gradients
Bug #10436856

Change-Id: I98cbce941a06842112b8caa3753a3fa32b227da9
2013-09-03 16:08:00 -07:00
Romain Guy
3e8105e212 Merge "Update Bitmap.Config.ARGB_4444 documentation Bug #10510122" into klp-dev 2013-09-03 21:41:39 +00:00
Romain Guy
25ba1c8694 Update Bitmap.Config.ARGB_4444 documentation
Bug #10510122

ARGB_4444 is deprecated and always replaced with ARGB_8888.

Change-Id: I0da96216af701a7df00ad35913066fbfa997d790
2013-09-03 11:50:23 -07:00
Jason Sams
a49e89d228 Cleanup API typo
bug 10548782

Change-Id: I3654b7d1f8ea10eb51006804248cc2a7d20eabb0
2013-08-29 17:00:37 -07:00
Jason Sams
6b11598048 Merge "Unhide USAGE_IO_INPUT functions" into klp-dev 2013-08-29 21:24:28 +00:00
Jason Sams
42ef238208 Unhide USAGE_IO_INPUT functions
Change-Id: I9c1a7e5d65adee133b99b9a94729ab0b3d5a097f
2013-08-29 13:30:59 -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
Alan Viverette
4d971c1fa0 Set alpha channel correctly when recomputing gradient
The alpha channel is applied by modulateAlpha(). Setting it to
mAlpha in ensureValidRect() locked the maximum alpha channel to
whatever value was set before layout. Setting it to BLACK
ensures it can be modulated later.

BUG: 10514848
Change-Id: If7a824410a66f1e9b648e20ee627bdf99a42ae78
2013-08-28 10:24:12 -07: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
Tim Murray
c264e04400 Merge "Add garbage collection hooks" into klp-dev 2013-08-23 23:40:48 +00:00
Tim Murray
2f2472c42b Add garbage collection hooks
bug 10428172

Change-Id: I6365aa58bbc99aa134e1f261a5819e07a7d70fb0
2013-08-23 13:35:19 -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
Eino-Ville Talvala
9fac8a6a4a Merge "Renderscript: Allow YUV_420_888 as a YUV type." into klp-dev 2013-08-21 00:36:45 +00:00
Eino-Ville Talvala
ccadaf1eb4 Renderscript: Allow YUV_420_888 as a YUV type.
Change-Id: I1ed731103a49a814f9a049ecd01be98261b6d06b
2013-08-14 10:40:30 -07:00
Mike Klein
be925721a5 Remove comment that's only relevant for the underlying SkMatrix. Matrix has constructors.
bug: 8470620

Change-Id: I00063dc03f752955c27c73e9c59b0496a1795924
2013-08-14 13:13:51 -04:00
Romain Guy
7fbbc3c9c3 Camera.applyToCanvas() now works with hardware canvases
Change-Id: I7f06b2a74ccc1941d51e12a0417028e094c1b669
2013-08-13 10:37:25 -07:00
Romain Guy
790552b240 Update Bitmap.createBitmap() documentation
Change-Id: Ic2efed6cc03c8b2c2d9810b7ab645b0b98b91e1f
2013-08-12 11:10:27 -07:00
Fabrice Di Meglio
5af4edef08 Merge "Fix bug #10205316 CTS (KLP): android.graphics tests are failing" into klp-dev 2013-08-09 18:11:33 +00:00
Romain Guy
003123004f Remove an unnecessary allocation
Also remove dead code from OpenGLRenderer.cpp

Change-Id: I7eb54ca19e77ee3c32f1fe9513a031e6b2e115cf
(cherry picked from commit 5c7d5ab878b26f855175a3305a14ac12fcacf25e)
2013-08-09 03:52:29 +00:00
Fabrice Di Meglio
41207bce2a Fix bug #10205316 CTS (KLP): android.graphics tests are failing
- fix null Shader case during copy

Related to https://googleplex-android-review.googlesource.com/#/c/336815/7

Change-Id: I920d6bb181ddb92d6f771e5060fd1858430e71ad
2013-08-08 19:11:34 -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
Elliott Hughes
f2ce9f994a am eab8e18d: am 8a736129: Merge "If graphics wants ASCII lowercasing, it needs to ask for it."
* commit 'eab8e18d8f6f34a9d35fbb120148956789ad48a2':
  If graphics wants ASCII lowercasing, it needs to ask for it.
2013-08-05 11:10:06 -07:00
Elliott Hughes
eab8e18d8f am 8a736129: Merge "If graphics wants ASCII lowercasing, it needs to ask for it."
* commit '8a736129faa9e41b5f33c42bbeae1f68cb42d38f':
  If graphics wants ASCII lowercasing, it needs to ask for it.
2013-08-05 11:07:13 -07:00
Igor Murashkin
b7645acfd9 Merge "graphics: Update ImageFormat#YUV_420_888 javadoc" 2013-08-02 23:43:54 +00:00
Igor Murashkin
7a600ff65f graphics: Update ImageFormat#YUV_420_888 javadoc
* Make it clear that the Y-plane is not interleaved for YUV_420_888
* Make it clear that the U/V plane have the same stride
* Make it clear what the order of Y/U/V planes is

Change-Id: Id85d7c68e84382149dbf0e8b4e965ba2988326fe
2013-08-02 16:39:03 -07:00
Elliott Hughes
aeb60fb86f If graphics wants ASCII lowercasing, it needs to ask for it.
http://elliotth.blogspot.com/2012/01/beware-convenience-methods.html

Bug: https://code.google.com/p/android/issues/detail?id=58359
Change-Id: I13c106985302335dbb15bb9176d35ec6b4546d4e
2013-08-02 09:31:11 -07:00
Fabrice Di Meglio
3f5a90b2fb Add automatic Drawable mirroring capability when in RTL layout direction
- default value is "no mirroring"
- introduce android:autoMirrored as a new attribute for Drawable,
BitmapDrawable, LayerDrawable, StateListDrawable and NinePatchDrawable
- setting android:autoMirrored="true" means that the drawable will
be mirrored when the layout direction is RTL (right-to-left)
- also fix an issue with ImageView drawable layout direction not
updated correctly when RTL properties were changed

See bug #7034321 Need Drawable RTL support

Change-Id: If595ee5106c786f38e786d3a032e182f784a9d97
2013-08-01 15:15:10 -07:00
Fabrice Di Meglio
851761574a Merge "Fix Paint Shader copy" 2013-08-01 21:50:14 +00:00
Fabrice Di Meglio
e3c526f4f6 Fix Paint Shader copy
- Paint.setClassVariablesFrom(Paint paint) was using the same Shader
for the copy as the initial Paint. Make sure that we are using a copy.
- implement a copy() API for shaders

See bug #7034321 Need Drawable RTL support

Change-Id: I4b9cee386edc72ad670723266333b85f4d2b0ab8
2013-08-01 14:33:22 -07:00
Romain Guy
5d3dff1d66 Merge "Add missing alpha channel to built-in colors" 2013-08-01 16:46:04 +00:00
Romain Guy
86d3e03d38 Add missing alpha channel to built-in colors
Change-Id: I911c17b623513b2715668d0f91604b28c32a969a
2013-08-01 09:43:26 -07:00