blob: 06f13e8b2a8bd88e52e30c29329a11f2a33cddf7 [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);
Dan Stozad723bd72014-11-18 10:24:03 -080031 output.writeUint32(z);
32 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);
Dan Stoza7dde5992015-05-22 09:51:44 -070041 output.writeStrongBinder(handle);
42 output.writeUint64(frameNumber);
Mathias Agopianac9fa422013-02-11 16:40:36 -080043 output.write(transparentRegion);
44 return NO_ERROR;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045}
46
47status_t layer_state_t::read(const Parcel& input)
48{
Mathias Agopianac9fa422013-02-11 16:40:36 -080049 surface = input.readStrongBinder();
Dan Stozad723bd72014-11-18 10:24:03 -080050 what = input.readUint32();
Mathias Agopianac9fa422013-02-11 16:40:36 -080051 x = input.readFloat();
52 y = input.readFloat();
Dan Stozad723bd72014-11-18 10:24:03 -080053 z = input.readUint32();
54 w = input.readUint32();
55 h = input.readUint32();
56 layerStack = input.readUint32();
Mathias Agopianac9fa422013-02-11 16:40:36 -080057 alpha = input.readFloat();
Dan Stozad723bd72014-11-18 10:24:03 -080058 flags = static_cast<uint8_t>(input.readUint32());
59 mask = static_cast<uint8_t>(input.readUint32());
Michael Lentine8afa1c42014-10-31 11:10:13 -070060 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
61 if (matrix_data) {
62 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
63 } else {
64 return BAD_VALUE;
65 }
Mathias Agopianac9fa422013-02-11 16:40:36 -080066 input.read(crop);
Dan Stoza7dde5992015-05-22 09:51:44 -070067 handle = input.readStrongBinder();
68 frameNumber = input.readUint64();
Mathias Agopianac9fa422013-02-11 16:40:36 -080069 input.read(transparentRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080070 return NO_ERROR;
71}
72
Mathias Agopian698c0872011-06-28 19:09:31 -070073status_t ComposerState::write(Parcel& output) const {
Marco Nelissen2ea926b2014-11-14 08:01:01 -080074 output.writeStrongBinder(IInterface::asBinder(client));
Mathias Agopian698c0872011-06-28 19:09:31 -070075 return state.write(output);
76}
77
78status_t ComposerState::read(const Parcel& input) {
79 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
80 return state.read(input);
81}
82
Mathias Agopian8b33f032012-07-24 20:43:54 -070083
Pablo Ceballos60d69222015-08-07 14:47:20 -070084DisplayState::DisplayState() :
85 what(0),
86 layerStack(0),
87 orientation(eOrientationDefault),
88 viewport(Rect::EMPTY_RECT),
89 frame(Rect::EMPTY_RECT),
90 width(0),
91 height(0) {
92}
93
Mathias Agopian8b33f032012-07-24 20:43:54 -070094status_t DisplayState::write(Parcel& output) const {
Mathias Agopiane57f2922012-08-09 16:29:12 -070095 output.writeStrongBinder(token);
Marco Nelissen2ea926b2014-11-14 08:01:01 -080096 output.writeStrongBinder(IInterface::asBinder(surface));
Dan Stozad723bd72014-11-18 10:24:03 -080097 output.writeUint32(what);
98 output.writeUint32(layerStack);
99 output.writeUint32(orientation);
Mathias Agopian8683fca2012-08-12 19:37:16 -0700100 output.write(viewport);
101 output.write(frame);
Dan Stozad723bd72014-11-18 10:24:03 -0800102 output.writeUint32(width);
103 output.writeUint32(height);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700104 return NO_ERROR;
105}
106
107status_t DisplayState::read(const Parcel& input) {
Mathias Agopiane57f2922012-08-09 16:29:12 -0700108 token = input.readStrongBinder();
Andy McFadden2adaf042012-12-18 09:49:45 -0800109 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
Dan Stozad723bd72014-11-18 10:24:03 -0800110 what = input.readUint32();
111 layerStack = input.readUint32();
112 orientation = input.readUint32();
Mathias Agopian8683fca2012-08-12 19:37:16 -0700113 input.read(viewport);
114 input.read(frame);
Dan Stozad723bd72014-11-18 10:24:03 -0800115 width = input.readUint32();
116 height = input.readUint32();
Mathias Agopian8b33f032012-07-24 20:43:54 -0700117 return NO_ERROR;
118}
119
120
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800121}; // namespace android