ISurfaceComposer.h revision 8b33f032327f8de0dcc0e6d0d43ed80f834b51f6
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 26#include <binder/IInterface.h> 27 28#include <ui/PixelFormat.h> 29 30#include <gui/IGraphicBufferAlloc.h> 31#include <gui/ISurfaceComposerClient.h> 32 33namespace android { 34// ---------------------------------------------------------------------------- 35 36class ComposerState; 37class DisplayState; 38class IDisplayEventConnection; 39class IMemoryHeap; 40 41class ISurfaceComposer : public IInterface 42{ 43public: 44 DECLARE_META_INTERFACE(SurfaceComposer); 45 46 enum { // (keep in sync with Surface.java) 47 eHidden = 0x00000004, 48 eDestroyBackbuffer = 0x00000020, 49 eSecure = 0x00000080, 50 eNonPremultiplied = 0x00000100, 51 eOpaque = 0x00000400, 52 eProtectedByApp = 0x00000800, 53 eProtectedByDRM = 0x00001000, 54 55 eFXSurfaceNormal = 0x00000000, 56 eFXSurfaceBlur = 0x00010000, 57 eFXSurfaceDim = 0x00020000, 58 eFXSurfaceScreenshot= 0x00030000, 59 eFXSurfaceMask = 0x000F0000, 60 }; 61 62 enum { 63 ePositionChanged = 0x00000001, 64 eLayerChanged = 0x00000002, 65 eSizeChanged = 0x00000004, 66 eAlphaChanged = 0x00000008, 67 eMatrixChanged = 0x00000010, 68 eTransparentRegionChanged = 0x00000020, 69 eVisibilityChanged = 0x00000040, 70 eCropChanged = 0x00000100, 71 }; 72 73 enum { 74 eLayerHidden = 0x01, 75 }; 76 77 enum { 78 eOrientationDefault = 0, 79 eOrientation90 = 1, 80 eOrientation180 = 2, 81 eOrientation270 = 3, 82 eOrientationUnchanged = 4, 83 eOrientationSwapMask = 0x01 84 }; 85 86 enum { 87 eSynchronous = 0x01, 88 }; 89 90 enum { 91 eElectronBeamAnimationOn = 0x01, 92 eElectronBeamAnimationOff = 0x10 93 }; 94 95 /* create connection with surface flinger, requires 96 * ACCESS_SURFACE_FLINGER permission 97 */ 98 virtual sp<ISurfaceComposerClient> createConnection() = 0; 99 100 /* create a graphic buffer allocator 101 */ 102 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0; 103 104 /* retrieve the control block */ 105 virtual sp<IMemoryHeap> getCblk() const = 0; 106 107 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */ 108 virtual void setTransactionState( 109 const Vector<ComposerState>& state, 110 const Vector<DisplayState>& displays, 111 uint32_t flags) = 0; 112 113 /* signal that we're done booting. 114 * Requires ACCESS_SURFACE_FLINGER permission 115 */ 116 virtual void bootFinished() = 0; 117 118 /* Capture the specified screen. requires READ_FRAME_BUFFER permission 119 * This function will fail if there is a secure window on screen. 120 */ 121 virtual status_t captureScreen(DisplayID dpy, 122 sp<IMemoryHeap>* heap, 123 uint32_t* width, uint32_t* height, PixelFormat* format, 124 uint32_t reqWidth, uint32_t reqHeight, 125 uint32_t minLayerZ, uint32_t maxLayerZ) = 0; 126 127 /* triggers screen off animation */ 128 virtual status_t turnElectronBeamOff(int32_t mode) = 0; 129 130 /* triggers screen on animation */ 131 virtual status_t turnElectronBeamOn(int32_t mode) = 0; 132 133 /* verify that an ISurfaceTexture was created by SurfaceFlinger. 134 */ 135 virtual bool authenticateSurfaceTexture( 136 const sp<ISurfaceTexture>& surface) const = 0; 137 138 /* return an IDisplayEventConnection */ 139 virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0; 140 141 /* triggers screen off and waits for it to complete */ 142 virtual void blank() = 0; 143 144 /* triggers screen on and waits for it to complete */ 145 virtual void unblank() = 0; 146 147 /* connects to an external display */ 148 virtual void connectDisplay(const sp<ISurfaceTexture> display) = 0; 149}; 150 151// ---------------------------------------------------------------------------- 152 153class BnSurfaceComposer : public BnInterface<ISurfaceComposer> 154{ 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 GET_CBLK, 163 SET_TRANSACTION_STATE, 164 SET_ORIENTATION, 165 CAPTURE_SCREEN, 166 TURN_ELECTRON_BEAM_OFF, 167 TURN_ELECTRON_BEAM_ON, 168 AUTHENTICATE_SURFACE, 169 CREATE_DISPLAY_EVENT_CONNECTION, 170 BLANK, 171 UNBLANK, 172 CONNECT_DISPLAY, 173 }; 174 175 virtual status_t onTransact( uint32_t code, 176 const Parcel& data, 177 Parcel* reply, 178 uint32_t flags = 0); 179}; 180 181// ---------------------------------------------------------------------------- 182 183}; // namespace android 184 185#endif // ANDROID_GUI_ISURFACE_COMPOSER_H 186