Add a tool to make calls to SurfaceFlinger
The tool should make the calls to SurfaceFlinger more user friendly and
also document them.
Bug: 269188249
Test: Manually build and call the functions.
Ignore-AOSP-First: sfdo is developed on main as it depends on surfaceflinger which is developed on that branch
Change-Id: I7136c9d7e98175c320dab33369858861831289e6
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 1ef381c..25124c2 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -6541,21 +6541,14 @@
case 1001:
return NAME_NOT_FOUND;
case 1002: // Toggle flashing on surface damage.
- if (const int delay = data.readInt32(); delay > 0) {
- mDebugFlashDelay = delay;
- } else {
- mDebugFlashDelay = mDebugFlashDelay ? 0 : 1;
- }
- scheduleRepaint();
+ sfdo_setDebugFlash(data.readInt32());
return NO_ERROR;
case 1004: // Force composite ahead of next VSYNC.
case 1006:
- scheduleComposite(FrameHint::kActive);
+ sfdo_scheduleComposite();
return NO_ERROR;
case 1005: { // Force commit ahead of next VSYNC.
- Mutex::Autolock lock(mStateLock);
- setTransactionFlags(eTransactionNeeded | eDisplayTransactionNeeded |
- eTraversalNeeded);
+ sfdo_scheduleCommit();
return NO_ERROR;
}
case 1007: // Unused.
@@ -6800,19 +6793,13 @@
return NO_ERROR;
}
case 1034: {
- auto future = mScheduler->schedule(
- [&]() FTL_FAKE_GUARD(mStateLock) FTL_FAKE_GUARD(kMainThreadContext) {
- switch (n = data.readInt32()) {
- case 0:
- case 1:
- enableRefreshRateOverlay(static_cast<bool>(n));
- break;
- default:
- reply->writeBool(isRefreshRateOverlayEnabled());
- }
- });
-
- future.wait();
+ n = data.readInt32();
+ if (n == 0 || n == 1) {
+ sfdo_enableRefreshRateOverlay(static_cast<bool>(n));
+ } else {
+ Mutex::Autolock lock(mStateLock);
+ reply->writeBool(isRefreshRateOverlayEnabled());
+ }
return NO_ERROR;
}
case 1035: {
@@ -8740,6 +8727,33 @@
std::move(hwcDump), &displays);
}
+// sfdo functions
+
+void SurfaceFlinger::sfdo_enableRefreshRateOverlay(bool active) {
+ auto future = mScheduler->schedule(
+ [&]() FTL_FAKE_GUARD(mStateLock)
+ FTL_FAKE_GUARD(kMainThreadContext) { enableRefreshRateOverlay(active); });
+ future.wait();
+}
+
+void SurfaceFlinger::sfdo_setDebugFlash(int delay) {
+ if (delay > 0) {
+ mDebugFlashDelay = delay;
+ } else {
+ mDebugFlashDelay = mDebugFlashDelay ? 0 : 1;
+ }
+ scheduleRepaint();
+}
+
+void SurfaceFlinger::sfdo_scheduleComposite() {
+ scheduleComposite(SurfaceFlinger::FrameHint::kActive);
+}
+
+void SurfaceFlinger::sfdo_scheduleCommit() {
+ Mutex::Autolock lock(mStateLock);
+ setTransactionFlags(eTransactionNeeded | eDisplayTransactionNeeded | eTraversalNeeded);
+}
+
// gui::ISurfaceComposer
binder::Status SurfaceComposerAIDL::bootFinished() {
@@ -9433,6 +9447,26 @@
return binderStatusFromStatusT(status);
}
+binder::Status SurfaceComposerAIDL::enableRefreshRateOverlay(bool active) {
+ mFlinger->sfdo_enableRefreshRateOverlay(active);
+ return binder::Status::ok();
+}
+
+binder::Status SurfaceComposerAIDL::setDebugFlash(int delay) {
+ mFlinger->sfdo_setDebugFlash(delay);
+ return binder::Status::ok();
+}
+
+binder::Status SurfaceComposerAIDL::scheduleComposite() {
+ mFlinger->sfdo_scheduleComposite();
+ return binder::Status::ok();
+}
+
+binder::Status SurfaceComposerAIDL::scheduleCommit() {
+ mFlinger->sfdo_scheduleCommit();
+ return binder::Status::ok();
+}
+
binder::Status SurfaceComposerAIDL::getGpuContextPriority(int32_t* outPriority) {
*outPriority = mFlinger->getGpuContextPriority();
return binder::Status::ok();