blob: 5c64b222bc5d4adf66d4be8737b921fc751d9ad6 [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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_ISURFACE_COMPOSER_H
18#define ANDROID_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/IInterface.h>
26
27#include <ui/PixelFormat.h>
28#include <ui/ISurfaceFlingerClient.h>
29
30namespace android {
31
32// ----------------------------------------------------------------------------
33
34class DisplayInfo;
35class IGPUCallback;
36
37class ISurfaceComposer : public IInterface
38{
39public:
40 DECLARE_META_INTERFACE(SurfaceComposer);
41
42 enum { // (keep in sync with Surface.java)
43 eHidden = 0x00000004,
44 eGPU = 0x00000008,
45 eHardware = 0x00000010,
46 eDestroyBackbuffer = 0x00000020,
47 eSecure = 0x00000080,
48 eNonPremultiplied = 0x00000100,
49 ePushBuffers = 0x00000200,
50
51 eFXSurfaceNormal = 0x00000000,
52 eFXSurfaceBlur = 0x00010000,
53 eFXSurfaceDim = 0x00020000,
54 eFXSurfaceMask = 0x000F0000,
55 };
56
57 enum {
58 ePositionChanged = 0x00000001,
59 eLayerChanged = 0x00000002,
60 eSizeChanged = 0x00000004,
61 eAlphaChanged = 0x00000008,
62 eMatrixChanged = 0x00000010,
63 eTransparentRegionChanged = 0x00000020,
64 eVisibilityChanged = 0x00000040,
65 eFreezeTintChanged = 0x00000080,
66 eDestroyed = 0x00000100
67 };
68
69 enum {
70 eLayerHidden = 0x01,
71 eLayerFrozen = 0x02,
72 eLayerDither = 0x04,
73 eLayerFilter = 0x08,
74 eLayerBlurFreeze = 0x10
75 };
76
77 enum {
78 eOrientationDefault = 0,
79 eOrientation90 = 1,
80 eOrientation180 = 2,
81 eOrientation270 = 3,
82 eOrientationSwapMask = 0x01
83 };
Mathias Agopianeb0c86e2009-03-27 18:11:38 -070084
85 // flags for setOrientation
86 enum {
87 eOrientationAnimationDisable = 0x00000001
88 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080089
90 /* create connection with surface flinger, requires
91 * ACCESS_SURFACE_FLINGER permission
92 */
93
94 virtual sp<ISurfaceFlingerClient> createConnection() = 0;
95
96 /* retrieve the control block */
97 virtual sp<IMemory> getCblk() const = 0;
98
99 /* open/close transactions. recquires ACCESS_SURFACE_FLINGER permission */
100 virtual void openGlobalTransaction() = 0;
101 virtual void closeGlobalTransaction() = 0;
102
103 /* [un]freeze display. recquires ACCESS_SURFACE_FLINGER permission */
104 virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0;
105 virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
106
107 /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700108 virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800109
110 /* signal that we're done booting.
111 * recquires ACCESS_SURFACE_FLINGER permission
112 */
113 virtual void bootFinished() = 0;
114
115 /* get access to the GPU. Access is relinquished when releasing regs */
116 struct gpu_info_t {
117 struct gpu_region_t {
118 sp<IMemory> region;
119 size_t reserved;
120 };
121 sp<IMemory> regs;
122 size_t count;
123 gpu_region_t regions[2];
124 };
125 virtual status_t requestGPU(
126 const sp<IGPUCallback>& callback,
127 gpu_info_t* gpu) = 0;
128
129 /* take the gpu back from any apps using it. They'll get a
130 * EGL_CONTEXT_LOST error */
131 virtual status_t revokeGPU() = 0;
132
133 /* Signal surfaceflinger that there might be some work to do
134 * This is an ASYNCHRONOUS call.
135 */
136 virtual void signal() const = 0;
137};
138
139class IGPUCallback : public IInterface
140{
141public:
142 DECLARE_META_INTERFACE(GPUCallback);
143 virtual void gpuLost() = 0; //one-way
144};
145
146// ----------------------------------------------------------------------------
147
148class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
149{
150public:
151 enum {
152 // Note: BOOT_FINISHED must remain this value, it is called from
153 // Java by ActivityManagerService.
154 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
155 CREATE_CONNECTION,
156 GET_CBLK,
157 OPEN_GLOBAL_TRANSACTION,
158 CLOSE_GLOBAL_TRANSACTION,
159 SET_ORIENTATION,
160 FREEZE_DISPLAY,
161 UNFREEZE_DISPLAY,
162 REQUEST_GPU,
163 REVOKE_GPU,
164 SIGNAL
165 };
166
167 virtual status_t onTransact( uint32_t code,
168 const Parcel& data,
169 Parcel* reply,
170 uint32_t flags = 0);
171};
172
173class BnGPUCallback : public BnInterface<IGPUCallback>
174{
175public:
176 virtual status_t onTransact( uint32_t code,
177 const Parcel& data,
178 Parcel* reply,
179 uint32_t flags = 0);
180};
181
182// ----------------------------------------------------------------------------
183
184}; // namespace android
185
186#endif // ANDROID_ISURFACE_COMPOSER_H