Commit Graph

3999 Commits

Author SHA1 Message Date
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
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
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
Sunny Goyal
77a2416924 Adding API to check if an icon returned by PackageManager
is a fallback icon

Bug: 141588119
Test: atest PackageManagerTest
Change-Id: I9ae5a74dd0b0c0c49a078d46914986ecb0d27a94
2020-01-21 16:17:49 -08:00
Haoyu Zhang
9f9301ccc2 Restrict UnsupportedAppUsage after Q
Bug: 145986883
Test: atest FontFamilyTest
Test: adb shell am instrument -w -r -e class 'androidx.core.graphics.TypefaceCompatTest' androidx.core.test/androidx.test.runner.AndroidJUnitRunner
Change-Id: I1cf0444b93df00532536531903e889ade9612597
2020-01-14 15:28:09 -08:00
TreeHugger Robot
c18efd1f4d Merge "Use new UnsupportedAppUsage annotation." 2020-01-08 07:55:21 +00:00
Leon Scroggins
d534534a72 Merge "Handle null assetFd like a FNF" 2020-01-07 17:34:59 +00:00
Artur Satayev
00f8b53650 Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I8ffa1da1bcd43c25f4ff817575db77a33c0f3d31
2020-01-07 14:40:02 +00:00
Brian Osman
bc44fa0fa8 Use SkRuntimeEffect rather than SkRuntimeShaderFactory
The old API was a shim over the new API, and will be deleted soon.
The new API is actually public, simpler, and more powerful.

Test: Everything still builds.
Change-Id: I11af8da9132e23a070e87dd5a7401c4854dd102a
2020-01-03 20:31:50 +00:00
Artur Satayev
53fe96661b Use new UnsupportedAppUsage annotation.
Existing annotations in libcore/ and frameworks/ will deleted after the migration. This also means that any java library that compiles @UnsupportedAppUsage requires a direct dependency on "unsupportedappusage" java_library.

Bug: 145132366
Test: m && diff unsupportedappusage_index.csv
Change-Id: I4bc8c9482e4bb1af21363f951affff7ee3fefeab
2019-12-18 15:42:06 +00:00
Derek Sollenberger
7da86dd922 Merge "Move FrameMetricsObserver logic into UI Module." 2019-12-18 12:14:26 +00:00
TreeHugger Robot
3d37450027 Merge "ImageDecoder: compare Strings with .equals()" 2019-12-17 23:37:52 +00:00
Derek Sollenberger
c4ef2c702a Move FrameMetricsObserver logic into UI Module.
Introduce HardwareRendererObserver to isolate the android.graphics
package from the android.view package.  The native code that
interacts with the observer was also moved from libandroid_runtime to
libandroid_graphics to keep it within the confines of the UI Rendering
module.

Bug: 137655431
Test: CtsUiRenderingTestCases
Change-Id: Ibccecbeda0c4d9501d86514a53eb98548233ba6a
2019-12-17 10:15:27 -05:00
TreeHugger Robot
ff4627bf4c Merge "Revert submission" 2019-12-17 03:06:55 +00:00
Nader Jawad
913dd6b9a9 Revert submission
Reason for revert: Causes regressions tracked in:

b/145900622
b/145864909
b/145948923

Change-Id: Ia24ece94d5281cd25d990d8cae923cf50497e1f1
2019-12-17 01:08:20 +00:00
Haoyu Zhang
fe7b206c8d Revert "Rmove @UnsupportedAppUsage"
This reverts commit 351df0901d.

Bug: 146181012
Bug: 145986883
Bug: 146318594
Bug: 146316215
Bug: 146315595

Reason for revert: This changed caused APP crash.
Change-Id: I0a1863176bf80ba5ad044621b5a2ff72e0d57fa4
2019-12-16 22:25:02 +00:00
Haoyu Zhang
351df0901d Rmove @UnsupportedAppUsage
Bug: 145986883
Test: atest FontFamilyTest
Test: adb shell am instrument -w -r -e class 'androidx.core.graphics.TypefaceCompatTest' androidx.core.test/androidx.test.runner.AndroidJUnitRunner
Change-Id: Iac6b9cb0dde2289604e5ec4b9bff8930fd9a4229
2019-12-12 14:40:52 -08:00
Leon Scroggins
773ae61247 Merge "ImageDecoder: Disallow empty/unsorted crop rects" 2019-12-11 14:44:28 +00:00
Leon Scroggins III
beebd3ca9b ImageDecoder: Disallow empty/unsorted crop rects
Bug: 135133301
Test: Idf64474f28c0bf3f77616a31d843d84fbfd570ab

If the specified crop Rect is empty or unsorted, throw an
IllegalStateException, like we do if the Rect does not fit in the target
size.

This is a change in behavior to make it more consistent. Here are the
specific behavior changes:
- an empty crop rect was previously supported in all cases, but would
  result in a zero width and/or height Bitmap/Drawable. If one
  dimension is non-zero, it still affects layout, though nothing is
  drawn. This is not useful, so the new Exception is more helpful. (It
  is also more consistent with setTargetSize, which throws an
  IllegalArgumentException for non-positive dimensions.)
- a negative width or height in decodeBitmap, or on a static image in
  decodeDrawable, previously threw an IOException when trying to call
  SkBitmap::setInfo with a negative width or height. Throwing an
  IllegalStateException is more consistent with other invalid crop rects
- a negative width or height in decodeDrawable on an animated image
  previously resulted in an AnimatedImageDrawable with a negative
  intrinsic width and/or height. When passed to an ImageView, this
  dimension ends up being 1. Again, this does not seem useful.

Change-Id: I15d2f77125799413eaf55d417e98ff34599e2eb4
2019-12-06 12:45:11 -05:00
Jeffrey Huang
cb78285b81 Rename writeToProto to be dumpDebug
We want to eventually migrate some of these APIs to be @SystemApi for mainline modules.
The #dumpDebug name is more appropriate than #writeToProto.

Bug: 142279786
Test: Manual
Change-Id: I60793e91cedf6b720d4ecef6a8484f4fed4ff30f
2019-12-05 11:28:11 -08:00