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