Commit Graph

3407 Commits

Author SHA1 Message Date
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
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
TreeHugger Robot
f10f40b03c Merge "setPreferRamOverQuality -> setConserveMemory" 2018-02-28 18:47:03 +00:00
TreeHugger Robot
bf6edacac9 Merge "New attribute textFontWeight for selecting weight in the font family" 2018-02-28 01:21:41 +00:00
Jason Monk
7b0b97a42a Add APIs to look into whats in an Icon
Test: cts
Bug: 73943728
Change-Id: Iefbb4cecad5dd4abfcfc4d2085b0df6b62392305
2018-02-27 18:02:23 -05:00
Seigo Nonaka
e245116af3 New attribute textFontWeight for selecting weight in the font family
Note that AppCompatTextView doesn't work well with this attribute since
it overwrites the selected Typeface.

Bug: 63135308
Test: atest android.widget.cts.TextViewFontWeightTest
Change-Id: I76ee5e3007ea5f96249d2a0bfb66ff5975c62522
2018-02-27 11:39:13 -08:00
Mike Reed
979b884a04 deprecate EmbossMaskFilter
Test: make

Bug: 14646735
Change-Id: Ic724954318e1ad6b0a61a29ec5dd1e926f93f8ab
2018-02-26 21:38:54 +00:00
Leon Scroggins III
62f0800ef4 Add prefix to ImageDecoder.Allocator
Bug: 73788928
Test: No change in behavior; no new tests

This will allow the generated JavaDocs to include these in setAllocator.

Change-Id: Icd109ddf45e8809da1a0980924a6f4feccefcac2
2018-02-26 17:53:31 +00:00
Leon Scroggins III
4367534058 slice() the ByteBuffer passed to ImageDecoder
Bug: 73788928
Test: I7d5082ba7319c6c069dde5d0efb22af6e92dd243

This way the input's position is unaffected. Update the docs to reflect
the new behavior.

Change-Id: I7212948ee289ea8da1be9fe81d3f4bc9296e3e61
2018-02-26 10:11:17 -05:00
Leon Scroggins
08ddee7303 Merge "Add AnimatedImageDrawable.getLoopCount" 2018-02-23 20:39:21 +00:00
Leon Scroggins III
5f7e948ad8 Allow chaining ImageDecoder's setters
Bug: 73788928
Test: None
Change-Id: Ica9ff0738e6929268d83353b9caedd27e3e99ddc
2018-02-23 13:45:23 -05:00
Leon Scroggins III
a38b2135a4 setPreferRamOverQuality -> setConserveMemory
Bug: 73788928
Test: Ic4198306aae7f11a935aeeb970c8e05fbe440e7f
Change-Id: Ia2d2a559c652647ab4ed86b99833d33224f453b9
2018-02-23 12:36:29 -05:00
Leon Scroggins
e06975dd27 Merge "Fixes for inflating AnimatedImageDrawable" 2018-02-23 14:45:54 +00:00
Leon Scroggins III
1474b78888 Add AnimatedImageDrawable.getLoopCount
Bug: 73791004
Test: Id0335f15fdf0ebdc16d1edcabca547b9399c506f
Change-Id: I1c048196e45b91a1039c1f89e2176592765d2967
2018-02-23 09:43:00 -05:00
Leon Scroggins III
7f66873e0e Fixes for inflating AnimatedImageDrawable
Bug: 73529437
Test: I7907f5dd7eb8d4ab72b8e9ddcbcbfc7aa8cb05ae

Support AutoMirroring, from inflation and setting manually.

Ensure that AnimatedImageDrawable always has a State object, even if
it has no mNativePtr. If it has no mNativePtr, throw an Exception when
trying to use it.

Require that inflation have a valid src, unless it is waiting on a theme
(like BitmapDrawable).

Change-Id: I5b22cdbf4b57862d6ccc5750a677168287860f9f
2018-02-22 11:23:24 -05:00
John Reck
9bdd2e6151 Handle window surface insets
Bug: 69413152
Test: PixelCopy CTS tests
Change-Id: Ie26c38e462fbc6c19669d33efaec5251f40f75bd
2018-02-21 11:02:20 -08:00
Seigo Nonaka
e68ba070bb Merge "Reorganize MeasuredText API (2nd)" 2018-02-20 21:14:53 +00:00
Leon Scroggins
67190cf8eb Merge "Deprecate Movie.java" 2018-02-20 21:08:14 +00:00
TreeHugger Robot
75c515effa Merge "Implement AnimatedImageDrawable.getColorFilter" 2018-02-20 17:04:14 +00:00
Leon Scroggins III
fe2ab67894 Deprecate Movie.java
Bug: 27847286
Test: none

Now that we have a framework replacement, deprecate this little-used
class.

Change-Id: Iedec214c7eb729ccb77d2b4818971393938b2295
2018-02-20 11:38:11 -05:00
Seigo Nonaka
beafa1f9d2 Reorganize MeasuredText API (2nd)
This is 2nd attempt of I7db9e2ca4db68a16648cfb8fcf63555f501304c2

This CL changes the MeasuredText API:
- Rename MeasuredText to PrecomputedText.
- Introduce PrecomputedText.Param which holds all text layout parameters.
- Add API to get PrecomputedText.Param from TextView.
- Remove MeasuredText.Builder and add PrecomputedText.create method instead.
- Remove setRange from MeasuredText since it is not for normal use case.
  (It can not be used for TextView)

Bug: 67504091
Bug: 72861572
Test: bit FrameworksCoreTests:android.text.
Test: atest CtsWidgetTestCases:EditTextTest \
    CtsWidgetTestCases:TextViewFadingEdgeTest \
    FrameworksCoreTests:TextViewFallbackLineSpacingTest \
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \
    CtsTextTestCases

Change-Id: Ie73bce52c6c673cda58973ddad04627a7cf2e5e9
2018-02-16 19:42:00 -08:00
John Reck
96fccbe20a Yet more alpha tweaks for Ripples
Change-Id: If714a90d847882e04863723e1849e12a8f987fac
Fixes: 72173993
Test: API demos controls tests, clicked stuff, mouse & kbd used.
2018-02-16 13:18:30 -08:00
Leon Scroggins
299b0e4b4e Merge "Reland "Call ImageDecoder directly in ResourcesImpl"" 2018-02-16 11:25:23 +00:00
Leon Scroggins III
513031d15b Reland "Call ImageDecoder directly in ResourcesImpl"
This reverts commit 0f05b4895d.

Bug: 73083791
Test: CTS (I08618dcd7707e5857ed8f8f01fd78b4129cd5804)

Change-Id: I8a95725c8453d94f406c2c14d2c3555dc1c2901f
2018-02-15 21:48:55 +00:00
Leon Scroggins III
2f1b06b58f Reland "Use ImageDecoder for NinePatchDrawable and BitmapDrawable"
This reverts commit ac9c8f7c1e.

Bug: 73083791
Bug: 73364985

Don't scale NinePatchDrawable if bitmap has no density (including fix
for 73364985).
Fixed bugs around density and input streams.

Update PointerIcon to account for the fact that BitmapDrawable no longer
scales its Bitmap up at decode time. PointerIcon now handles the
scaling. This is necessary because PointerIcon never draws its Bitmap.
Instead, native code uses the Bitmap's internal SkBitmap without
accounting for density.

Test: Ran CTS:
- CtsUiRenderingTestCases
- CtsGraphicsTestCases
  - I2d3976061d164ab4d58209db1320917f272a1958
- CtsViewTestCases
- ThemeHostTests

Change-Id: I3e0c11195622d65f084ce79dad887504630177ca
2018-02-15 14:14:25 -05:00
Seigo Nonaka
f0b0a10de5 Merge "Revert "Reorganize MeasuredText API"" 2018-02-15 03:56:04 +00:00
Seigo Nonaka
4e90fa262d Revert "Reorganize MeasuredText API"
The last change needs more discussion and found some edge cases. Revert and make small step-by-step changes.

Bug: 73091756

This reverts commit 7fd36d19e3.

Change-Id: I89ff52a70cf6a5d6c553afa20f83719e1f9eb726
2018-02-14 17:03:16 +00:00
TreeHugger Robot
72698e6f39 Merge "Revert "Use ImageDecoder for NinePatchDrawable and BitmapDrawable"" 2018-02-13 20:13:04 +00:00
Seigo Nonaka
7fd36d19e3 Reorganize MeasuredText API
This CL changes the MeasuredText API:
- Rename MeasuredText to PrecomputedText.
- PrecomputedText is no longer a Spanned.
- Introduce PrecomputedText.Param which holds all text layout parameters.
- Add API to get PrecomputedText.Param from TextView.
- Remove MeasuredText.Builder and add PrecomputedText.create method instead.
- Remove setRange from MeasuredText since it is not for normal use case.
  (It can not be used for TextView)

Here is a performance scores: (median, walleye-userdebug, N=20)

StaticLayout creation time (w/o patch -> w/ patch)
 PrecomputedText Balanced Hyphenation  :    743,615 ->    737,145: (-0.9%)
 PrecomputedText Balanced NoHyphenation:    551,544 ->    542,715: (-1.6%)
 PrecomputedText Greedy Hyphenation    :    500,343 ->    499,601: (-0.1%)
 PrecomputedText Greedy NoHyphenation  :    497,987 ->    492,587: (-1.1%)
 RandomText Balanced Hyphenation       : 19,100,592 -> 19,135,289: (+0.2%)
 RandomText Balanced NoHyphenation     :  8,015,088 ->  7,954,260: (-0.8%)
 RandomText Greedy Hyphenation         :  7,950,915 ->  7,877,424: (-0.9%)
 RandomText Greedy NoHyphenation       :  7,939,337 ->  7,863,471: (-1.0%)

PrecomputedText creation time (w/o patch -> w/ patch)
 NoStyled Hyphenation                  : 18,935,638 -> 18,925,422: (-0.1%)
 NoStyled Hyphenation WidthOnly        : 18,469,726 -> 18,978,413: (+2.8%)
 NoStyled NoHyphenation                :  7,940,792 ->  7,919,127: (-0.3%)
 NoStyled NoHyphenation WidthOnly      :  7,463,230 ->  7,922,643: (+6.2%)
 Styled Hyphenation                    : 14,822,501 -> 14,809,017: (-0.1%)
 Styled Hyphenation WidthOnly          : 13,891,770 -> 14,656,617: (+5.5%)
 Styled NoHyphenation                  : 14,511,134 -> 14,301,503: (-1.4%)
 Styled NoHyphenation WidthOnly        : 13,495,345 -> 14,264,314: (+5.7%)

StaticLayout draw time (w/o patch -> w/ patch)
 PrecomputedText NoStyled              :    663,974 ->    661,610: (-0.4%)
 PrecomputedText NoStyled WithoutCache :    648,294 ->    648,766: (+0.1%)
 PrecomputedText Styled                :    879,322 ->    852,770: (-3.0%)
 PrecomputedText Styled WithoutCache   :  1,084,570 ->  1,110,147: (+2.4%)
 RandomText NoStyled                   :    565,682 ->    555,435: (-1.8%)
 RandomText NoStyled WithoutCache      :  9,070,533 ->  9,064,825: (-0.1%)
 RandomText Styled                     :  2,955,202 ->  2,962,008: (+0.2%)
 RandomText Styled WithoutCache        : 12,242,325 -> 12,228,573: (-0.1%)

Bug: 67504091
Bug: 73091756
Test: bit FrameworksCoreTests:android.text.
Test: atest CtsWidgetTestCases:EditTextTest \
    CtsWidgetTestCases:TextViewFadingEdgeTest \
    FrameworksCoreTests:TextViewFallbackLineSpacingTest \
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest \
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest \
    CtsTextTestCases
Change-Id: I7db9e2ca4db68a16648cfb8fcf63555f501304c2
2018-02-12 20:50:41 -08:00
Leon Scroggins III
ac9c8f7c1e Revert "Use ImageDecoder for NinePatchDrawable and BitmapDrawable"
Test: CTS tests

This reverts commit 5aec67ca1b.

Reason for revert: b/73166619

Bug: 73166619
Change-Id: Ic8b2a83abf5567119c8b6af1ec00445a5a6a9cc2
2018-02-12 12:36:49 -05:00
Siyamed Sinir
7cc9c01db7 Merge "Fix imports in text related graphics classes" 2018-02-09 22:47:41 +00:00
Siyamed Sinir
46dd24a710 Fix imports in text related graphics classes
Test: atest CanvasTest
Test: atest TypefaceTest
Test: atest PaintTest

Change-Id: I0d022e39a68be1b22d3036e928eaec1929789261
2018-02-09 12:35:22 -08:00
TreeHugger Robot
25d7f46aa9 Merge "Revert "Call ImageDecoder directly in ResourcesImpl"" 2018-02-09 03:47:26 +00:00
TreeHugger Robot
88f284a3d3 Merge "Change Resources.getDrawable nullability" 2018-02-09 01:30:23 +00:00
Stan Iliev
7717e22c85 Draw text with a hairline stroke as if it is fill style
Dew to a side effect of HWUI opengl pipeline, the hairline stroke
is not respected, but it is drawn as a fill style. Implement the
same behaviour for skiagl pipeline with SDK API 27 and older.
On SDK released with Android P, the hairline stroke is respected.

Bug: 72494357
Test: Ran duolingo app
Change-Id: I48bdcf3ddec4bf65b5e93e01c5002177c4e3da90
2018-02-08 23:04:47 +00:00
Leon Scroggins
0f05b4895d Revert "Call ImageDecoder directly in ResourcesImpl"
This reverts commit 40c59fdef0.

Reason for revert: b/73083791

Change-Id: I044e534be07c5fd18c99dcc65a14b72eaf1fecd5
2018-02-08 21:14:32 +00:00