blob: 6500ad5841f9a17836d7a606bb43a6af63543477 [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 */
Jamie Gennisdd3cb842012-10-19 18:19:11 -070072 virtual sp<IBinder> createDisplay(const String8& displayName,
73 bool secure) = 0;
Mathias Agopiane57f2922012-08-09 16:29:12 -070074
75 /* get the token for the existing default displays. possible values
76 * for id are eDisplayIdMain and eDisplayIdHdmi.
77 */
78 virtual sp<IBinder> getBuiltInDisplay(int32_t id) = 0;
79
Mathias Agopian9cce3252010-02-09 17:46:37 -080080 /* open/close transactions. requires ACCESS_SURFACE_FLINGER permission */
Mathias Agopian3165cc22012-08-08 19:42:09 -070081 virtual void setTransactionState(const Vector<ComposerState>& state,
82 const Vector<DisplayState>& displays, uint32_t flags) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080083
84 /* signal that we're done booting.
Mathias Agopian9cce3252010-02-09 17:46:37 -080085 * Requires ACCESS_SURFACE_FLINGER permission
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080086 */
87 virtual void bootFinished() = 0;
88
Mathias Agopiane57f2922012-08-09 16:29:12 -070089 /* verify that an ISurfaceTexture was created by SurfaceFlinger.
90 */
91 virtual bool authenticateSurfaceTexture(
92 const sp<ISurfaceTexture>& surface) const = 0;
93
Mathias Agopian1b0b30d2010-09-24 11:26:58 -070094 /* Capture the specified screen. requires READ_FRAME_BUFFER permission
95 * This function will fail if there is a secure window on screen.
96 */
Jeff Brown9d4e3d22012-08-24 20:00:51 -070097 virtual status_t captureScreen(const sp<IBinder>& display, sp<IMemoryHeap>* heap,
Mathias Agopian74c40c02010-09-29 13:02:36 -070098 uint32_t* width, uint32_t* height, PixelFormat* format,
Jeff Brown9d4e3d22012-08-24 20:00:51 -070099 uint32_t reqWidth, uint32_t reqHeight,
100 uint32_t minLayerZ, uint32_t maxLayerZ) = 0;
Mathias Agopian1b0b30d2010-09-24 11:26:58 -0700101
Colin Cross8e533062012-06-07 13:17:52 -0700102
103 /* triggers screen off and waits for it to complete */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700104 virtual void blank(const sp<IBinder>& display) = 0;
Colin Cross8e533062012-06-07 13:17:52 -0700105
106 /* triggers screen on and waits for it to complete */
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700107 virtual void unblank(const sp<IBinder>& display) = 0;
Mathias Agopian3094df32012-06-18 18:06:45 -0700108
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700109 /* returns information about a display
110 * intended to be used to get information about built-in displays */
111 virtual status_t getDisplayInfo(const sp<IBinder>& display, DisplayInfo* info) = 0;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800112};
113
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800114// ----------------------------------------------------------------------------
115
Mathias Agopian3165cc22012-08-08 19:42:09 -0700116class BnSurfaceComposer: public BnInterface<ISurfaceComposer> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800117public:
118 enum {
119 // Note: BOOT_FINISHED must remain this value, it is called from
120 // Java by ActivityManagerService.
121 BOOT_FINISHED = IBinder::FIRST_CALL_TRANSACTION,
122 CREATE_CONNECTION,
Jamie Gennis9a78c902011-01-12 18:30:40 -0800123 CREATE_GRAPHIC_BUFFER_ALLOC,
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800124 CREATE_DISPLAY_EVENT_CONNECTION,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700125 CREATE_DISPLAY,
126 GET_BUILT_IN_DISPLAY,
127 SET_TRANSACTION_STATE,
128 AUTHENTICATE_SURFACE,
129 CAPTURE_SCREEN,
Colin Cross8e533062012-06-07 13:17:52 -0700130 BLANK,
131 UNBLANK,
Mathias Agopiane57f2922012-08-09 16:29:12 -0700132 GET_DISPLAY_INFO,
Mathias Agopian3094df32012-06-18 18:06:45 -0700133 CONNECT_DISPLAY,
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800134 };
135
Mathias Agopian3165cc22012-08-08 19:42:09 -0700136 virtual status_t onTransact(uint32_t code, const Parcel& data,
137 Parcel* reply, uint32_t flags = 0);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800138};
139
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800140// ----------------------------------------------------------------------------
141
142}; // namespace android
143
Mathias Agopian90ac7992012-02-25 18:48:35 -0800144#endif // ANDROID_GUI_ISURFACE_COMPOSER_H