summaryrefslogtreecommitdiff
path: root/libs/gui/SurfaceControl.cpp
AgeCommit message (Collapse)Author
2025-04-07Revert "Ensure Choreographer is held as sp<> in SurfaceControl." Anton Ivanov
This reverts commit 9045666047d55134c2e4f0108a88b5799653003e. Reason for revert: Supsected cause for b/405669080 Test: presubmit Flag: EXEMPT refactor Bug: 405669080 (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:ade9b0ca6046beae913335000cdd398ac4381bb9) Merged-In: I96c45abfe8446c924e9ea31f822e040134e87db9 Change-Id: I96c45abfe8446c924e9ea31f822e040134e87db9
2025-03-17Ensure Choreographer is held as sp<> in SurfaceControl. Anton Ivanov
Test: ChoreographerTests pass Flag: EXEMPT refactor Bug: 393217449 Change-Id: I60d42f383d4b73b60de1a7a1bbeec5170b805ebb
2025-02-26Revert^2 "Harden construction sites of android::StrongPointer." Anton Ivanov
This reverts commit f73db7a6242e297ead71df0d0d1fb3a8515245d3. Reason for revert: Scope restricted to sp<>::make which is a safe replacement for assignment from new. Bug: 393217449 Test: ChoreographerTests pass locally. Flag: EXEMPT_refactor Change-Id: I9a38c54c06cc64da099d282c05ccf20f40b70a72
2025-02-19Revert "Harden construction sites of android::StrongPointer." Priyanka Advani (xWF)
This reverts commit 81793808b9347a52dd979e4b3d5d9d10fc8c4915. Reason for revert: Droidmonitor created revert due to b/397788382. Will be verifying through ABTD before submission. Change-Id: Idd58b82a5a5380053cdff4e7b92eafa66b2c2782
2025-02-17Harden construction sites of android::StrongPointer. Anton Ivanov
Bug: 393217449 Test: presubmit Flag: EXEMPT_refactor Change-Id: Icf703aed608531e9b302b299481af00a52074731
2025-01-14Remove obsolete BLASTBufferQueue constructor Vishnu Nair
This constructor may apply a transaction using the default apply token. Calling update after construction allows the caller to specify the token. Remove the constructor since its redundant and maybe error prone in cases where the caller needs to specify a token. Bug: 386289111 Test: presubmit Flag: EXEMPT refactor Change-Id: Id4f196b029a5c07e2b3c299d14b81f9c548d6d6b
2024-09-20Fix the input info missing for SurfaceView Wenhui Yang
Layer snapshots with buffers but without inputinfo were not sent to input or other window info listeners. This was due to a bug in how we checked to see if the layer needed an input info. FIx this to send SurfaceView layers to window info listeners. Fixes: 365167765 Test: LayerSnapshotTest Test: LayerLifecycleManagerTest Flag: EXEMPT bugfix Change-Id: I49e5d1e503af860a8324cc8b36589748ca2b7a25
2023-02-01Framework code for Attached Choreographer. Rachel Lee
Allows a direct association of a Layer (via LayerHistory) to attached choreographer. The EventThread checks whether the vsync is in phase for a choreographer. Bug: 255838011 Test: atest AttachedChoreographerNativeTest Change-Id: I9cb35bced5e6d4509609ad7698ab2902a31d5b98
2022-10-07Add layer name to layer_state_t and SurfaceControl Patrick Williams
This information will be used in subsequent CLs to trace layer cache events. Bug: 244218818 Test: presubmits Change-Id: I98bcd97310e3a2f061994481911073e8a1545cab
2022-04-12Migrate ISurfaceComposerClient to AIDL Huihong Luo
Migrate and clean up ISurfaceComposerClient to aidl, removed the deprecated createWithParent method, removed non used parameters. Bug: 172002646 Test: atest libgui_test Change-Id: I8ceb7cd90104f2ad9ca72c8025f6298de1fb1ba0
2022-03-22SurfaceControl: Ensure unused fields are zeroed Robert Carr
Otherwise we could leak uninitialized memory to an untrusted process. Bug: 214999987 Test: Existing tests pass Change-Id: I87993fbb920b3af938a311e6afc15383d571823a
2022-03-18Support setBuffer w/ release callback John Reck
Allow setBuffer to take a release callback without passing a frame number. A fallback frame number on the target SurfaceControl is used instead. Bug: 220897032 Test: SurfaceControlTest CTS Change-Id: Ib110755e2887396d41a5d52af1305ccc2bf0e9bd
2021-06-17SF: increase the number of buffers for SurfaceView Ady Abraham
3 buffers are not sufficient for most apps to render at high refresh rates. This change increases the maxAcquiredBufferCount on the buffer queue for all surfaces, and removes the hwui-specific extra buffer allocations. All Surfaces connected to SurfaceFlinger will have now enough buffers to account for configured 'debug.sf.late.app.duration' value. Test: Run backpressure based game on 60Hz and 120Hz and collect traces Bug: 188553729 Change-Id: Ib8fda5db3f48c3bfc6fbf07167b4313674512cee
2021-05-10Fix java SurfaceControl BBQ wrapper update path Vishnu Nair
We were passing in the wrong surface control by mistake which meant BlastBufferQueue would fight with the parent SurfaceControl. Test: repro steps in bug Fixes: 187397208 Change-Id: I71b1fa1d2d537411d4e6a3ec09c1189a1e7199ff
2021-04-15SurfaceFlinger: Prepare to remove BufferQueueLayer Robert Carr
To prepare to remove BufferQueueLayer we port over the public Java API (getSurface) and a few remaining clients (largely tests), by returning a BBQ from getSurface. Bug: 185492007 Test: Existing tests pass Change-Id: I0ec0d765659783e1bdbb3f243ad60e3355cfdf4f
2021-03-18Extract ParcelableUtils to avoid code duplication Marin Shalamanov
Currently the SAFE_PARCEL macros are copies on multiple places. This CL extracts them in a single ParcelableUtils. Additionally in SAFE_PARCEL also the stringified error is printed. Bug: 179116474 Test: presubmit Change-Id: Ie09c3a9753b5742be14fe3cdb0061d5c64465e66
2021-02-22Introduce DynamicDisplayInfo Marin Shalamanov
In this CL we introduce the getDynamicDisplayInfo call on ISurfaceComposer which replaces the existing - getDisplayModes - getActiveDisplayMode - getColorModes - getActiveColorMode - getHdrCapabilities This way all display properties can be queried atomically. The current DisplayInfo class is moved to the androd::ui namespace and it's renamed to StaticDisplayInfo. ui::DisplayMode is now LightFlattenable and the mode ID is int32_t instead of size_t in order to prevent serialization problems. Additionally we add the ID field to ui::DisplayMode. This way we no longer need the supported display IDs to be from 0 to N-1. Bug: 159590486 Bug: 180539476 Test: presubmit, manually test that device boots Change-Id: I52b170913ce47cb5df2e8417e6cc95d395df1fda
2020-10-01Pass surface control instead of handle as reference to layers in Pablo Gamito
LayerState Allows us to have access to the layer id stored in surface control so that it can be dumped when tracing the transaction merges Test: Existing tests Change-Id: I3e466c69585937d8ce74a29a49fdbb7b3353a460
2020-09-25Add LayerId to SurfaceControl and LayerState when created Pablo Gamito
Allows us to then dump the LayerState on transaction merges and have an id to associate the LayerState with a layer Test: Check if layer id is available in the LayerState when we dump the LayerState on merges Change-Id: I5046835d6a82574110125c7dbdf2098bd10ac296
2020-09-25Add functions to parcel nullable surface controls Pablo Gamito
Test: None Change-Id: Ia1bb5771b9d5ea9f70519d92f37ba95d57b4d6fe
2020-09-25Convert SurfaceControl parceling to SAFE_PARCEL Pablo Gamito
Test: Existing tests Change-Id: I7618f9677e538fca90ae5cfb0693e5926701f564
2020-06-23Read everything and return NULL in SurfaceControl. Garfield Tan
We used to early return when we got an invalid SurfaceControl for any reason, but that'll mess up the Parcel location and make all following reading from this Parcel fail in a very obscure way. To avoid that let's read up everything SurfaceControl wrote and return NULL if it indeed is invalid. Also change to call readStrongBinder() that can return status_t, and check all status_t returned by readStrongBinder() and readNullableStrongBinder() to catch all cases. Note this issue came to ARC++ because our ArcSystemUI crashed earlier, which is the root cause to the invalid SurfaceControl. Therefore this change doesn't aim to fix any issue in normal code path. Bug: 159627603 Test: atest ActivityVisibilityTests#testTurnScreenOnSingleTask failed with using invalid SurfaceControl rather than ClassNotFoundException. Change-Id: Icd2f694f2696458041f449f74186653791236010
2020-02-18SurfaceControl: C++ Binding Lifetime refactoring Robert Carr
First we eliminate the "dropReferenceTransaction" semantic. This semantic reparents the surface to null if the C++ object dies before release() is called. This is a legacy semantic from before SurfaceControls were reference counted. I point that it's unused by noting that all Java code paths will lead to calling release() in the JNI code before dropping the last reference. With dropReferenceTransaction gone we can remove mOwned it has no further uses. With these gone we now remove release() all together on the native side. This means that mClient and mHandle will only be written from the constructor and destructor making access to them thread-safe as long as you hold an sp<> to the SurfaceControl. This should prevent bugs like we've had in the past about who calls release when, no one calls it! The final question is: is removing the call to release on the Java side safe? We still need an explicit Java binding release call so we can drop the native reference in a timely fashion. This then breaks down in to two scenarios: 1. We are the last reference 2. Someone else holds a reference If we are in the first scenario, then calling release or not is equivalent to just dropping the reference. If we are in the second scenario, calling release() will be unsafe. Because we could at any time overwrite mClient/mHandle after the other ref holder had verified it was null. The main path I know of for how native code could acquire a second reference to the JNI owned SurfaceControl is via Transaction::registerSurfaceControlForCallback then if we release while Transaction::writeToParcel is running, it will inevitably segfault. This change could lead to the extension of life-time for SurfaceControl.cpp objects while the Transaction containing them is alive (but previously the SurfaceControl.cpp proxy would have been released). I also argue this is safe since the sp<IBinder> itself was reffed in another place in the Transaction so the lifetime of the actual server side resource isn't extended at all. Only the lightweight proxy object. Bug: 149055469 Bug: 149315421 Test: Existing tests pass. Change-Id: Ibd4d1804ef18a9c389c7f9112d15872cfe44b22e
2019-11-06Pass back transformHint on Surface Creation Valerie Hau
Bug: 141939598 Test: build, boot, SurfaceFlinger_test, libgui_test, libsurfaceflinger_unittest Change-Id: I35a77ac1399ad4248cb1c2357afb869de4c15170
2019-07-16Store layer state changes by layer handle in Transaction objects Vishnu Nair
Layer state changes are stored in an unordered map with the surface control as the key and state changes as the value. This causes a few problems when merging the transactions. If transactions contained state changes from a cloned surface control then it will not be merged. This will cause ordering issues when the transaction is applied since the changes are stored in and unordered map. When parcelling transactions, a new surface control is created from the existing one and this surfaces the problem more frequently. Instead we store the layer changes by the layer handle which is consistent across processes. Test: atest SurfaceFlinger_test Test: go/wm-smoke Change-Id: I2e041d70ae24db2c1f26ada003532ad97f667167
2019-06-26Merge "Remove SurfaceControl.destroy function" Chavi Weingarten
2019-06-12Make SurfaceControl Transaction parcelable 2/2 Vishnu Nair
Allow clients to send SurfaceControl Transactions across processes to enable more advanced synchronization use cases. Bug: 132205507 Test: atest SurfaceFlinger_test Change-Id: I20a33cafc0960e73f9a2c3d740f81319e02b68ff
2019-06-10Remove SurfaceControl.destroy function chaviw
The destroy function was only used temporarily instead of all call points calling reparent(null) explicitly. Removing the Java destroy request so no need for the SurfaceControl.destroy method anymore. Test: SurfaceControlTest Change-Id: If69e030f3babf83a6382f85a26f0bb1eb451dc23
2019-02-07Merge "SurfaceControl life-cycle refactoring." Rob Carr
2019-02-05SurfaceControl life-cycle refactoring. Robert Carr
We provide a method called "release" which allows the client to drop its references without reparenting the SurfaceControl to null as the destructor would. The Java and NDK API's already have this method but it's not perfectly functional at the moment. Additionally we remove the strange pass-through of clear to destroy and expose destroy directly. Test: Builds Bug: 123587983 Change-Id: Ia89ada1476daef97e6f30d50a57065c3636a6489
2019-02-01SurfaceControl: Allow calling destroy when mOwned is true Robert Carr
mOwned was just put in place to prevent the finalizer in SysUI from destroying leashes, it was never meant to prevent explicit calls to destroy. On another note we should probably remove destroy or call it "release" but we can come back to that. Change-Id: I72b0ab467105dc63094994de5482cec651fffaa3 Fixes: 113820778 Test: Builds
2019-01-29Expose IGBP getter Robert Carr
Useful for comparing a SurfaceControl to an existing Surface, but without calling getSurface which may cause the allocation of an as of yet unexisting Surface wrapper. Bug: 122588130 Test: None Change-Id: I5742bf6af06bd48013a2418b583de8eeeecba2df
2019-01-08SurfaceFlinger: Remove removeLayer Robert Carr
We remove explicit layer destruction and replace it with reparent->null, completing the transition to a reference counted model. Test: Manual Bug: 62536731 Bug: 111373437 Bug: 111297488 Change-Id: I8ac7c5c5125e1c8daf84b42db00e1dd93a544bb5
2019-01-04SurfaceFlinger: Removed createScopedConnection. Robert Carr
Scoped connections existed to constrain clients to only making surfaces with parents. However now that we support off-screen parents this is no longer required and we can use normal connections everywhere. We take however care that only priviledged clients can place layers in the current state. Test: Manual Bug: 62536731 Bug: 111373437 Bug: 111297488 Change-Id: I0a034767e92becec63071d7b1e3e71b95d505b77
2018-08-06Replace magic 0 with enum in surfacecontrol Aleks Rozman
Test: m Fixes: nothing Change-Id: Iab9348dcf57bfb72069655ec9fc7f443d30f3e1b
2018-06-05Replace NULL/0 with nullptr Yi Kong
Fixes -Wzero-as-null-pointer-constant warning. clang-tidy -checks=modernize-use-nullptr -p compile_commands.json -fix ... Test: m Bug: 68236239 Change-Id: I3a8e982ba40f9b029bafef78437b146a878f56a9
2018-01-29Fix issue with Surface loss Jorim Jaggi
Some remote animations didn't use all surfaces, meaning that these became unreachable objects in the object tree, meaning that they we're finalized during the animation, causing the leash to be destroyed in SurfaceFlinger, causing to suffering because the AWT surface got released, meaning that we can never allocate the main windows Surface anymore. Fix this by not releasing surfaces that you don't own. Test: go/wm-smoke Test: Notification launch animation over app Change-Id: Ia99b4e814bfb286ae1d3639c525fc8f6c42c0e0f Fixes: No bug yet, but expect to have a chaselist bug soon!
2017-12-05Make SurfaceControl parcelable (2/2) Jorim Jaggi
Bug: 69145041 Test: Send SurfaceControl over binder Change-Id: I47aa4a4bb39fab3ed4d1d30d4e472de7cbc5ca38
2017-10-11SurfaceFlinger Transactions as distinct objects. Robert Carr
Essentially a process global singleton for transactions is not so useful once we make surface control public API as process isn't something an app developer is really thinking about. It's also nice that we get to delete two of the plumbing layers. Test: Boots Change-Id: I8864bd7e2f5865e3c0a425cf82f9928211911774
2017-09-21Added native functionality to create a color layer. chaviw
Added a new layer that can draw a specified color and specified alpha. This will replace creating a dim layer and allow any colors, not just black, to be set for this layer. Test: Added tests to Transaction_test.cpp to test with a color and a color layer with alpha. Change-Id: I00a38d1bbc01093026f088c3347454281bdc2b8c
2017-09-20Re-parent invoked on child instead of on parent. chaviw
The function to re-parent an individual child is now invoked on the child instead of the parent. This ensures the child ends up with the last parent set if multiple reparent requests are made in the same transaction. This also allows adding a parent to a layer that didn't have one previously. Test: Transaction_test -> Reparent, ReparentToNoParent, ReparentFromNoParent Change-Id: Idab429eb2dca5a4ae1b020a5a7629d719dd4d995
2017-08-23Add a re-parent function to re-parent a specific child. chaviw
This is similar to reparentChildren, but the reparentChild will only re-parent a specific child to the new parent and not all children. Test: Added test in Transaction_test for reparentChild. Change-Id: I4275e0d5f1d5601b489956753c78a56d1a5d4c1c
2017-06-16Add method to explicitly create Surface. Bryce Lee
It is sometimes necessary for a SurfaceControl client to request the associated Surface object be created rather than reuse the cached value. This changelist adds an additional method that performs the same creation operations as if the Surface object was created for the first time. Bug: 62108743 Test: go/wm-smoke Change-Id: I2f460f20b2d16ed9ff81cb36842bcd2f8641e03c
2017-04-12SurfaceFlinger: Add parent-less relative layering. Robert Carr
This is a temporary functionality for the intermediate state where not all child-surface like things in WM land are ported to use Child Surfaces. In particular, we have ported SurfaceView to use child surfaces and relative Z ordering. However the TV frameworks provide a View framework component which overlays views over the SurfaceView but below the main application window. Since we have not ported View framework surfaces to use child layers, there is nothing the WM or View Framework can do about this situation. Luckily the WM API's to have requested this are @hide but we have the one media framework component using it. In order to solve this issue we provide a method to set Z ordering relative to another window without inheriting its coordinate space as a child window would. This way the WM can recognize these TYPE_APPLICATION_MEDIA_OVERLAY windows and Z-order them at -1 with respect to the parents (and the SurfaceView can be at -2). Test: Included in transaction tests. Also manual test of bug repro steps with accomp frameworks/base CL Bug: 36693738 Change-Id: I921852d3d34f67f79ec745b9703f9e679867e7a1
2017-03-30Fix seamless rotation with SurfaceView WM bypass. Robert Carr
First a brief review on seamless rotation. In seamless rotation the WM will do the following atomically: 1. Update the display transform. 2. Set window transforms to make the surfaces at their old size appear at the correct location in the new coordinate space. 3. Set a flag to undo the transforms when the surfaces resize. However, windows with NATIVE_WINDOW_TRANSFORM_DISPLAY needed to be special cased. The flag will perform step 2 in terms of buffer mapping, but not in terms of bounds computation. So to compensate the WM would apply the transform to the bounds, set these bounds, and then skip applying the transform matrix (as the buffer is transformed by the flag). Now that the WM can't see the Camera view, it can't implement this special logic and the Camera view inherits the parent transform. We compensate for this in SurfaceFlinger by omitting parent rotation transform components for Surfaces with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY. To some extent this breaks arbitrary rotation for surfaces with NATIVE_WINDOW_TRANSFORM_INVERSE_DISPLAY but this is essentially ok: 1. We lived with that bug until N-MR1 2. We fixed it in N-MR1 because the camera was falling back to ROTATE a lot which shouldn't be happening anymore, following introduction of specifying rotation animation in manifest. Test: Rotate camera, disable HWC, rotate camera some more. Switch to front camera, repeat. Bug: 36230754 Bug: 36727915 Change-Id: Ied390c9cb3968fcce32a84ee7947f699746fdc81
2017-03-01Merge changes from topic 'surfaceview-without-wm' Rob Carr
* changes: Add detachChildren transaction. Add deferTransaction variant taking GraphicBufferProducer.
2017-02-27Add detachChildren transaction. Robert Carr
Add SurfaceControl#detachChildren for use by the WindowManager. This method is used in cases where the WM would previously preserve windows the client tried to destroy. For example, when becoming invisible (in the activity lifecycle sense, not in the SurfaceFlinger sense) an app will destroy its child surfaces. Previously the WM would keep child windows alive until the animation finishes to prevent glitches. The new scheme for this is the WM will detach the children at this point, at which point the parent layer becomes the owner of the children and the WM can control the lifecycle as it wishes. I also included a test for reparentChildren as I realized I had forgotten that. Test: New test in Transaction_test.cpp Change-Id: I79c22b2ccccceb9bdcc37b70c491bdf33dcf83d2
2017-02-27Add deferTransaction variant taking GraphicBufferProducer. Robert Carr
For SurfaceView using child layers, the client framework will not have access to the Handle* for the parent surface, but still needs a way to defer transactions to it's frames. Test: Tested with corresponding SurfaceView modifications and existing tests. Change-Id: I6f01c360e85a95ff0ab08db406741221152e5d5c
2017-02-21SurfaceControl: Correct setMatrix parameter naming. Robert Carr
The first parameter dsdx controls the X scaling. The last parameter is called dtdy but controls the Y scaling. Clearly this was meant to be named dsdy. You can verify this with a quick look at Transaction_test. Test: Tried various stuff, phone still works. Change-Id: Ie9e898443350ffdcf227888a8d85efdbe1b6b033
2017-01-31Refactor how layer metadata for use by VR is propagated Albert Chaulk
from WindowManager based on feedback in frameworks/base. Since windowType and ownerUid are immutable, they are sent on creation instead of separate IPC. Bug: 30984984 Test: built locally Change-Id: I380b3cdcf6aec471fc23f1e27846ab80492e8add