3109 Commits

Author SHA1 Message Date
Clara Bayarri
b44abf2901 Use weight & style data for fonts from xml source
Bug: 34916944
Test: manual tests
Change-Id: I1d6e1c4c52859c5e9d7a8b0a247e4d0581935833
2017-02-16 18:21:23 +00:00
Romain Guy
8ec21062de Add RGBA 10:10:10:2 format for surfaces
Bug: 2984164
Test: CtsHardwareTestCases
Change-Id: I4a42cb9002d8f1f1362999f2739d06c712157620
2017-02-15 18:29:50 -08:00
Hyunyoung Song
966ad0b2f5 Remove color attribute from MaskableIconDrawable foreground/background tag
Test: manual test

Change-Id: Ia8426051aed8c4451b10cf415e179930caede974
2017-02-14 10:23:06 -08:00
TreeHugger Robot
02761acc67 Merge "Declarative downloadable fonts" 2017-02-14 15:39:04 +00:00
Clara Bayarri
4b5a4d221f Declarative downloadable fonts
Implement support for downloadable font requests in xml. Given the
xml fonts feature in O, this adds support to not only declare
local font files as font resources, but also Downloadable fonts
from a fonts provider.

A provider returns a font family (of one or more files) given a
query, so the new attributes are added to the font-family tag.

Additionally, add support to pre-declare downloadable font resources
in the Android Manifest. These will then be fetched at app startup
time so they are available to use from the Typeface cache asap.

When retrieving downloadable fonts via resources, the cache is
checked to see if the font is already there and is used, otherwise
a request is sent to the provider and the default font is returned
as we need a result synchronously.

To do this, the developer declares an additional fonts xml resource
file with the list of fonts to preload and links it in the manifest
with a meta-data tag.

E.g.:

res/font/mydownloadedfont.xml

<font-family xmlns:android="http://schemas.android.com/apk/res/android"
        android:fontProviderAuthority="com.example.test.fontprovider"
        android:fontProviderQuery="myrequestedfont">
</font-family>

res/font/preloaded_fonts.xml

<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
    <font android:font="@font/mydownloadedfont" />
</font-family>

and in the AndroidManifest.xml

<meta-data android:name="preloaded_fonts"
    android:resource="@font/preloaded_fonts" />

Bug: 34660500, 34658116
Test: WIP, need to add more
Change-Id: I1d92555e115e241bf23b59e6f5c6cca6c7361de7
2017-02-14 13:32:41 +00:00
Derek Sollenberger
7183b6908b Merge "Deprecate Canvas save/saveLayer flags." 2017-02-14 13:31:21 +00:00
Hyunyoung Song
4d20ee8c46 Merge "Icon class should support Maskable bitmap type" 2017-02-13 23:36:15 +00:00
Derek Sollenberger
427acd7c77 Merge "Deprecate Canvas clipping for arbitrary Region.Ops." 2017-02-13 20:16:26 +00:00
Hyunyoung Song
9ee90a42dc Icon class should support Maskable bitmap type
Test: Unit test on IconTest
$ runtest --path=frameworks/base/graphics/tests/graphicstests/src/android/graphics/drawable/IconTest.java

b/34196580

Change-Id: I321c4b02f17ad9426c053216c4c88616a605aacf
2017-02-13 09:56:05 -08:00
Romain Guy
e8d2ebb5c2 Report bitmap config when decoding only metadata
With the introduction of support for 16 bit images, bitmaps returned
by BitmapFactory may be using the RGBA_F16 configuration. Some apps
and libraries assume the returned configuration is always ARGB_8888
and make assumptions based on that to compute cache sizes, etc.

This changes extract the output config when BitmapFactory is invoked
with the inJustDecodeBounds option. Despite its name, this option
is already used (and documented!) to decode more than bounds as it
also decodes the MIME type.

Bug: 35108998
Test: CtsGraphicsTestCases
Change-Id: If71959751458816678e42b21ab26c889aba5dea0
2017-02-10 11:37:54 -08:00
Derek Sollenberger
8c5759624c Deprecate Canvas clipping for arbitrary Region.Ops.
Operations that can expand the clip are difficult to support and
don't fit the parent child model that is used by the view system.

Test: compile
Bug: 14650725
Change-Id: I67e99d3e1a1eb0b231910ee5d277a38e8a953dc4
2017-02-09 14:17:55 -05:00
Derek Sollenberger
b8201195df Deprecate Canvas save/saveLayer flags.
Test: compile
Bug: 14650725
Change-Id: I6424ac46bae0a7a87c4b7743e81319945dfdd087
2017-02-09 13:18:25 -05:00
Phil Weaver
1e2758256a Merge "Provide text locations to accessibility services." 2017-02-07 19:14:09 +00:00
Phil Weaver
c2e28932d2 Provide text locations to accessibility services.
Bug: 30170631
Test: New CTS tests on linked CL.
Change-Id: I723e3777189c8df71c59dada00abdf339ebc983d
2017-02-06 12:57:17 -08:00
Clara Bayarri
b12397e57e Cache Downloaded Fonts in Typeface
If the requested Typeface is already loaded into memory, return
from the cache.

Test: none, optimization
Change-Id: I32422c47c68502ba83b7d976f6e05f70dda5daed
2017-02-06 10:46:34 +00:00
Hyunyoung Song
3084ec2df4 Handle nullable drawables inside MaskableIconDrawable
Test: manual test
b/34902453

Change-Id: I36fc48f7e4c1f6503a9c26b8f239c62da729b490
2017-02-02 00:59:13 -08:00
TreeHugger Robot
cf45c85297 Merge "Introduce set/getFontVariationSettings." 2017-01-31 05:46:27 +00:00
Seigo Nonaka
9ff994d988 Introduce set/getFontVariationSettings.
This is 2nd attempt of I249d464f8cdaa56017a987588b94ed685aadeb58.
The original CL was reverted due to conflicting with another CL submitted
before.
Nothing has changed except for following class name changes.

Here is the original commit message of reverted change.

This CL enables developers to specify axis values to the underlying
font collection. The specification of the font variation settings is
the same as the CSS font-variation-settings attribute in CSS working
draft as of 2016-11-30.

Code example: Here is an example to set width 100 and weight 1.5.

  TextView tv = (TextView) findViewById(R.id.textView);
  tv.setFontVariationSettings("'wdth' 100, 'wght' 1.5");

Bug: 33062398
Test: Manually done. Ran FrameworksGraphicsTests, CtsGraphicsTestCases
      and CtsWidgetTestCases

Change-Id: I9cdfbdecc87c995d805096883ef2652768c6c21e
2017-01-30 20:22:41 +09:00
TreeHugger Robot
fe98ad919b Merge "Implement .xml font resource support" 2017-01-30 09:37:13 +00:00
Clara Bayarri
ed00bfdfae Implement .xml font resource support
This change implements the loading and parsing
of xml type font resources, and makes sure it is
used properly by TextView styles.

Test: run cts -m CtsContentTestCases -t android.content.res.cts.ResourcesTest
run cts -m CtsWidgetTestCases -t android.widget.cts.TextViewTest#testFontResources*

Change-Id: I5a2930b3ba7dad67d9607e9036a5dde6bab0c5a4
2017-01-27 20:16:48 +00:00
Elliot Waite
0ce4b0e4c3 Fix @links in reference docs. am: 54de77470d am: ab978c035e am: 28ba4722a9
am: 9b21265b2c

Change-Id: If246ebdb36cf2832d5a6c42cbe752e290b6fb6e8
2017-01-26 04:49:33 +00:00
Elliot Waite
9b21265b2c Fix @links in reference docs. am: 54de77470d am: ab978c035e
am: 28ba4722a9

Change-Id: I98177a8cf0a20677e140406bb7371474ca259e5b
2017-01-26 04:44:54 +00:00
Elliot Waite
54de77470d Fix @links in reference docs.
Change-Id: I40cea46efd80c448640ff69753698fe8404da40b
2017-01-25 17:00:55 -08:00
Seigo Nonaka
c65ea181da Fix crash with FontProvider
Need to freeze the FontFamily otherwise the FontFamily is not created.

Test: manually done
Change-Id: I81a6f0d295f13bbeb059deafb4283654f97c0090
2017-01-25 22:25:10 +09:00
TreeHugger Robot
68eb1ac342 Merge "Follow minikin::FontFamily constructor signature change." 2017-01-25 07:05:50 +00:00
Hyunyoung Song
8d07bfa437 Merge "Adds MaskableIconDrawable class to android.graphics.drawable package" 2017-01-24 23:01:40 +00:00
Hyunyoung Song
f665a32950 Adds MaskableIconDrawable class to android.graphics.drawable package
Test: manual test ag/1774462, cts tests ag/1813947

Bug: 32063838
Design doc: http://go/layered-icons-eng

- Reads in the mask path from config.
- If <maskable-icon> is dynamically created, clip the drawable using the mask path.
- Instead of using clipPath method, used BitmapShader for performance.

Change-Id: If5b4a24127bf823477c6c5d8a81d5093501d58e7
2017-01-24 12:00:02 -08:00
Clara Bayarri
b0812a3049 Introduce Fonts Content Provider
This change exposes to developers the ability to request fonts
from a provider via Typeface.

Until further security is implemented, only system apps can
provide fonts.

Test: See topic for CTS change
Change-Id: Ic7d5e2648340ee561f4d4c2d73a673748d2af076
2017-01-24 19:32:09 +00:00
Seigo Nonaka
8b48e62445 Follow minikin::FontFamily constructor signature change.
This is 2nd attempt of Id10ca97f6f6f5bbe4999c1ad2736423a204d6e87.
The root caus of crash is due touching null pointer in nUnrefFamily.
After above change, native object may not be created on error case.
In that case, nUnrefFamily can not be called. In addition to this issue
there is also memory leak on error case. This fixes it by introducing
abortCreation method.

Also this contains fix of layout lib breakage done by jgaillard@.
Originally submitted by Ic8872a43993bcb0a157c5e3f0ce423af9b47f606

Here is original commit message of reverted change.

minikin::FontFamily no longer has addFont function, instead it accept
vector of Fonts in its constructor. To follow this signature change,
holding minikin::Font instance in native and build minikin::FontFamily
instance in FontFamily.freeze() method.

Bug: 34042446
Bug: 28119474
Bug: 34378805
Test: hwui test has passed
Test: m layoutlib layoutlib-tests
Change-Id: Ic34ebaa8191273d4c9f49c43124f15a1da5f7b78
2017-01-24 15:10:29 +09:00
Chris Craik
540dbd08ad Merge "Use @CriticalNative in Canvas" 2017-01-24 00:15:02 +00:00
Chris Craik
bfa0b29883 Use @CriticalNative in Canvas
Bug: 33460152
Test: ViewShowHidePerfTests

Switches non-drawing @FastNative methods to @CriticalNative, except
where out arguments prevent it.

Performance in ViewShowHidePerfTests not significantly impacted.

Change-Id: I3edc963accb4f87f73d175c7b2534868602a7db3
2017-01-23 14:25:06 -08:00
TreeHugger Robot
4a65687b85 Merge "Expose fonts.xml via public API with a service" 2017-01-23 19:57:23 +00:00
Clara Bayarri
764ff2740f Delete accidentally submitted FontResourcesParser
This should have not been part of commit
Idc06bfbfd16452a328bfcc6ea9dcfb723b633f0c

Test: none
Change-Id: I0701e5fad0df898ba64ea695ec31d0dd7d3bb333
2017-01-23 15:43:54 +00:00
Clara Bayarri
04d72abde1 Expose fonts.xml via public API with a service
This change creates a new FontManagerService, in charge of providing
font management data. It exposes a public API to retrieve the
information in fonts.xml without accessing it directly. To do this,
it also refactors FontListParser's internal classes into a new public
FontConfig class holding all the font data.

getSystemFonts() returns all the available information in fonts.xml
as well as file descriptors for all the fonts. This allows us to
share the memory consumed by these files between all clients.

Bug: 34190490
Test: See attached CTS change in topic
Change-Id: I0e922f8bcc9a197a1988d04071eb485328d66fb7
2017-01-23 15:02:23 +00:00
Clara Bayarri
18e9f9f377 Expose Resources.getFont
Based on the work already done in aapt2, load a Font from a
resource id.

Test: WIP
Change-Id: Idc06bfbfd16452a328bfcc6ea9dcfb723b633f0c
2017-01-23 11:18:09 +00:00
Siyamed Sinir
c0d685b87a Revert "Follow minikin::FontFamily constructor signature change."
This reverts commit a0a4828614edfd633ab86f04408e7f4e55b491dd.

Bug: 34378805
Change-Id: Icbdbfbde2efe8eaebbe4334a679e3b3247057388
2017-01-20 02:01:25 +00:00
Siyamed Sinir
24fac986ec Merge "Revert "Introduce set/getFontVariationSettings."" 2017-01-20 01:59:52 +00:00
Siyamed Sinir
a3b9f2e3c6 Revert "Introduce set/getFontVariationSettings."
This reverts commit ba3028c1fc9fca2d45acc841557da2c9a83923bf.

Bug: 34378805
Change-Id: I8250c87af5d65fb45789632580be4ae1b8711372
2017-01-20 01:13:23 +00:00
TreeHugger Robot
03ab3520a8 Merge "Color API to create/store wide-gamut colors in a long" 2017-01-18 04:17:47 +00:00
Romain Guy
77b161e0b1 Color API to create/store wide-gamut colors in a long
This change also includes the ability to create instances of
the Color class to represent more complex colors (any number
of components, etc.).

Test: CtsGraphicsTestCase
Bug: 32984164

Change-Id: I59399547c4aa2580901c93dd16e626fe07f8f23a
2017-01-17 14:32:10 -08:00
Sergei Vasilinetc
1f6df68a90 Merge "Prohibit rendering hardware bitmaps in software mode." 2017-01-17 21:27:52 +00:00
Robert Carr
6486d31dcb Expose SurfaceControl method to screenshot to GraphicBuffer.
A graphic buffer is most useful, as we can both attach it
to starting windows, and directly use it in Sys-UI. The old
codepath for starting windows/saved surfaces, is co-existing
at the moment, so I don't make large attempts to clean up
the existing screenshot code.

Bug: 31339431
Test: Manual test in combination with other branches
Change-Id: I562fdd5460dbce3201ba090272e8731850780f20
2017-01-12 11:16:34 -08:00
Seigo Nonaka
ba3028c1fc Introduce set/getFontVariationSettings.
This CL enables developers to specify axis values to the underlying
font collection. The specification of the font variation settings is
the same as the CSS font-variation-settings attribute in CSS working
draft as of 2016-11-30.

Code example: Here is an example to set width 100 and weight 1.5.

  TextView tv = (TextView) findViewById(R.id.textView);
  tv.setFontVariationSettings("'wdth' 100, 'wght' 1.5");

Bug: 33062398
Test: Manually done. Ran FrameworksGraphicsTests, CtsGraphicsTestCases
      and CtsWidgetTestCases
Change-Id: I249d464f8cdaa56017a987588b94ed685aadeb58
2017-01-12 18:11:03 +09:00
sergeyv
b3061e82eb Prohibit rendering hardware bitmaps in software mode.
Test: CanvasTest#testHwBitmapShaderInSwCanvas1,
CanvasTest#testHwBitmapShaderInSwCanvas2
CanvasTest#testDrawHwBitmapInSwCanvas

bug:30999911
Change-Id: Ia8cf4578db160d52a4c56060beb66ed9a58f1eaa
2017-01-11 10:28:09 -08:00
Seigo Nonaka
a0a4828614 Follow minikin::FontFamily constructor signature change.
minikin::FontFamily no longer has addFont function, instead it accept
vector of Fonts in its constructor. To follow this signature change,
holding minikin::Font instance in native and build minikin::FontFamily
instance in FontFamily.freeze() method.

Test: hwui test passed
Change-Id: Id10ca97f6f6f5bbe4999c1ad2736423a204d6e87
2017-01-11 17:57:59 +09:00
Derek Sollenberger
c543713bab Merge "Remove clipRegion from the public API." 2017-01-09 18:01:50 +00:00
sergeyv
6e3658a638 Hidden method to get a graphic buffer from a hardware bitmap
Test: locally tested Bitmap.getGraphicBuffer()
bug:30999911
Change-Id: I68d56d769045bada6a5db90ed884a570c49be4fd
2017-01-05 17:03:48 -08:00
sergeyv
0a0f23163a Move GraphicBuffer to graphics package
Test: locally tested Bitmap.createHardwareBitmap method
bug: 30999911
Change-Id: Iad432577f26f2362ede9e77cd8a5425c010692e5
2017-01-04 14:01:52 -08:00
Derek Sollenberger
b29b16e542 Remove clipRegion from the public API.
This API is difficult to support for printing and has other negative
effects as it does not respect the current matrix/clip.

Test: compile
Bug: 14650725
Change-Id: I71f9bd687d446c7ce8910d755421aad8e09458db
2017-01-04 14:57:43 -05:00
sergeyv
980bead518 Prohibit copyPixelsToBuffer & copyPixelsFromBuffer
Test: BitmapTest#testHardwareCopyPixels(From|To)Buffer
bug:30999911
Change-Id: I3bfa2846bff574bc0bfd54674eac794d1a6a0ff9
2017-01-03 15:54:57 -08:00