blob: 573f6856d64dd64bd589ca03fe1a4aaa7a9cad39 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2008 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#include <utils/Errors.h>
Mathias Agopianc5b2c0b2009-05-19 19:08:10 -070018#include <binder/Parcel.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080019#include <gui/ISurfaceComposerClient.h>
Andy McFadden2adaf042012-12-18 09:49:45 -080020#include <gui/IGraphicBufferProducer.h>
Mathias Agopian90ac7992012-02-25 18:48:35 -080021#include <private/gui/LayerState.h>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080022
23namespace android {
24
25status_t layer_state_t::write(Parcel& output) const
26{
Mathias Agopianac9fa422013-02-11 16:40:36 -080027 output.writeStrongBinder(surface);
Dan Stozad723bd72014-11-18 10:24:03 -080028 output.writeUint32(what);
Mathias Agopianac9fa422013-02-11 16:40:36 -080029 output.writeFloat(x);
30 output.writeFloat(y);
Robert Carrae060832016-11-28 10:51:00 -080031 output.writeInt32(z);
Dan Stozad723bd72014-11-18 10:24:03 -080032 output.writeUint32(w);
33 output.writeUint32(h);
34 output.writeUint32(layerStack);
Mathias Agopianac9fa422013-02-11 16:40:36 -080035 output.writeFloat(alpha);
Dan Stozad723bd72014-11-18 10:24:03 -080036 output.writeUint32(flags);
37 output.writeUint32(mask);
Mathias Agopianac9fa422013-02-11 16:40:36 -080038 *reinterpret_cast<layer_state_t::matrix22_t *>(
39 output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
40 output.write(crop);
Pablo Ceballosacbe6782016-03-04 17:54:21 +000041 output.write(finalCrop);
Robert Carr0d480722017-01-10 16:42:54 -080042 output.writeStrongBinder(barrierHandle);
Robert Carr1db73f62016-12-21 12:58:51 -080043 output.writeStrongBinder(reparentHandle);
Dan Stoza7dde5992015-05-22 09:51:44 -070044 output.writeUint64(frameNumber);
Robert Carrc3574f72016-03-24 12:19:32 -070045 output.writeInt32(overrideScalingMode);
Robert Carr0d480722017-01-10 16:42:54 -080046 output.writeStrongBinder(IInterface::asBinder(barrierGbp));
Robert Carrdb66e622017-04-10 16:55:57 -070047 output.writeStrongBinder(relativeLayerHandle);
chaviw06178942017-07-27 10:25:59 -070048 output.writeStrongBinder(parentHandleForChild);
49 output.writeStrongBinder(childHandle);
Mathias Agopianac9fa422013-02-11 16:40:36 -080050 output.write(transparentRegion);
51 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052}
53
54status_t layer_state_t::read(const Parcel& input)
55{
Mathias Agopianac9fa422013-02-11 16:40:36 -080056 surface = input.readStrongBinder();
Dan Stozad723bd72014-11-18 10:24:03 -080057 what = input.readUint32();
Mathias Agopianac9fa422013-02-11 16:40:36 -080058 x = input.readFloat();
59 y = input.readFloat();
Robert Carrae060832016-11-28 10:51:00 -080060 z = input.readInt32();
Dan Stozad723bd72014-11-18 10:24:03 -080061 w = input.readUint32();
62 h = input.readUint32();
63 layerStack = input.readUint32();
Mathias Agopianac9fa422013-02-11 16:40:36 -080064 alpha = input.readFloat();
Dan Stozad723bd72014-11-18 10:24:03 -080065 flags = static_cast<uint8_t>(input.readUint32());
66 mask = static_cast<uint8_t>(input.readUint32());
Michael Lentine8afa1c42014-10-31 11:10:13 -070067 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
68 if (matrix_data) {
69 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
70 } else {
71 return BAD_VALUE;
72 }
Mathias Agopianac9fa422013-02-11 16:40:36 -080073 input.read(crop);
Pablo Ceballosacbe6782016-03-04 17:54:21 +000074 input.read(finalCrop);
Robert Carr0d480722017-01-10 16:42:54 -080075 barrierHandle = input.readStrongBinder();
Robert Carr1db73f62016-12-21 12:58:51 -080076 reparentHandle = input.readStrongBinder();
Dan Stoza7dde5992015-05-22 09:51:44 -070077 frameNumber = input.readUint64();
Robert Carrc3574f72016-03-24 12:19:32 -070078 overrideScalingMode = input.readInt32();
Robert Carr0d480722017-01-10 16:42:54 -080079 barrierGbp =
80 interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
Robert Carrdb66e622017-04-10 16:55:57 -070081 relativeLayerHandle = input.readStrongBinder();
chaviw06178942017-07-27 10:25:59 -070082 parentHandleForChild = input.readStrongBinder();
83 childHandle = input.readStrongBinder();
Mathias Agopianac9fa422013-02-11 16:40:36 -080084 input.read(transparentRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080085 return NO_ERROR;
86}
87
Mathias Agopian698c0872011-06-28 19:09:31 -070088status_t ComposerState::write(Parcel& output) const {
Marco Nelissen2ea926b2014-11-14 08:01:01 -080089 output.writeStrongBinder(IInterface::asBinder(client));
Mathias Agopian698c0872011-06-28 19:09:31 -070090 return state.write(output);
91}
92
93status_t ComposerState::read(const Parcel& input) {
94 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
95 return state.read(input);
96}
97
Mathias Agopian8b33f032012-07-24 20:43:54 -070098
Pablo Ceballos60d69222015-08-07 14:47:20 -070099DisplayState::DisplayState() :
100 what(0),
101 layerStack(0),
102 orientation(eOrientationDefault),
103 viewport(Rect::EMPTY_RECT),
104 frame(Rect::EMPTY_RECT),
105 width(0),
106 height(0) {
107}
108
Mathias Agopian8b33f032012-07-24 20:43:54 -0700109status_t DisplayState::write(Parcel& output) const {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700110 output.writeStrongBinder(token);
Marco Nelissen2ea926b2014-11-14 08:01:01 -0800111 output.writeStrongBinder(IInterface::asBinder(surface));
Dan Stozad723bd72014-11-18 10:24:03 -0800112 output.writeUint32(what);
113 output.writeUint32(layerStack);
114 output.writeUint32(orientation);
Mathias Agopian8683fca2012-08-12 19:37:16 -0700115 output.write(viewport);
116 output.write(frame);
Dan Stozad723bd72014-11-18 10:24:03 -0800117 output.writeUint32(width);
118 output.writeUint32(height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700119 return NO_ERROR;
120}
121
122status_t DisplayState::read(const Parcel& input) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700123 token = input.readStrongBinder();
Andy McFadden2adaf042012-12-18 09:49:45 -0800124 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
Dan Stozad723bd72014-11-18 10:24:03 -0800125 what = input.readUint32();
126 layerStack = input.readUint32();
127 orientation = input.readUint32();
Mathias Agopian8683fca2012-08-12 19:37:16 -0700128 input.read(viewport);
129 input.read(frame);
Dan Stozad723bd72014-11-18 10:24:03 -0800130 width = input.readUint32();
131 height = input.readUint32();
Mathias Agopian8b33f032012-07-24 20:43:54 -0700132 return NO_ERROR;
133}
134
135
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800136}; // namespace android