blob: 48629498bf2173cda90dce5f7384e4e900c23e52 [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
Jeff Brown9d4e3d22012-08-24 20:00:51 -070073 /* create a 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
79 /* get the token for the existing default displays. possible values
80 * for id are eDisplayIdMain and eDisplayIdHdmi.
81 */
82 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
83
Mathias Agopian9cce3252010-02-09 17:46:37 -080084 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
Mathias Agopian3165cc22012-08-08 19:42:09 -070085 virtual void setTransactionState(const Vector<ComposerState>& state,
86 const Vector<DisplayState>& displays, uint32_t flags) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080087
88 /* signal that we're done booting.
Mathias Agopian9cce3252010-02-09 17:46:37 -080089 * Requires ACCESS_SURFACE_FLINGER permission
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 */
91 virtual void bootFinished() = 0;
92
Andy McFadden2adaf042012-12-18 09:49:45 -080093 /* verify that an IGraphicBufferProducer was created by SurfaceFlinger.
Mathias Agopiane57f2922012-08-09 16:29:12 -070094 */
95 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -080096 const sp<IGraphicBufferProducer>& surface) const = 0;
Mathias Agopiane57f2922012-08-09 16:29:12 -070097
Mathias Agopian1b0b30d2010-09-24 11:26:58 -070098 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
99 * This function will fail if there is a secure window on screen.
100 */
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700101 virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
Mathias Agopian74c40c02010-09-29 13:02:36 -0700102 uint32_t* width, uint32_t* height, PixelFormat* format,
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700103 uint32_t reqWidth, uint32_t reqHeight,
104 uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
Mathias Agopian1b0b30d2010-09-24 11:26:58 -0700105
Colin Cross8e533062012-06-07 13:17:52 -0700106
107 /* triggers screen off and waits for it to complete */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700108 virtual void blank(const sp<IBinder>& display) = 0;
Colin Cross8e533062012-06-07 13:17:52 -0700109
110 /* triggers screen on and waits for it to complete */
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;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800116};
117
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800118// ----------------------------------------------------------------------------
119
Mathias Agopian3165cc22012-08-08 19:42:09 -0700120class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800121public:
122 enum {
123 // Note: BOOT_FINISHED must remain this value, it is called from
124 // Java by ActivityManagerService.
125 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
126 CREATE_CONNECTION,
Jamie Gennis9a78c902011-01-12 18:30:40 -0800127 CREATE_GRAPHIC_BUFFER_ALLOC,
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800128 CREATE_DISPLAY_EVENT_CONNECTION,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700129 CREATE_DISPLAY,
130 GET_BUILT_IN_DISPLAY,
131 SET_TRANSACTION_STATE,
132 AUTHENTICATE_SURFACE,
133 CAPTURE_SCREEN,
Colin Cross8e533062012-06-07 13:17:52 -0700134 BLANK,
135 UNBLANK,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700136 GET_DISPLAY_INFO,
Mathias Agopian3094df32012-06-18 18:06:45 -0700137 CONNECT_DISPLAY,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800138 };
139
Mathias Agopian3165cc22012-08-08 19:42:09 -0700140 virtual status_t onTransact(uint32_t code, const Parcel& data,
141 Parcel* reply, uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800142};
143
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800144// ----------------------------------------------------------------------------
145
146}; // namespace android
147
Mathias Agopian90ac7992012-02-25 18:48:35 -0800148#endif // ANDROID_GUI_ISURFACE_COMPOSER_H