blob: ae4b74e03b67c8c49cd6d1e0eb7f565df5127c97 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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 Luo6fac5232021-11-22 16:05:23 -080020#include <android/gui/IDisplayEventConnection.h>
Huihong Luoecc1f902021-11-20 11:55:05 -080021#include <android/gui/IRegionSamplingListener.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070022#include <binder/IPCThreadState.h>
23#include <binder/IServiceManager.h>
Alec Mouriadebf5c2021-01-05 12:57:36 -080024#include <binder/Parcel.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080025#include <gui/IGraphicBufferProducer.h>
Mathias Agopian2b5dd402017-02-07 17:36:19 -080026#include <gui/ISurfaceComposer.h>
Robert Carr4cdc58f2017-08-23 14:22:20 -070027#include <gui/LayerState.h>
Ady Abraham07d03c42023-09-27 19:15:08 -070028#include <gui/SchedulingPolicy.h>
Anton Ivanovd7b71ac2025-03-18 13:41:02 -070029#include <gui/TransactionState.h>
Marin Shalamanov3b1f7bc2021-03-16 15:51:53 +010030#include <private/gui/ParcelUtils.h>
Alec Mouriadebf5c2021-01-05 12:57:36 -080031#include <stdint.h>
32#include <sys/types.h>
Michael Wright28f24d02016-07-12 13:30:53 -070033#include <system/graphics.h>
Marin Shalamanova7fe3042021-01-29 21:02:08 +010034#include <ui/DisplayMode.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070035#include <ui/DisplayStatInfo.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080036#include <ui/DisplayState.h>
Marin Shalamanov228f46b2021-01-28 21:11:45 +010037#include <ui/DynamicDisplayInfo.h>
Dan Stozac4f471e2016-03-24 09:31:08 -070038#include <ui/HdrCapabilities.h>
Jamie Gennis134f0422011-03-08 12:18:54 -080039#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080040
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041// ---------------------------------------------------------------------------
42
Leon Scroggins IIIe7c51c62022-02-01 15:53:54 -050043using namespace aidl::android::hardware::graphics;
44
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045namespace android {
46
Huihong Luof5029222021-12-16 14:33:46 -080047using gui::DisplayCaptureArgs;
Huihong Luo6fac5232021-11-22 16:05:23 -080048using gui::IDisplayEventConnection;
Huihong Luoecc1f902021-11-20 11:55:05 -080049using gui::IRegionSamplingListener;
chaviw60c9d3e2021-06-04 12:52:17 -050050using gui::IWindowInfosListener;
Huihong Luof5029222021-12-16 14:33:46 -080051using gui::LayerCaptureArgs;
Peiyong Lin9f034472018-03-28 15:29:00 -070052using ui::ColorMode;
53
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
55{
56public:
Chih-Hung Hsiehe2347b72016-04-25 15:41:05 -070057 explicit BpSurfaceComposer(const sp<IBinder>& impl)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080058 : BpInterface<ISurfaceComposer>(impl)
59 {
60 }
61
Dan Stozad723bd72014-11-18 10:24:03 -080062 virtual ~BpSurfaceComposer();
63
Anton Ivanovd7b71ac2025-03-18 13:41:02 -070064 status_t setTransactionState(TransactionState&& state) override {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065 Parcel data, reply;
66 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Anton Ivanovd7b71ac2025-03-18 13:41:02 -070067 SAFE_PARCEL(state.writeToParcel, &data);
Dan Stozad723bd72014-11-18 10:24:03 -080068
Anton Ivanovd7b71ac2025-03-18 13:41:02 -070069 if (state.mFlags & ISurfaceComposer::eOneWay) {
Robert Carr79dc06a2022-02-22 15:28:59 -080070 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 Projectedbf3b62009-03-03 19:31:44 -080076 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080077};
78
Dan Stozad723bd72014-11-18 10:24:03 -080079// Out-of-line virtual method definition to trigger vtable emission in this
80// translation unit (see clang warning -Wweak-vtables)
81BpSurfaceComposer::~BpSurfaceComposer() {}
82
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080083IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
84
85// ----------------------------------------------------------------------
86
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080087status_t BnSurfaceComposer::onTransact(
88 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
89{
Huihong Luod3d8f8e2022-03-08 14:48:46 -080090 switch (code) {
Mathias Agopian698c0872011-06-28 19:09:31 -070091 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -070092 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -080093
Anton Ivanovd7b71ac2025-03-18 13:41:02 -070094 TransactionState state;
95 SAFE_PARCEL(state.readFromParcel, &data);
96 return setTransactionState(std::move(state));
Jesse Hall6c913be2013-08-08 12:15:49 -070097 }
Ady Abraham07d03c42023-09-27 19:15:08 -070098 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 Hall6c913be2013-08-08 12:15:49 -0700110 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700111 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700112 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800113 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800114}
115
Dominik Laskowskidcb38bb2019-01-25 02:35:50 -0800116} // namespace android