blob: f9eeb30e1b0ce1dbe75461c61756bfaf4c3e6d6c [file] [log] [blame]
The Android Open Source Project7c1b96a2008-10-21 07:00:00 -07001/*
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 };
84
85 /* create connection with surface flinger, requires
86 * ACCESS_SURFACE_FLINGER permission
87 */
88
89 virtual sp<ISurfaceFlingerClient> createConnection() = 0;
90
91 /* retrieve the control block */
92 virtual sp<IMemory> getCblk() const = 0;
93
94 /* open/close transactions. recquires ACCESS_SURFACE_FLINGER permission */
95 virtual void openGlobalTransaction() = 0;
96 virtual void closeGlobalTransaction() = 0;
97
98 /* [un]freeze display. recquires ACCESS_SURFACE_FLINGER permission */
99 virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0;
100 virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
101
102 /* Set display orientation. recquires ACCESS_SURFACE_FLINGER permission */
103 virtual int setOrientation(DisplayID dpy, int orientation) = 0;
104
105 /* signal that we're done booting.
106 * recquires ACCESS_SURFACE_FLINGER permission
107 */
108 virtual void bootFinished() = 0;
109
110 /* get access to the GPU. Access is relinquished when releasing regs */
111 struct gpu_info_t {
112 struct gpu_region_t {
113 sp<IMemory> region;
114 size_t reserved;
115 };
116 sp<IMemory> regs;
117 size_t count;
118 gpu_region_t regions[2];
119 };
120 virtual status_t requestGPU(
121 const sp<IGPUCallback>& callback,
122 gpu_info_t* gpu) = 0;
123
124 /* take the gpu back from any apps using it. They'll get a
125 * EGL_CONTEXT_LOST error */
126 virtual status_t revokeGPU() = 0;
127
128 /* Signal surfaceflinger that there might be some work to do
129 * This is an ASYNCHRONOUS call.
130 */
131 virtual void signal() const = 0;
132};
133
134class IGPUCallback : public IInterface
135{
136public:
137 DECLARE_META_INTERFACE(GPUCallback);
138 virtual void gpuLost() = 0; //one-way
139};
140
141// ----------------------------------------------------------------------------
142
143class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
144{
145public:
146 enum {
147 // Note: BOOT_FINISHED must remain this value, it is called from
148 // Java by ActivityManagerService.
149 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
150 CREATE_CONNECTION,
151 GET_CBLK,
152 OPEN_GLOBAL_TRANSACTION,
153 CLOSE_GLOBAL_TRANSACTION,
154 SET_ORIENTATION,
155 FREEZE_DISPLAY,
156 UNFREEZE_DISPLAY,
157 REQUEST_GPU,
158 REVOKE_GPU,
159 SIGNAL
160 };
161
162 virtual status_t onTransact( uint32_t code,
163 const Parcel& data,
164 Parcel* reply,
165 uint32_t flags = 0);
166};
167
168class BnGPUCallback : public BnInterface<IGPUCallback>
169{
170public:
171 virtual status_t onTransact( uint32_t code,
172 const Parcel& data,
173 Parcel* reply,
174 uint32_t flags = 0);
175};
176
177// ----------------------------------------------------------------------------
178
179}; // namespace android
180
181#endif // ANDROID_ISURFACE_COMPOSER_H