Commit Graph

4014 Commits

Author SHA1 Message Date
Leon Scroggins III
f00b5a580b Make ImageDecoder#getSampledSize private
Bug: 152322291
Test: make

I originally added this thinking a client might use the following
pattern:

    Size size = decoder.getSampledSize(sampleSize);
    decoder.setTargetSize(size.getWidth(), size.getHeight());

But this is unnecessary. The client can directly call:

    decoder.setTargetSampleSize(sampleSize);

OTOH, if the client wanted to use a crop, too, then it would be useful
to know the exact sampled size. That could also be satisfied by adding
accessors that return the target size.

Change-Id: Id61907a8268f424d70503598d5bf844cde469d60
2020-03-30 14:12:17 +00:00
TreeHugger Robot
e270f1452f Merge "Add mSourceDrawableId to copy constructor" into rvc-dev am: 8e32fa537b am: 4f72ff09ec am: 1450d0afd1 am: be358e3b47
Change-Id: I8b594f7fdb40bd194465412531cb9df3524347a3
2020-03-27 22:36:06 +00:00
TreeHugger Robot
918b16d55c Merge "Remove Bitmap#createAshmemBitmap(Config)" 2020-03-27 21:56:50 +00:00
TreeHugger Robot
536b6cff44 Merge "Address @hides in ImageDecoder" 2020-03-27 20:43:14 +00:00
TreeHugger Robot
793a685653 Merge "Remove UnsupportedAppUsage from ImageDecoder" 2020-03-27 20:04:52 +00:00
Leon Scroggins
c101eb6a44 Merge "Remove Bitmap#wrapHardwareBuffer(GraphicBuffer)" 2020-03-27 18:58:29 +00:00
Leon Scroggins III
35f16e81dd Address @hides in ImageDecoder
Bug: 152322291
Test: make

Once ImageDecoder is in a mainline module, the system can no longer
access @hidden methods (unless they're @SystemApi), so this
removes/documents some. The ones in Source are not used anywhere outside
ImageDecoder AFAICT, so they are unneeded. Document setOutPaddingRect,
which needs to be public/@hide so it can be accessed by the drawable
package, which will also be in the module.

Change-Id: I5cd9c0553e8d27d6679cbc431fcadc96d818687d
2020-03-27 17:59:51 +00:00
Ryan Mitchell
26ff673458 Add mSourceDrawableId to copy constructor
The copy constructor of AdaptiveIconDrawable#LayerState currently does
not copy mSourceDrawableId from the original layer state. This prevents
drawables created from preloaded AdaptiveIconDrawables from having the
correct source drawable resource id.

Bug: 148488431
Test: CtsContentTestCases:android.content.pm.cts.PackageManagerTest
Change-Id: I7795a337a2a364677e375776c7aec5bc9189e0da
2020-03-27 10:32:52 -07:00
Leon Scroggins III
0356f7b169 Remove UnsupportedAppUsage from ImageDecoder
Bug: 152322291
Test: none

go/nonsdk-dash shows no usage of postProcessAndRelease, so remove the
annotation.

Change-Id: I7c7b91bd58c30f901f98a11c9688beb0fcd7db91
2020-03-27 13:20:44 -04:00
TreeHugger Robot
85f2116091 Merge "Add public API for @hidden Bitmap#createAshmemBitmap" 2020-03-27 16:08:33 +00:00
Leon Scroggins
789b93f006 Merge "Make Bitmap#setNinePatchChunk private" 2020-03-27 14:17:26 +00:00
Leon Scroggins
2a1b63c7df Merge "Convert ScreenshotGraphicBuffer to ScreenshotHardwareBuffer" 2020-03-26 17:29:14 +00:00
Leon Scroggins III
bef9efe885 Remove Bitmap#wrapHardwareBuffer(GraphicBuffer)
Bug: 150395371
Test: make

This method is being replaced by
Bitmap#wrapHardwareBuffer(HardwareBuffer) as part of the switch to a
mainline module.

With I41cb03fb65432d208820a428783de82a9f152035, there are no more
callers of this overload.

Change-Id: Ia837d6c4019d1e8495829b606fe62a68d557119a
2020-03-25 13:45:22 -04:00
Leon Scroggins III
46c927ed33 Convert ScreenshotGraphicBuffer to ScreenshotHardwareBuffer
Bug: 150395371
Test: make && flashall

Bitmap is replacing methods that use a hidden GraphicBuffer with ones
that use the public HardwareBuffer. ScreenshotGraphicBuffer is just a
holder for GraphicBuffer and some metadata; switch it to hold a
HardwareBuffer (and rename to match).

Remove GraphicBuffer#createFromExisting, which was only called by
ScreenshotGraphicBuffer#createFromNative. Also remove JNI references to
that method, which were no longer in use.

Switch uses of GraphicBuffer that retrieve it from a
ScreenshotGraphicBuffer to HardwareBuffer.

Changes are almost entirely mechanical:
- (Screenshot)GraphicBuffer -> (Screenshot)HardwareBuffer
- GraphicBuffer#destroy -> HardwareBuffer#close
- getGraphicBuffer -> getHardwareBuffer

When creating a Snapshot in SurfaceFreezer, use the ColorSpace of the
ScreenshotHardwareBuffer.

Remove GraphicBuffer#createFromExisting. This is no longer necessary,
and although it was marked UnsupportedAppUsage, go/nonsdk-dash shows no
usage.

Change-Id: I41cb03fb65432d208820a428783de82a9f152035
2020-03-25 13:45:12 -04:00
Alec Mouri
1559ca9889 Merge "Initial boilerplate for an updatable graphics jar" 2020-03-25 17:03:51 +00:00
Leon Scroggins III
b133bbf60c Make Bitmap#setNinePatchChunk private
Bug: 150395371
Test: make

This is no longer used internally. Remove @hide so no one is tempted to
use it. Leave the method here out of caution - it is marked
@UnsupportedAppUsage and static analysis shows some usage (though
runtime analysis shows none). Though it's likely unnecessary to keep,
there is little to no burden to keeping it.

Change-Id: I2f2f7b6cec45630acde1e0d903ca5dc6a3fec349
2020-03-24 11:46:55 -04:00
Leon Scroggins III
76d32b9732 Remove Bitmap#createAshmemBitmap(Config)
Bug: 150395371
Test: make

After I359187a5c70b5e241c7f5879d50fde2a7449c818, there are no more
internal callers. go/nonsdk-dash only shows Instagram apps calling it.
We've discussed with Instagram, and they no longer use this version.

Change-Id: Ic152223f62becf3e6b3cb0006ad762bf85337db6
2020-03-23 16:09:34 -04:00
Leon Scroggins III
3eb9843a2f Add public API for @hidden Bitmap#createAshmemBitmap
Bug: 150395371
Test: I442cd0c7a849e4c6a2fe7ba21b25a6e44417bbf5

The system needs to move off of @hidden Bitmap APIs so Bitmap can move
to a mainline module. It is valuable to provide a public way for clients
to create a Bitmap backed by ashmem, and the method's usage level is
HIGH. As I understand it, ashmem is being deprecated, so make the new
name more general: #asShared(). This method calls createAshmemBitmap(),
which must continue to exist for now due to the greylist. Add a
maxTargetSdk and publicAlternatives to move clients to the new method.

Mark asShared as @NonNull. It should only fail due to a failure to
allocate the shared memory. Throw a RunTimeException in this (rare)
case.

Add a (private) native method to check whether the Bitmap is already
backed by ashmem so it can skip the copy as necessary.

Remove outdated comments in both createAshmemBitmap methods regarding
SRGB. The new Bitmap will have the same ColorSpace as the original.

Remove the Config param from DisplayContent#screenshotLocked. It is only
ever called with ARGB_8888, which matches the ScreenshotGraphicBuffer
it is copied from. This means Bitmap#createAshmemBitmap(Config) does not
need a public version. It may need to continue to exist due to
@UnsupportedAppUsage.

Change-Id: I359187a5c70b5e241c7f5879d50fde2a7449c818
2020-03-23 16:09:26 -04:00
Leon Scroggins III
0bd3a6b356 Remove UnsupportedAppUsage from nativeNewInstance([BII)
Test: make

This method is marked as UnsupportedAppUsage, but that was for the
signature prior to I0bf8c4c72cc118d2799a59e8eb6c2cede546fceb (which has
not been released). This was a false positive, anyway. No app should be
using this while there is an almost identical public method.

Change-Id: Ib71a58be6ec72cd4c52e8fca3c2cd4055df55ecf
2020-03-20 13:53:14 -04:00
Alec Mouri
ef37c24f44 Initial boilerplate for an updatable graphics jar
Bug: 149773383
Test: builds
Test: hacks to verify that @hide apis are actually two-way hidden
Change-Id: I148b54fe47560b2335e9d878ed93bf167d6c7517
2020-03-18 19:50:27 +00:00
Leon Scroggins
a9fec9eeeb Merge "Remove isShareable from BitmapRegionDecoder" 2020-03-11 18:58:18 +00:00
TreeHugger Robot
b378dc2514 Merge "Remove LargeBitmap" 2020-03-08 19:35:27 +00:00
Leon Scroggins III
37d87372b8 Remove LargeBitmap
Bug: 150395371
Test: make

This became BitmapRegionDecoder in
I3e60c7fe4abd0289e1384e69a08fd20fe6fb0e10, but we forgot to delete the
Java file. It's been unused since then.

Change-Id: Ibe4e813d448346c9b15d4e112a2062713321edc9
2020-03-06 16:47:05 -05:00
Leon Scroggins III
a72a7ffe47 Expose Bitmap#getHardwareBuffer
Bug: 148155907
Bug: 150395371
Test: I652101b6a4b3d9de4e77a316ba0436ce466f3620

Bitmap already has a method to create a Bitmap from a HardwareBuffer,
and the NDK allows doing the reverse. This updates the SDK to allow
retrieving the HardwareBuffer, too.

Update the docs to match wrapHardwareBuffer regarding modifications.

Throw an Exception if called on a non-HARDWARE Bitmap, which is
friendlier than the crash that previously happened on the hidden API
(and the one it replaced).

Change-Id: I408cff708efa76f89e0c4c6dae16f19166ffe74d
2020-03-05 17:51:56 -05:00
Leon Scroggins III
96a13885e8 Remove isShareable from BitmapRegionDecoder
Bug: 140600285
Test: CtsGraphicsTestCases:android.graphics.cts.BitmapRegionDecoderTest
Test: I684e0ed6049e146e2c1698383c73709a7163b642

Clean up BRD in preparation for mainline module changes.
isShareable has been ignored for a long time, so update the APIs to
reflect that. Deprecate the existing ones, and add replacements without
isShareable. Make newInstance(FileDescriptor, boolean) into
newInstance(ParcelFileDescriptor), as recommended by the build failure.
- newInstance(byte[], int, int, boolean) has ignored it since
I7dd545c9d52d21c226e11b8921e35a1d9bba9515 (GB)
- newInstance(FileDescriptor, boolean) has ignored it since
Id1e1c8c5938ee1a33c6fa3caabd2c28e89243eb4 (KITKAT)
- newInstance(InputStream, boolean) and newInstance(String, boolean)
have always ignored it

Document WebP and HEIF support.

Add @NonNull annotations. Remove misleading comments about
returning null on failure. My understanding is that if it either returns
an object or throws an Exception, @NonNull is the appropriate
annotation - the client does not need to check for null.

Change-Id: I0bf8c4c72cc118d2799a59e8eb6c2cede546fceb
2020-03-05 14:28:09 +00:00
Leon Scroggins
1c49a551c8 Merge "Clean up easy Bitmap dependencies" 2020-03-04 14:18:22 +00:00
Leon Scroggins III
a4b20522f3 Clean up easy Bitmap dependencies
Bug: 150395371
Test: make

- Mark mDensity as package-protected, since it is not used elsewhere.
- Document getNativeInstance, getOpticalInsets, getNinePatchInsets,
  and scaleFromDensity - where they are called, and that they should not
  be called from outside the module.
- Mark setImmutable as private. No outside callers use it.

Change-Id: I85efe4829e2914222696aa659f8a21b699c3d788
2020-03-03 12:47:48 -05:00
Leon Scroggins
fb654cf97a Revert "Better preload drawable logging"
Bug: 63136392
Bug: 150395371
Test: make

This reverts commit 1480b67635.

Bitmap moving into a new mainline module in S. These module-boundary-
crossing hidden APIs need to be either made official or removed.

We already got the information we need from this logging, so remove it
and the hidden APIs. If/when we need to investigate this in the future,
we should be able to recreate the logging without crossing the boundary.

Change-Id: I5d094a0e427d225719614745867d5b00888d8fec
2020-03-03 10:17:53 -05:00
Derek Sollenberger
f8d4a6684c Fix mmap errors when reading font files via the AssetManager.
Previous attempts to do this ignored the offset that the
AssetFileDescriptor may have.

Bug: 149927583
Test: CtsTextTestCases and androidx.appcompat.widget.AppCompatTextViewTest
Change-Id: Idcc8cb83a7f265cfa12707b7ce643b35f7f72352
2020-02-27 15:12:43 -05:00
TreeHugger Robot
781185099b Merge "Do not attempt to special case uncompressed font assets." 2020-02-21 22:35:55 +00:00
Derek Sollenberger
dd03a8ef81 Do not attempt to special case uncompressed font assets.
The logic to attempt to directly mmap uncompressed font assets
has resulted in breakages for some applications and utilities.
This CL disables this speculative optimzation until we can determine
the problem with this approach and if such an optimization is required.

Bug: 149780695
Test: CtsTextTestCases and androidx.appcompat.widget.AppCompatTextViewTest
Change-Id: I3b10a801a5600aefe8573fab1b28cd79c848c892
2020-02-21 15:28:52 -05:00
Derek Sollenberger
76e7430bae Merge changes from topic "HWUI_JNI"
* changes:
  Export symbols for the newly exposed APEX/internal headers
  Remove dependence on libandroid_runtime from Bitmap.cpp
  Update Region.cpp to use AParcel NDK APIs
  Cleanup header and build targets for libhwui clients.
  Remove dependencies on headers outside UI module
  Cleanup LOG_TAG when bundled in HWUI
  Move android.graphics JNI & APEX files into HWUI
2020-02-21 11:43:02 +00:00
Derek Sollenberger
42c50042d1 Remove dependence on libandroid_runtime from Bitmap.cpp
The end goal is to have Bitmap.cpp use AParcel, but until that
API is extended to support this use case this is an alternative
way to isolate the graphics files from the libandroid_runtime.

Test: CtsGraphicsTestCases
Bug: 145227478
Change-Id: Ie3854fe03dec4f7b1b485295bb9a5ebba52ddb7c
2020-02-20 21:50:06 -05:00
Leon Scroggins
251888e9eb Merge "Add details regarding setConvexPath deprecation" 2020-02-20 20:00:38 +00:00
Leon Scroggins III
076bbe1ceb Add details regarding setConvexPath deprecation
Bug: 149857968
Test: make docs
Change-Id: I995e035fc7d73d196a50b4e515db38110baa0fe5
2020-02-20 11:16:11 -05:00
Leon Scroggins III
5a190b19bb Add Bitmap#getHardwareBuffer
Bug: 148155907
Bug: 135299581
Test: TODO

Hidden for now. We'd like to make it an SDK API eventually
(b/148155907).

Internal code is currently calling createGraphicBufferHandle. This is
not something we plan to expose from the UI rendering module, so add a
method to get a HardwareBuffer instead. This is something we were
already planning to add. It seems that clients of
createGraphicBufferHandle really wanted a Parcelable to pass the
HARDWARE Bitmap to another thread. This should satisfy that use case.

Change-Id: Id701f7c7eab37830cd7d2cdb929cbe6ba4eca119
2020-02-18 16:35:56 -05:00
Derek Sollenberger
db8164c0ac Merge "Move RenderNodeAnimator to android.graphics.animation package" 2020-02-14 16:32:50 +00:00
TreeHugger Robot
8780aae16c Merge "Create a ParcelableColorSpace" 2020-02-14 00:58:30 +00:00
Derek Sollenberger
8c2f6b6e15 Move RenderNodeAnimator to android.graphics.animation package
A wrapper still exists at android.view.RenderNode animator
as it needs access to internals of the view that would violate
the package layering if moved into android.graphics.animation.

This CL also moves the Java and cpp files associated with creating
a native interpolator that can be run directly on the RenderThread.

Bug: 149293249
Test: CtsViewTestCases
Change-Id: I5260331fedbd634cf2f6d6d392941e7284527420
2020-02-13 16:14:06 -05:00
John Reck
aa5f38577a Create a ParcelableColorSpace
Bug: 148412652
Test: ParcelableColorSpaceTest CTS
Change-Id: If0901367e501e2ecfc71b9ed29ec7d8dd4d0550f
2020-02-12 14:28:10 -08:00
Derek Sollenberger
e2edcebb2b Merge "Consolidate AssetManager calls in Font/FontFamily" 2020-02-11 13:11:42 +00:00
Derek Sollenberger
4db7bd28e7 Consolidate AssetManager calls in Font/FontFamily
The Font/FontFamily classes use private API calls in native
code to get the contents of an Asset.  These calls need to
be made on public APIs in order to isolate the graphics module
from the rest of the system.  Public Java APIs already exist so
this CL refactors the code to use those methods.

Test: CtsTextTestCases
Bug: 147136234
Change-Id: I35a6558b597684e59279d7a841669c5f909d5152
2020-02-10 20:05:31 +00:00
Stan Iliev
c90438175f Refactor GraphicsStatsService for updateability
Move GraphicsStatsService to android.graphics package.
Move GraphicsStatsService JNI from libservices.core to
libandroid_runtime.
Declare GraphicsStatsService ctor as the only @SystemApi.
Remove MemoryFile usage from GraphicsStatsService, but use
SharedMemory and other SDK APIs instead. This is done to
avoid using unstable API MemoryFile.getFileDescriptor.
Propose new SharedMemory.getFdDup API for next release, which
is hidden for now.
Refactor statsd puller to avoid proto serialization by moving
data directly into AStatsEventList.
"libprotoutil" is added as a static dependancy to libhwui, which
should be fine because its implementation does not link anything.

Bug: 146353313
Test: Ran "adb shell cmd stats pull-source 10068"
Test: Passed unit tests and GraphicsStatsValidationTest CTS
Change-Id: If16c5addbd519cba33e03bd84ac312595032e0e1
2020-02-07 12:27:07 -05:00
Derek Sollenberger
1863d94e9a Ensure SkiaPipeline always has a valid colorspace.
Previously we didn't assign a colorspace to the pipeline until it
was provided a surface to render into.  This resulted in undefined
behavior if the application attempted to render an offscreen layer
before the OS provided the main window with its surface. Now instead
of deferring setting whether or not the application is wide gamut we
do initialize it to a default setting when the pipeline is created.

Bug: 148042673
Test: apct/device_boot_health_check_extra_postsubmit
Change-Id: I84d743511e949ac977486470bb14eec936de7f88
2020-02-06 07:41:50 -05:00
Leon Scroggins III
a49beaaa69 Replace Outline#setConvexPath with Outline#setPath
Bug: 148544953
Test: No change in behavior, no new tests

setConvexPath no longer requires that the Path be Convex, so deprecate
the method and replace it with a name that does not imply it must be
Convex.

Update internal references to the Path being Convex as well.

Change-Id: I8935dc8ac7f7fb7db0d667e35fda67afdf2e6ac8
2020-01-31 14:21:46 -05:00
Leon Scroggins
e98ae477cc Merge "Deprecate Path#isConvex" 2020-01-29 18:10:14 +00:00
TreeHugger Robot
e428a2cc04 Merge "Deprecate Canvas.EdgeType" 2020-01-28 18:13:01 +00:00
John Reck
efac0521d6 Improve bitmap IPC
Make all received bitmaps immutable as this
improves re-use for subsequent transfers.

Remove minimum size to stay on ashmem, as
Parcel's writeBlob already has similar logic.
This effectively reduces the minimum size to 16kB.

Bug: 148301859
Test: device booted, a notification showed up
Change-Id: I2fafb0989944c0ef82de6edcb4924056a592cf66
2020-01-24 16:06:14 -08:00
Leon Scroggins III
2410b90e06 Deprecate Canvas.EdgeType
Bug: 129694386
Test: No change in behavior, no new tests

EdgeType is only used as a parameter to quickReject, but it is always
ignored. Deprecate it and the existing quickReject methods. Add new
versions of quickReject without EdgeType parameters. Switch clients to
the new versions.

Change-Id: Id932f10915a8c4959fe0e85f507ce7fd2da8a576
2020-01-23 20:43:34 +00:00
Leon Scroggins III
6a0cdd24df Deprecate Path#isConvex
Bug: 133807397
Test: No change in behavior, no new tests

isConvex is unreliable. We may change how we compute it from release to
release, and it could change based on various factors like a rotation.

Change-Id: Ib76246fc24f09bd13cf63b4b96b56afa613d0bc9
2020-01-23 12:41:08 -05:00