The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | // tag as surfaceflinger |
| 18 | #define LOG_TAG "SurfaceFlinger" |
| 19 | |
Huihong Luo | 6fac523 | 2021-11-22 16:05:23 -0800 | [diff] [blame] | 20 | #include <android/gui/IDisplayEventConnection.h> |
Huihong Luo | ecc1f90 | 2021-11-20 11:55:05 -0800 | [diff] [blame] | 21 | #include <android/gui/IRegionSamplingListener.h> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 22 | #include <binder/IPCThreadState.h> |
| 23 | #include <binder/IServiceManager.h> |
Alec Mouri | adebf5c | 2021-01-05 12:57:36 -0800 | [diff] [blame] | 24 | #include <binder/Parcel.h> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 25 | #include <gui/IGraphicBufferProducer.h> |
Mathias Agopian | 2b5dd40 | 2017-02-07 17:36:19 -0800 | [diff] [blame] | 26 | #include <gui/ISurfaceComposer.h> |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 27 | #include <gui/LayerState.h> |
Ady Abraham | 07d03c4 | 2023-09-27 19:15:08 -0700 | [diff] [blame] | 28 | #include <gui/SchedulingPolicy.h> |
Anton Ivanov | ed63243 | 2025-03-04 10:28:38 -0800 | [diff] [blame] | 29 | #include <gui/TransactionState.h> |
Marin Shalamanov | 3b1f7bc | 2021-03-16 15:51:53 +0100 | [diff] [blame] | 30 | #include <private/gui/ParcelUtils.h> |
Alec Mouri | adebf5c | 2021-01-05 12:57:36 -0800 | [diff] [blame] | 31 | #include <stdint.h> |
| 32 | #include <sys/types.h> |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 33 | #include <system/graphics.h> |
Marin Shalamanov | a7fe304 | 2021-01-29 21:02:08 +0100 | [diff] [blame] | 34 | #include <ui/DisplayMode.h> |
Lajos Molnar | 67d8bd6 | 2014-09-11 14:58:45 -0700 | [diff] [blame] | 35 | #include <ui/DisplayStatInfo.h> |
Dominik Laskowski | 3cb3d4e | 2019-11-21 11:14:45 -0800 | [diff] [blame] | 36 | #include <ui/DisplayState.h> |
Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 37 | #include <ui/DynamicDisplayInfo.h> |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 38 | #include <ui/HdrCapabilities.h> |
Jamie Gennis | 134f042 | 2011-03-08 12:18:54 -0800 | [diff] [blame] | 39 | #include <utils/Log.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 40 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | // --------------------------------------------------------------------------- |
| 42 | |
Leon Scroggins III | e7c51c6 | 2022-02-01 15:53:54 -0500 | [diff] [blame] | 43 | using namespace aidl::android::hardware::graphics; |
| 44 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | namespace android { |
| 46 | |
Huihong Luo | f502922 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 47 | using gui::DisplayCaptureArgs; |
Huihong Luo | 6fac523 | 2021-11-22 16:05:23 -0800 | [diff] [blame] | 48 | using gui::IDisplayEventConnection; |
Huihong Luo | ecc1f90 | 2021-11-20 11:55:05 -0800 | [diff] [blame] | 49 | using gui::IRegionSamplingListener; |
chaviw | 60c9d3e | 2021-06-04 12:52:17 -0500 | [diff] [blame] | 50 | using gui::IWindowInfosListener; |
Huihong Luo | f502922 | 2021-12-16 14:33:46 -0800 | [diff] [blame] | 51 | using gui::LayerCaptureArgs; |
Peiyong Lin | 9f03447 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 52 | using ui::ColorMode; |
| 53 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 54 | class BpSurfaceComposer : public BpInterface<ISurfaceComposer> |
| 55 | { |
| 56 | public: |
Chih-Hung Hsieh | e2347b7 | 2016-04-25 15:41:05 -0700 | [diff] [blame] | 57 | explicit BpSurfaceComposer(const sp<IBinder>& impl) |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | : BpInterface<ISurfaceComposer>(impl) |
| 59 | { |
| 60 | } |
| 61 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 62 | virtual ~BpSurfaceComposer(); |
| 63 | |
Anton Ivanov | ed63243 | 2025-03-04 10:28:38 -0800 | [diff] [blame] | 64 | status_t setTransactionState(TransactionState&& state) override { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 65 | Parcel data, reply; |
| 66 | data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor()); |
Anton Ivanov | ed63243 | 2025-03-04 10:28:38 -0800 | [diff] [blame] | 67 | SAFE_PARCEL(state.writeToParcel, &data); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 68 | |
Anton Ivanov | ed63243 | 2025-03-04 10:28:38 -0800 | [diff] [blame] | 69 | if (state.mFlags & ISurfaceComposer::eOneWay) { |
Robert Carr | 79dc06a | 2022-02-22 15:28:59 -0800 | [diff] [blame] | 70 | return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, |
| 71 | data, &reply, IBinder::FLAG_ONEWAY); |
| 72 | } else { |
| 73 | return remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, |
| 74 | data, &reply); |
| 75 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 76 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | }; |
| 78 | |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 79 | // Out-of-line virtual method definition to trigger vtable emission in this |
| 80 | // translation unit (see clang warning -Wweak-vtables) |
| 81 | BpSurfaceComposer::~BpSurfaceComposer() {} |
| 82 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 83 | IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer"); |
| 84 | |
| 85 | // ---------------------------------------------------------------------- |
| 86 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 87 | status_t BnSurfaceComposer::onTransact( |
| 88 | uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) |
| 89 | { |
Huihong Luo | d3d8f8e | 2022-03-08 14:48:46 -0800 | [diff] [blame] | 90 | switch (code) { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 91 | case SET_TRANSACTION_STATE: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 92 | CHECK_INTERFACE(ISurfaceComposer, data, reply); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 93 | |
Anton Ivanov | ed63243 | 2025-03-04 10:28:38 -0800 | [diff] [blame] | 94 | TransactionState state; |
| 95 | SAFE_PARCEL(state.readFromParcel, &data); |
| 96 | return setTransactionState(std::move(state)); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 97 | } |
Ady Abraham | 07d03c4 | 2023-09-27 19:15:08 -0700 | [diff] [blame] | 98 | case GET_SCHEDULING_POLICY: { |
| 99 | gui::SchedulingPolicy policy; |
| 100 | const auto status = gui::getSchedulingPolicy(&policy); |
| 101 | if (!status.isOk()) { |
| 102 | return status.exceptionCode(); |
| 103 | } |
| 104 | |
| 105 | SAFE_PARCEL(reply->writeInt32, policy.policy); |
| 106 | SAFE_PARCEL(reply->writeInt32, policy.priority); |
| 107 | return NO_ERROR; |
| 108 | } |
| 109 | |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 110 | default: { |
Mathias Agopian | 83c0446 | 2009-05-22 19:00:22 -0700 | [diff] [blame] | 111 | return BBinder::onTransact(code, data, reply, flags); |
Jesse Hall | 6c913be | 2013-08-08 12:15:49 -0700 | [diff] [blame] | 112 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 114 | } |
| 115 | |
Dominik Laskowski | dcb38bb | 2019-01-25 02:35:50 -0800 | [diff] [blame] | 116 | } // namespace android |