ISurfaceComposer.h revision d85084b2b65828442eafaff9b811e9b6c9ca9fad
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 about a display 117 * intended to be used to get information about built-in displays */ 118 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0; 119 120 /* Capture the specified screen. requires READ_FRAME_BUFFER permission 121 * This function will fail if there is a secure window on screen. 122 */ 123 virtual status_t captureScreen(const sp<IBinder>& display, 124 const sp<IGraphicBufferProducer>& producer, 125 uint32_t reqWidth, uint32_t reqHeight, 126 uint32_t minLayerZ, uint32_t maxLayerZ, 127 bool useIdentityTransform) = 0; 128 129 130 /* Clears the frame statistics for animations. 131 * 132 * Requires the ACCESS_SURFACE_FLINGER permission. 133 */ 134 virtual status_t clearAnimationFrameStats() = 0; 135 136 /* Gets the frame statistics for animations. 137 * 138 * Requires the ACCESS_SURFACE_FLINGER permission. 139 */ 140 virtual status_t getAnimationFrameStats(FrameStats* outStats) const = 0; 141}; 142 143// ---------------------------------------------------------------------------- 144 145class BnSurfaceComposer: public BnInterface<ISurfaceComposer> { 146public: 147 enum { 148 // Note: BOOT_FINISHED must remain this value, it is called from 149 // Java by ActivityManagerService. 150 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION, 151 CREATE_CONNECTION, 152 CREATE_GRAPHIC_BUFFER_ALLOC, 153 CREATE_DISPLAY_EVENT_CONNECTION, 154 CREATE_DISPLAY, 155 DESTROY_DISPLAY, 156 GET_BUILT_IN_DISPLAY, 157 SET_TRANSACTION_STATE, 158 AUTHENTICATE_SURFACE, 159 BLANK, 160 UNBLANK, 161 GET_DISPLAY_INFO, 162 CONNECT_DISPLAY, 163 CAPTURE_SCREEN, 164 CLEAR_ANIMATION_FRAME_STATS, 165 GET_ANIMATION_FRAME_STATS 166 }; 167 168 virtual status_t onTransact(uint32_t code, const Parcel& data, 169 Parcel* reply, uint32_t flags = 0); 170}; 171 172// ---------------------------------------------------------------------------- 173 174}; // namespace android 175 176#endif // ANDROID_GUI_ISURFACE_COMPOSER_H 177