1 /*
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>
18 #include <binder/Parcel.h>
19 #include <gui/ISurfaceComposerClient.h>
20 #include <gui/IGraphicBufferProducer.h>
21 #include <private/gui/LayerState.h>
22
23 namespace android {
24
write(Parcel & output) const25 status_t layer_state_t::write(Parcel& output) const
26 {
27 output.writeStrongBinder(surface);
28 output.writeUint32(what);
29 output.writeFloat(x);
30 output.writeFloat(y);
31 output.writeInt32(z);
32 output.writeUint32(w);
33 output.writeUint32(h);
34 output.writeUint32(layerStack);
35 output.writeFloat(alpha);
36 output.writeUint32(flags);
37 output.writeUint32(mask);
38 *reinterpret_cast<layer_state_t::matrix22_t *>(
39 output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix;
40 output.write(crop);
41 output.write(finalCrop);
42 output.writeStrongBinder(barrierHandle);
43 output.writeStrongBinder(reparentHandle);
44 output.writeUint64(frameNumber);
45 output.writeInt32(overrideScalingMode);
46 output.writeStrongBinder(IInterface::asBinder(barrierGbp));
47 output.writeStrongBinder(relativeLayerHandle);
48 output.write(transparentRegion);
49 return NO_ERROR;
50 }
51
read(const Parcel & input)52 status_t layer_state_t::read(const Parcel& input)
53 {
54 surface = input.readStrongBinder();
55 what = input.readUint32();
56 x = input.readFloat();
57 y = input.readFloat();
58 z = input.readInt32();
59 w = input.readUint32();
60 h = input.readUint32();
61 layerStack = input.readUint32();
62 alpha = input.readFloat();
63 flags = static_cast<uint8_t>(input.readUint32());
64 mask = static_cast<uint8_t>(input.readUint32());
65 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t));
66 if (matrix_data) {
67 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data);
68 } else {
69 return BAD_VALUE;
70 }
71 input.read(crop);
72 input.read(finalCrop);
73 barrierHandle = input.readStrongBinder();
74 reparentHandle = input.readStrongBinder();
75 frameNumber = input.readUint64();
76 overrideScalingMode = input.readInt32();
77 barrierGbp =
78 interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
79 relativeLayerHandle = input.readStrongBinder();
80 input.read(transparentRegion);
81 return NO_ERROR;
82 }
83
write(Parcel & output) const84 status_t ComposerState::write(Parcel& output) const {
85 output.writeStrongBinder(IInterface::asBinder(client));
86 return state.write(output);
87 }
88
read(const Parcel & input)89 status_t ComposerState::read(const Parcel& input) {
90 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
91 return state.read(input);
92 }
93
94
DisplayState()95 DisplayState::DisplayState() :
96 what(0),
97 layerStack(0),
98 orientation(eOrientationDefault),
99 viewport(Rect::EMPTY_RECT),
100 frame(Rect::EMPTY_RECT),
101 width(0),
102 height(0) {
103 }
104
write(Parcel & output) const105 status_t DisplayState::write(Parcel& output) const {
106 output.writeStrongBinder(token);
107 output.writeStrongBinder(IInterface::asBinder(surface));
108 output.writeUint32(what);
109 output.writeUint32(layerStack);
110 output.writeUint32(orientation);
111 output.write(viewport);
112 output.write(frame);
113 output.writeUint32(width);
114 output.writeUint32(height);
115 return NO_ERROR;
116 }
117
read(const Parcel & input)118 status_t DisplayState::read(const Parcel& input) {
119 token = input.readStrongBinder();
120 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
121 what = input.readUint32();
122 layerStack = input.readUint32();
123 orientation = input.readUint32();
124 input.read(viewport);
125 input.read(frame);
126 width = input.readUint32();
127 height = input.readUint32();
128 return NO_ERROR;
129 }
130
131
132 }; // namespace android
133