Commit Graph

3245 Commits

Author SHA1 Message Date
Philip P. Moltmann
7bc18b20fa Deal with finalize() after failed constructor
If the constructor throws an exception, the object will still be
finalized. Hence we have to make sure to set objects that are cleaned up
to 0/null and clean up everything else. Otherwise the finalizer might
double clean up a failed PdfRenderer.

It also appears that the Pdfium error state is only set if a open-doc
function fail. Hence remove it in every other case. Otherwise successes
might read the error of the last call.

Fixes: 63875707, 37052344
Test: cts-tradefed run singleCommand cts-dev -m Pdf --test=android.graphics.pdf.cts.PdfRendererTest
Change-Id: I6d9fc26be768ba1e338344740e340cf9b56386e9
2017-08-29 08:22:15 -07:00
John Reck
1d4be040e0 Merge "Avoid setting high contrast in every view draw" 2017-08-25 04:33:31 +00:00
John Reck
938e884a1f Avoid setting high contrast in every view draw
Test: high contrast text still works
Change-Id: I6674d1aca8dddf7eb9725a5346aed12ef1dbc195
2017-08-24 16:15:58 -07:00
Seigo Nonaka
4a40e0febf Make Typeface.create thread safe.
Typeface.create has not been thread-safe. This CL makes it thread safe.
At the same time, reorganize cache and lock in Typeface.

Bug: 64606109
Test: bit FrameworksCoreTests:android.graphics.TypefaceTest
Test: bit CtsGraphicsTestCases:android.graphics.cts.TypefaceTest
Change-Id: Id18e9b8bfab508a26fc0c83af6b1ca97e132b732
2017-08-23 14:41:25 -07:00
Roozbeh Pournader
737dfead64 Support extra linespacing based on fallback fonts
* Increase the ascent and descent of individual lines in StaticLayout
  as needed, if any fallback fonts that end up getting used call for
  it. For backward compatibility, this is hidden behind a builder
  flag.
* Document in Paint.java that the returned parameters are only for
  the default font, and a layout may need more space based on
  fallbacks used.

Also update for changes in minikin API:

* MinikinFont now requires a method for getting vertical extents
  (ascent, descent, and line gap).
* minikin API now allows asking for vertical extents of laid out
  text.
* minikin API's LineBreaker now returns ascents and descents for each
  line.

Finally, added performances test for creating a StaticLayout.
Follwing are the numbers on a marlin with a stable clock before and
after this CL.

For fixed text almost always hitting the cache:
Before: mean=260684 median=260188 min=258532 standardDeviation=1897
After:  mean=262432 median=261509 min=260429 standardDeviation=2185

For random text almost never hitting the cache:
Before: mean=5971827 median=5991126 min=5886871 standardDeviation=83724
After:  mean=6337093 median=6317010 min=6311222 standardDeviation=40213

Bug: 28963299
Bug: 29063863
Bug: 32057121
Bug: 37756858
Test: bit FrameworksCoreTests:android.text.
Test: bit CtsTextTestCases:*
Change-Id: I482a98ff8f472e8bab4f0ba9d1d7b368858038ff
2017-08-17 12:10:31 -07:00
Steven Timotius
af03df6a7a Update WindowManager to output dumpsys in protobuf format
Implement enough functionality in protobuf dumpsys to replicate
old functionaltiy in android.server.cts.WindowManagerState

Test: cts-tradefed run commandAndExit cts-dev --module CtsWindowManagerHostTestCases
cts-tradefed run commandAndExit cts-dev --module CtsServicesHostTestCases
Change-Id: Ib527ab3f44620a08cf03b77c37c2bae883d90e13
2017-08-14 17:06:17 -07:00
Roozbeh Pournader
c9c6ee667f Merge "Support multiple languages per font in fonts.xml" 2017-08-11 23:27:50 +00:00
Roozbeh Pournader
99975a3e25 Support multiple languages per font in fonts.xml
Minikin already supports multiple languages specified per font in
I7f13b51464c9b01982bb573251d77052b9ddbd70. This CL adds a couple of
such cases into fonts.xml and clarifies in the method and the
variable names and parameters that the frameworks is handling a
multi-language string when it is.

Fixes: 26687969
Test: make -j checkbuild
Test: bit FrameworksCoreTests:android.graphics.TypefaceSystemFallbackTest
Change-Id: Ifa540a95f87921983f9069330d1dd0892538a8df
2017-08-11 12:34:26 -07:00
TreeHugger Robot
891f481ef8 Merge "Refactoring: Deprecate Paint.mNativeTypeface." 2017-08-08 19:48:05 +00:00
Seigo Nonaka
318ca04079 Refactoring: Deprecate Paint.mNativeTypeface.
Bug: 64269689
Test: m checkbuild
Test: bit CtsGraphicsTestCases:*
Test: bit CtsViewTestCases:*
Test: bit CtsTextTestCases:*
Change-Id: Idc9f2b4612741be949204cd06efc41e1738d6587
2017-08-08 18:07:28 +00:00
Roozbeh Pournader
e88b5df5b7 Make ellipsize retry if text doesn't fit
This fixes the cases where the replacement of parts of text with
ellipsis may result in more-than-expected width of text due to
contextual width changes in the font, such as kerning or Arabic
shaping.

The calculations in TextUtils.ellipsize() and StaticLayout are fixed
to recalculate the new width and reduce it further until the text
actuall fits. BoringLayout and DynamicLayout get fixed too since
they use the other two implementations indirectly.

Also reverse a recently-introduced incorrect check for
multi-character ellipsis in Layout.java.

Fixes: 31537595
Fixes: 64156587
Test: Manual (Arabic edge cases ellipsize correctly)
Test: bit CtsTextTestCases:*
Test: bit CtsWidgetTestCases:android.widget.cts.TextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.EditTextTest
Test: bit CtsWidgetTestCases:android.widget.cts.CheckedTextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.AutoCompleteTextViewTest
Test: bit CtsWidgetTestCases:android.widget.cts.MultiAutoCompleteTextViewTest
Test: bit FrameworksCoreTests:android.text.
Test: adb shell am instrument -w com.android.documentsui.tests/android.support.test.runner.AndroidJUnitRunner
Change-Id: Iaddcc8b01c78d477e2c29b339d321c9631426f34
2017-08-07 16:22:00 -07:00
Seigo Nonaka
762dc8bdae Introduce new public API for specifying exact weight.
Adding Typeface.create(Tyepface, int weight, boolean italic).
This API is a most primitive API for specifying exact weight value
for drawing text.

Test: CtsGraphicsTestCases:android.graphics.cts.TypefaceTest
Bug: 63135308
Change-Id: I5766870f68026fd1b13815e794f5df243cd8c912
2017-08-01 02:04:18 +00:00
TreeHugger Robot
89e4c1ce17 Merge "Refactor TextUtils.join() and add documentation" 2017-07-21 08:08:31 +00:00
Roozbeh Pournader
42673c33ee Refactor TextUtils.join() and add documentation
Added documentation to clarify what happens in the case of null or
empty arguments.

Change-Id: I694dc0f6a6d95ab6ca7ed95b51d81938618eb75f
Fixes: 36861796
Test: bit CtsTextTestCases:*
Test: bit CtsGraphicsTestCases:android.graphics.cts.FontVariationAxisTest
2017-07-20 17:22:30 -07:00
Seigo Nonaka
c49ee3bde9 Support font resource in TextAppearanceSpan
To be able to parcel/unparcel Typeface, keep it in static context.

Bug: 62850669
Test: Manually done
Test: bit CtsTextTestCases:android.text.style.cts.TextAppearanceSpanTest
Change-Id: I408cd33b98d8bb13776560231d1eeaac0a7c6bf8
2017-07-20 12:01:05 -07:00
Selim Cinek
d0426628f6 Reducing bitmap sizes in notifications
Bitmap sizes could be arbitrary large when they were sent
over to the system. We're now reducing them to reasonable
sizes.s

Also fixed that notification bitmaps were not put into
ashmem anymore since it got lost in a refactor.

Test: code inspection
Bug: 62319200
Change-Id: I87db7656e749666b9eab1f67fd497f155c407e18
2017-07-19 11:05:26 -07:00
Makoto Onuki
1480b67635 Better preload drawable logging
Bug 63136392
Test: Manual test

Change-Id: I8753b36f632cf2ff57a5ef28df29f3fc5657f607
2017-07-14 11:40:29 -07:00
Roozbeh Pournader
e2393ae726 Merge "Make strike-through respect kerning at boundaries" 2017-07-14 02:17:43 +00:00
Roozbeh Pournader
1378a9d72c Make strike-through respect kerning at boundaries
Also clean up lower-level drawing of strike-through in Cavas.cpp.

We still cannot use the strike-through information from the font
since Skia doesn't provide it, so we are going with the default
values.

Test: Manual
Test: bit CtsTextTestCases:*
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Bug: 32907446
Change-Id: Iee6f8102a35eba0ff4127dbbef189529ab573e6d
2017-07-13 13:21:00 -07:00
Seigo Nonaka
0d253e46aa Implement family fallback.
Introduce new attribute "fallbackFor" to font element.
By specifying name of the family to this attribute, that font is used
when the developer specifies the font family.
For example, if fonts.xml has the following family entry,
  <family lang="ja">
    <font fallbackFor="serif">NotoSerifJP-Regular.ttf</font>
    <font>NotoSansJP-Regular.ttf</font>
  </family>
the Japanese text is rendered by NotoSansJP-Regular.ttf by default.
Then, if developer specifies fontFamily="serif" in TextView, the Japanese
text is rendered by NotoSerifJP-Regular.ttf.

Bug: 37328609
Bug: 31491668
Test: bit FrameworksCoreTests:android.graphics.TypefaceSystemFallbackTest

Change-Id: I2744db7384c8056795e841c88b387545434131f4
2017-07-13 10:47:48 -07:00
Selim Cinek
3594b9f4fd Merge "Fixed an issue where the shelf could be hidden" into oc-dr1-dev am: fdc84a13a2
am: 3ec9d993ce

Change-Id: I307a3d65603f5ede0e283f36715271bc68b8eabd
2017-07-03 10:59:17 +00:00
Selim Cinek
fdc84a13a2 Merge "Fixed an issue where the shelf could be hidden" into oc-dr1-dev 2017-07-03 10:46:35 +00:00
Selim Cinek
707e2072c8 Fixed an issue where the shelf could be hidden
During reinflation, the panel could be stuck in
a bad state where qs edit mode was on but not
visible. QS edit now persists through reinflations.

Test: manual
Change-Id: I6e7a20fda2db2184a26a11093064a1367469ab45
Fixes: 62807612
2017-06-30 18:40:53 +02:00
Hyunyoung Song
0e00add46a Merge "AdaptiveIconDrawable should not update layer bounds when bound is empty" into oc-dr1-dev am: e54ad58aea
am: 73035910fc

Change-Id: I43e867115e6242ef5a19795c8e53cccb5097d633
2017-06-29 19:33:54 +00:00
Hyunyoung Song
dba9934fb7 AdaptiveIconDrawable should not update layer bounds when bound is empty
Test: build succeeds. Also, setting tint mode does not result in error.

Bug: 37682281
Change-Id: I5991b8e58514a2130a793a5edb90baeafae9b148
2017-06-28 00:13:15 +00:00
Chris Craik
fc651ecf81 Merge "Use NativeAllocationRegistry for ColorFilter" into oc-dr1-dev am: 049543b771
am: bc1db397eb

Change-Id: I76e107bbbb89e32f535324f393c8f4ad3341bed3
2017-06-27 02:08:00 +00:00
Chris Craik
f65e92d9f9 Use NativeAllocationRegistry for ColorFilter
Bug: 62994689
Test: bit CtsGraphicsTestCases:*

Change-Id: Icea01fa7d4c6e78f3a93434de64bc8ddfe0c7a0e
2017-06-26 21:33:47 +00:00
Roozbeh Pournader
554585e08d Merge "Get underline position and thickness from the font" 2017-06-09 21:44:59 +00:00
Roozbeh Pournader
ca8a04a366 Get underline position and thickness from the font
Previously, font underline position and thickness were fixed in Android.
Although a custom font may have specified a different value, such a value
would never be used. Now we use the values from the font if they are
provided and fall back to the old default values only if needed.

Bug: 62353930

Test: adb shell am instrument -w -e package android.graphics com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: adb shell am instrument -w -e package android.text com.android.frameworks.coretests/android.support.test.runner.AndroidJUnitRunner
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: Manual
Change-Id: I6bf21000dd69a2780c894b231638bc0c122e41f4
2017-06-08 14:13:57 -07:00
Doris Liu
21d562c122 Merge "Better error message for AVD" into oc-dev am: cabf9cdc2e
am: cab35e9b0e

Change-Id: I48726108f88abbe3d08973259e1be1a1683df797
2017-06-07 19:45:52 +00:00
Doris Liu
7bbb50e21d Merge "Better error message for AVD" into oc-dev
am: cabf9cdc2e

Change-Id: I6e63b81fd2168780d23a88d7340812b55db98497
2017-06-07 19:40:53 +00:00
Doris Liu
cabf9cdc2e Merge "Better error message for AVD" into oc-dev 2017-06-07 19:31:14 +00:00
John Reck
4ee3fb4c54 Merge "Clear native shader when Paint shader changes" into oc-dev
am: d3e78478aa

Change-Id: I7d96db34b1894e1064116b830a8fb159ad4c57b0
2017-06-07 16:49:12 +00:00
John Reck
fbff7117ab Clear native shader when Paint shader changes
Since Recents never goes away that means TaskViewThumbnail
never goes away which in turn means mDrawPaint never goes away.

mDrawPaint has a setShader(null) called on it to release
the BitmapShader it was previously drawn with, but that
change didn't push down to native until the next time the
paint was used. As a result, the Paint held on to a
reference to the bitmap.

The fix is simple, when the shader is changed simply
push down an immediate clear of the native shader. Since
the bitmap of a BitmapShader isn't changeable we don't
need to worry about clearing references for shader mutation,
merely when Paint#setShader() happens.

Bug: 38258699
Test: Open & close recents, observe EGL memory immediately returns
to sub-5MB.

Change-Id: I6742efa8ae8dfca76b62a06bc1a1a00646feba64
2017-06-06 12:14:04 -07:00
Roozbeh Pournader
fd8c22d513 Move underline thickness and position computation to Paint
Also, in TextLine, fix underline color and thickness to come from the
underline info rather than the TextPaint object.

Bug: 32907446
Bug: 62353930
Test: Manual
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: cts-tradefed run cts-dev --module CtsWidgetTestCases
Change-Id: I259e9cf635a7056ccd367baa77c03100c69e3b98
2017-06-05 15:57:14 -07:00
Doris Liu
03f2fcbd88 Better error message for AVD
Moved the error checking to an earlier stage of the AVD, so that
the error message can contain more information.

BUG: 36571432
Test: Follow the repro step in b/36244835, the error message
      is much clear now.

Change-Id: Ibc6a0e666cc4c23c3dfa589755a77a015da2db1c
2017-06-05 15:51:18 -07:00
Roozbeh Pournader
cc4f086c94 Merge "Make underlining spans independent of actual class" 2017-06-05 17:30:27 +00:00
Roozbeh Pournader
538de5bb3b Make underlining spans independent of actual class
Previously, we had singled out UnderlineSpan for special treatment
for proper kerning at span boundaries. That had the limitation that
any other span that used underlining, or even subclasses of
UnderlineSpan were not getting the fix.

With this CL, we actually look at all the effects of applying a
span's updateDrawState() and if the changes were only in underlining,
we merge the pieces and call handleText() on the merged chunk of
text.

Change-Id: I829162c758192b80594f164d1105699224b627ba
Bug: 32907446
Test: cts-tradefed run cts-dev --module CtsTextTestCases
Test: cts-tradefed run cts-dev --module CtsWidgetTestCases
Test: manual
2017-06-01 16:45:33 -07:00
TreeHugger Robot
2a3220b247 Merge "graphics: Icon: use Arrays#equals for byte array comparison" 2017-06-01 20:31:50 +00:00
Peter Qiu
335a6e0f74 graphics: Icon: use Arrays#equals for byte array comparison
Bug: 62258815
Test: build

Change-Id: I95b7b7b663a8067aea40f36944003901afd8988c
2017-06-01 10:45:56 -07:00
Seigo Nonaka
0ee11e3f7e Merge "Fix NPE and wrong behavior of Typeface.isSupportedAxes" into oc-dev am: 633b32be55
am: bc790383d2

Change-Id: Ie308baed43bf39394949e2fa9fc1ebab1dc98e65
2017-05-31 00:27:12 +00:00
TreeHugger Robot
633b32be55 Merge "Fix NPE and wrong behavior of Typeface.isSupportedAxes" into oc-dev 2017-05-30 23:58:11 +00:00
Roozbeh Pournader
a63794c9cc Merge "Update Paint#mFontVariationSettings in set() and reset()" into oc-dev am: d865c624bd
am: 1ee4894e6c

Change-Id: I6c9bff56660ec6b6bddc48da9f629a571c7fe2d6
2017-05-30 21:35:50 +00:00
TreeHugger Robot
d865c624bd Merge "Update Paint#mFontVariationSettings in set() and reset()" into oc-dev 2017-05-30 21:15:20 +00:00
Seigo Nonaka
ffae6c7f71 Fix NPE and wrong behavior of Typeface.isSupportedAxes
The Typeface kept by Paint object can be null if nobody calls
setTypeface. The null typeface is equivalent to the Typeface.DEFAULT.
To check whether the passed axis is usable for Typeface.DEFAULT, we
need to pass Typeface.DEFAULT to isSupportedAxes if no typeface was set
on the Paint.

At the same time this CL fixes an issue in isSupportedAxes.
If the requested axis is listed in the first element of axes list,
isSupportedAxes returned false due to wrong handling of binarySearch
result.

Bug: 62146672
Bug: 62147012
Test: am instrument -w -e class android.graphics.cts.PaintTest
android.graphics.cts/android.support.test.runner.AndroidJUnitRunner

Change-Id: I7c154adfe8a19d6ed24ad645df7c10cee7880461
2017-05-30 13:40:49 -07:00
Hyunyoung Song
d04970da5d Merge "Merge "Fix safezone and getAlpha b/38361276 Test: frameworks/base/core/tests/coretests/src/android/graphics/drawable/IconTest.java" into oc-dev am: cca181bfbb" into oc-dev-plus-aosp
am: fa5f8fa8a8

Change-Id: I11d97f6c553882c0fb2423c1a62ee540378fcd25
2017-05-25 23:52:25 +00:00
TreeHugger Robot
cca181bfbb Merge "Fix safezone and getAlpha b/38361276 Test: frameworks/base/core/tests/coretests/src/android/graphics/drawable/IconTest.java" into oc-dev 2017-05-25 22:55:56 +00:00
Hyunyoung Song
ac2f74e80e Fix safezone and getAlpha
b/38361276
Test: frameworks/base/core/tests/coretests/src/android/graphics/drawable/IconTest.java

Change-Id: I3e1c73276968747249b053fd581f289c340d98af
2017-05-24 17:29:34 -07:00
Roozbeh Pournader
425e719c46 Update Paint#mFontVariationSettings in set() and reset()
Change-Id: I2dc41a998c940c4a4a98a06aaa6038cbca457186
Fixes: 62066408
Test: none
2017-05-24 15:16:55 -07:00
Tenghui Zhu
c495d8f1b5 Merge "Add documentation about 0 scale matrix to Shader" into oc-dev am: 52ca75011b
am: e7bc3d70b5

Change-Id: I1f659529a22072d329af949bedb3636400f0fde3
2017-05-24 21:36:45 +00:00