Commit Graph

3562 Commits

Author SHA1 Message Date
Seigo Nonaka
601622ab5c Merge "Make text related Paint API public" 2018-09-06 00:12:43 +00:00
TreeHugger Robot
b1559cdfac Merge "API Review: StateListDrawables#getDrawableForState" 2018-09-05 23:33:57 +00:00
Seigo Nonaka
3ffe6176b6 Make text related Paint API public
Following APIs are used by the text stack, and there is no reason for
them to be hidden. Make them public.
- getStrikeThruPosition
- getStrikeThruThickness
- getUnderlinePosition
- getUnderlineThickness
- getWordSpacing
- setWordSpacing

Bug: 112327179
Test: m docs
Test: atest android.graphics.cts.PaintTest
Change-Id: I651a5d620968fedcff2059e0e0694aa4ee770014
2018-09-05 10:31:22 -07:00
Nader Jawad
071149a9e7 API Review: StateListDrawables#getDrawableForState
Renamed getStateDrawableIndex to findStateDrawableIndex
based on API review feedback.

Change-Id: If07fe279fb02bc8180a28c7f58ea84ca030773ad
Fixes: 113856171
Test: Re-ran CTS
2018-09-05 17:28:37 +00:00
Nader Jawad
5078f4e79b Addressing API Review feedback
Marked Insets class as final and added nullability
annotations for static factory methods

Change-Id: Id2092704e0e464bf783a5f33a90cad2e37972b57
Fixes: 113855954
Test: re-ran CTS test cases
2018-09-05 15:28:39 +00:00
TreeHugger Robot
2672466f38 Merge "Implement #mutate for ColorStateListDrawable" 2018-08-30 15:47:28 +00:00
TreeHugger Robot
84f7d7b37c Merge "Deprecate Resources#getMovie()" 2018-08-27 21:06:28 +00:00
Ashley Rose
931435cf26 Implement #mutate for ColorStateListDrawable
ColorStateListDrawable did not implement #mutate correctly. This adds an
implementation for it.

Change-Id: I823b2096194ebc4e3424283ad5bad9d0f8df10df
Fixes: 113099852
Test: atest ColorStateListDrawable
2018-08-24 14:36:14 -04:00
TreeHugger Robot
83f8d6d2e1 Merge "Fix robolectric test" 2018-08-22 21:45:20 +00:00
Aurimas Liutikas
f0764b5c46 Deprecate Resources#getMovie()
Movie class has been deprecated, deprecate the getMovie as well.

Bug: 113054577
Test: None
Change-Id: Ic217adc002c7cfbe795e855689af1a58447b7d39
2018-08-22 13:13:07 -07:00
Ashley Rose
e3b135743f Create ColorStateListDrawable
Previously, you could not use references to colors in places that
expected a Drawable. This new class, ColorStateListDrawable bridges the
gap by attaching a ColorStateList to a ColorDrawable, and hooks it into
resource loading wherever you might expect a Drawable.

Fixes: 18126411
Test: Unit tests to be added to CTS
Change-Id: I0ff9a089669da96e6b22b214f04d6726bc278152
2018-08-22 14:08:30 -04:00
Seigo Nonaka
2bc7087125 Fix robolectric test
Bug: 112843740
Test: N/A
Change-Id: I54663725ace7bbc9b0c3ad582937162e82fec682
2018-08-22 10:46:29 -07:00
Seigo Nonaka
c02b7544f1 Fix NPE with Roboletric by returning emptyArray
Previous change I69e21940eaec4427f62abe59ae003b4f60855f22
did not handle the case of missing /system/etc/fonts.xml
This happens on roboletric test and crash with NPE.

Bug: 112843740
Test: N/A
Change-Id: I6d183dab9af66abf777f2e5b1fa633ff979fea55
2018-08-20 11:38:32 -07:00
Seigo Nonaka
c937328ba6 Address comments from API council for Font/FontFamily
- Change Font/FontFamily final
- Introduce equals/hashCode to Font class
-- Add equals and hashCode to FontVariationAxis as well
- Rename FontFamily.getFontCount to FontFamily.getSize
- Change Font ctor not to throw IOException and throw that in build()
  instead.

Bug: 112303038
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    CtsGraphicsTestCases:android.graphics.fonts

Change-Id: I079c99cfd579d07b6f3643e41415e58dc8b26492
2018-08-16 11:57:45 -07:00
Seigo Nonaka
eaa917e694 Rewrite system fallback construction with new FontFamily
Bug: 111133573
Bug: 112196940
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
    CtsGraphicsTestCases:android.graphics.fonts

Change-Id: I69e21940eaec4427f62abe59ae003b4f60855f22
2018-08-14 11:17:12 -07:00
Doris Liu
f6bdfbc979 Merge "Support theme attrs in non-stateful CSL for VD" 2018-08-03 21:12:44 +00:00
Doris Liu
5035238d95 Support theme attrs in non-stateful CSL for VD
BUG: 111446567
Test: ag/4686005
Change-Id: Ic79b13b62252d6ff294984ae82aec09708c9ba68
2018-08-03 01:36:49 +00:00
Seigo Nonaka
ef855275fc Merge "Introduce FontFamily and its builder" 2018-08-02 23:41:44 +00:00
John Reck
410c9d7396 Merge "Remove unneccessary #isHardwareAccelerated" 2018-08-02 19:28:44 +00:00
Seigo Nonaka
88930f1df4 Introduce FontFamily and its builder
This CL is a ground work of the new Typeface construction API and
nobody uses this class except for CTS now.
I'll add new builder in Typeface to be able to create Typeface
from this FontFamily.

Bug: 72665240
Test: atest FontFamilyTest
Test: CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I15d412c367037554d911fc9e20c0cfb44aefb89a
2018-08-02 11:04:44 -07:00
John Reck
8530853158 Remove unneccessary #isHardwareAccelerated
Test: CameraTests#testBasicTranslate
Change-Id: I2b5378edc3c975609bd1b427eac5677f87f601ac
2018-08-01 16:39:22 -07:00
Laura Davis
39c212abc6 Merge "Docs: fixed typo" into pi-dev am: 63e36667da
am: 902341345b

Change-Id: I41d0f700ebf4f6e47af90ca1af6738144f3fc3ff
2018-08-01 11:18:13 -07:00
Mathew Inwood
0d649f291a Add @UnsupportedAppUsage annotations
For packages:
  android.graphics
  android.graphics.drawable
  android.graphics.drawable.shapes
  android.graphics.fonts
  android.graphics.pdf

This is an automatically generated CL. See go/UnsupportedAppUsage
for more details.

Exempted-From-Owner-Approval: Mechanical changes to the codebase
which have been approved by Android API council and announced on
android-eng@

Bug: 110868826
Test: m
Change-Id: I7fc1162d2c63df8751a4660607e8ce72070efed8
2018-07-31 14:29:22 +01:00
Seigo Nonaka
a1b12c82a1 Merge "Introduce Font and its builder class" 2018-07-29 03:16:22 +00:00
Laura Davis
42d27af0da Docs: fixed typo
Test: make ds-docs

Bug: 111817624
Change-Id: I908e06419ab56220b41be6f821cff3258691b3b9
2018-07-27 12:07:27 -07:00
Seigo Nonaka
6f11c6e7e2 Extract native methods into isolated classes
StaticLayout/MeasuredParagraph uses native methods which is a pain point
of porting TextView to JetPack.
To make minimize the dependency to the native methods, extract native
methods and put them into a thin wrapper class.

The performance impact is limited:

android.text.StaticLayoutPerfTest:
    PrecomputedText Balanced Hyphenation  :    602 ->    644: ( +42, +7.0%)
    PrecomputedText Balanced NoHyphenation:    457 ->    476: ( +19, +4.2%)
    PrecomputedText Greedy Hyphenation    :    397 ->    412: ( +15, +3.8%)
    PrecomputedText Greedy NoHyphenation  :    397 ->    411: ( +14, +3.5%)
    RandomText Balanced Hyphenation       : 17,594 -> 17,715: (+121, +0.7%)
    RandomText Balanced NoHyphenation     :  7,146 ->  7,236: ( +90, +1.3%)
    RandomText Greedy Hyphenation         :  7,125 ->  7,196: ( +71, +1.0%)
    RandomText Greedy NoHyphenation       :  7,099 ->  7,187: ( +88, +1.2%)
  draw
    PrecomputedText NoStyle               :    614 ->    628: ( +14, +2.3%)
    PrecomputedText Style                 :    778 ->    826: ( +48, +6.2%)
    RandomText NoStyle                    :    537 ->    540: (  +3, +0.6%)
    RandomText Style                      :    786 ->    759: ( -27, -3.4%)

Bug: N/A
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I976df4db63be241af395dd30dd94182f76bdae53
2018-07-27 11:08:43 -07:00
Seigo Nonaka
a1c21c0a02 Introduce Font and its builder class
This CL is a ground work of the new Typeface construction API and
nobody uses this class except for CTS.
I'll add FontFamily class to be able to bundle these Font clases
and register to the Typeface.

Bug: 72665240
Test: atest FontTest
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest

Change-Id: I68555a8b4bd6dd770ba7baae72d9a3777b2087a5
2018-07-26 16:38:44 -07:00
Seigo Nonaka
fc09c9ee91 Introduce FontFileUtil
FontFileUtil provides style analysis of font file.
This CL also introduce a basic test functionality of font families.

Test: atest android.graphics.FontFileUtilTest
Bug: 72665240
Change-Id: I967d56eb37ee0e4c6d59f59c301a4a6f009fad2d
2018-07-19 10:37:33 -07:00
Jake Wharton
22c3c8d52e Annotate Region with nullability annotations
And a missing override or four.

Bug: 78245676
Test: none
Change-Id: Ib089a1e4b23ae8bd84b44b4638ee2f505ab760ba
2018-07-18 19:07:02 +00:00
Jake Wharton
30d287aa8b Annotate Point/PointF with nullability annotations
And a missing override or four.

Bug: 78245676
Test: none
Change-Id: I0293eaeb4ec9659b8ee09ac29351f995bb166dbc
2018-07-18 12:11:47 -04:00
Laura Davis
07cbe91d29 Merge "docs: repaired link to internal section" into pi-dev am: bcae0ff7a2
am: ad824eb7a8

Change-Id: I0c4d86cf6d6cf2465f01e209edf3b47c6c6bb4a2
2018-06-13 11:41:18 -07:00
Laura Davis
22dbf294bb docs: repaired link to internal section
Test: make ds-docs

Bug: 79236136
Change-Id: Idf48cf7a055a0aa3841d6b4d0540724b43c61241
2018-06-07 13:29:41 -07:00
Jake Wharton
1aa6c61b8b Annotate Path with nullability annotations
Bug: 78245676
Test: none
Change-Id: Ibf906c35245cef35505f6286472a01f6a2751f1c
2018-06-06 13:58:19 +00:00
Jake Wharton
dfda4ea9aa Annotate Rect/RectF with nullability annotations
And a missing override or eight.

Bug: 78245676
Test: none
Change-Id: I4476646f03f88753db358d01a6ad65a0982a160f
2018-06-05 19:03:56 -04:00
John Reck
93e87cf197 Merge "Ensure picture isn't recording in createBitmap" into pi-dev am: c4f520ddb6
am: 39636318ca

Change-Id: If964e798cf39c03cb6d2232d103dbd7bf4941d5a
2018-06-01 16:02:30 -07:00
John Reck
44fc6317f1 Ensure picture isn't recording in createBitmap
Picture#draw() will silently due an #endRecording() if it
wasn't called. Bitmap.createBitmap doesn't do this until
after it's too late.

So do an up-front #endRecording() to ensure state is
good to go

Bug: 80539264
Test: HardwareBitmapTests#testReadbackThroughPictureNoEndRecording
Change-Id: Ic66c41462e88880b73c5093d7541c4ce3d71adeb
2018-06-01 12:55:13 -07:00
Leon Scroggins III
f8adae1b33 Cleanup Bitmap#recycle
Test: Build, CTS

mNativePtr can never be 0 (it is final, and the constructor prevents
setting it to 0), so do not check for it. nativeRecycle only ever
returns true, so make it return void.

Change-Id: Ib94c0304ca7303d6899f085e64be7c051908d173
2018-05-24 15:31:20 -04:00
Leon Scroggins III
117f0c2833 Merge "AnimatedImageDrawable: Eliminate unnecessary calls to redraw" into pi-dev am: a2113aa4ad
am: 6353ff5bb5

Change-Id: I5258721b49834aba58e9bf19162e6a4588f68f0f
2018-05-17 13:16:13 -07:00
Leon Scroggins III
4afdd1caa4 AnimatedImageDrawable: Eliminate unnecessary calls to redraw
Bug: 78866720
Test: Manual + systrace; existing CTS

Previously, we set hasAnimations to true when the AnimatedImageDrawable,
so that we would get a call to redraw. But if the image does not need to
show its next frame yet, the redraw was unnecessary.

Instead, add a new field to TreeInfo::Out, representing the delay time
until the image will need to be redrawn - i.e. when the duration of the
current frame has passed. Each call to prepareTree will post at most one
message to redraw, in time for the earliest animated image to be
redrawn. Post the message for one rendered frame ahead of time, so that
when it is time to show the next frame, the image has already gotten the
message to update.

On a screen with a single animated image, this drops the number of calls
to dispatchFrameCallbacks to as infrequent as possible. It is called
only when we need to draw a new frame of the image. On a screen with
multiple animated images, the calls may be redundant, but they will not
be more frequent than they would be without this change.

Switch to nsecs_t and systemTime internally, matching the rest of HWUI.

Remove mDidDraw and related. Its purpose was to prevent advancing the
animation while the image is not being drawn. But it isn't really
necessary. If it's not drawn, onDraw is not called, which is where we
trigger decoding. And onDraw already has a defense against getting too
far ahead - if its timer indicates that it should skip a frame or show
it very briefly, it will back up its timer. More importantly, mDidDraw
caused a bug, when combined with less frequent redraws. If the display
list containing the drawable doesn't need to be redrawn for other
reasons, the drawable's timer never advanced, so its animation stopped.

Fix software drawing. Compute the milliseconds in the future to draw the
next frame, and add that to SystemClock.uptimeMillis() to compute the
time to pass to scheduleSelf.

Change-Id: I13aab49922fa300f73b327be25561d7120c09ec4
2018-05-16 18:51:07 -04:00
Nader Jawad
5d678b6486 Update Drawable API to expose getOpticalBounds method as well as
the Insets class

Updated all Drawable implementations to remove the @hide annotation

Fixes: 78942648
Test: Re-run CtsGraphicsTestCases and updated Drawable CTS tests to
verify getOpticalBounds implementations

Change-Id: Id9b6bbbe15173e310bbf44184b4678fb29ef1cd8
2018-05-09 10:51:36 -07:00
Nader Jawad
8ed9796bd5 Merge "Updated documentation of StateListDrawable#addState in order to indicate that sharing a Drawable across multiple Views/Drawables can lead to undefined rendering behavior" 2018-05-01 22:50:38 +00:00
Nader Jawad
d5a51a82b4 Merge "Removed the @hide annotation on various StateListDrawable APIs to better match the API surface exposed in ColorStateList." 2018-05-01 21:42:30 +00:00
Nader Jawad
e44e7fd612 Updated documentation of StateListDrawable#addState in order to indicate
that sharing a Drawable across multiple Views/Drawables can lead to
undefined rendering behavior

Bug: 70594326
Test: Re-ran CtsGraphicsTestCases

Change-Id: Ia6923886c809b6d81ead43becd8c725ae79ee999
2018-05-01 14:22:53 -07:00
android-build-team Robot
f4c79874e9 Merge "Stop copying PrecomputedText buffer" 2018-05-01 17:36:09 +00:00
Seigo Nonaka
2a6fb346dc Stop copying PrecomputedText buffer
PrecomputedText already has a copy of the text. No need to copy the
buffer.

android.text.StaticLayoutPerfTest:
  draw
    PrecomputedText NoStyle: 610 -> 616: (  +6, +1.0%)
    PrecomputedText Style  : 811 -> 831: ( +20, +2.5%)
    RandomText NoStyle     : 547 -> 544: (  -3, -0.5%)
    RandomText Style       : 730 -> 744: ( +14, +1.9%)

Bug: 72461923
Test: atest CtsWidgetTestCases:EditTextTest
    CtsWidgetTestCases:TextViewFadingEdgeTest
    FrameworksCoreTests:TextViewFallbackLineSpacingTest
    FrameworksCoreTests:TextViewTest FrameworksCoreTests:TypefaceTest
    CtsGraphicsTestCases:TypefaceTest CtsWidgetTestCases:TextViewTest
    CtsTextTestCases FrameworksCoreTests:android.text
    CtsWidgetTestCases:TextViewPrecomputedTextTest
Change-Id: I4b9d1c003f127a796d7d4f0d4aecfa7d016b89f6
2018-04-30 17:18:50 -07:00
Nader Jawad
4f614c8864 Removed the @hide annotation on various StateListDrawable APIs to better
match the API surface exposed in ColorStateList.

Removed the @hide annotation for the following StateListDrawable APIs:
--getStateCount
--getStateSet
--getStateDrawable
--getStateDrawableIndex

Fixes: 30325322
Test: Re-ran StateListDrawable CTS tests and added tests to verify each
of the newly exposed APIs

Change-Id: If93a017b6cf690fc38381a234bf3bd19d0bfc675
2018-04-27 22:06:14 +00:00
Derek Sollenberger
c18bcee38f Merge "Temporarily allow StackView to use a canvas.clipRectUnion" into pi-dev am: 7a7b2369fe
am: 8f0335fdec

Change-Id: Id22c0ad948b9aecfc0844ab0ad9b0d9eb376febb
2018-04-25 11:34:51 -07:00
TreeHugger Robot
7a7b2369fe Merge "Temporarily allow StackView to use a canvas.clipRectUnion" into pi-dev 2018-04-25 17:36:47 +00:00
TreeHugger Robot
88363dfc70 Merge "Updated ColorDrawable to implement getColorFilter" 2018-04-24 20:53:29 +00:00
Leon Scroggins III
33bd4a883f Merge "Fix rounding of padding in NinePatchDrawable" into pi-dev am: eabeec49c4
am: ac2454c905

Change-Id: Ia2693ba87ed07a79315282ed5ab7f6c89cb11c6e
2018-04-24 13:42:36 -07:00