Loading libs/gui/ISurfaceComposer.cpp +56 −9 Original line number Diff line number Diff line Loading @@ -17,15 +17,10 @@ // tag as surfaceflinger #define LOG_TAG "SurfaceFlinger" #include <stdint.h> #include <sys/types.h> #include <android/gui/ITransactionTraceListener.h> #include <binder/Parcel.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Parcel.h> #include <gui/IDisplayEventConnection.h> #include <gui/IGraphicBufferProducer.h> #include <gui/IRegionSamplingListener.h> Loading @@ -33,16 +28,15 @@ #include <gui/ISurfaceComposerClient.h> #include <gui/LayerDebugInfo.h> #include <gui/LayerState.h> #include <stdint.h> #include <sys/types.h> #include <system/graphics.h> #include <ui/DisplayMode.h> #include <ui/DisplayStatInfo.h> #include <ui/DisplayState.h> #include <ui/DynamicDisplayInfo.h> #include <ui/HdrCapabilities.h> #include <ui/StaticDisplayInfo.h> #include <utils/Log.h> // --------------------------------------------------------------------------- Loading Loading @@ -761,6 +755,33 @@ public: return error; } virtual status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) { Parcel data, reply; SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor()); SAFE_PARCEL(data.writeStrongBinder, layerHandle); SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener)); const status_t error = remote()->transact(BnSurfaceComposer::ADD_FPS_LISTENER, data, &reply); if (error != OK) { ALOGE("addFpsListener: Failed to transact"); } return error; } virtual status_t removeFpsListener(const sp<gui::IFpsListener>& listener) { Parcel data, reply; SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor()); SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener)); const status_t error = remote()->transact(BnSurfaceComposer::REMOVE_FPS_LISTENER, data, &reply); if (error != OK) { ALOGE("removeFpsListener: Failed to transact"); } return error; } status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, ui::DisplayModeId defaultMode, bool allowGroupSwitching, float primaryRefreshRateMin, float primaryRefreshRateMax, Loading Loading @@ -1646,6 +1667,32 @@ status_t BnSurfaceComposer::onTransact( } return removeRegionSamplingListener(listener); } case ADD_FPS_LISTENER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> layerHandle; status_t result = data.readNullableStrongBinder(&layerHandle); if (result != NO_ERROR) { ALOGE("addFpsListener: Failed to read layer handle"); return result; } sp<gui::IFpsListener> listener; result = data.readNullableStrongBinder(&listener); if (result != NO_ERROR) { ALOGE("addFpsListener: Failed to read listener"); return result; } return addFpsListener(layerHandle, listener); } case REMOVE_FPS_LISTENER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<gui::IFpsListener> listener; status_t result = data.readNullableStrongBinder(&listener); if (result != NO_ERROR) { ALOGE("removeFpsListener: Failed to read listener"); return result; } return removeFpsListener(listener); } case SET_DESIRED_DISPLAY_MODE_SPECS: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> displayToken = data.readStrongBinder(); Loading libs/gui/SurfaceComposerClient.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -1982,6 +1982,15 @@ status_t SurfaceComposerClient::removeRegionSamplingListener( return ComposerService::getComposerService()->removeRegionSamplingListener(listener); } status_t SurfaceComposerClient::addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) { return ComposerService::getComposerService()->addFpsListener(layerHandle, listener); } status_t SurfaceComposerClient::removeFpsListener(const sp<gui::IFpsListener>& listener) { return ComposerService::getComposerService()->removeFpsListener(listener); } bool SurfaceComposerClient::getDisplayBrightnessSupport(const sp<IBinder>& displayToken) { bool support = false; ComposerService::getComposerService()->getDisplayBrightnessSupport(displayToken, &support); Loading libs/gui/aidl/android/gui/IFpsListener.aidl 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.gui; /** @hide */ oneway interface IFpsListener { // Reports the most recent recorded fps for the tree rooted at this layer void onFpsReported(float fps); } No newline at end of file libs/gui/include/gui/ISurfaceComposer.h +24 −10 Original line number Diff line number Diff line Loading @@ -16,21 +16,17 @@ #pragma once #include <stdint.h> #include <sys/types.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <android/gui/IFpsListener.h> #include <android/gui/IScreenCaptureListener.h> #include <android/gui/ITransactionTraceListener.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <gui/FrameTimelineInfo.h> #include <gui/ITransactionCompletedListener.h> #include <input/Flags.h> #include <math/vec4.h> #include <stdint.h> #include <sys/types.h> #include <ui/ConfigStoreTypes.h> #include <ui/DisplayId.h> #include <ui/DisplayMode.h> Loading @@ -40,7 +36,6 @@ #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> #include <ui/Rotation.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> Loading Loading @@ -354,6 +349,23 @@ public: */ virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) = 0; /* Registers a listener that streams fps updates from SurfaceFlinger. * * The listener will stream fps updates for the layer tree rooted at layerHandle. Usually, this * should be tied to a task. Layers that are not descendants of that task are out of scope for * FPS computations. * * Multiple listeners may be supported. * * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) = 0; /* * Removes a listener that was streaming fps updates from SurfaceFlinger. */ virtual status_t removeFpsListener(const sp<gui::IFpsListener>& listener) = 0; /* Sets the refresh rate boundaries for the display. * * The primary refresh rate range represents display manager's general guidance on the display Loading Loading @@ -559,6 +571,8 @@ public: GET_GPU_CONTEXT_PRIORITY, GET_EXTRA_BUFFER_COUNT, GET_DYNAMIC_DISPLAY_INFO, ADD_FPS_LISTENER, REMOVE_FPS_LISTENER, // Always append new enum to the end. }; Loading libs/gui/include/gui/SurfaceComposerClient.h +3 −0 Original line number Diff line number Diff line Loading @@ -589,6 +589,9 @@ public: const sp<IBinder>& stopLayerHandle, const sp<IRegionSamplingListener>& listener); static status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener); static status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener); static status_t removeFpsListener(const sp<gui::IFpsListener>& listener); private: virtual void onFirstRef(); Loading Loading
libs/gui/ISurfaceComposer.cpp +56 −9 Original line number Diff line number Diff line Loading @@ -17,15 +17,10 @@ // tag as surfaceflinger #define LOG_TAG "SurfaceFlinger" #include <stdint.h> #include <sys/types.h> #include <android/gui/ITransactionTraceListener.h> #include <binder/Parcel.h> #include <binder/IPCThreadState.h> #include <binder/IServiceManager.h> #include <binder/Parcel.h> #include <gui/IDisplayEventConnection.h> #include <gui/IGraphicBufferProducer.h> #include <gui/IRegionSamplingListener.h> Loading @@ -33,16 +28,15 @@ #include <gui/ISurfaceComposerClient.h> #include <gui/LayerDebugInfo.h> #include <gui/LayerState.h> #include <stdint.h> #include <sys/types.h> #include <system/graphics.h> #include <ui/DisplayMode.h> #include <ui/DisplayStatInfo.h> #include <ui/DisplayState.h> #include <ui/DynamicDisplayInfo.h> #include <ui/HdrCapabilities.h> #include <ui/StaticDisplayInfo.h> #include <utils/Log.h> // --------------------------------------------------------------------------- Loading Loading @@ -761,6 +755,33 @@ public: return error; } virtual status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) { Parcel data, reply; SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor()); SAFE_PARCEL(data.writeStrongBinder, layerHandle); SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener)); const status_t error = remote()->transact(BnSurfaceComposer::ADD_FPS_LISTENER, data, &reply); if (error != OK) { ALOGE("addFpsListener: Failed to transact"); } return error; } virtual status_t removeFpsListener(const sp<gui::IFpsListener>& listener) { Parcel data, reply; SAFE_PARCEL(data.writeInterfaceToken, ISurfaceComposer::getInterfaceDescriptor()); SAFE_PARCEL(data.writeStrongBinder, IInterface::asBinder(listener)); const status_t error = remote()->transact(BnSurfaceComposer::REMOVE_FPS_LISTENER, data, &reply); if (error != OK) { ALOGE("removeFpsListener: Failed to transact"); } return error; } status_t setDesiredDisplayModeSpecs(const sp<IBinder>& displayToken, ui::DisplayModeId defaultMode, bool allowGroupSwitching, float primaryRefreshRateMin, float primaryRefreshRateMax, Loading Loading @@ -1646,6 +1667,32 @@ status_t BnSurfaceComposer::onTransact( } return removeRegionSamplingListener(listener); } case ADD_FPS_LISTENER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> layerHandle; status_t result = data.readNullableStrongBinder(&layerHandle); if (result != NO_ERROR) { ALOGE("addFpsListener: Failed to read layer handle"); return result; } sp<gui::IFpsListener> listener; result = data.readNullableStrongBinder(&listener); if (result != NO_ERROR) { ALOGE("addFpsListener: Failed to read listener"); return result; } return addFpsListener(layerHandle, listener); } case REMOVE_FPS_LISTENER: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<gui::IFpsListener> listener; status_t result = data.readNullableStrongBinder(&listener); if (result != NO_ERROR) { ALOGE("removeFpsListener: Failed to read listener"); return result; } return removeFpsListener(listener); } case SET_DESIRED_DISPLAY_MODE_SPECS: { CHECK_INTERFACE(ISurfaceComposer, data, reply); sp<IBinder> displayToken = data.readStrongBinder(); Loading
libs/gui/SurfaceComposerClient.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -1982,6 +1982,15 @@ status_t SurfaceComposerClient::removeRegionSamplingListener( return ComposerService::getComposerService()->removeRegionSamplingListener(listener); } status_t SurfaceComposerClient::addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) { return ComposerService::getComposerService()->addFpsListener(layerHandle, listener); } status_t SurfaceComposerClient::removeFpsListener(const sp<gui::IFpsListener>& listener) { return ComposerService::getComposerService()->removeFpsListener(listener); } bool SurfaceComposerClient::getDisplayBrightnessSupport(const sp<IBinder>& displayToken) { bool support = false; ComposerService::getComposerService()->getDisplayBrightnessSupport(displayToken, &support); Loading
libs/gui/aidl/android/gui/IFpsListener.aidl 0 → 100644 +24 −0 Original line number Diff line number Diff line /* * Copyright 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.gui; /** @hide */ oneway interface IFpsListener { // Reports the most recent recorded fps for the tree rooted at this layer void onFpsReported(float fps); } No newline at end of file
libs/gui/include/gui/ISurfaceComposer.h +24 −10 Original line number Diff line number Diff line Loading @@ -16,21 +16,17 @@ #pragma once #include <stdint.h> #include <sys/types.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <android/gui/IFpsListener.h> #include <android/gui/IScreenCaptureListener.h> #include <android/gui/ITransactionTraceListener.h> #include <binder/IBinder.h> #include <binder/IInterface.h> #include <gui/FrameTimelineInfo.h> #include <gui/ITransactionCompletedListener.h> #include <input/Flags.h> #include <math/vec4.h> #include <stdint.h> #include <sys/types.h> #include <ui/ConfigStoreTypes.h> #include <ui/DisplayId.h> #include <ui/DisplayMode.h> Loading @@ -40,7 +36,6 @@ #include <ui/GraphicTypes.h> #include <ui/PixelFormat.h> #include <ui/Rotation.h> #include <utils/Errors.h> #include <utils/RefBase.h> #include <utils/Timers.h> Loading Loading @@ -354,6 +349,23 @@ public: */ virtual status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener) = 0; /* Registers a listener that streams fps updates from SurfaceFlinger. * * The listener will stream fps updates for the layer tree rooted at layerHandle. Usually, this * should be tied to a task. Layers that are not descendants of that task are out of scope for * FPS computations. * * Multiple listeners may be supported. * * Requires the ACCESS_SURFACE_FLINGER permission. */ virtual status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener) = 0; /* * Removes a listener that was streaming fps updates from SurfaceFlinger. */ virtual status_t removeFpsListener(const sp<gui::IFpsListener>& listener) = 0; /* Sets the refresh rate boundaries for the display. * * The primary refresh rate range represents display manager's general guidance on the display Loading Loading @@ -559,6 +571,8 @@ public: GET_GPU_CONTEXT_PRIORITY, GET_EXTRA_BUFFER_COUNT, GET_DYNAMIC_DISPLAY_INFO, ADD_FPS_LISTENER, REMOVE_FPS_LISTENER, // Always append new enum to the end. }; Loading
libs/gui/include/gui/SurfaceComposerClient.h +3 −0 Original line number Diff line number Diff line Loading @@ -589,6 +589,9 @@ public: const sp<IBinder>& stopLayerHandle, const sp<IRegionSamplingListener>& listener); static status_t removeRegionSamplingListener(const sp<IRegionSamplingListener>& listener); static status_t addFpsListener(const sp<IBinder>& layerHandle, const sp<gui::IFpsListener>& listener); static status_t removeFpsListener(const sp<gui::IFpsListener>& listener); private: virtual void onFirstRef(); Loading