blob: 35dcd4e8fb6f61170b3a71fd1188f11f4261f880 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-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 Agopian90ac7992012-02-25 18:48:35 -080017#ifndef ANDROID_GUI_ISURFACE_COMPOSER_H
18#define ANDROID_GUI_ISURFACE_COMPOSER_H
The Android Open Source Projectedbf3b62009-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 Agopian9cce3252010-02-09 17:46:37 -080025
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070026#include <binder/IInterface.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027
28#include <ui/PixelFormat.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080029
Mathias Agopian90ac7992012-02-25 18:48:35 -080030#include <gui/IGraphicBufferAlloc.h>
31#include <gui/ISurfaceComposerClient.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080032
33namespace android {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034// ----------------------------------------------------------------------------
35
Mathias Agopian439cf852011-11-29 13:07:24 -080036class ComposerState;
Mathias Agopian8b33f032012-07-24 20:43:54 -070037class DisplayState;
Mathias Agopianc666cae2012-07-25 18:56:13 -070038class DisplayInfo;
Mathias Agopiand0566bc2011-11-17 17:49:17 -080039class IDisplayEventConnection;
40class IMemoryHeap;
Mathias Agopiana67932f2011-04-20 14:20:59 -070041
Andy McFadden882e3a32013-01-08 16:06:15 -080042/*
43 * This class defines the Binder IPC interface for accessing various
44 * SurfaceFlinger features.
45 */
Mathias Agopian3165cc22012-08-08 19:42:09 -070046class ISurfaceComposer: public IInterface {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047public:
48 DECLARE_META_INTERFACE(SurfaceComposer);
49
Mathias Agopian3165cc22012-08-08 19:42:09 -070050 // flags for setTransactionState()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080051 enum {
Mathias Agopian3165cc22012-08-08 19:42:09 -070052 eSynchronous = 0x01,
Jamie Gennis2d5e2302012-10-15 18:24:43 -070053 eAnimation = 0x02,
Jamie Gennis28378392011-10-12 17:39:00 -070054 };
55
Mathias Agopiane57f2922012-08-09 16:29:12 -070056 enum {
57 eDisplayIdMain = 0,
58 eDisplayIdHdmi = 1
59 };
60
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061 /* create connection with surface flinger, requires
62 * ACCESS_SURFACE_FLINGER permission
63 */
Mathias Agopian7e27f052010-05-28 14:22:23 -070064 virtual sp<ISurfaceComposerClient> createConnection() = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080065
Jamie Gennis9a78c902011-01-12 18:30:40 -080066 /* create a graphic buffer allocator
67 */
68 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
69
Mathias Agopiane57f2922012-08-09 16:29:12 -070070 /* return an IDisplayEventConnection */
71 virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
72
Jesse Hall6c913be2013-08-08 12:15:49 -070073 /* create a virtual display
Mathias Agopiane57f2922012-08-09 16:29:12 -070074 * requires ACCESS_SURFACE_FLINGER permission.
75 */
Jamie Gennisdd3cb842012-10-19 18:19:11 -070076 virtual sp<IBinder> createDisplay(const String8& displayName,
77 bool secure) = 0;
Mathias Agopiane57f2922012-08-09 16:29:12 -070078
Jesse Hall6c913be2013-08-08 12:15:49 -070079 /* destroy a virtual display
80 * requires ACCESS_SURFACE_FLINGER permission.
81 */
82 virtual void destroyDisplay(const sp<IBinder>& display) = 0;
83
Mathias Agopiane57f2922012-08-09 16:29:12 -070084 /* get the token for the existing default displays. possible values
85 * for id are eDisplayIdMain and eDisplayIdHdmi.
86 */
87 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
88
Mathias Agopian9cce3252010-02-09 17:46:37 -080089 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
Mathias Agopian3165cc22012-08-08 19:42:09 -070090 virtual void setTransactionState(const Vector<ComposerState>& state,
91 const Vector<DisplayState>& displays, uint32_t flags) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080092
93 /* signal that we're done booting.
Mathias Agopian9cce3252010-02-09 17:46:37 -080094 * Requires ACCESS_SURFACE_FLINGER permission
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080095 */
96 virtual void bootFinished() = 0;
97
Andy McFadden2adaf042012-12-18 09:49:45 -080098 /* verify that an IGraphicBufferProducer was created by SurfaceFlinger.
Mathias Agopiane57f2922012-08-09 16:29:12 -070099 */
100 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800101 const sp<IGraphicBufferProducer>& surface) const = 0;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700102
Mathias Agopian041a0752013-03-15 18:31:56 -0700103 /* triggers screen off and waits for it to complete
104 * requires ACCESS_SURFACE_FLINGER permission.
105 */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700106 virtual void blank(const sp<IBinder>& display) = 0;
Colin Cross8e533062012-06-07 13:17:52 -0700107
Mathias Agopian041a0752013-03-15 18:31:56 -0700108 /* triggers screen on and waits for it to complete
109 * requires ACCESS_SURFACE_FLINGER permission.
110 */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700111 virtual void unblank(const sp<IBinder>& display) = 0;
Mathias Agopian3094df32012-06-18 18:06:45 -0700112
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700113 /* returns information about a display
114 * intended to be used to get information about built-in displays */
115 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800116
Mathias Agopian041a0752013-03-15 18:31:56 -0700117 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
118 * This function will fail if there is a secure window on screen.
119 */
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800120 virtual status_t captureScreen(const sp<IBinder>& display,
121 const sp<IGraphicBufferProducer>& producer,
122 uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800123 uint32_t minLayerZ, uint32_t maxLayerZ,
124 bool useIdentityTransform) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800125};
126
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800127// ----------------------------------------------------------------------------
128
Mathias Agopian3165cc22012-08-08 19:42:09 -0700129class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800130public:
131 enum {
132 // Note: BOOT_FINISHED must remain this value, it is called from
133 // Java by ActivityManagerService.
134 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
135 CREATE_CONNECTION,
Jamie Gennis9a78c902011-01-12 18:30:40 -0800136 CREATE_GRAPHIC_BUFFER_ALLOC,
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800137 CREATE_DISPLAY_EVENT_CONNECTION,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700138 CREATE_DISPLAY,
Jesse Hall6c913be2013-08-08 12:15:49 -0700139 DESTROY_DISPLAY,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700140 GET_BUILT_IN_DISPLAY,
141 SET_TRANSACTION_STATE,
142 AUTHENTICATE_SURFACE,
Colin Cross8e533062012-06-07 13:17:52 -0700143 BLANK,
144 UNBLANK,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700145 GET_DISPLAY_INFO,
Mathias Agopian3094df32012-06-18 18:06:45 -0700146 CONNECT_DISPLAY,
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800147 CAPTURE_SCREEN,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800148 };
149
Mathias Agopian3165cc22012-08-08 19:42:09 -0700150 virtual status_t onTransact(uint32_t code, const Parcel& data,
151 Parcel* reply, uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800152};
153
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800154// ----------------------------------------------------------------------------
155
156}; // namespace android
157
Mathias Agopian90ac7992012-02-25 18:48:35 -0800158#endif // ANDROID_GUI_ISURFACE_COMPOSER_H