Commit Graph

3991 Commits

Author SHA1 Message Date
Leon Scroggins
ceb14e015b Merge changes from topics "DecodeException_ERROR", "AID_autoStart", "onPartialImage" into pi-dev
* changes:
  Rename ImageDecoder.ERRORs
  Add the ability to autoStart AID from xml
  Re-write onPartialImage API
2018-03-22 21:53:05 +00:00
TreeHugger Robot
e7c26531c0 Merge "Disable Bitmap density scaling to Picture" into pi-dev 2018-03-22 21:34:32 +00:00
Leon Scroggins III
cf7294fda6 Rename ImageDecoder.ERRORs
Bug: 73788969
Test: I501e8b76aacd785cb994165ab01dc1b39fea3a1c

Move them into ImageDecoder.DecodeException, which is where they are
actually used. This also provides some more context, so that the prefix
"ERROR_" is no longer necessary, fixing the redundancy/awkwardness in
ERROR_SOURCE_ERROR. Further rename that to SOURCE_MALFORMED_DATA, which
is more descriptive, and does not imply a Java Error.

Change-Id: Ied17ad343650f9c33d9a35b0f9d00ccc22264bd6
2018-03-22 13:09:02 -04:00
Leon Scroggins III
5388f79a45 Disable Bitmap density scaling to Picture
Bug: 76144110
Test: I95165583649a1df86782d3684f7bf9bcd8dab7bd

This matches the behavior of DisplayListCanvas. Not scaling means that
we can draw a Bitmap to a Picture, and then play that back in HW mode
and see the same result.

Change-Id: I7421431bad0531112e06ab5c14814b6b6f1591d9
2018-03-22 12:36:22 -04:00
Leon Scroggins III
1dd88daf92 Add the ability to autoStart AID from xml
Bug: 73529437
Test: Ic818bbf1091d12631aedd6475d225fa4a708b29c
Change-Id: I4807409895a057e775bfee5dea407e8dc1af94be
2018-03-22 09:05:42 -04:00
Leon Scroggins
442522d112 Merge "Report native allocation size of AnimatedImageDrawable" into pi-dev am: d848f75f99
am: 6413aebc02

Change-Id: Id1a101b08f8f9b9b53875bd9c784dea04a5b4110
2018-03-21 17:46:16 +00:00
Mike Reed
322bc57a33 detect api version, and start respecting offsets
Test: make

Bug: 36471624
Change-Id: Ica10c557bf35e8d707fabbafab49d22109916fd3
2018-03-21 17:39:01 +00:00
Leon Scroggins III
1d2bf2b846 Re-write onPartialImage API
Bug: 73788969
Test: If9e27a6ce2604128a619bc4843d62711f94b4d87

Add a new Exception subclass that contains information about the type of
error, and the original Exception, if any. Remove the old
IncompleteException class. If the decode creates a partial image, pass
the information up to Java, where we create the new Exception and pass
it to the callback and/or throw it. Rewrite nDecodeBitmap to always take
the ImageDecoder as a parameter for this callback, and simply use a
boolean to determine whether to call onPostProcess

Check for exceptions in some overlooked cases in native code, and
route to the new type.

Remove FIXME to avoid parsing the whole image. In my limited testing,
it didn't seem to speed anything up, and this should be called in a
background thread anyway. Parsing now also ensures that we've read the
stream when we can have a chance to handle the exception from the right
place.

Remove fixme for b/70626068, which has been marked as WontFix.

Add a TestApi for testing an Exception thrown by an InputStream.

Remove onPartialImage from hiddenapi-light-greylist.txt to fix the build
error this change introduces. onPartialImage was erroneously added to
the list.

Change-Id: I12f69857328e63c993bd669412b06addeb6a74f1
2018-03-21 12:55:46 -04:00
Leon Scroggins
d848f75f99 Merge "Report native allocation size of AnimatedImageDrawable" into pi-dev 2018-03-21 16:48:19 +00:00
Leon Scroggins III
eb3b38e22c Report native allocation size of AnimatedImageDrawable
Bug: 73641604
Test: infeasible

Fix nNativeByteSize's return value to be jlong, instead of long.
Add up the bytes used by the SkAnimatedImage and SkPictures and store
them on the AnimatedImageDrawable for registration.
Note that this is an approximation, and it assumes it will be drawn to a
hardware canvas and animated.
2018-03-21 09:28:00 -04:00
Leon Scroggins
bb00d03e4e Merge "Scale up in ImageDecoder based on API level" into pi-dev am: 83ad4e53b6
am: 27e12ac211

Change-Id: Ie015dd5fe1ebcf66fbb347c9183062c6cd5b1714
2018-03-20 17:51:07 +00:00
Leon Scroggins
83ad4e53b6 Merge "Scale up in ImageDecoder based on API level" into pi-dev 2018-03-20 16:44:44 +00:00
Leon Scroggins
87f7911ce2 Merge "Add an asset source for ImageDecoder" into pi-dev am: 51d2cc45d8
am: c2af8747cb

Change-Id: I91aed3bc526a7de70b522d042225669725754c72
2018-03-20 15:11:04 +00:00
Leon Scroggins
51d2cc45d8 Merge "Add an asset source for ImageDecoder" into pi-dev 2018-03-20 14:33:43 +00:00
Leon Scroggins III
8290eaba47 Scale up in ImageDecoder based on API level
Bug: 74061412
Bug: 73893665
Test: Manual, I5669a97c70d726826c5c00bc1413c2f97d95d88c

ImageDecoder typically does not scale a Bitmap up to handle density.
This saves memory, and we already handle the density by scaling at
draw time. But some apps rely on the size of the Bitmap without taking
density into account. For backwards compatibility, on apps that are
built for a pre-P version of Android, scale up in ImageDecoder.

Change-Id: I9991d1286e386b47fc57bcfbf0c6652beb1a53ef
2018-03-20 10:30:32 -04:00
Leon Scroggins III
2b0e828b63 Merge "Work around incorrect Skia gamma" into pi-dev am: c45c2d65a5
am: 2a23ef3785

Change-Id: I8e70a674fd222070b1782f40b74e5a36b7b141a4
2018-03-20 04:41:20 +00:00
Leon Scroggins
b2c060fc6a Merge "Merge "Add ImageDecoder.Source for resources" into pi-dev am: d65f5ed038" into pi-dev-plus-aosp
am: 84474dbe76

Change-Id: If06c6c2e18a685e949c51a033200c9b044e4007c
2018-03-19 23:37:35 +00:00
TreeHugger Robot
c45c2d65a5 Merge "Work around incorrect Skia gamma" into pi-dev 2018-03-19 22:10:31 +00:00
Leon Scroggins III
121ef98bfb Add an asset source for ImageDecoder
Bug: 74545298
Test: I6a633553bbb5ff26d84aaf5371b8b43a770afd4f

This allows using ImageDecoder to decode a file in the "assets"
directory of an app.

Change-Id: I2193f052cc2e16c55c7f68f7e51e07cd24ee4df9
2018-03-19 13:01:57 -04:00
Leon Scroggins III
1eccac89c1 Add ImageDecoder.Source for resources
Bug: 74545298
Test: Ibc283c2e8aee999e951de51f3a43b581a765aaf5

Although resources can already be accessed with ContentResolver + URI,
this allows a simple method to do the same.

Change-Id: I1bf698f36d5540f6de7cb9957e4223123d0f4331
2018-03-19 13:01:52 -04:00
Seigo Nonaka
a7a62d0b81 Merge "Remove mtOffset from drawTextRun" into pi-dev am: bc20993e4b
am: 17abcf0b76

Change-Id: Ib0dbce1bc5efe12193d0d9770830ed046c08869d
2018-03-15 06:49:49 +00:00
Seigo Nonaka
83143d005b Remove mtOffset from drawTextRun
Bug: 72998298
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: Ia886c1ce9f7387559d7fe00b34ce03378d56ecec
2018-03-15 04:09:19 +00:00
Derek Sollenberger
5054949580 Merge "Document the byte packing order of the current Bitmap.Configs" into pi-dev am: 13cd2c9227
am: ab7295bdb4

Change-Id: I4c83882e257b51a37681135dae7239dbce228eef
2018-03-14 21:00:19 +00:00
TreeHugger Robot
13cd2c9227 Merge "Document the byte packing order of the current Bitmap.Configs" into pi-dev 2018-03-14 20:23:29 +00:00
Derek Sollenberger
186ea1218e Document the byte packing order of the current Bitmap.Configs
This CL documents the byte order for 585, 8888, and fp16 buffers.

Test: documenting existing behavior
Bug: 71518511
Change-Id: I128344db318eb4597b6eb00f0ae317e369145152
2018-03-14 13:29:22 -04:00
TreeHugger Robot
4abaae5ab9 Merge "Fix leading '*' in equations" 2018-03-14 01:26:22 +00:00
Seigo Nonaka
14b2e32af6 Merge "Unhide getWeight of Typeface" into pi-dev am: 1b8333d1fb
am: e039c5f543

Change-Id: Ied7efc7895fe1a38352ea49c21c3cd136716fef2
2018-03-14 01:05:38 +00:00
Seigo Nonaka
a56810409d Merge "Revive old private api for saving supportlib-v27" into pi-dev am: cd9a549e36
am: 9b8e53d4c1

Change-Id: I2d6b91abd94823c8fb5d0fd95a5ae89486dc783e
2018-03-14 00:59:13 +00:00
TreeHugger Robot
1b8333d1fb Merge "Unhide getWeight of Typeface" into pi-dev 2018-03-13 22:24:41 +00:00
Romain Guy
339176353f Fix leading '*' in equations
Test: javadoc only

Change-Id: Ice09fe387aaf36f367e5f37ecc0b13aa1d11a689
2018-03-13 14:13:11 -07:00
Leon Scroggins III
ce89a6e656 Work around incorrect Skia gamma
Bug: 74408046
Test: Ic6acdc4a1a16840ec6ad9b13b4926c643d0f81ae

Skia incorrectly sets the gamma for LINEAR_EXTENDED_SRGB to 0 as a
misguided optimization attempt. As a result, a HARDWARE Bitmap which
natively has this color space does not match it properly. (Note that we
already catch an F16 Bitmap, above.) Add a workaround in
Bitmap.getColorSpace() to check for the color space explicitly.

Change-Id: Id595e365d1c8d572cfcea214d230a8ce1decdc01
2018-03-13 15:39:39 -04:00
Seigo Nonaka
59897ec4ab Revive old private api for saving supportlib-v27
The method signature of the createFromFamiliesWithDefault is changed
for supporting multiple font fallback. The old method is used by
supportlib-v27.

Bug: 73981003
Test: Manually done
Change-Id: I45ee9975b0f15481b60362113b89d4a1bf5a5338
2018-03-13 11:45:43 -07:00
TreeHugger Robot
134b5c7490 Merge "hide serialization methods on Picture" 2018-03-10 00:02:50 +00:00
Mike Reed
99a83d26b1 hide serialization methods on Picture
Test: make

Bug: 14646703
Change-Id: I50bde70c16f7eaf3f31a373e5507a2c34a6eb1e7
2018-03-09 20:42:17 +00:00
Seigo Nonaka
f3523ec524 Unhide getWeight of Typeface
Bug: 64852739
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
Change-Id: Ic360cee7d57b38f3b92ecb68ab6bd46d961c3232
2018-03-09 19:15:13 +00:00
TreeHugger Robot
2b6db8d278 Merge "ImageDecoder: Add getters. Rename setAsAlphaMask" into pi-dev 2018-03-08 21:40:22 +00:00
TreeHugger Robot
7d968346bf Merge "Stop using finalizer in Typeface and FontFamily" into pi-dev 2018-03-08 21:16:47 +00:00
Leon Scroggins III
746a9fee93 ImageDecoder: Add getters. Rename setAsAlphaMask
Bug: 73788928
Test: I1606cbb4e71579160ffaef12c1ed738fad882cd1

This will allow Kotlin developers to treat the setters as properties.

Part of the motivation for the rename is that "getAsAlphaMask" sounds
like it returns an alpha mask itself. Rename both to
_etDecodeAsAlphaMask.

Change-Id: I8f9b04f8381840490b662c3bcd37a95442af8110
2018-03-08 14:22:56 -05:00
TreeHugger Robot
b577d00c35 Merge "Setting the alpha on the full bitmap for AdaptiveIcon instead of individual layers" into pi-dev 2018-03-07 23:58:24 +00:00
Seigo Nonaka
abe5031416 Stop using finalizer in Typeface and FontFamily
Use NativeAllocationRegistry instead.

Verified this doesn't cause performance regressions:

StaticLayout creation time:
 MeasuredText Balanced Hyphenation  :    721,055 ->    723,812: (+0.4%)
 MeasuredText Balanced NoHyphenation:    527,880 ->    505,843: (-4.2%)
 MeasuredText Greedy Hyphenation    :    476,982 ->    460,241: (-3.5%)
 MeasuredText Greedy NoHyphenation  :    471,074 ->    459,013: (-2.6%)
 RandomText Balanced Hyphenation    : 18,566,915 -> 18,514,633: (-0.3%)
 RandomText Balanced NoHyphenation  :  7,697,772 ->  7,658,458: (-0.5%)
 RandomText Greedy Hyphenation      :  7,648,606 ->  7,602,026: (-0.6%)
 RandomText Greedy NoHyphenation    :  7,643,946 ->  7,618,898: (-0.3%)

MeasuredText creation time:
 NoStyled Hyphenation               : 18,377,293 -> 18,521,296: (+0.8%)
 NoStyled Hyphenation WidthOnly     : 17,852,099 -> 17,889,073: (+0.2%)
 NoStyled NoHyphenation             :  7,608,972 ->  7,614,311: (+0.1%)
 NoStyled NoHyphenation WidthOnly   :  7,194,461 ->  7,192,043: (-0.0%)
 Styled Hyphenation                 : 15,396,698 -> 15,352,501: (-0.3%)
 Styled Hyphenation WidthOnly       : 14,356,020 -> 14,379,205: (+0.2%)
 Styled NoHyphenation               : 14,926,657 -> 14,971,723: (+0.3%)
 Styled NoHyphenation WidthOnly     : 13,964,537 -> 13,874,324: (-0.6%)

StaticLayout draw time:
 MeasuredText NoStyled              :    644,795 ->    635,241: (-1.5%)
 MeasuredText NoStyled WithoutCache :    637,943 ->    616,369: (-3.4%)
 MeasuredText Styled                :    866,664 ->    860,322: (-0.7%)
 MeasuredText Styled WithoutCache   :    917,795 ->    897,164: (-2.2%)
 RandomText NoStyled                :    538,196 ->    533,253: (-0.9%)
 RandomText NoStyled WithoutCache   :  7,012,076 ->  7,047,498: (+0.5%)
 RandomText Styled                  :  3,011,941 ->  2,999,661: (-0.4%)
 RandomText Styled WithoutCache     :  3,486,225 ->  3,462,493: (-0.7%)

Bug: 70185027
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases

Change-Id: I7ebb8a219a8eb07c8ad9fa432e8454e4e06be386
2018-03-07 11:46:13 -08:00
Sunny Goyal
32b64217a9 Setting the alpha on the full bitmap for AdaptiveIcon instead of individual layers
Test: atest FrameworksCoreTests:AdaptiveIconDrawableTest
Bug: 72798522
Change-Id: I3862942bf6f2c4767c293f09ad14725b5f0fbb2b
2018-03-07 10:11:56 -08:00
Leon Scroggins III
5e8447f74d Draw AnimatedImageDrawable mirrored if desired
Bug: 73529437
Test: I27af7c3b2e08fa50bc19e08930d970931ce4b5e9

If isAutoMirrored, and the layout direction is RTL, make
AnimatedImageDrawable draw flipped.

Change-Id: I9a3436ef4cb9df2845a67663a2503c2c1a3dba89
2018-03-05 15:06:40 -05:00
Leon Scroggins III
6de55b88f7 AID: Change loop to repeat and set from xml
Bug: 73529437
Test: I60fbee6d3610070413e8c46f363ec3c19c2e7c52

Allow setting AnimatedImageDrawable's loop count in xml. Use
"repeatCount" to match the existing attr used by other objects, and
change the Java api from "loop" to "repeat".

Cache the repeat count in the State object for the situation where we
inflate but are waiting on a theme, so that when we get a src we can
apply the existing repeat count.

Change-Id: Ie723fe9a40c64dd0e1e8fd7b5d5cf81e5c5ccd0d
2018-03-02 16:11:37 -05:00
Leon Scroggins III
c9aa856559 Make OnHeaderDecodedListener NonNull
Bug: 73788928
Test: No change in behavior; no new tests.

There is already an overload for both decodeDrawable and decodeBitmap
that allows not using an OnHeaderDecodedListener, so require calls to
the method that includes a parameter for it to contain a non-null
version.

Throw an exception if OnHeaderDecodedListener is null. Move
implementation to Impl methods to share code without lint warnings.
Rename the non-static decodeBitmap to decodeBitmapInternal, to
distinguish it from the others.

Change-Id: I12c0a35786d8d1267044ac09b5c9203cdfb7175a
2018-03-02 16:11:36 -05:00
Doris Liu
fd81bcf7ce Merge "Recommend res/animator/ for animator style res in AVD" 2018-03-01 21:21:02 +00:00
Doris Liu
0e9418eff6 Recommend res/animator/ for animator style res in AVD
BUG: 74074384
Test: Visual inspection
Change-Id: Ifd268efd85124c7597b5b135a3dbe13d009dc917
2018-03-01 11:24:47 -08:00
TreeHugger Robot
3fe18d9c92 Merge "slice() the ByteBuffer passed to ImageDecoder" 2018-02-28 21:22:30 +00:00
Jason Monk
0e35073ec9 Merge "Add APIs to look into whats in an Icon" 2018-02-28 20:01:09 +00:00
TreeHugger Robot
67e5ac94cd Merge "deprecate EmbossMaskFilter" 2018-02-28 19:55:15 +00:00
TreeHugger Robot
824095856b Merge "Allow chaining ImageDecoder's setters" 2018-02-28 19:05:29 +00:00