• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2006 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 #pragma once
18 
19 #include <android/gui/CachingHint.h>
20 #include <android/gui/DisplayBrightness.h>
21 #include <android/gui/FrameTimelineInfo.h>
22 #include <android/gui/IDisplayEventConnection.h>
23 #include <android/gui/IFpsListener.h>
24 #include <android/gui/IHdrLayerInfoListener.h>
25 #include <android/gui/IRegionSamplingListener.h>
26 #include <android/gui/IScreenCaptureListener.h>
27 #include <android/gui/ITunnelModeEnabledListener.h>
28 #include <android/gui/IWindowInfosListener.h>
29 #include <android/gui/IWindowInfosPublisher.h>
30 #include <binder/IBinder.h>
31 #include <binder/IInterface.h>
32 #include <gui/ITransactionCompletedListener.h>
33 #include <gui/SpHash.h>
34 #include <math/vec4.h>
35 #include <stdint.h>
36 #include <sys/types.h>
37 #include <ui/ConfigStoreTypes.h>
38 #include <ui/DisplayId.h>
39 #include <ui/DisplayMode.h>
40 #include <ui/DisplayedFrameStats.h>
41 #include <ui/FrameStats.h>
42 #include <ui/GraphicBuffer.h>
43 #include <ui/GraphicTypes.h>
44 #include <ui/PixelFormat.h>
45 #include <ui/Rotation.h>
46 #include <utils/Errors.h>
47 #include <utils/RefBase.h>
48 #include <utils/Timers.h>
49 #include <utils/Vector.h>
50 
51 #include <optional>
52 #include <unordered_set>
53 #include <vector>
54 
55 #include <aidl/android/hardware/graphics/common/DisplayDecorationSupport.h>
56 
57 namespace android {
58 
59 struct client_cache_t;
60 class ComposerState;
61 struct DisplayStatInfo;
62 struct DisplayState;
63 struct InputWindowCommands;
64 class HdrCapabilities;
65 class Rect;
66 
67 using gui::FrameTimelineInfo;
68 using gui::IDisplayEventConnection;
69 using gui::IRegionSamplingListener;
70 using gui::IScreenCaptureListener;
71 using gui::SpHash;
72 
73 namespace gui {
74 
75 struct DisplayCaptureArgs;
76 struct LayerCaptureArgs;
77 class LayerDebugInfo;
78 
79 } // namespace gui
80 
81 namespace ui {
82 
83 struct DisplayMode;
84 struct DisplayState;
85 struct DynamicDisplayInfo;
86 
87 } // namespace ui
88 
89 /*
90  * This class defines the Binder IPC interface for accessing various
91  * SurfaceFlinger features.
92  */
93 class ISurfaceComposer: public IInterface {
94 public:
95     DECLARE_META_INTERFACE(SurfaceComposer)
96 
97     // flags for setTransactionState()
98     enum {
99         eAnimation = 0x02,
100 
101         // Explicit indication that this transaction and others to follow will likely result in a
102         // lot of layers being composed, and thus, SurfaceFlinger should wake-up earlier to avoid
103         // missing frame deadlines. In this case SurfaceFlinger will wake up at
104         // (sf vsync offset - debug.sf.early_phase_offset_ns). SurfaceFlinger will continue to be
105         // in the early configuration until it receives eEarlyWakeupEnd. These flags are
106         // expected to be used by WindowManager only and are guarded by
107         // android.permission.WAKEUP_SURFACE_FLINGER
108         eEarlyWakeupStart = 0x08,
109         eEarlyWakeupEnd = 0x10,
110         eOneWay = 0x20
111     };
112 
113     /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
114     virtual status_t setTransactionState(
115             const FrameTimelineInfo& frameTimelineInfo, Vector<ComposerState>& state,
116             const Vector<DisplayState>& displays, uint32_t flags, const sp<IBinder>& applyToken,
117             InputWindowCommands inputWindowCommands, int64_t desiredPresentTime,
118             bool isAutoTimestamp, const std::vector<client_cache_t>& uncacheBuffer,
119             bool hasListenerCallbacks, const std::vector<ListenerCallbacks>& listenerCallbacks,
120             uint64_t transactionId, const std::vector<uint64_t>& mergedTransactionIds) = 0;
121 };
122 
123 // ----------------------------------------------------------------------------
124 
125 class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
126 public:
127     enum ISurfaceComposerTag {
128         // Note: BOOT_FINISHED must remain this value, it is called from
129         // Java by ActivityManagerService.
130         BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
131         CREATE_CONNECTION,               // Deprecated. Autogenerated by .aidl now.
132         GET_STATIC_DISPLAY_INFO,         // Deprecated. Autogenerated by .aidl now.
133         CREATE_DISPLAY_EVENT_CONNECTION, // Deprecated. Autogenerated by .aidl now.
134         CREATE_DISPLAY,                  // Deprecated. Autogenerated by .aidl now.
135         DESTROY_DISPLAY,                 // Deprecated. Autogenerated by .aidl now.
136         GET_PHYSICAL_DISPLAY_TOKEN,      // Deprecated. Autogenerated by .aidl now.
137         SET_TRANSACTION_STATE,
138         AUTHENTICATE_SURFACE,           // Deprecated. Autogenerated by .aidl now.
139         GET_SUPPORTED_FRAME_TIMESTAMPS, // Deprecated. Autogenerated by .aidl now.
140         GET_DISPLAY_MODES,              // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
141         GET_ACTIVE_DISPLAY_MODE,        // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
142         GET_DISPLAY_STATE,
143         CAPTURE_DISPLAY,             // Deprecated. Autogenerated by .aidl now.
144         CAPTURE_LAYERS,              // Deprecated. Autogenerated by .aidl now.
145         CLEAR_ANIMATION_FRAME_STATS, // Deprecated. Autogenerated by .aidl now.
146         GET_ANIMATION_FRAME_STATS,   // Deprecated. Autogenerated by .aidl now.
147         SET_POWER_MODE,              // Deprecated. Autogenerated by .aidl now.
148         GET_DISPLAY_STATS,
149         GET_HDR_CAPABILITIES,       // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
150         GET_DISPLAY_COLOR_MODES,    // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
151         GET_ACTIVE_COLOR_MODE,      // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
152         SET_ACTIVE_COLOR_MODE,      // Deprecated. Autogenerated by .aidl now.
153         ENABLE_VSYNC_INJECTIONS,    // Deprecated. Autogenerated by .aidl now.
154         INJECT_VSYNC,               // Deprecated. Autogenerated by .aidl now.
155         GET_LAYER_DEBUG_INFO,       // Deprecated. Autogenerated by .aidl now.
156         GET_COMPOSITION_PREFERENCE, // Deprecated. Autogenerated by .aidl now.
157         GET_COLOR_MANAGEMENT,       // Deprecated. Autogenerated by .aidl now.
158         GET_DISPLAYED_CONTENT_SAMPLING_ATTRIBUTES, // Deprecated. Autogenerated by .aidl now.
159         SET_DISPLAY_CONTENT_SAMPLING_ENABLED,      // Deprecated. Autogenerated by .aidl now.
160         GET_DISPLAYED_CONTENT_SAMPLE,
161         GET_PROTECTED_CONTENT_SUPPORT,   // Deprecated. Autogenerated by .aidl now.
162         IS_WIDE_COLOR_DISPLAY,           // Deprecated. Autogenerated by .aidl now.
163         GET_DISPLAY_NATIVE_PRIMARIES,    // Deprecated. Autogenerated by .aidl now.
164         GET_PHYSICAL_DISPLAY_IDS,        // Deprecated. Autogenerated by .aidl now.
165         ADD_REGION_SAMPLING_LISTENER,    // Deprecated. Autogenerated by .aidl now.
166         REMOVE_REGION_SAMPLING_LISTENER, // Deprecated. Autogenerated by .aidl now.
167         SET_DESIRED_DISPLAY_MODE_SPECS,  // Deprecated. Autogenerated by .aidl now.
168         GET_DESIRED_DISPLAY_MODE_SPECS,  // Deprecated. Autogenerated by .aidl now.
169         GET_DISPLAY_BRIGHTNESS_SUPPORT,  // Deprecated. Autogenerated by .aidl now.
170         SET_DISPLAY_BRIGHTNESS,          // Deprecated. Autogenerated by .aidl now.
171         CAPTURE_DISPLAY_BY_ID,           // Deprecated. Autogenerated by .aidl now.
172         NOTIFY_POWER_BOOST,              // Deprecated. Autogenerated by .aidl now.
173         SET_GLOBAL_SHADOW_SETTINGS,
174         GET_AUTO_LOW_LATENCY_MODE_SUPPORT, // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
175         SET_AUTO_LOW_LATENCY_MODE,         // Deprecated. Autogenerated by .aidl now.
176         GET_GAME_CONTENT_TYPE_SUPPORT,     // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
177         SET_GAME_CONTENT_TYPE,             // Deprecated. Use GET_DYNAMIC_DISPLAY_INFO instead.
178         SET_FRAME_RATE,                    // Deprecated. Autogenerated by .aidl now.
179         // Deprecated. Use DisplayManager.setShouldAlwaysRespectAppRequestedMode(true);
180         ACQUIRE_FRAME_RATE_FLEXIBILITY_TOKEN,
181         SET_FRAME_TIMELINE_INFO,        // Deprecated. Autogenerated by .aidl now.
182         ADD_TRANSACTION_TRACE_LISTENER, // Deprecated. Autogenerated by .aidl now.
183         GET_GPU_CONTEXT_PRIORITY,
184         GET_MAX_ACQUIRED_BUFFER_COUNT,
185         GET_DYNAMIC_DISPLAY_INFO,            // Deprecated. Autogenerated by .aidl now.
186         ADD_FPS_LISTENER,                    // Deprecated. Autogenerated by .aidl now.
187         REMOVE_FPS_LISTENER,                 // Deprecated. Autogenerated by .aidl now.
188         OVERRIDE_HDR_TYPES,                  // Deprecated. Autogenerated by .aidl now.
189         ADD_HDR_LAYER_INFO_LISTENER,         // Deprecated. Autogenerated by .aidl now.
190         REMOVE_HDR_LAYER_INFO_LISTENER,      // Deprecated. Autogenerated by .aidl now.
191         ON_PULL_ATOM,                        // Deprecated. Autogenerated by .aidl now.
192         ADD_TUNNEL_MODE_ENABLED_LISTENER,    // Deprecated. Autogenerated by .aidl now.
193         REMOVE_TUNNEL_MODE_ENABLED_LISTENER, // Deprecated. Autogenerated by .aidl now.
194         ADD_WINDOW_INFOS_LISTENER,           // Deprecated. Autogenerated by .aidl now.
195         REMOVE_WINDOW_INFOS_LISTENER,        // Deprecated. Autogenerated by .aidl now.
196         GET_PRIMARY_PHYSICAL_DISPLAY_ID,     // Deprecated. Autogenerated by .aidl now.
197         GET_DISPLAY_DECORATION_SUPPORT,
198         GET_BOOT_DISPLAY_MODE_SUPPORT, // Deprecated. Autogenerated by .aidl now.
199         SET_BOOT_DISPLAY_MODE,         // Deprecated. Autogenerated by .aidl now.
200         CLEAR_BOOT_DISPLAY_MODE,       // Deprecated. Autogenerated by .aidl now.
201         SET_OVERRIDE_FRAME_RATE,       // Deprecated. Autogenerated by .aidl now.
202         // Always append new enum to the end.
203     };
204 
205     virtual status_t onTransact(uint32_t code, const Parcel& data,
206             Parcel* reply, uint32_t flags = 0);
207 };
208 
209 } // namespace android
210