blob: dea1b101e6ac70fa37911c0b6fa076efd49946e8 [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
Mathias Agopian000479f2010-02-09 17:46:37 -080017#ifndef ANDROID_SF_ISURFACE_COMPOSER_H
18#define ANDROID_SF_ISURFACE_COMPOSER_H
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080019
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/RefBase.h>
24#include <utils/Errors.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080025
Mathias Agopian07952722009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080027
28#include <ui/PixelFormat.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080029
Mathias Agopian770492c2010-05-28 14:22:23 -070030#include <surfaceflinger/ISurfaceComposerClient.h>
Jamie Gennisf7acf162011-01-12 18:30:40 -080031#include <surfaceflinger/IGraphicBufferAlloc.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
33namespace android {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034// ----------------------------------------------------------------------------
35
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080036class ISurfaceComposer : public IInterface
37{
38public:
39 DECLARE_META_INTERFACE(SurfaceComposer);
40
41 enum { // (keep in sync with Surface.java)
42 eHidden = 0x00000004,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 eDestroyBackbuffer = 0x00000020,
44 eSecure = 0x00000080,
45 eNonPremultiplied = 0x00000100,
Romain Guyd10cd572010-10-10 13:33:22 -070046 eOpaque = 0x00000400,
Glenn Kastend6f5bde2011-01-19 15:27:27 -080047 eProtectedByApp = 0x00000800,
48 eProtectedByDRM = 0x00001000,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080049
50 eFXSurfaceNormal = 0x00000000,
51 eFXSurfaceBlur = 0x00010000,
52 eFXSurfaceDim = 0x00020000,
53 eFXSurfaceMask = 0x000F0000,
54 };
55
56 enum {
57 ePositionChanged = 0x00000001,
58 eLayerChanged = 0x00000002,
59 eSizeChanged = 0x00000004,
60 eAlphaChanged = 0x00000008,
61 eMatrixChanged = 0x00000010,
62 eTransparentRegionChanged = 0x00000020,
63 eVisibilityChanged = 0x00000040,
64 eFreezeTintChanged = 0x00000080,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080065 };
66
67 enum {
68 eLayerHidden = 0x01,
69 eLayerFrozen = 0x02,
70 eLayerDither = 0x04,
71 eLayerFilter = 0x08,
72 eLayerBlurFreeze = 0x10
73 };
74
75 enum {
76 eOrientationDefault = 0,
77 eOrientation90 = 1,
78 eOrientation180 = 2,
79 eOrientation270 = 3,
80 eOrientationSwapMask = 0x01
81 };
Mathias Agopianeb0c86e2009-03-27 18:11:38 -070082
Mathias Agopiand4e03f32010-10-14 14:54:06 -070083 enum {
84 eElectronBeamAnimationOn = 0x01,
85 eElectronBeamAnimationOff = 0x10
86 };
87
Mathias Agopianeb0c86e2009-03-27 18:11:38 -070088 // flags for setOrientation
89 enum {
90 eOrientationAnimationDisable = 0x00000001
91 };
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080092
93 /* create connection with surface flinger, requires
94 * ACCESS_SURFACE_FLINGER permission
95 */
Mathias Agopian770492c2010-05-28 14:22:23 -070096 virtual sp<ISurfaceComposerClient> createConnection() = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080097
Mathias Agopian7623da42010-06-01 15:12:58 -070098 /* create a client connection with surface flinger
99 */
100 virtual sp<ISurfaceComposerClient> createClientConnection() = 0;
101
Jamie Gennisf7acf162011-01-12 18:30:40 -0800102 /* create a graphic buffer allocator
103 */
104 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
105
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800106 /* retrieve the control block */
Mathias Agopiand763b5d2009-07-02 18:11:53 -0700107 virtual sp<IMemoryHeap> getCblk() const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800108
Mathias Agopian000479f2010-02-09 17:46:37 -0800109 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800110 virtual void openGlobalTransaction() = 0;
111 virtual void closeGlobalTransaction() = 0;
112
Mathias Agopian000479f2010-02-09 17:46:37 -0800113 /* [un]freeze display. requires ACCESS_SURFACE_FLINGER permission */
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800114 virtual status_t freezeDisplay(DisplayID dpy, uint32_t flags) = 0;
115 virtual status_t unfreezeDisplay(DisplayID dpy, uint32_t flags) = 0;
116
Mathias Agopian000479f2010-02-09 17:46:37 -0800117 /* Set display orientation. requires ACCESS_SURFACE_FLINGER permission */
Mathias Agopianeb0c86e2009-03-27 18:11:38 -0700118 virtual int setOrientation(DisplayID dpy, int orientation, uint32_t flags) = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800119
120 /* signal that we're done booting.
Mathias Agopian000479f2010-02-09 17:46:37 -0800121 * Requires ACCESS_SURFACE_FLINGER permission
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800122 */
123 virtual void bootFinished() = 0;
124
Mathias Agopianca5edbe2010-09-24 11:26:58 -0700125 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
126 * This function will fail if there is a secure window on screen.
127 */
128 virtual status_t captureScreen(DisplayID dpy,
129 sp<IMemoryHeap>* heap,
Mathias Agopian38ed2e32010-09-29 13:02:36 -0700130 uint32_t* width, uint32_t* height, PixelFormat* format,
Mathias Agopian3dd25a62010-12-10 16:22:31 -0800131 uint32_t reqWidth, uint32_t reqHeight,
132 uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
Mathias Agopianca5edbe2010-09-24 11:26:58 -0700133
Mathias Agopianaab758e2010-10-11 12:37:43 -0700134 virtual status_t turnElectronBeamOff(int32_t mode) = 0;
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700135 virtual status_t turnElectronBeamOn(int32_t mode) = 0;
Mathias Agopianaab758e2010-10-11 12:37:43 -0700136
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800137 /* Signal surfaceflinger that there might be some work to do
138 * This is an ASYNCHRONOUS call.
139 */
140 virtual void signal() const = 0;
Jamie Gennisd2acedf2011-03-08 12:18:54 -0800141
142 /* verify that an ISurface was created by SurfaceFlinger.
143 */
144 virtual bool authenticateSurface(const sp<ISurface>& surface) const = 0;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800145};
146
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800147// ----------------------------------------------------------------------------
148
149class BnSurfaceComposer : public BnInterface<ISurfaceComposer>
150{
151public:
152 enum {
153 // Note: BOOT_FINISHED must remain this value, it is called from
154 // Java by ActivityManagerService.
155 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
156 CREATE_CONNECTION,
Mathias Agopian7623da42010-06-01 15:12:58 -0700157 CREATE_CLIENT_CONNECTION,
Jamie Gennisf7acf162011-01-12 18:30:40 -0800158 CREATE_GRAPHIC_BUFFER_ALLOC,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800159 GET_CBLK,
160 OPEN_GLOBAL_TRANSACTION,
161 CLOSE_GLOBAL_TRANSACTION,
162 SET_ORIENTATION,
163 FREEZE_DISPLAY,
164 UNFREEZE_DISPLAY,
Mathias Agopianca5edbe2010-09-24 11:26:58 -0700165 SIGNAL,
Mathias Agopianaab758e2010-10-11 12:37:43 -0700166 CAPTURE_SCREEN,
Mathias Agopian2d2b8032010-10-12 16:05:48 -0700167 TURN_ELECTRON_BEAM_OFF,
Jamie Gennisd2acedf2011-03-08 12:18:54 -0800168 TURN_ELECTRON_BEAM_ON,
169 AUTHENTICATE_SURFACE,
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800170 };
171
172 virtual status_t onTransact( uint32_t code,
173 const Parcel& data,
174 Parcel* reply,
175 uint32_t flags = 0);
176};
177
The Android Open Source Project9066cfe2009-03-03 19:31:44 -0800178// ----------------------------------------------------------------------------
179
180}; // namespace android
181
Mathias Agopian000479f2010-02-09 17:46:37 -0800182#endif // ANDROID_SF_ISURFACE_COMPOSER_H