ISurfaceComposer.h revision c18790018be5d7ea7061ccbc81f3044e74adc823
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;
44class Rect;
45
46/*
47 * This class defines the Binder IPC interface for accessing various
48 * SurfaceFlinger features.
49 */
50class ISurfaceComposer: public IInterface {
51public:
52    DECLARE_META_INTERFACE(SurfaceComposer);
53
54    // flags for setTransactionState()
55    enum {
56        eSynchronous = 0x01,
57        eAnimation   = 0x02,
58    };
59
60    enum {
61        eDisplayIdMain = 0,
62        eDisplayIdHdmi = 1
63    };
64
65    /* create connection with surface flinger, requires
66     * ACCESS_SURFACE_FLINGER permission
67     */
68    virtual sp<ISurfaceComposerClient> createConnection() = 0;
69
70    /* create a graphic buffer allocator
71     */
72    virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
73
74    /* return an IDisplayEventConnection */
75    virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
76
77    /* create a virtual display
78     * requires ACCESS_SURFACE_FLINGER permission.
79     */
80    virtual sp<IBinder> createDisplay(const String8& displayName,
81            bool secure) = 0;
82
83    /* destroy a virtual display
84     * requires ACCESS_SURFACE_FLINGER permission.
85     */
86    virtual void destroyDisplay(const sp<IBinder>& display) = 0;
87
88    /* get the token for the existing default displays. possible values
89     * for id are eDisplayIdMain and eDisplayIdHdmi.
90     */
91    virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
92
93    /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
94    virtual void setTransactionState(const Vector<ComposerState>& state,
95            const Vector<DisplayState>& displays, uint32_t flags) = 0;
96
97    /* signal that we're done booting.
98     * Requires ACCESS_SURFACE_FLINGER permission
99     */
100    virtual void bootFinished() = 0;
101
102    /* verify that an IGraphicBufferProducer was created by SurfaceFlinger.
103     */
104    virtual bool authenticateSurfaceTexture(
105            const sp<IGraphicBufferProducer>& surface) const = 0;
106
107    /* triggers screen off and waits for it to complete
108     * requires ACCESS_SURFACE_FLINGER permission.
109     */
110    virtual void blank(const sp<IBinder>& display) = 0;
111
112    /* triggers screen on and waits for it to complete
113     * requires ACCESS_SURFACE_FLINGER permission.
114     */
115    virtual void unblank(const sp<IBinder>& display) = 0;
116
117    /* returns information for each configuration of the given display
118     * intended to be used to get information about built-in displays */
119    virtual status_t getDisplayConfigs(const sp<IBinder>& display,
120            Vector<DisplayInfo>* configs) = 0;
121
122    /* indicates which of the configurations returned by getDisplayInfo is
123     * currently active */
124    virtual int getActiveConfig(const sp<IBinder>& display) = 0;
125
126    /* specifies which configuration (of those returned by getDisplayInfo)
127     * should be used */
128    virtual status_t setActiveConfig(const sp<IBinder>& display, int id) = 0;
129
130    /* Capture the specified screen. requires READ_FRAME_BUFFER permission
131     * This function will fail if there is a secure window on screen.
132     */
133    virtual status_t captureScreen(const sp<IBinder>& display,
134            const sp<IGraphicBufferProducer>& producer,
135            Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
136            uint32_t minLayerZ, uint32_t maxLayerZ,
137            bool useIdentityTransform) = 0;
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