2 * Copyright (C) 2006 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_GUI_ISURFACE_COMPOSER_H
18 #define ANDROID_GUI_ISURFACE_COMPOSER_H
21 #include <sys/types.h>
23 #include <utils/RefBase.h>
24 #include <utils/Errors.h>
25 #include <utils/Timers.h>
26 #include <utils/Vector.h>
28 #include <binder/IInterface.h>
30 #include <ui/FrameStats.h>
31 #include <ui/PixelFormat.h>
33 #include <gui/IGraphicBufferAlloc.h>
34 #include <gui/ISurfaceComposerClient.h>
37 // ----------------------------------------------------------------------------
42 class DisplayStatInfo;
43 class IDisplayEventConnection;
48 * This class defines the Binder IPC interface for accessing various
49 * SurfaceFlinger features.
51 class ISurfaceComposer: public IInterface {
53 DECLARE_META_INTERFACE(SurfaceComposer);
55 // flags for setTransactionState()
73 /* create connection with surface flinger, requires
74 * ACCESS_SURFACE_FLINGER permission
76 virtual sp<ISurfaceComposerClient> createConnection() = 0;
78 /* create a graphic buffer allocator
80 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
82 /* return an IDisplayEventConnection */
83 virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
85 /* create a virtual display
86 * requires ACCESS_SURFACE_FLINGER permission.
88 virtual sp<IBinder> createDisplay(const String8& displayName,
91 /* destroy a virtual display
92 * requires ACCESS_SURFACE_FLINGER permission.
94 virtual void destroyDisplay(const sp<IBinder>& display) = 0;
96 /* get the token for the existing default displays. possible values
97 * for id are eDisplayIdMain and eDisplayIdHdmi.
99 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
101 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
102 virtual void setTransactionState(const Vector<ComposerState>& state,
103 const Vector<DisplayState>& displays, uint32_t flags) = 0;
105 /* signal that we're done booting.
106 * Requires ACCESS_SURFACE_FLINGER permission
108 virtual void bootFinished() = 0;
110 /* verify that an IGraphicBufferProducer was created by SurfaceFlinger.
112 virtual bool authenticateSurfaceTexture(
113 const sp<IGraphicBufferProducer>& surface) const = 0;
115 /* set display power mode. depending on the mode, it can either trigger
116 * screen on, off or low power mode and wait for it to complete.
117 * requires ACCESS_SURFACE_FLINGER permission.
119 virtual void setPowerMode(const sp<IBinder>& display, int mode) = 0;
121 /* returns information for each configuration of the given display
122 * intended to be used to get information about built-in displays */
123 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
124 Vector<DisplayInfo>* configs) = 0;
126 /* returns display statistics for a given display
127 * intended to be used by the media framework to properly schedule
129 virtual status_t getDisplayStats(const sp<IBinder>& display,
130 DisplayStatInfo* stats) = 0;
132 /* indicates which of the configurations returned by getDisplayInfo is
133 * currently active */
134 virtual int getActiveConfig(const sp<IBinder>& display) = 0;
136 /* specifies which configuration (of those returned by getDisplayInfo)
138 virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0;
140 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
141 * This function will fail if there is a secure window on screen.
143 virtual status_t captureScreen(const sp<IBinder>& display,
144 const sp<IGraphicBufferProducer>& producer,
145 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
146 uint32_t minLayerZ, uint32_t maxLayerZ,
147 bool useIdentityTransform,
148 Rotation rotation = eRotateNone) = 0;
150 /* Clears the frame statistics for animations.
152 * Requires the ACCESS_SURFACE_FLINGER permission.
154 virtual status_t clearAnimationFrameStats() = 0;
156 /* Gets the frame statistics for animations.
158 * Requires the ACCESS_SURFACE_FLINGER permission.
160 virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0;
163 // ----------------------------------------------------------------------------
165 class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
168 // Note: BOOT_FINISHED must remain this value, it is called from
169 // Java by ActivityManagerService.
170 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
172 CREATE_GRAPHIC_BUFFER_ALLOC,
173 CREATE_DISPLAY_EVENT_CONNECTION,
176 GET_BUILT_IN_DISPLAY,
177 SET_TRANSACTION_STATE,
178 AUTHENTICATE_SURFACE,
184 CLEAR_ANIMATION_FRAME_STATS,
185 GET_ANIMATION_FRAME_STATS,
190 virtual status_t onTransact(uint32_t code, const Parcel& data,
191 Parcel* reply, uint32_t flags = 0);
194 // ----------------------------------------------------------------------------
196 }; // namespace android
198 #endif // ANDROID_GUI_ISURFACE_COMPOSER_H