Commit Graph

3752 Commits

Author SHA1 Message Date
TreeHugger Robot
6f55e56e29 Merge "Make Drawable#createFrom* support incomplete images" 2019-02-02 01:28:48 +00:00
Peiyong Lin
dd4b22e66c Merge "[Color] Make setColorMode togglable." 2019-02-01 23:20:30 +00:00
Leon Scroggins III
c0fa2b9570 Make Drawable#createFrom* support incomplete images
Bug: 120786924
Test: I18463379d8e3d354ffafd006abd79c0a7918b500

Prior to P, createFrom* supported incomplete images, but this
regressed in P with the switch to ImageDecoder, which does not succeed
on incomplete images by default. Add a PartialImageListener, so that
incomplete images succeed.

Change-Id: Icb57d5857e1dcf6a347bb198f49284ac1975b54b
2019-02-01 21:31:07 +00:00
Kevin DuBois
a28aa5e6ec Merge "Pipe through color sampling to BrightnessChangeEvent" 2019-02-01 17:42:00 +00:00
Peiyong Lin
a94f3221da [Color] Make setColorMode togglable.
Previously setColorMode must be called before view is set, and has no effect
after that. The state of WCG on Android when this patch was written, was that
most hardware out there can not handle mixed color spaces composition well
which results in GPU composition. And this situation will remain true for a
long time.

Despite photography applications want to have WCG, it's a power cost especially
during video playback. In order to mitigate this fact and the desire to move
the ecosystem forward in WCG, we make setColorMode togglable such that in the
next app vsync, when color mode is changed we issue a surface update which
results in the old EGLSurface or VkSurface being destroyed and new EGLSurface
or VkSurface being created with the target color space being set. As a result,
applications can now togglable WCG on/off.

BUG: 120288123
Test: Build, flash and boot. Verify with SurfaceFlinger dumpsys on demo app.
Change-Id: I09bf8c380a01f4dde364873d37b248cedc6ccfd3
2019-01-31 21:34:50 -08:00
TreeHugger Robot
8116124801 Merge "Remove Shader#copy()" 2019-01-31 16:41:50 +00:00
Kenny Guy
908108aa4b Pipe through color sampling to BrightnessChangeEvent
Change brightness tracker to enable / disable color
sampling on screen on / off.
Add value channel to BrightnessChangeEvent if available.

Bug: 112756444
Test: atest BrightnessTrackerTest
Test: atest android.display.cts.BrightnessTest
Test: manual checked pixel3 which supports this and pixel2 which doesn't

Change-Id: I94384752235d891cee975b01f933c0bc0b4572a9
2019-01-31 16:33:06 +00:00
Peiyong Lin
a0baea28b7 Merge "Replace createHardwareBitmap with wrapHardwareBuffer." 2019-01-31 15:37:56 +00:00
TreeHugger Robot
1bd8c8bb4f Merge "Use ColorLongs in Linear-, Radial-, and Sweep-Gradient" 2019-01-31 04:44:38 +00:00
Peiyong Lin
9d4274005e Replace createHardwareBitmap with wrapHardwareBuffer.
The bitmap.createHardwareBitmap doesn't take a ColorSpace as input, as a result
the returned bitmap is always in SRGB color space. Given that we want to remove
the assumption of SRGB color space, we replace the usage of
createHardwareBitmap with wrapHardwareBuffer which takes an extra argument
ColorSpace. As a result, we will be able to also fix SurfaceControl and various
other places that use screenshot in follow up patches.

BUG: 120904891
Test: CtsUiRenderingTestCases
Change-Id: I57fc0c85d68df43b0e69f9a1ebac00d2ba39554d
2019-01-30 15:22:54 -08:00
TreeHugger Robot
028b73d3c0 Merge "Expose new color long Graphics APIs as public APIs." 2019-01-30 22:04:02 +00:00
Leon Scroggins III
85a13eee5e Remove Shader#copy()
Test: make

This is a hidden, protected API that is not called anywhere on the
system. Remove it.

Change-Id: I6d908945826be6f0cf19278d3d3d8d653faf8ebe
2019-01-30 16:01:36 -05:00
Leon Scroggins III
b0aecc22d3 Use ColorLongs in Linear-, Radial-, and Sweep-Gradient
Bug: 122844033
Test: Id1809aef84eca0ccc61bafc2476ad52ed78d5f22

Add APIs that mirror the existing creation APIs, but use @ColorLongs
instead of @ColorInts. Note that call-sites that used a null array (but
not a variable "int[]" pointing to a null array) are now ambiguous. It
is unlikely that there are any such call-sites, though, since they would
throw NullPointerException.

Consolidate constructors. Those that take two color endpoints now create
two-member long-arrays and call the more general constructor, saving
lots of code. The additional cost of small arrays is not as much as it
used to be, in the early days of Android, when this class was written.

In *Gradient#copy, there is no longer any need to clone the colors
array, since the mColorLongs was created by the Gradient. Similarly,
there never was any need to clone mPositions, which was always a clone
of the user-supplied array anyway.

Clean up Shader.cpp:
 - Throw and return if the pointer is null before dereferencing it.
 - Simplify and put together matrix-related code.

Change-Id: Ib71c5e85b2a398959bf687bce33980d3429bcbc3
2019-01-30 16:01:31 -05:00
Derek Sollenberger
a141563dc2 Expose new color long Graphics APIs as public APIs.
Test: existing CtsGraphicsTestCases and CtsUiRenderingTestCases
Bug: 120904891
Change-Id: I1d760a9a4681bd3e01132fe1b9213e5a17eb9c3d
2019-01-30 13:10:11 -05:00
Leon Scroggins III
bee5e20495 Add Canvas#drawColor(@ColorLong)
Bug: 120904891
Test: I857b8c1c9346285b2f6e4670c501c9d0d4053a0e

Change-Id: If08e8b805a4bba1a526efcd3cb05d4cd19f82eff
2019-01-30 10:10:04 -05:00
Leon Scroggins III
870053d44b Add Bitmap#getColor
Bug: 120904891
Test: I61ba938cdbea5154187c3a075c84436f2db81174

getColor returns a Color object in the ColorSpace of the Bitmap.
The underlying SkBitmap may contain values that are outside the
numerical range of the ColorSpace, so clamp them to fit.

Change-Id: I4174b75a83f18d6e165dbd2c724708276e80af21
2019-01-29 08:42:58 -05:00
Derek Sollenberger
7671e41efa Merge "Add Bitmap.setColorSpace()" 2019-01-29 01:58:58 +00:00
TreeHugger Robot
3ffd2c30ac Merge "Suppress IllegalArgumentException on API 28 or before" 2019-01-28 23:14:47 +00:00
Derek Sollenberger
202084c9b8 Add Bitmap.setColorSpace()
Bug: 120904891
Test: CtsGraphicsTestCases
Change-Id: I30be2cd77d810210ad87b281e6bb5587863982c3
2019-01-28 17:25:29 -05:00
TreeHugger Robot
5e55e809a7 Merge "Camera: Add support for dynamic depth image format" 2019-01-28 22:21:46 +00:00
Daniel Solomon
7d7a498788 Hide new ColorSpace APIs
A previous change added two new public ColorSpace APIs. These APIs are
being used only by ColorDisplayService for specific purposes, so for now
make them hidden.

Bug 116516917

Change-Id: Ib644d356a84d4122173ea4cafbac88bd63b1afcd
2019-01-25 15:43:10 -08:00
Seigo Nonaka
d01a515f55 Suppress IllegalArgumentException on API 28 or before
The suppression was added to FontsContract by
I7fba3e4d21fc895dfee4300db7d7e3000095ff92 but not in
Resources.getFont.
This CL adds suppression for Resources.getFont too.

Bug: 122262093
Test: locally verified
Change-Id: I15159dadc7e3694be5d90435a7a24cd626086656
2019-01-24 17:03:01 -08:00
Derek Sollenberger
48340af06e Merge "Don't assume all FP16 bitmaps are linearly encoded." 2019-01-24 16:32:31 +00:00
Derek Sollenberger
6e35e63740 Don't assume all FP16 bitmaps are linearly encoded.
The bitmap.create() function that does not take a colorspace does
not enforce that the bitmap is linearly encoded and as such it is
possible for us to end up with FP16 bitmaps that are sRGB encoded.

Given that we want to remove that restriction (see b/120870651)
we update getColorSpace to report the actual colorSpace of the
underlying bitmap. This pulls a thread that causes a chain of
updates to various classes to ensure proper handling of the native
colorspace.

Bug: 120904891
Test: CtsUiRenderingTestCases
Change-Id: I27780aa603138b0e48f9320c2837bc53e22cdf95
2019-01-23 16:31:52 -05:00
John Reck
5cca8f250c Add continuous SKP capture test api
Bug: 122856066
Test: PictureCaptureDemo
Change-Id: Iaf3a4bc1c8a2c18c7dff635c5f1cf726b331f8bf
2019-01-22 13:13:06 -08:00
Leon Scroggins III
94ba100c50 Convert @ColorLongs in native code
Bug: 120904891
Bug: 122844033
Bug: 122514935
Test: CtsGraphicsTestCases

Only convert rgba. ColorSpace should be converted in Java, so we can
just pass the native pointer and handle potential Exceptions before
going into native code.

Requires a change to external/skia [1] to make SkHalfToFloat SK_API.

[1] https://skia-review.googlesource.com/c/skia/+/185140

Change-Id: I0b42c17159b290868a6bed7b90da096995504c4d
2019-01-18 16:19:53 -05:00
Leon Scroggins III
0e443d1633 ColorSpaces have native SkColorSpaces
Bug: 120904891
Bug: 122844033
Bug: 122514935
Test: CtsGraphicsTestCases

Create an SkColorSpace when creating an android.graphics.ColorSpace.Rgb.
This allows simplifying getNativeColorSpace, so that each time we need
it, we do not need to call back up into Java or reconstruct the
SkColorSpace.

Funnel all ColorSpace.Rgb constructors into one, so we can set a final
mNativePtr in the base constructor. Update TransferParameters to also be
final.

Use the same TransferParameters as SRGB in EXTENDED_SRGB and DISPLAY_P3.

When passing a BitmapFactory.Options to native, call getNativeInstance()
(which may throw an Exception) and pass the result to native.

Move native ColorSpace code into its own file.

Make Paint methods @CriticalNative again, now that they do not need the
JNIEnv.

Remove unused decodeBitmap.

Change-Id: I60adbb060b87ab6f92559f1217bfefc0b9ea72e1
2019-01-18 16:19:48 -05:00
Leon Scroggins III
6ee411010e Add Paint#get(ShadowLayer)ColorLong
Bug: 120904891
Test: I6de01bd94fade605643af590f8d6909f09a5831e

Store Paint's colors (both the ShadowLayerColor, and the previously
uncached color that is stored in the native SkPaint) as @ColorLongs.
When setting or retrieving the int version, convert. This allows
returning the long value that was manually set, so that we return the
color in the ColorSpace that was requested.

Since the color is already stored in Java, remove nGetAlpha, and return
the alpha from the ColorLong. When setting alpha, update the cached
value, too.

Make setShadowLayer(..., @ColorInt) and setColor(@ColorInt) call the
@ColorLong versions, so they can share single JNI entry points.

Change-Id: Ifc559893dd4db2629c59b6e53f0b2166d43e6049
2019-01-16 14:26:20 -05:00
Leon Scroggins III
8bbcd3477c Add Paint#setShadowLayer(..., @ColorLong)
Bug: 120904891
Test: I38537394bf314668cc38349c34b9492164cb0c92

Change-Id: Id1c294a2a79087cfaaf4a25fa4888f706fdb8124
2019-01-15 15:37:36 -05:00
Leon Scroggins III
aefa03dd9e Add Paint#setColor(@ColorLong)
Bug: 120904891
Test: Iba796744a9cc3652a6bc1881a9b229403ffaed31
Change-Id: Ib03212b27bc330e61b876a4be3d45c34ed551540
2019-01-15 15:37:36 -05:00
Daniel Solomon
edb5e1a1b8 Merge "Add Display Auto White Balance to ColorDisplayService" 2019-01-15 19:29:16 +00:00
TreeHugger Robot
77571c7f31 Merge "Add Bitmap#eraseColor(@ColorLong) + helpers" 2019-01-15 18:50:21 +00:00
Leon Scroggins III
4c4259b339 Add Bitmap#eraseColor(@ColorLong) + helpers
Bug: 120904891
Test: I162451ebf807f3a8a44679e5c10406468c922500

- Add Bitmap#eraseColor(@ColorLong). This allows erasing in ColorSpaces
  besides SRGB. New API is hidden pending API-council approval. It is
  @TestApi so it can be used by the new tests.
- Rewrite Bitmap#erase(@ColorInt)'s internals. The ColorInt should be
  treated as an SRGB color. The old code (deep in SkPixmap::erase)
  treated the color as being in the SkColorSpace of the SkBitmap.
- Update getNativeColorSpace to return immediately when it throws.
  Existing callers should never throw anyway, since they do their own
  checks (and throws) in Java before reaching this method. But relying
  on this method to properly return simplifies the new callers.

Change-Id: I1b736934ce1b8294c827bb61c2a363207569da4f
2019-01-15 12:16:19 -05:00
Seigo Nonaka
74cababfd5 Merge "Add Canvas.drawTextRun(MeasuredText)" 2019-01-15 08:55:13 +00:00
Daniel Solomon
8b72c5b1d3 Add Display Auto White Balance to ColorDisplayService
This change adds Display Auto White Balance to ColorDisplayService.
Given panel chromaticity data, a nominal white point, and a desired
correlated color temperature (CCT), this logic generates and applies a
matrix transform to shift the nominal white point to match the desired
CCT.

Bug 116516917

Change-Id: I07e341881a020a130944217fff372003edac0a8c
2019-01-14 17:37:15 -08:00
Leon Scroggins
151b6729ab Merge "Make ColorSpace#isSrgb more restrictive" 2019-01-14 17:23:36 +00:00
Leon Scroggins III
203034fe2c Make ColorSpace#isSrgb more restrictive
Test: Ide74c2e98d4aadba8bb0a24d132f161dbe64f4db

Previously, BT709 was believed to be SRGB, resulting in errors when we
tried to convert between them. Make isSrgb test several values passed to
OETF and EOTF to verify that it is very close to SRGB. This results in
BT709 no longer being considered SRGB, fixing the conversion.

Update the documentation to reflect the new behavior.

Now that isSrgb is more restrictive, a gamma of 2.2 is no longer
considered to be SRGB, which requires a change to a CTS test.

Change-Id: I7bf8d5e3af2f91e38ca0b0d5d906713a125dd484
2019-01-11 14:31:52 -05:00
Emilian Peev
934ffa6d40 Camera: Add support for dynamic depth image format
The Jpeg image format must support additional dynamic
depth metadata according to the new standard. Camera
devices supporting non-exclusive depth map streams
along with appropriate Jpeg output will include this
new format by default.

Bug: 109735087
Test: Camera CTS
Change-Id: Id628466323a1ffbbdc7b44a5d15fe8df1cab8743
2019-01-11 15:24:21 +00:00
Seigo Nonaka
3fea923b47 Ignore missing target font family during alias registration
Bug: 122665938
Test: TreeHugger
Change-Id: Ic9f72bf5e6891f4d30d54b3f1a3b6a6fc8424788
2019-01-10 13:24:22 -08:00
Hans Boehm
13f86506cc Merge "Fix spelling of "HARDWARE"" am: 9fbe481727 am: 281664abf5
am: 5ff66466e5

Change-Id: I54f91677a909281b402f2be8658813d3a91e3ae0
2019-01-09 11:55:01 -08:00
TreeHugger Robot
d3a110b811 Merge "Fix a typo in ColorSpace.get" 2019-01-08 20:38:47 +00:00
Leon Scroggins III
f50e8d4bc0 Fix a typo in ColorSpace.get
Test: I1759437bf620868706be0aadce2250ac9194ca7d

The intent is that an index that does not match a Named ColorSpace will
throw an IllegalArgumentException, so make that true for
Named.values().length, which does not correspond to one.

Also, update the Exception message to make it clear that the last index
is exclusive.

Change-Id: I015b7ee6274873cc329653473ead04b08f1cd55f
2019-01-08 09:20:07 -05:00
Hans Boehm
e5b337dd88 Fix spelling of "HARDWARE"
Happened to notice this while reading the code for other purposes.

Test: Treehugger
Change-Id: I2d1b1e239bfd8d2506a62173fe854f608a45f5b0
2019-01-07 17:42:05 -08:00
Mathew Inwood
55418eada5 Limit access to suspected false positives.
Members modified herein are suspected to be false positives: i.e. things
that were added to the greylist in P, but subsequent data analysis
suggests that they are not, in fact, used after all.

Add a maxTargetSdk=P to these APIs. This is lower-risk that simply
removing these things from the greylist, as none of out data sources are
perfect nor complete.

For APIs that are not supported yet by annotations, move them to
hiddenapi-greylist-max-p.txt instead which has the same effect.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: Ia937d8c41512e7f1b6e7f67b9104c1878b5cc3a0
Merged-In: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28 14:26:35 +00:00
Mathew Inwood
31755f94e1 Limit access to suspected false positives.
Members modified herein are suspected to be false positives: i.e. things
that were added to the greylist in P, but subsequent data analysis
suggests that they are not, in fact, used after all.

Add a maxTargetSdk=P to these APIs. This is lower-risk that simply
removing these things from the greylist, as none of out data sources are
perfect nor complete.

For APIs that are not supported yet by annotations, move them to
hiddenapi-greylist-max-p.txt instead which has the same effect.

Exempted-From-Owner-Approval: Automatic changes to the codebase
affecting only @UnsupportedAppUsage annotations, themselves added
without requiring owners approval earlier.

Bug: 115609023
Test: m
Change-Id: I020a9c09672ebcae64c5357abc4993e07e744687
2018-12-28 11:50:04 +00:00
Jorim Jaggi
99dc47483c Merge "A brave new world for window insets (5/n)" 2018-12-21 14:00:45 +00:00
Jorim Jaggi
5bb571dc40 A brave new world for window insets (5/n)
Implement controlWindowInsetsAnimation

Based on the leashes we have on the client, and the insets the
client has requested, we are able to move the surfaces around
such that the resulting insets will match what the client
requested.

Bug: 118118435
Change-Id: I0616e53455a6544aaf374c1b0eb10e258aced21d
2018-12-21 13:05:30 +01:00
Derek Sollenberger
24fc901e5f Improve performance of unclipped save layers.
Instead of allocating a separate renderTarget and switching
between them on each draw the new implementation follows the same
pattern that the old HWUI renderer used. The area of the layer is
now copied to a buffer on the GPU, the area is then cleared, rendered
as normal, and finally the texture is redrawn using dst_over blending.

This results in no render target switches and is considerably faster
on some hardware.

Test: CtsGraphicsTestCases, CtsUiRenderingTestCases
Bug: 119222339
Change-Id: I716aac1fc31e4c7a171373d37dee82034c01cf18
2018-12-20 10:04:46 -05:00
John Reck
c0cd1d7f33 Merge "New WebViewFunctor API" 2018-12-18 17:50:37 +00:00
John Reck
3a0041cf1d Merge "Add missing getter & improve docs" 2018-12-17 23:52:21 +00:00