3109 Commits

Author SHA1 Message Date
sergeyv
81f97ee47c HardwareBitmaps: support createBitmap methods that return immutable bitmap
Test: testCreateScaledBitmap, testCreateTransformedBitmap, testCreateSubsetBitmap in HardwareBitmapTests
bug:30999911
Change-Id: Ic128dfed78b18ad6f12dad50023ee7c2f5bfa4ad
2017-01-03 15:53:03 -08:00
Sergei Vasilinetc
99418fb205 Merge "Throw exception if getPixel(s) is called on a hardware bitmap" 2016-12-20 18:56:31 +00:00
Sergei Vasilinetc
3029730399 Merge "Add docs about Config.HARDWARE in Bitmap.writeToParcel method" 2016-12-20 18:55:21 +00:00
Mark Lu
b927731284 docs: update Paint.setTextSize() to indicate pixel units am: 5f05256106 am: 9c834b1241 am: 4da3266828
am: 84f12cd33e

Change-Id: I463334d7c43cb934848e10eb3040f4a898f6ed2c
2016-12-19 20:34:29 +00:00
Mark Lu
84f12cd33e docs: update Paint.setTextSize() to indicate pixel units am: 5f05256106 am: 9c834b1241
am: 4da3266828

Change-Id: I65e2a1c43bd049e5c4cada55e8689ecc98a70fa5
2016-12-19 20:27:51 +00:00
sergeyv
57eafc6f90 Throw exception if getPixel(s) is called on a hardware bitmap
Test: android.graphics.cts.BitmapTest#testHardwareGetPixel
bug:30999911
Change-Id: Ifa5a80d048c44c91122e9e7c79ca3ef9ecab963e
2016-12-19 11:52:06 -08:00
sergeyv
f161dce70e Add docs about Config.HARDWARE in Bitmap.writeToParcel method
Test: android.graphics.cts.BitmapTest#testWriteHwBitmapToParcel
bug:30999911
Change-Id: I5282df7d881d76f3e78979a2e5d3777f78673a5d
2016-12-19 10:56:27 -08:00
Sergei Vasilinetc
8b6fe1d894 Merge "Support Bitmap.copy for hardware bitmaps" 2016-12-19 18:41:21 +00:00
Mark Lu
cab02c5b3a docs: update description for BitmapFactory.Options#inBitmap am: a8f4286272 am: 58d24b22ed am: 2b77de3a44
am: f34e9fc48d

Change-Id: I856c71a7b0dd930ecc0b5cc8805060a65a197324
2016-12-19 18:14:24 +00:00
Mark Lu
5f05256106 docs: update Paint.setTextSize() to indicate pixel units
bug: 2321154
Change-Id: Ic71404677a8079c744b99d4848d69c6ff52089ab
2016-12-17 07:23:29 +00:00
Mark Lu
2b77de3a44 docs: update description for BitmapFactory.Options#inBitmap am: a8f4286272
am: 58d24b22ed

Change-Id: I8e3a23304924623e2379155dcc7df1f739a5b7f0
2016-12-17 02:28:22 +00:00
sergeyv
05126d151e Support Bitmap.copy for hardware bitmaps
Test: android.uirendering.cts.testclasses.HardwareBitmapTests#testBitmapConfig*
bug:30999911
Change-Id: I2e80dff914bfa0666290701072ac93d30d218e8d
2016-12-16 17:46:10 -08:00
Mark Lu
a8f4286272 docs: update description for BitmapFactory.Options#inBitmap
bug: 18730109
Change-Id: Iab062d41af3a32208d3500179d3737278a035188
2016-12-16 15:43:27 -08:00
Romain Guy
f7e79d6eb3 Remove RGBX_FP16 format
Bug: 32984164
Test: compile
Change-Id: I22ffe0991d3c4add68317a0554dcac6a7ac56d12
2016-12-16 10:23:21 -08:00
Romain Guy
9505a65527 Add new RGBA_F16 bitmap config
This configuration uses 64 bits per pixel. Heach component is stored as a
half precision float value (16 bits). Half floats can be decoded/encoded
using android.util.Half.

RGBA_F16 bitmaps are used to decode wide-gamut images stored in 16 bit
formats (PNG 16 bit for instance). aapt is currently not aware of PNG
16 bits so such files must be placed in raw/ resource directories.

This first pass provides only partial drawing support with hardware
acceleration. RGBA_F16 bitmaps are stored in linear space and need
to be encoded to gamma space with the appropriate OETF to be rendered
properly on Android's current surfaces. They are however suitable for
linear blending. Full rendering support will be provided in a future
CL (BitmapShaders might be a bit tricky to handle properly during
shader generation).

Bug: 32984164
Test: bit CtsGraphicsTestCases:android.graphics.cts.BitmapRGBAF16Test

Change-Id: I328e6b567441a1b9d152a3e7be944a2cf63193bd
2016-12-16 09:15:07 -08:00
Chris Craik
15589c36d7 Merge "Outline & Path perf improvements" 2016-12-14 18:03:22 +00:00
Sergei Vasilinetc
82f8f3e04e Merge "Prohibit Config.HARDWARE in factory methods, that create mutable bitmaps" 2016-12-14 17:40:49 +00:00
Chris Craik
2414e1b051 Outline & Path perf improvements
Bug: 33460152
Test: device boots, ViewShowHidePerfTests#add[Factory:NestedLinearLayoutTree,depth:6] 770us -> 650us (userdebug 960MHz bullhead)

Improve perf for outline & simple path methods

native_methodName -> nMethodName in Path.java

Change-Id: Id2374bbaca3256d2e4f19dae9abe67f794a171b3
2016-12-13 16:52:08 -08:00
sergeyv
9fbb0b5ab3 Prohibit Config.HARDWARE in factory methods, that create mutable bitmaps
Test: android.cts.graphics.BitmapTest#testCreateMutableBitmapWithHardwareConfig
bug:30999911
Change-Id: I7cd4e2625563b6659613ccd180a57c56dcf7c2b1
2016-12-12 17:46:59 -08:00
Derek Sollenberger
dcc3630100 Remove Rasterizer and its subclasses from the public API.
Test: compile
Bug: 14650725
Change-Id: I99e1942d4d1b85f4efdcb3faf3fee1aa6c839b7e
2016-12-12 10:53:58 -05:00
TreeHugger Robot
0221d16cf4 Merge "Allow only U+0020..U+007E characters for axis tag." 2016-12-02 19:48:57 +00:00
Seigo Nonaka
0ec4f416ff Allow only U+0020..U+007E characters for axis tag.
CSS Font4 only allows U+0020..U+007E characters for tag string.
Reject outside of this range.

Bug: 33062398
Test: am instrument -w -e class android.graphics.VariationParserTest \
com.android.frameworks.graphicstests/android.test.InstrumentationTestRunner
Change-Id: Ia119151bc67caebfdaacda17aa3ee261a9e5d872
2016-12-02 18:24:00 +00:00
Teng-Hui Zhu
14efe881d4 Update the documentation related to VD / AVD
fix:32705240
fix:32683765
fix:32831830
fix:32705244

Test: make offline-sdk-docs and view the HTML file.
Merged-In: I6ae3e5850494f13a241b2e9e4d2c5b95d5199aae

Change-Id: I6ae3e5850494f13a241b2e9e4d2c5b95d5199aae
2016-12-01 11:18:51 -08:00
Amith Yamasani
f81df2d5e5 Merge "Secure MATCH_UNINSTALLED_PACKAGES across users" 2016-12-01 17:01:07 +00:00
TreeHugger Robot
b059a0826d Merge "Add API to visualize/debug/compare color spaces and colors" 2016-12-01 02:23:47 +00:00
Amith Yamasani
0d1fd8d091 Secure MATCH_UNINSTALLED_PACKAGES across users
Introduce a new internal flag MATCH_ANY_USER for genuine uses
of searching through all apps on the device.

Some temporary accommodations for Launchers that reach across
to the work profile until we have a new LauncherApps API to do
that officially.

Bug: 31000380
Test: CTS tests added
Change-Id: I2e43dc49d6c2e11814a8f8d1eb07ef557f31af34
2016-11-30 13:24:53 -08:00
Romain Guy
15296a2d34 Add API to visualize/debug/compare color spaces and colors
ColorSpace.createRenderer() returns a ColorSpace.Renderer which
can be used to visualize multiple color spaces and colors (each
associated with a specific color space) in the same CIE 1931 xyY
chromaticity diagram. This API was used to generate all the
diagrams shown in the documentation.

Bug: 32984164
Test: ColorSpaceTest in CTS
Change-Id: Ic94d939d5cfd563d826701f5e876b67b47ed56ec
2016-11-30 09:33:28 -08:00
Yirui Huang
e4b016ec41 Merge "Introduce font variation settings parser" 2016-11-30 01:13:04 +00:00
TreeHugger Robot
df68c9119c Merge "Make LD stateful / opacity management look more like DC" 2016-11-29 18:05:39 +00:00
yirui
3002ab6729 Introduce font variation settings parser
Font variation settings enables developer to specify font axes for
configuring glyph looking. This CL parse Font Variation settings to
make a array of Axis. More work is needed for using parsed axes.

Bug: 33062398
Test: Done by unittests.
Change-Id: I529b98b28df1c738237bee0729d9f479bd656dd3
2016-11-29 18:04:03 +09:00
TreeHugger Robot
b6504180ec Merge "Add images to document built-in color spaces" 2016-11-29 03:48:51 +00:00
Romain Guy
199e5a98dd Add images to document built-in color spaces
Bug: 32984164
Test: make offline-sdk-referenceonly-docs and manual validation of output

Change-Id: I2f0e00e5a0581517bb7c535e8aee150f87ac7a6e
2016-11-28 17:38:27 -08:00
Alan Viverette
eb7277590a Make LD stateful / opacity management look more like DC
Some initial cleanup before making changes to either class.

Test: n/a, refactoring only
Bug: 33124798
Change-Id: Idf0328bcc6de72b694ca7b35122ecad845cf1c4b
2016-11-28 14:55:18 -05:00
TreeHugger Robot
ab3225d742 Merge "Introduce android.graphics.ColorSpace" 2016-11-24 04:05:20 +00:00
Romain Guy
68bd5fdd1a Introduce android.graphics.ColorSpace
This class can be used to define color spaces. A color space has a color model
and a profile connection space (CIE XYZ D50). This implementation can be used
to query various properties of RGB color spaces or perform conversions between
various color spaces (RGB, XYZ and Lab).

Refer to the documentation for more details.

Test: cts-tradefed run singleCommand cts-dev --module CtsGraphicsTestCases --test android.graphics.cts.ColorSpaceTest
Bug: 32984164
Change-Id: Ie2117c1212c1375a7d403d3c1afaf73d7c2e0b47
2016-11-23 18:10:04 -08:00
sergeyv
da6c8ffcc5 Introduce Bitmap.Config.Hardware with @hide annotation
Test: HardwareBitmapTests
bug:30999911
Change-Id: Iaa0e18842704cb6bcd483c63a095dcb22baaf5e0
2016-11-22 18:28:54 -08:00
TreeHugger Robot
583727a345 Merge "Update the documentation related to VD / AVD" 2016-11-21 05:49:19 +00:00
Seigo Nonaka
1a625911a2 Merge "Add wordSpacing parameter to Paint" 2016-11-17 08:00:01 +00:00
Teng-Hui Zhu
18ad5f4368 Update the documentation related to VD / AVD
fix:32705240
fix:32683765
fix:32831830
fix:32705244

Test: make offline-sdk-docs and view the HTML file.

Change-Id: I6ae3e5850494f13a241b2e9e4d2c5b95d5199aae
2016-11-16 15:14:10 -08:00
Seigo Nonaka
219e2c7949 Add wordSpacing parameter to Paint
Adds the ability to control word spacing from Java, wiring up the
plumbing to the corresponding change that adds it at the Minikin
level.

Bug: 31707212
Test: ran graphicstests
Change-Id: I568186aca961d51ee5231cb0331f882b7b005e90
2016-11-16 16:24:07 +09:00
John Reck
3bdecbf0fd return 0 for allocation size if recycled
Change-Id: Ic471701faf026411938ebe87131533a8ef09bbd7
Fixes: 19804653
Test: none
2016-11-14 11:28:17 -08:00
John Reck
9192d5e8d7 Remove unused method
Test: builds

Change-Id: I8ad660f083a57f30db5ed0e2fe777286720033ca
2016-10-31 10:44:12 -07:00
John Reck
1ece145e01 Re-order draw methods to make update-api happy
update-api orders methods alhabetically by name, but when
there's multiple methods with the same name it falls back to
the ordering within the file.

Re-order the methods in canvas.java to match what's already in
current.txt to avoid unnecessary changes.

Also auto-formatted the draw methods as some were mis-indented.

Test: No behavior change, just method re-ordering
Change-Id: I2a7d313c8e7a6bd9187c4ed7dbde944b88aa32bb
2016-10-20 17:05:10 +00:00
John Reck
caa08ff5e9 The bigger update to Canvas
All draw* calls in Canvas are regular JNI
All draw* calls in DisplayListCanvas are FastNative
Unifies Canvas JNI on nMethodName naming

CanvasPerf results before:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=12492
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13912

and after:
INSTRUMENTATION_STATUS: basicViewGroupDraw_min=11945
INSTRUMENTATION_STATUS: recordSimpleBitmapView_min=13318

Test: refactor, makes & boots
Change-Id: I06000df1d125e17d60c6498865be7a7638a4a13e
2016-10-17 11:33:28 -07:00
Romain Guy
1158b6d4ee layoutlib relies on refSkPixelRef(), put it back
Test: Build aosp_arm64-eng successfully
Change-Id: Ic00cacac9aa1006ec16060a95bd1a22133e9a4bd
2016-10-12 10:55:50 -07:00
Romain Guy
253f2c213f Linear blending, step 1
NOTE: Linear blending is currently disabled in this CL as the
      feature is still a work in progress

Android currently performs all blending (any kind of linear math
on colors really) on gamma-encoded colors. Since Android assumes
that the default color space is sRGB, all bitmaps and colors
are encoded with the sRGB Opto-Electronic Conversion Function
(OECF, which can be approximated with a power function). Since
the power curve is not linear, our linear math is incorrect.
The result is that we generate colors that tend to be too dark;
this affects blending but also anti-aliasing, gradients, blurs,
etc.

The solution is to convert gamma-encoded colors back to linear
space before doing any math on them, using the sRGB Electo-Optical
Conversion Function (EOCF). This is achieved in different
ways in different parts of the pipeline:

- Using hardware conversions when sampling from OpenGL textures
  or writing into OpenGL frame buffers
- Using software conversion functions, to translate app-supplied
  colors to and from sRGB
- Using Skia's color spaces

Any type of processing on colors must roughly ollow these steps:

[sRGB input]->EOCF->[linear data]->[processing]->OECF->[sRGB output]

For the sRGB color space, the conversion functions are defined as
follows:

OECF(linear) :=
linear <= 0.0031308 ? linear * 12.92 : (pow(linear, 1/2.4) * 1.055) - 0.055

EOCF(srgb) :=
srgb <= 0.04045 ? srgb / 12.92 : pow((srgb + 0.055) / 1.055, 2.4)

The EOCF is simply the reciprocal of the OECF.
While it is highly recommended to use the exact sRGB conversion
functions everywhere possible, it is sometimes useful or beneficial
to rely on approximations:

- pow(x,2.2) and pow(x,1/2.2)
- x^2 and sqrt(x)

The latter is particularly useful in fragment shaders (for instance
to apply dithering in sRGB space), especially if the sqrt() can be
replaced with an inversesqrt().

Here is a fairly exhaustive list of modifications implemented
in this CL:

- Set TARGET_ENABLE_LINEAR_BLENDING := false in BoardConfig.mk
  to disable linear blending. This is only for GLES 2.0 GPUs
  with no hardware sRGB support. This flag is currently assumed
  to be false (see note above)
- sRGB writes are disabled when entering a functor (WebView).
  This will need to be fixed at some point
- Skia bitmaps are created with the sRGB color space
- Bitmaps using a 565 config are expanded to 888
- Linear blending is disabled when entering a functor
- External textures are not properly sampled (see below)
- Gradients are interpolated in linear space
- Texture-based dithering was replaced with analytical dithering
- Dithering is done in the quantization color space, which is
  why we must do EOCF(OECF(color)+dither)
- Text is now gamma corrected differently depending on the luminance
  of the source pixel. The asumption is that a bright pixel will be
  blended on a dark background and the other way around. The source
  alpha is gamma corrected to thicken dark on bright and thin
  bright on dark to match the intended design of fonts. This also
  matches the behavior of popular design/drawing applications
- Removed the asset atlas. It did not contain anything useful and
  could not be sampled in sRGB without a yet-to-be-defined GL
  extension
- The last column of color matrices is converted to linear space
  because its value are added to linear colors

Missing features:
- Resource qualifier?
- Regeneration of goldeng images for automated tests
- Handle alpha8/grey8 properly
- Disable sRGB write for layers with external textures

Test: Manual testing while work in progress
Bug: 29940137

Change-Id: I6a07b15ab49b554377cd33a36b6d9971a15e9a0b
2016-10-11 17:47:58 -07:00
John Reck
5cb74bca88 Canvas fastjni -> @FastNative
Just the basic cleanup first, will follow-up with a more
comprehensive update later
Test: builds & boots, refactor no behavior change

Change-Id: Ie3a7144b5fefdfda085e2ab50da8b0e627a1ecb8
2016-10-10 08:19:15 -07:00
Alan Viverette
39a561f5bb Scale bitmap shaders for target density am: 0d2a46b733 am: 444f2043d1
am: 36d83ffc5b

Change-Id: I97a23b431247f4541f5517787a486aca7d95a618
2016-10-10 14:30:50 +00:00
Alan Viverette
444f2043d1 Scale bitmap shaders for target density
am: 0d2a46b733

Change-Id: I8e3274a9c6047d943336827e7e0c8563e40c2ca5
2016-10-07 20:39:48 +00:00
TreeHugger Robot
0f6cec369f Merge "Scale bitmap shaders for target density" into nyc-mr1-dev 2016-10-07 20:31:01 +00:00