Commit Graph

51 Commits

Author SHA1 Message Date
Rachel Lee
b6c93aa789 Use start time in SurfaceControl setFrameTimeline.
Users of the API will see in the "Actual Timeline" the actual start time
rather than expected start time.

Bug: 210043506
Test: perfetto log of with & w/o CL, using Chromium apk, bug 198192946
Change-Id: I013bf6e28de32c82c9d645cc4cacf0cc01e0dd9f
2022-02-26 01:23:00 +00:00
Ady Abraham
5f7f72779e Merge "surface_control: handle acquire fence on BLAST callbacks" 2022-02-10 18:29:24 +00:00
Ady Abraham
62e15f0a20 surface_control: handle acquire fence on BLAST callbacks
When latching unsignaled buffers, the acquire fence is
not signaled by the time BLAST callback is invoked. In
that case pass a fence instead. For latch signaled, we still
pass the acquire time itself to avoid sending file descriptors
over binder.

Bug: 198190384
Test: TBD
Change-Id: I949fd396ec36ee759327a952239509d10259be1b
2022-01-21 17:01:03 -08:00
Rachel Lee
7e47b3dd7d Use AVsyncId typedef.
Test: atest ASurfaceControlTest
Bug: 214063411
Change-Id: I5dd6a0e467f3acc46bf4ce65dde0df265b590697
2022-01-14 15:38:18 -08:00
Rachel Lee
7834d38d95 Merge changes from topic "surfacectrl"
* changes:
  Pass start time from HWUI canvas context.
  Implement timeline in libandroid ASurfaceControl.
2021-12-15 20:02:30 +00:00
Rachel Lee
e1e77cca8a Implement timeline in libandroid ASurfaceControl.
As part of choreographer project.

Bug: 198192003
Test: atest ASurfaceControlTest
Change-Id: I36fdeae1d2bc07fdbd487fc0a40324fe48baca09
2021-12-09 16:04:06 -08:00
John Reck
7f55b13182 Reduce SurfaceControl feature gap to NDK API
Bug: 200697201
Test: atest android.view.cts.SurfaceControlTest

Change-Id: I1d0cff355714acb5668952b3d7f6fc0c15952523
2021-12-09 17:15:11 -05:00
chaviw
5513c615e7 Update setBuffer to use the new setBuffer API
Transaction.setAcquireFence is removed and instead the fence can be sent
directly in the setBuffer call.

Test: Chrome works
Fixes: 200065015
Change-Id: I248f07d7ce5a3faa0d7482fe4e0e7b33f3cfea55
2021-09-15 15:26:23 -05:00
Pablo Gamito
14b28ce9ce Get rid of unused ASurfaceControl in frame metrics listener callback
Test: Existing tests
Change-Id: Ia071814dabfc762d00d3324bfaa343ff94ab8338
2021-09-07 16:47:25 +00:00
Pablo Gamito
bc9e529031 Pass surface control id to callback to accurately identify surface metrics belongs to
Avoid getting the wrong frame info when duplicate frame numbers are found in the ring buffer. Will ensure there isn't a mismatch in the metrics data reported.

Test: Existing tests
Bug: 197515602
Change-Id: Iff9ba01f575f94e5a9872ee48c0dd1e5067880c3
2021-09-06 17:23:39 +00:00
Pablo Gamito
88660d77da Stop reporting frame stats from frames completed before observer was attached
Test: Run app from bug report
Fixes: 195699687
Change-Id: If80825dfb41467917b7b9b1e8c9ead1a0dcbffae
2021-08-31 10:33:28 +00:00
John Reck
2b2ba935f8 Remove isDataspaceValid
isDataspaceValid is problematic in that it prevents
applications from being able to pass-through dataspaces
they receive from other APIs, and it also assumes that
the display's capabilities are the only things that are supported.

Although it's recommended that applications stick to dataspaces
that the display can handle, it's not strictly required. RenderEngine
can handle more dataspaces than the display can, applying appropriate
color conversion. Similarly this could be going to a virtual display
instead, in which case the physical display's capabilities are not
necessarily relevant.

Bug: 149931223
Test: make
Change-Id: I475f4e4dcbcdb4765670f6a8eb4cc047a9babb43
2021-07-12 21:53:35 -04:00
Vishnu Nair
0d7aff7b35 Remove rotation based scaling
In order to simplify some of the geometry logic in BufferStateLayer,
and unify with the rest of the layer in SurfaceFlinger we translate the
concept of source and dest frame into crop, scale and position. This is
currently done on the client side.

But if there is buffer rotation transform, we will generate an
additional scale, to scale the buffer size to the new orientation. This
causes issues with rounded corners because the additional scale
stretches the rounded corner incorrectly. And translating the buffer
rotation into a rotation matrix affects child layers.

This solution only adjusts the buffer size based on the rotation
matrix and the scale is generated based on the rotated buffer.
This cannot be done in the client side because we do not have
the current display orientation to unflip the buffer if the client
sets the transformToDisplayInverse flag.

In the future the plan is to drive the transform hint and the
display orientation down from WM so this calculation can go
back to the client.

Also fixes incorrect additional scaling from source frame to dest frame
in ASurfaceTransaction_setGeometry.

Test: atest SurfaceControlTest ASurfaceControlTest libgui_test SurfaceFlinger_test
Test: go/wm-smoke
Bug: 185597146
Change-Id: I38adbc72c7567510c953cfd362a94b2b38d7fda7
2021-05-11 10:55:24 -07:00
chaviw
87a07ea39d Restore old behavior in pulic API setGeometry
When setFrame was removed, it required some changes to setGeometry.
However, this created some behavior changes between R and S. Modified
setGeometry to restore old behavior.

1. Destination can't have negative left and top. If negative values are
set, it will revert to (0,0,w,h)
2. If invalid source is set, an invalid rect for crop will be sent to SF
which would normally mean crop is ignored.

Test: ASurfaceControlTest
Bug: 185533162
Change-Id: I5c86da7327f97e82c63ae1f1c985829b8a4dbaef
2021-04-29 10:41:01 -05:00
chaviw
9b2ac24f09 Added setBufferCrop to setGeometry
The crop being sent to SF is in layer space where the setGeometry API is
getting buffer space crop. This breaks the API behavior so call
setBufferCrop instead of setCrop

Test: ASurfaceControlTest
Fixes: 186266903

Change-Id: I8f2567aa41b9525c3c3dc08855d14d8a9b11c7e2
2021-04-27 16:47:45 -05:00
Vishnu Nair
beb3b482db Introduce ASurfaceTransaction_setOnCommit api
Introduce a new callback for SurfaceControl transactions that
fire after we commit a transaction in SurfaceFlinger. This
will help some clients pace when they should apply the next
transaction so it get applied on the next vsync. If they wait for
the existing transaction complete callback, there may not be
enough time between when the client applies the transaction
and surface flinger waking up and apply it on the new vsync.
This would mean the update would arrive a frame late.

Bug: 185843251
Test: atest ASurfaceControlTest
Change-Id: If0d5d01a1d5c2029eb81667356e666d7297376d4
2021-04-21 15:06:19 -07:00
chaviw
ccf3e8b9f9 Updated native SurfaceControl APIs to reflect their behavior.
Updated setPosition, setCrop, setBufferTransform, and added setScale
to native SurfaceControl API. The new functions should be pass through
calls to SurfaceComposerClient that sends it to SurfaceFlinger.

Test: ASurfaceControlTest
Bug: 170765639
Change-Id: I214c5ae998d8f896200f3010cf2de6754d1e8510
2021-04-14 16:40:33 -05:00
Chavi Weingarten
a6d011d092 Merge "Revert^2 "Remove setFrame from surface_control setGeometry"" into sc-dev 2021-04-12 13:51:01 +00:00
Chavi Weingarten
305ec1d5c8 Revert^2 "Remove setFrame from surface_control setGeometry"
98aa7d4c88

Change-Id: I9172fac77048f548e1adacdc0041dc52a25eac0d
2021-04-09 13:37:33 +00:00
Orion Hodson
397cb14bd3 Merge "Revert "Remove setFrame from surface_control setGeometry"" into sc-dev 2021-04-09 07:34:01 +00:00
Orion Hodson
98aa7d4c88 Revert "Remove setFrame from surface_control setGeometry"
Revert "Remove setFrame from BufferStateLayer"

Revert "Update tests to reflect the new behavior for setGeometry"

Revert submission 13843937-sc_remove_set_frame

Reason for revert: Candidate CL for b/184807094
Reverted Changes:
Iffbd955a3:Remove setFrame
I27f17bc61:Update tests to reflect the new behavior for setGe...
I5720276c1:Remove setFrame from surface_control setGeometry
I32ee0e3e4:Remove setFrame from BufferStateLayer

Bug: 184807094
Change-Id: I7f6f0d7799e6e2858af2ce2e8acb5c67db8714f8
2021-04-08 12:30:21 +00:00
Chavi Weingarten
56fa22a105 Merge "Remove setFrame from surface_control setGeometry" into sc-dev 2021-04-07 18:56:42 +00:00
Rob Carr
782102ccd5 Merge "ASurfaceTransaction: Add setEnableBackpressure" into sc-dev 2021-04-02 19:03:09 +00:00
Robert Carr
f57c0163f9 ASurfaceTransaction: Add setEnableBackpressure
Expose the backpressure flag to NDK. See comment in
header file for extensive discussion.

Bug: 177458703
Test: Need new CTS
Change-Id: I97cdaef5d499f57a270972f001517b8a520aa2fe
2021-04-01 19:41:40 +00:00
Marin Shalamanov
d15b4b5473 Merge "setFrameRate: Make shouldBeSeamless an enum" into sc-dev 2021-03-31 14:30:23 +00:00
chaviw
5bdebd04de Remove setFrame from surface_control setGeometry
Use setMatrix and setPosition instead

Test: SurfaceFlinger_tests
Test: ASurfaceControlTest
Bug: 170765639
Change-Id: I5720276c12f085d564c19849c356ab304326979e
2021-03-30 16:51:17 -05:00
Marin Shalamanov
511f9145ba setFrameRate: Make shouldBeSeamless an enum
Change the shouldBeSeamless parameter to an enum
in order to make the API easier to understand.

This changes
 - SurfaceControl.setFrameRate
 - Surface.setFrameRate
 - ANativeWindow_setFrameRateWithChangeStrategy
 - ASurfaceTransaction_setFrameRateWithChangeStrategy

Bug: 179116474
Test: atest SetFrameRateTest
Change-Id: I55265399238e2c95fbb90fd33a4c2513d1fc5cec
2021-03-24 21:34:04 +01:00
Vasiliy Telezhnikov
5ead3aa5f2 Split ASurfaceTransaction_setGeometry api
This CL adds three new methods: setSourceRect, setPosition and
setTransform.

Test: ASurfaceControlTest
Bug: 173671170
Change-Id: I00f05a45bfa2b6e53735d95977d32bdecbce3df1
2021-03-17 18:14:55 +00:00
Marin Shalamanov
1b520a6d3f Merge "Introduce DynamicDisplayInfo" into sc-dev 2021-02-22 18:28:27 +00:00
Marin Shalamanov
463ad8ee22 Introduce DynamicDisplayInfo
In this CL we introduce SurfaceContorl.getDynamicDisplayInfo
which replaces the current seprate calls for supported and
active display mode, supproted and active color modes and
HDR capabilities.

This way display capabilities can be queried atomically.

Additionally this CL pipes an DisplayMode IDs from
SurfaceFlinger and updates LocalDislayAdapter to use
IDs instead of array indices.

Test: presubmit
Bug: 159590486
Bug: 175678215
Change-Id: I169e3055d07905e2330e11f158b61ffd366f97e6
2021-02-18 18:54:41 +01:00
Jorim Jaggi
71db8892ac Add GPU completion to FrameMetrics (1/3)
- Add SurfaceStatsCallback to TransactionCompletedListener
- Register a callback in RenderProxy to be called when we have
surface stats from SF via the BLAST callback.
- Instead of finishing a frame for frame metrics reporting
immediately, wait until BLAST callback fires, note GPU completion
time and finish frame.
- Expose GPU_COMPLETION in FrameMetrics
- Modify TOTAL_DURATION to also include GPU_COMPLETION

Test: FrameMetricsListenerTest
Fixes: 171046219
Change-Id: I16fa1d80cfc4e7a5527c18fec7e885409f17ee4d
2021-02-17 14:55:22 +01:00
Huihong Luo
91697e13ff Add ASurfaceControl_acquire api
hwui needs this api to hold a reference to a surface control object passed from java layer.

Bug: 173671170
Test: manual
Change-Id: I2b8417c289718bb1b99af47d7828e91b16785123
2021-02-11 17:59:04 +00:00
Marin Shalamanov
41ffa8dd06 Add shouldBeSeamless param to Surface.setFrameRate
This CL adds a new parameter shouldBeSeamless to the existing
setFrameRate APIs. This parameter indicates whether the desired
refresh rate should be achieved only seamlessly or also switches
with visual interruptions for the user are allowed. The default
value of the new parameter is "true".

Test: atest SetFrameRateTest
Test: atest RefreshRateConfigsTest
Test: atest libsurfaceflinger_unittest
Bug: 161776961
Change-Id: Ic2446d278e4f57fe507d30a0a18ef7b85909da4b
2020-11-17 11:53:14 +01:00
Vishnu Nair
ce1a648484 Allow creating child surfaces from BlastBufferQueue
App such as Chrome create child surfaces and parent them to
surfaces provided by SurfaceView. When we enable the blast
adapter for SurfaceView, the IGBP returned to the app is
created in the client and SurfaceFlinger does not know about it.
When the app creates a child surface and provides the IGBP as the
parent surface identifier, SF fails to validate the IGBP and the
surface is not created. This can be avoid if the client creates the
child surface from the SV SurfaceControl but we still need to
support existing APIs.

To fix this, when we create a Surface from the adapter, pass in
the handle of the Blast SurfaceControl. When calling
ASurfaceControl_createFromWindow, use this handle to identify
the parent.

Bug: 168917217
Test: adb shell settings put global use_blast_adapter_sv 1 & launch chrome
Change-Id: I879b411c47e8558397516bd7b7278813e79e005f
2020-10-22 18:03:22 -07:00
Pablo Gamito
117040c542 Update JNI to pass SurfaceControls rather than handles to layer state
updates

This allows us to have all the information that is stored in surface control including the layer id in the layer state so that it can be dumped directly from the client side

Test: N/A
Change-Id: I3d953382d0aad1a192ad9f767daa09a4ceefba8b
2020-10-01 17:34:18 +00:00
Steven Thomas
dd7bf2fea5 Add compatibility param to setFrameRate() api
Add a compatiblity param to the setFrameRate() api, so the system has
more info to decide the device frame rate when there are multiple
competing preferences.

I also changed the plumbing for setFrameRate() to go directly to surface
flinger, instead of through buffer queue. We're trying to avoid changes
to buffer queue code, to avoid disturbing the prebuilts.

Bug: 137287430

Test: Added new cts tests to verify behavior of the compatibility param.
      cts-tradefed run commandAndExit cts-dev --module CtsGraphicsTestCases --test android.graphics.cts.SetFrameRateTest

Test: /data/nativetest64/SurfaceFlinger_test/SurfaceFlinger_test --gtest_filter='SetFrameRateTest.*'

Change-Id: I9123afee2ba63d01ff35fb2b257a1ee0e4928ddd
2020-02-17 00:38:43 -08:00
Valerie Hau
d6a222eab0 Pass back frame event stats
Adding frame event stats to SurfaceControlStats
Not exposing to ASurfaceControlStats

Bug: 141939081
Test: build, boot
Change-Id: If64056514be6b5161d52f5e8c2cc499bd8389099
2020-01-29 20:01:38 -08:00
Steven Thomas
6cf051ef89 Add setFrameRate() api
setFrameRate() is a new api in Android 11 that will enable apps to
specify their intended frame rate.

Bug: 143912624
Bug: 137287430

Test: Added a new CTS test - android.graphics.cts.SetFrameRateTest.

Change-Id: I922573c0d704e2e0ce4cfc2a462f14dce8cb7a79
2020-01-22 13:20:42 -08:00
Valerie Hau
ec453e1423 Adding transformHint to callbacks
Bug: 141939598, 133512804
Test: build, boot, manual
Change-Id: I58411368e5187b3a23eb9e8ac9abbf1cb1a5d97e
2019-10-21 14:43:28 -07:00
Valerie Hau
5e18c43fa7 Do not crash on invalid dataspace
Prior logic caused device to crash when setting the dataspace for a
layer to hdr on a non-hdr device.  Update to log the failure and perform
a no-op to match framework APIs.

Bug: 140029823
Test: build, boot, CtsViewTestCases:android.view.cts.ASurfaceControlTest
Change-Id: I9baf88a6d787e043b440ad4c2ebeb4c7a1fd90a2
2019-08-26 14:23:52 -07:00
Vishnu Nair
1ad69541a4 Handle NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY flag in ASurfaceTransaction
BufferStateLayer ignores NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY flag if its set as part of
the transform.

Fix this by calling Transaction::setTransformToDisplayInverse when calling
ASurfaceTransaction_setGeometry.

Bug: 133330435
Test: Test landscape orientation in test app
Test: go/wm-smoke
Change-Id: Id499448d822425e5b7be4efed7f448c4e4378b87
2019-05-23 09:09:09 +00:00
Marissa Wall
bb9b14f020 ASurfaceControl: fix surface damage
There are two problems with surface control.
1) By merging the rects, the Region turned into 0,0,0,0 instead of
an or of the Rects.
2) In the case where an app intends to have a region of 0,0,0,0,
we should treat it the same as a region of 0,0,-1,-1.

Bug: 131175047
Test: ASurfaceControl
Change-Id: Ib2e3b90ac215e069d3d3c2eca81ff1013b4287aa
2019-04-23 14:10:15 -07:00
TreeHugger Robot
5ea4f3ce4e Merge "ASurfaceControl: dataspace (1/2)" 2019-02-11 20:36:39 +00:00
Marissa Wall
7f24f79bc8 ASurfaceControl: dataspace (1/2)
Allow dataspace to be set on the SurfaceControl.

Test: atest CtsViewTestCases:android.view.cts.ASurfaceControlTest
Bug: 80477568
Change-Id: Idc12d0a4024fc21d570c5190af33559b818b4b08
2019-02-08 10:53:56 -08:00
Dominik Laskowski
9e7dce3833 Merge "Generalize physical display management" 2019-02-06 22:46:09 +00:00
Dominik Laskowski
3316a0a08e Generalize physical display management
This CL enables the framework to manage an arbitrary number of physical
displays. It also surfaces physical display IDs, which are stable across
reboots and encode (model, port) information that will be propagated
further up in a follow-up CL.

Bug: 116025192
Test: Boot with more than two displays
Test: Hotplug works with any number of displays
Test: Verify stable display IDs with "dumpsys display"
Change-Id: Idb2eaff66b2e0873be6ad27d337ff18b730d1331
2019-02-04 10:06:15 -08:00
Valerie Hau
6bc48231fc Combining background color transactions
Bug: 122326454
Test: ASurfaceControlTest cts test
Change-Id: Ie6d6c5d4d8a27cbf936936200d1c81619d83ca87
2019-02-01 13:18:56 -08:00
Peiyong Lin
0d04f32385 Eliminate the usage of ConfigStore.
Ideally modules above SurfaceFlinger should query ConfigStore through
ISurfaceComposer APIs. Previously getWideColorSupport directly evaluate wide
color support for built-in display, we don't want that, we should align it with
SurfaceFlinger.

BUG: 123312783
Test: Build, flash and boot. Verify in logcat.
Change-Id: I6299fe1a5483075a98adbb903d3bb68255afb699
2019-01-24 17:57:50 -08:00
Valerie Hau
5bbfd51757 Add setColor, setColorAlpha, and setColorDataspace to ASurfaceControl
Bug:122326454
Test: atest CtsViewTestCases:android.view.cts.ASurfaceControlTests

Change-Id: If41f0a6b736315dbdb829cf3f8fefc654ede9bcf
2019-01-23 12:12:27 -08:00
Marissa Wall
1be5a10c39 ASurfaceControl: add more support to NDK (1/2)
Adds several new functions and updates existing functions.
 - release fences
 - desired present time
 - alpha
 - hdr metadata

Test: atest CtsViewTestCases:android.view.cts.ASurfaceControlTest
Bug: 80477568
Change-Id: Iabda5936a51030bebabc4328dbd83108401603c2
2019-01-18 16:35:49 -08:00