blob: 002aafc5297d5bb9bbabf3bea4019e90aecc458e [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
Mathias Agopian3165cc22012-08-08 19:42:09 -070042class ISurfaceComposer: public IInterface {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043public:
44 DECLARE_META_INTERFACE(SurfaceComposer);
45
Mathias Agopian3165cc22012-08-08 19:42:09 -070046 // flags for setTransactionState()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080047 enum {
Mathias Agopian3165cc22012-08-08 19:42:09 -070048 eSynchronous = 0x01,
Jamie Gennis2d5e2302012-10-15 18:24:43 -070049 eAnimation = 0x02,
Jamie Gennis28378392011-10-12 17:39:00 -070050 };
51
Mathias Agopiane57f2922012-08-09 16:29:12 -070052 enum {
53 eDisplayIdMain = 0,
54 eDisplayIdHdmi = 1
55 };
56
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 /* create connection with surface flinger, requires
58 * ACCESS_SURFACE_FLINGER permission
59 */
Mathias Agopian7e27f052010-05-28 14:22:23 -070060 virtual sp<ISurfaceComposerClient> createConnection() = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080061
Jamie Gennis9a78c902011-01-12 18:30:40 -080062 /* create a graphic buffer allocator
63 */
64 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc() = 0;
65
Mathias Agopiane57f2922012-08-09 16:29:12 -070066 /* return an IDisplayEventConnection */
67 virtual sp<IDisplayEventConnection> createDisplayEventConnection() = 0;
68
Jeff Brown9d4e3d22012-08-24 20:00:51 -070069 /* create a display
Mathias Agopiane57f2922012-08-09 16:29:12 -070070 * requires ACCESS_SURFACE_FLINGER permission.
71 */
Andy McFadden8dfa92f2012-09-17 18:27:17 -070072 virtual sp<IBinder> createDisplay(const String8& displayName) = 0;
Mathias Agopiane57f2922012-08-09 16:29:12 -070073
74 /* get the token for the existing default displays. possible values
75 * for id are eDisplayIdMain and eDisplayIdHdmi.
76 */
77 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
78
Mathias Agopian9cce3252010-02-09 17:46:37 -080079 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
Mathias Agopian3165cc22012-08-08 19:42:09 -070080 virtual void setTransactionState(const Vector<ComposerState>& state,
81 const Vector<DisplayState>& displays, uint32_t flags) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080082
83 /* signal that we're done booting.
Mathias Agopian9cce3252010-02-09 17:46:37 -080084 * Requires ACCESS_SURFACE_FLINGER permission
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080085 */
86 virtual void bootFinished() = 0;
87
Mathias Agopiane57f2922012-08-09 16:29:12 -070088 /* verify that an ISurfaceTexture was created by SurfaceFlinger.
89 */
90 virtual bool authenticateSurfaceTexture(
91 const sp<ISurfaceTexture>& surface) const = 0;
92
Mathias Agopian1b0b30d2010-09-24 11:26:58 -070093 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
94 * This function will fail if there is a secure window on screen.
95 */
Jeff Brown9d4e3d22012-08-24 20:00:51 -070096 virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
Mathias Agopian74c40c02010-09-29 13:02:36 -070097 uint32_t* width, uint32_t* height, PixelFormat* format,
Jeff Brown9d4e3d22012-08-24 20:00:51 -070098 uint32_t reqWidth, uint32_t reqHeight,
99 uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
Mathias Agopian1b0b30d2010-09-24 11:26:58 -0700100
Colin Cross8e533062012-06-07 13:17:52 -0700101
102 /* triggers screen off and waits for it to complete */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700103 virtual void blank(const sp<IBinder>& display) = 0;
Colin Cross8e533062012-06-07 13:17:52 -0700104
105 /* triggers screen on and waits for it to complete */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700106 virtual void unblank(const sp<IBinder>& display) = 0;
Mathias Agopian3094df32012-06-18 18:06:45 -0700107
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700108 /* returns information about a display
109 * intended to be used to get information about built-in displays */
110 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
Mathias Agopianc666cae2012-07-25 18:56:13 -0700111
Mathias Agopian3094df32012-06-18 18:06:45 -0700112 /* connects to an external display */
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700113 virtual void connectDisplay(const sp<ISurfaceTexture>& display) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800114};
115
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800116// ----------------------------------------------------------------------------
117
Mathias Agopian3165cc22012-08-08 19:42:09 -0700118class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800119public:
120 enum {
121 // Note: BOOT_FINISHED must remain this value, it is called from
122 // Java by ActivityManagerService.
123 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
124 CREATE_CONNECTION,
Jamie Gennis9a78c902011-01-12 18:30:40 -0800125 CREATE_GRAPHIC_BUFFER_ALLOC,
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800126 CREATE_DISPLAY_EVENT_CONNECTION,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700127 CREATE_DISPLAY,
128 GET_BUILT_IN_DISPLAY,
129 SET_TRANSACTION_STATE,
130 AUTHENTICATE_SURFACE,
131 CAPTURE_SCREEN,
Colin Cross8e533062012-06-07 13:17:52 -0700132 BLANK,
133 UNBLANK,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700134 GET_DISPLAY_INFO,
Mathias Agopian3094df32012-06-18 18:06:45 -0700135 CONNECT_DISPLAY,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800136 };
137
Mathias Agopian3165cc22012-08-08 19:42:09 -0700138 virtual status_t onTransact(uint32_t code, const Parcel& data,
139 Parcel* reply, uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800140};
141
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800142// ----------------------------------------------------------------------------
143
144}; // namespace android
145
Mathias Agopian90ac7992012-02-25 18:48:35 -0800146#endif // ANDROID_GUI_ISURFACE_COMPOSER_H