blob: 36ddb13a685e740e11cc12efe7be3f43e732ba6c [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
17// tag as surfaceflinger
18#define LOG_TAG "SurfaceFlinger"
19
20#include <stdint.h>
21#include <sys/types.h>
22
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070023#include <binder/Parcel.h>
24#include <binder/IMemory.h>
25#include <binder/IPCThreadState.h>
26#include <binder/IServiceManager.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080027
Mathias Agopiand0566bc2011-11-17 17:49:17 -080028#include <gui/BitTube.h>
29#include <gui/IDisplayEventConnection.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080030#include <gui/ISurfaceComposer.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080031#include <gui/IGraphicBufferProducer.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080032
33#include <private/gui/LayerState.h>
Mathias Agopiand0566bc2011-11-17 17:49:17 -080034
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035#include <ui/DisplayInfo.h>
Lajos Molnar67d8bd62014-09-11 14:58:45 -070036#include <ui/DisplayStatInfo.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
Jamie Gennis134f0422011-03-08 12:18:54 -080038#include <utils/Log.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080039
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040// ---------------------------------------------------------------------------
41
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080042namespace android {
43
Mathias Agopiand0566bc2011-11-17 17:49:17 -080044class IDisplayEventConnection;
45
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046class BpSurfaceComposer : public BpInterface<ISurfaceComposer>
47{
48public:
49 BpSurfaceComposer(const sp<IBinder>& impl)
50 : BpInterface<ISurfaceComposer>(impl)
51 {
52 }
53
Dan Stozad723bd72014-11-18 10:24:03 -080054 virtual ~BpSurfaceComposer();
55
Mathias Agopian7e27f052010-05-28 14:22:23 -070056 virtual sp<ISurfaceComposerClient> createConnection()
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 {
58 uint32_t n;
59 Parcel data, reply;
60 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
61 remote()->transact(BnSurfaceComposer::CREATE_CONNECTION, data, &reply);
Mathias Agopian7e27f052010-05-28 14:22:23 -070062 return interface_cast<ISurfaceComposerClient>(reply.readStrongBinder());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063 }
64
Jamie Gennis9a78c902011-01-12 18:30:40 -080065 virtual sp<IGraphicBufferAlloc> createGraphicBufferAlloc()
66 {
67 uint32_t n;
68 Parcel data, reply;
69 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
70 remote()->transact(BnSurfaceComposer::CREATE_GRAPHIC_BUFFER_ALLOC, data, &reply);
71 return interface_cast<IGraphicBufferAlloc>(reply.readStrongBinder());
72 }
73
Mathias Agopian8b33f032012-07-24 20:43:54 -070074 virtual void setTransactionState(
75 const Vector<ComposerState>& state,
76 const Vector<DisplayState>& displays,
77 uint32_t flags)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080078 {
79 Parcel data, reply;
80 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Dan Stozad723bd72014-11-18 10:24:03 -080081
82 data.writeUint32(static_cast<uint32_t>(state.size()));
83 for (const auto& s : state) {
84 s.write(data);
Mathias Agopian698c0872011-06-28 19:09:31 -070085 }
Dan Stozad723bd72014-11-18 10:24:03 -080086
87 data.writeUint32(static_cast<uint32_t>(displays.size()));
88 for (const auto& d : displays) {
89 d.write(data);
Mathias Agopian8b33f032012-07-24 20:43:54 -070090 }
Dan Stozad723bd72014-11-18 10:24:03 -080091
92 data.writeUint32(flags);
Jamie Gennisb8d69a52011-10-10 15:48:06 -070093 remote()->transact(BnSurfaceComposer::SET_TRANSACTION_STATE, data, &reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080094 }
95
96 virtual void bootFinished()
97 {
98 Parcel data, reply;
99 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
100 remote()->transact(BnSurfaceComposer::BOOT_FINISHED, data, &reply);
101 }
102
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800103 virtual status_t captureScreen(const sp<IBinder>& display,
104 const sp<IGraphicBufferProducer>& producer,
Dan Stozac1879002014-05-22 15:59:05 -0700105 Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight,
Dan Stozac7014012014-02-14 15:03:43 -0800106 uint32_t minLayerZ, uint32_t maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700107 bool useIdentityTransform,
108 ISurfaceComposer::Rotation rotation)
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800109 {
110 Parcel data, reply;
111 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
112 data.writeStrongBinder(display);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800113 data.writeStrongBinder(IInterface::asBinder(producer));
Dan Stozac1879002014-05-22 15:59:05 -0700114 data.write(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800115 data.writeUint32(reqWidth);
116 data.writeUint32(reqHeight);
117 data.writeUint32(minLayerZ);
118 data.writeUint32(maxLayerZ);
Dan Stozac7014012014-02-14 15:03:43 -0800119 data.writeInt32(static_cast<int32_t>(useIdentityTransform));
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700120 data.writeInt32(static_cast<int32_t>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800121 remote()->transact(BnSurfaceComposer::CAPTURE_SCREEN, data, &reply);
122 return reply.readInt32();
123 }
124
Jamie Gennis582270d2011-08-17 18:19:00 -0700125 virtual bool authenticateSurfaceTexture(
Andy McFadden2adaf042012-12-18 09:49:45 -0800126 const sp<IGraphicBufferProducer>& bufferProducer) const
Jamie Gennis134f0422011-03-08 12:18:54 -0800127 {
128 Parcel data, reply;
129 int err = NO_ERROR;
130 err = data.writeInterfaceToken(
131 ISurfaceComposer::getInterfaceDescriptor());
132 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000133 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis134f0422011-03-08 12:18:54 -0800134 "interface descriptor: %s (%d)", strerror(-err), -err);
135 return false;
136 }
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800137 err = data.writeStrongBinder(IInterface::asBinder(bufferProducer));
Jamie Gennis134f0422011-03-08 12:18:54 -0800138 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000139 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
Jamie Gennis582270d2011-08-17 18:19:00 -0700140 "strong binder to parcel: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800141 return false;
142 }
143 err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
144 &reply);
145 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000146 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700147 "performing transaction: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800148 return false;
149 }
150 int32_t result = 0;
151 err = reply.readInt32(&result);
152 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000153 ALOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
Jamie Gennis582270d2011-08-17 18:19:00 -0700154 "retrieving result: %s (%d)", strerror(-err), -err);
Jamie Gennis134f0422011-03-08 12:18:54 -0800155 return false;
156 }
157 return result != 0;
158 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800159
160 virtual sp<IDisplayEventConnection> createDisplayEventConnection()
161 {
162 Parcel data, reply;
163 sp<IDisplayEventConnection> result;
164 int err = data.writeInterfaceToken(
165 ISurfaceComposer::getInterfaceDescriptor());
166 if (err != NO_ERROR) {
167 return result;
168 }
169 err = remote()->transact(
170 BnSurfaceComposer::CREATE_DISPLAY_EVENT_CONNECTION,
171 data, &reply);
172 if (err != NO_ERROR) {
Steve Blocke6f43dd2012-01-06 19:20:56 +0000173 ALOGE("ISurfaceComposer::createDisplayEventConnection: error performing "
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800174 "transaction: %s (%d)", strerror(-err), -err);
175 return result;
176 }
177 result = interface_cast<IDisplayEventConnection>(reply.readStrongBinder());
178 return result;
179 }
Colin Cross8e533062012-06-07 13:17:52 -0700180
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700181 virtual sp<IBinder> createDisplay(const String8& displayName, bool secure)
Mathias Agopiane57f2922012-08-09 16:29:12 -0700182 {
183 Parcel data, reply;
184 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700185 data.writeString8(displayName);
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700186 data.writeInt32(secure ? 1 : 0);
Mathias Agopiane57f2922012-08-09 16:29:12 -0700187 remote()->transact(BnSurfaceComposer::CREATE_DISPLAY, data, &reply);
188 return reply.readStrongBinder();
189 }
190
Jesse Hall6c913be2013-08-08 12:15:49 -0700191 virtual void destroyDisplay(const sp<IBinder>& display)
192 {
193 Parcel data, reply;
194 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
195 data.writeStrongBinder(display);
196 remote()->transact(BnSurfaceComposer::DESTROY_DISPLAY, data, &reply);
197 }
198
Mathias Agopiane57f2922012-08-09 16:29:12 -0700199 virtual sp<IBinder> getBuiltInDisplay(int32_t id)
200 {
201 Parcel data, reply;
202 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
203 data.writeInt32(id);
204 remote()->transact(BnSurfaceComposer::GET_BUILT_IN_DISPLAY, data, &reply);
205 return reply.readStrongBinder();
206 }
207
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700208 virtual void setPowerMode(const sp<IBinder>& display, int mode)
Colin Cross8e533062012-06-07 13:17:52 -0700209 {
210 Parcel data, reply;
211 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Andy McFaddenc01a79d2012-09-27 16:02:06 -0700212 data.writeStrongBinder(display);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700213 data.writeInt32(mode);
214 remote()->transact(BnSurfaceComposer::SET_POWER_MODE, data, &reply);
Colin Cross8e533062012-06-07 13:17:52 -0700215 }
Mathias Agopian3094df32012-06-18 18:06:45 -0700216
Dan Stoza7f7da322014-05-02 15:26:25 -0700217 virtual status_t getDisplayConfigs(const sp<IBinder>& display,
218 Vector<DisplayInfo>* configs)
Mathias Agopianc666cae2012-07-25 18:56:13 -0700219 {
220 Parcel data, reply;
221 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700222 data.writeStrongBinder(display);
Dan Stoza7f7da322014-05-02 15:26:25 -0700223 remote()->transact(BnSurfaceComposer::GET_DISPLAY_CONFIGS, data, &reply);
224 status_t result = reply.readInt32();
225 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800226 size_t numConfigs = reply.readUint32();
Dan Stoza7f7da322014-05-02 15:26:25 -0700227 configs->clear();
228 configs->resize(numConfigs);
229 for (size_t c = 0; c < numConfigs; ++c) {
230 memcpy(&(configs->editItemAt(c)),
231 reply.readInplace(sizeof(DisplayInfo)),
232 sizeof(DisplayInfo));
233 }
234 }
235 return result;
236 }
237
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700238 virtual status_t getDisplayStats(const sp<IBinder>& display,
239 DisplayStatInfo* stats)
240 {
241 Parcel data, reply;
242 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
243 data.writeStrongBinder(display);
244 remote()->transact(BnSurfaceComposer::GET_DISPLAY_STATS, data, &reply);
245 status_t result = reply.readInt32();
246 if (result == NO_ERROR) {
247 memcpy(stats,
248 reply.readInplace(sizeof(DisplayStatInfo)),
249 sizeof(DisplayStatInfo));
250 }
251 return result;
252 }
253
Dan Stoza7f7da322014-05-02 15:26:25 -0700254 virtual int getActiveConfig(const sp<IBinder>& display)
255 {
256 Parcel data, reply;
257 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
258 data.writeStrongBinder(display);
259 remote()->transact(BnSurfaceComposer::GET_ACTIVE_CONFIG, data, &reply);
260 return reply.readInt32();
261 }
262
263 virtual status_t setActiveConfig(const sp<IBinder>& display, int id)
264 {
265 Parcel data, reply;
266 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
267 data.writeStrongBinder(display);
268 data.writeInt32(id);
269 remote()->transact(BnSurfaceComposer::SET_ACTIVE_CONFIG, data, &reply);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700270 return reply.readInt32();
271 }
Svetoslavd85084b2014-03-20 10:28:31 -0700272
273 virtual status_t clearAnimationFrameStats() {
274 Parcel data, reply;
275 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
276 remote()->transact(BnSurfaceComposer::CLEAR_ANIMATION_FRAME_STATS, data, &reply);
277 return reply.readInt32();
278 }
279
280 virtual status_t getAnimationFrameStats(FrameStats* outStats) const {
281 Parcel data, reply;
282 data.writeInterfaceToken(ISurfaceComposer::getInterfaceDescriptor());
283 remote()->transact(BnSurfaceComposer::GET_ANIMATION_FRAME_STATS, data, &reply);
284 reply.read(*outStats);
285 return reply.readInt32();
286 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800287};
288
Dan Stozad723bd72014-11-18 10:24:03 -0800289// Out-of-line virtual method definition to trigger vtable emission in this
290// translation unit (see clang warning -Wweak-vtables)
291BpSurfaceComposer::~BpSurfaceComposer() {}
292
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800293IMPLEMENT_META_INTERFACE(SurfaceComposer, "android.ui.ISurfaceComposer");
294
295// ----------------------------------------------------------------------
296
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800297status_t BnSurfaceComposer::onTransact(
298 uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
299{
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800300 switch(code) {
301 case CREATE_CONNECTION: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700302 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800303 sp<IBinder> b = IInterface::asBinder(createConnection());
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800304 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700305 return NO_ERROR;
306 }
Jamie Gennis9a78c902011-01-12 18:30:40 -0800307 case CREATE_GRAPHIC_BUFFER_ALLOC: {
308 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800309 sp<IBinder> b = IInterface::asBinder(createGraphicBufferAlloc());
Jamie Gennis9a78c902011-01-12 18:30:40 -0800310 reply->writeStrongBinder(b);
Jesse Hall6c913be2013-08-08 12:15:49 -0700311 return NO_ERROR;
312 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700313 case SET_TRANSACTION_STATE: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700314 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stozad723bd72014-11-18 10:24:03 -0800315
316 size_t count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700317 if (count > data.dataSize()) {
318 return BAD_VALUE;
319 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700320 ComposerState s;
321 Vector<ComposerState> state;
322 state.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800323 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700324 if (s.read(data) == BAD_VALUE) {
325 return BAD_VALUE;
326 }
Mathias Agopian698c0872011-06-28 19:09:31 -0700327 state.add(s);
328 }
Dan Stozad723bd72014-11-18 10:24:03 -0800329
330 count = data.readUint32();
Michael Lentine8afa1c42014-10-31 11:10:13 -0700331 if (count > data.dataSize()) {
332 return BAD_VALUE;
333 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700334 DisplayState d;
335 Vector<DisplayState> displays;
336 displays.setCapacity(count);
Dan Stozad723bd72014-11-18 10:24:03 -0800337 for (size_t i = 0; i < count; i++) {
Michael Lentine8afa1c42014-10-31 11:10:13 -0700338 if (d.read(data) == BAD_VALUE) {
339 return BAD_VALUE;
340 }
Mathias Agopian8b33f032012-07-24 20:43:54 -0700341 displays.add(d);
342 }
Dan Stozad723bd72014-11-18 10:24:03 -0800343
344 uint32_t stateFlags = data.readUint32();
345 setTransactionState(state, displays, stateFlags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700346 return NO_ERROR;
347 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800348 case BOOT_FINISHED: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700349 CHECK_INTERFACE(ISurfaceComposer, data, reply);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800350 bootFinished();
Jesse Hall6c913be2013-08-08 12:15:49 -0700351 return NO_ERROR;
352 }
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800353 case CAPTURE_SCREEN: {
354 CHECK_INTERFACE(ISurfaceComposer, data, reply);
355 sp<IBinder> display = data.readStrongBinder();
356 sp<IGraphicBufferProducer> producer =
357 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
Dan Stozac1879002014-05-22 15:59:05 -0700358 Rect sourceCrop;
359 data.read(sourceCrop);
Dan Stozad723bd72014-11-18 10:24:03 -0800360 uint32_t reqWidth = data.readUint32();
361 uint32_t reqHeight = data.readUint32();
362 uint32_t minLayerZ = data.readUint32();
363 uint32_t maxLayerZ = data.readUint32();
Dan Stozac7014012014-02-14 15:03:43 -0800364 bool useIdentityTransform = static_cast<bool>(data.readInt32());
Dan Stozad723bd72014-11-18 10:24:03 -0800365 int32_t rotation = data.readInt32();
Dan Stozac7014012014-02-14 15:03:43 -0800366
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800367 status_t res = captureScreen(display, producer,
Dan Stozac1879002014-05-22 15:59:05 -0700368 sourceCrop, reqWidth, reqHeight, minLayerZ, maxLayerZ,
Riley Andrewsc3ebe662014-09-04 16:20:31 -0700369 useIdentityTransform,
370 static_cast<ISurfaceComposer::Rotation>(rotation));
Mathias Agopian2a9fc492013-03-01 13:42:57 -0800371 reply->writeInt32(res);
Jesse Hall6c913be2013-08-08 12:15:49 -0700372 return NO_ERROR;
373 }
Jamie Gennis134f0422011-03-08 12:18:54 -0800374 case AUTHENTICATE_SURFACE: {
375 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden2adaf042012-12-18 09:49:45 -0800376 sp<IGraphicBufferProducer> bufferProducer =
377 interface_cast<IGraphicBufferProducer>(data.readStrongBinder());
378 int32_t result = authenticateSurfaceTexture(bufferProducer) ? 1 : 0;
Jamie Gennis134f0422011-03-08 12:18:54 -0800379 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700380 return NO_ERROR;
381 }
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800382 case CREATE_DISPLAY_EVENT_CONNECTION: {
383 CHECK_INTERFACE(ISurfaceComposer, data, reply);
384 sp<IDisplayEventConnection> connection(createDisplayEventConnection());
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800385 reply->writeStrongBinder(IInterface::asBinder(connection));
Mathias Agopiand0566bc2011-11-17 17:49:17 -0800386 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700387 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700388 case CREATE_DISPLAY: {
389 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700390 String8 displayName = data.readString8();
Jamie Gennisdd3cb842012-10-19 18:19:11 -0700391 bool secure = bool(data.readInt32());
392 sp<IBinder> display(createDisplay(displayName, secure));
Mathias Agopiane57f2922012-08-09 16:29:12 -0700393 reply->writeStrongBinder(display);
394 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700395 }
396 case DESTROY_DISPLAY: {
397 CHECK_INTERFACE(ISurfaceComposer, data, reply);
398 sp<IBinder> display = data.readStrongBinder();
399 destroyDisplay(display);
400 return NO_ERROR;
401 }
Mathias Agopiane57f2922012-08-09 16:29:12 -0700402 case GET_BUILT_IN_DISPLAY: {
403 CHECK_INTERFACE(ISurfaceComposer, data, reply);
404 int32_t id = data.readInt32();
405 sp<IBinder> display(getBuiltInDisplay(id));
406 reply->writeStrongBinder(display);
407 return NO_ERROR;
Jesse Hall6c913be2013-08-08 12:15:49 -0700408 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700409 case GET_DISPLAY_CONFIGS: {
Mathias Agopianc666cae2012-07-25 18:56:13 -0700410 CHECK_INTERFACE(ISurfaceComposer, data, reply);
Dan Stoza7f7da322014-05-02 15:26:25 -0700411 Vector<DisplayInfo> configs;
Jeff Brown9d4e3d22012-08-24 20:00:51 -0700412 sp<IBinder> display = data.readStrongBinder();
Dan Stoza7f7da322014-05-02 15:26:25 -0700413 status_t result = getDisplayConfigs(display, &configs);
414 reply->writeInt32(result);
415 if (result == NO_ERROR) {
Dan Stozad723bd72014-11-18 10:24:03 -0800416 reply->writeUint32(static_cast<uint32_t>(configs.size()));
Dan Stoza7f7da322014-05-02 15:26:25 -0700417 for (size_t c = 0; c < configs.size(); ++c) {
418 memcpy(reply->writeInplace(sizeof(DisplayInfo)),
419 &configs[c], sizeof(DisplayInfo));
420 }
421 }
422 return NO_ERROR;
423 }
Lajos Molnar67d8bd62014-09-11 14:58:45 -0700424 case GET_DISPLAY_STATS: {
425 CHECK_INTERFACE(ISurfaceComposer, data, reply);
426 DisplayStatInfo stats;
427 sp<IBinder> display = data.readStrongBinder();
428 status_t result = getDisplayStats(display, &stats);
429 reply->writeInt32(result);
430 if (result == NO_ERROR) {
431 memcpy(reply->writeInplace(sizeof(DisplayStatInfo)),
432 &stats, sizeof(DisplayStatInfo));
433 }
434 return NO_ERROR;
435 }
Dan Stoza7f7da322014-05-02 15:26:25 -0700436 case GET_ACTIVE_CONFIG: {
437 CHECK_INTERFACE(ISurfaceComposer, data, reply);
438 sp<IBinder> display = data.readStrongBinder();
439 int id = getActiveConfig(display);
440 reply->writeInt32(id);
441 return NO_ERROR;
442 }
443 case SET_ACTIVE_CONFIG: {
444 CHECK_INTERFACE(ISurfaceComposer, data, reply);
445 sp<IBinder> display = data.readStrongBinder();
446 int id = data.readInt32();
447 status_t result = setActiveConfig(display, id);
Mathias Agopianc666cae2012-07-25 18:56:13 -0700448 reply->writeInt32(result);
Jesse Hall6c913be2013-08-08 12:15:49 -0700449 return NO_ERROR;
450 }
Svetoslavd85084b2014-03-20 10:28:31 -0700451 case CLEAR_ANIMATION_FRAME_STATS: {
452 CHECK_INTERFACE(ISurfaceComposer, data, reply);
453 status_t result = clearAnimationFrameStats();
454 reply->writeInt32(result);
455 return NO_ERROR;
456 }
457 case GET_ANIMATION_FRAME_STATS: {
458 CHECK_INTERFACE(ISurfaceComposer, data, reply);
459 FrameStats stats;
460 status_t result = getAnimationFrameStats(&stats);
461 reply->write(stats);
462 reply->writeInt32(result);
463 return NO_ERROR;
464 }
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700465 case SET_POWER_MODE: {
466 CHECK_INTERFACE(ISurfaceComposer, data, reply);
467 sp<IBinder> display = data.readStrongBinder();
468 int32_t mode = data.readInt32();
469 setPowerMode(display, mode);
470 return NO_ERROR;
471 }
Jesse Hall6c913be2013-08-08 12:15:49 -0700472 default: {
Mathias Agopian83c04462009-05-22 19:00:22 -0700473 return BBinder::onTransact(code, data, reply, flags);
Jesse Hall6c913be2013-08-08 12:15:49 -0700474 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800475 }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800476}
477
478// ----------------------------------------------------------------------------
479
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800480};