ISurfaceComposer.h revision 7f7da32569f8e0b3d383a40b95f8ac1d55afd801
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#ifndef ANDROID_GUI_ISURFACE_COMPOSER_H 18#define ANDROID_GUI_ISURFACE_COMPOSER_H 19 20#include <stdint.h> 21#include <sys/types.h> 22 23#include <utils/RefBase.h> 24#include <utils/Errors.h> 25#include <utils/Timers.h> 26#include <utils/Vector.h> 27 28#include <binder/IInterface.h> 29 30#include <ui/FrameStats.h> 31#include <ui/PixelFormat.h> 32 33#include <gui/IGraphicBufferAlloc.h> 34#include <gui/ISurfaceComposerClient.h> 35 36namespace android { 37// ---------------------------------------------------------------------------- 38 39class ComposerState; 40class DisplayState; 41class DisplayInfo; 42class IDisplayEventConnection; 43class IMemoryHeap; 44 45/* 46 * This class defines the Binder IPC interface for accessing various 47 * SurfaceFlinger features. 48 */ 49class ISurfaceComposer: public IInterface { 50public: 51 DECLARE_META_INTERFACE(SurfaceComposer); 52 53 // flags for setTransactionState() 54 enum { 55 eSynchronous = 0x01, 56 eAnimation = 0x02, 57 }; 58 59 enum { 60 eDisplayIdMain = 0, 61 eDisplayIdHdmi = 1 62 }; 63 64 /* create connection with surface flinger, requires 65 * ACCESS_SURFACE_FLINGER permission 66 */ 67 virtual sp<ISurfaceComposerClient> createConnection() = 0; 68 69 /* create a graphic buffer allocator 70 */ 71 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0; 72 73 /* return an IDisplayEventConnection */ 74 virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0; 75 76 /* create a virtual display 77 * requires ACCESS_SURFACE_FLINGER permission. 78 */ 79 virtual sp<IBinder> createDisplay(const String8& displayName, 80 bool secure) = 0; 81 82 /* destroy a virtual display 83 * requires ACCESS_SURFACE_FLINGER permission. 84 */ 85 virtual void destroyDisplay(const sp<IBinder>& display) = 0; 86 87 /* get the token for the existing default displays. possible values 88 * for id are eDisplayIdMain and eDisplayIdHdmi. 89 */ 90 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0; 91 92 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */ 93 virtual void setTransactionState(const Vector<ComposerState>& state, 94 const Vector<DisplayState>& displays, uint32_t flags) = 0; 95 96 /* signal that we're done booting. 97 * Requires ACCESS_SURFACE_FLINGER permission 98 */ 99 virtual void bootFinished() = 0; 100 101 /* verify that an IGraphicBufferProducer was created by SurfaceFlinger. 102 */ 103 virtual bool authenticateSurfaceTexture( 104 const sp<IGraphicBufferProducer>& surface) const = 0; 105 106 /* triggers screen off and waits for it to complete 107 * requires ACCESS_SURFACE_FLINGER permission. 108 */ 109 virtual void blank(const sp<IBinder>& display) = 0; 110 111 /* triggers screen on and waits for it to complete 112 * requires ACCESS_SURFACE_FLINGER permission. 113 */ 114 virtual void unblank(const sp<IBinder>& display) = 0; 115 116 /* returns information for each configuration of the given display 117 * intended to be used to get information about built-in displays */ 118 virtual status_t getDisplayConfigs(const sp<IBinder>& display, 119 Vector<DisplayInfo>* configs) = 0; 120 121 /* indicates which of the configurations returned by getDisplayInfo is 122 * currently active */ 123 virtual int getActiveConfig(const sp<IBinder>& display) = 0; 124 125 /* specifies which configuration (of those returned by getDisplayInfo) 126 * should be used */ 127 virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0; 128 129 /* Capture the specified screen. requires READ_FRAME_BUFFER permission 130 * This function will fail if there is a secure window on screen. 131 */ 132 virtual status_t captureScreen(const sp<IBinder>& display, 133 const sp<IGraphicBufferProducer>& producer, 134 uint32_t reqWidth, uint32_t reqHeight, 135 uint32_t minLayerZ, uint32_t maxLayerZ, 136 bool useIdentityTransform) = 0; 137 138 139 /* Clears the frame statistics for animations. 140 * 141 * Requires the ACCESS_SURFACE_FLINGER permission. 142 */ 143 virtual status_t clearAnimationFrameStats() = 0; 144 145 /* Gets the frame statistics for animations. 146 * 147 * Requires the ACCESS_SURFACE_FLINGER permission. 148 */ 149 virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0; 150}; 151 152// ---------------------------------------------------------------------------- 153 154class BnSurfaceComposer: public BnInterface<ISurfaceComposer> { 155public: 156 enum { 157 // Note: BOOT_FINISHED must remain this value, it is called from 158 // Java by ActivityManagerService. 159 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, 160 CREATE_CONNECTION, 161 CREATE_GRAPHIC_BUFFER_ALLOC, 162 CREATE_DISPLAY_EVENT_CONNECTION, 163 CREATE_DISPLAY, 164 DESTROY_DISPLAY, 165 GET_BUILT_IN_DISPLAY, 166 SET_TRANSACTION_STATE, 167 AUTHENTICATE_SURFACE, 168 BLANK, 169 UNBLANK, 170 GET_DISPLAY_CONFIGS, 171 GET_ACTIVE_CONFIG, 172 SET_ACTIVE_CONFIG, 173 CONNECT_DISPLAY, 174 CAPTURE_SCREEN, 175 CLEAR_ANIMATION_FRAME_STATS, 176 GET_ANIMATION_FRAME_STATS 177 }; 178 179 virtual status_t onTransact(uint32_t code, const Parcel& data, 180 Parcel* reply, uint32_t flags = 0); 181}; 182 183// ---------------------------------------------------------------------------- 184 185}; // namespace android 186 187#endif // ANDROID_GUI_ISURFACE_COMPOSER_H 188