reduce reflection usages
--Marked GradientState parameter as hidden as each field on it is
accessible through GradientDrawable's public API
--Updated setColors API method to enable setting color stop positions
array
--Fixed issue where GradientDrawable with start/center/end colors
configured via xml would crash at runtime if the colors were modified
with a different number of colors. Resolved by providing optional
float array parameter that defaults to null if unset.
--Added public setters to GradientState parameters that were not
previously exposed
Bug: 124051827
Bug: 124051738
Bug: 124050218
Bug: 124050917
Test: Added CTS tests to GradientDrawableTest for new API coverage
Change-Id: I175998c9920d0ecca021fc3cac7d3a3f9e4b61cf
Developers can use font in xml and also application global theme in
order to change the default Typeface. android:textViewStyle and its
attribute android:textAppearance can be used to change typeface and
other text related properties.
Test: None
Bug: 123769410
Change-Id: I5923da9c7a31a5da0466fd864dd37100d896e2b0
Added comments and trackingBug for UnsupportedAppUsage annotation of
Typeface.sDefault.
Developers can already use theme to customize font for their app.
But it still has a huge amount of usage.
For that reason we can't put it into black list now, and further
investigate is required for future action.
Bug: 123769446
Test: atest TypefaceTest
Change-Id: I238c4dfbbf4a4df6a0c477d36560a28cf4dc081b
We won't change anything of the reflection access of creatFromFamiliesWithDefault.
So we only add the bug number for tracking purpose.
And the TODO is removed because the corresponding ticket is marked as fix.
Bug: 123768395
Test: atest TypefaceTest
Change-Id: I802392859fb611ea558d0c06fc0bd77f5a38c439
Hidden API usage in Bitmap->mNinePatchChunk. Annotated the field
with the max sdk annotation as there is a public getNinePatchChunk
method on Bitmap.
Bug: 123769491
Test: N/A
Change-Id: I59cee2b8af238e5656b1366c044600f6feaa95ab
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
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
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
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
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
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
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
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
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
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
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
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