LayerState.cpp revision 1db73f66624e7d151710483dd58e03eed672f064
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
23namespace android {
24
25status_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(handle);
43    output.writeStrongBinder(reparentHandle);
44    output.writeUint64(frameNumber);
45    output.writeInt32(overrideScalingMode);
46    output.writeUint32(type);
47    output.writeUint32(appid);
48    output.write(transparentRegion);
49    return NO_ERROR;
50}
51
52status_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    handle = input.readStrongBinder();
74    reparentHandle = input.readStrongBinder();
75    frameNumber = input.readUint64();
76    overrideScalingMode = input.readInt32();
77    type = input.readUint32();
78    appid = input.readUint32();
79    input.read(transparentRegion);
80    return NO_ERROR;
81}
82
83status_t ComposerState::write(Parcel& output) const {
84    output.writeStrongBinder(IInterface::asBinder(client));
85    return state.write(output);
86}
87
88status_t ComposerState::read(const Parcel& input) {
89    client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
90    return state.read(input);
91}
92
93
94DisplayState::DisplayState() :
95    what(0),
96    layerStack(0),
97    orientation(eOrientationDefault),
98    viewport(Rect::EMPTY_RECT),
99    frame(Rect::EMPTY_RECT),
100    width(0),
101    height(0) {
102}
103
104status_t DisplayState::write(Parcel& output) const {
105    output.writeStrongBinder(token);
106    output.writeStrongBinder(IInterface::asBinder(surface));
107    output.writeUint32(what);
108    output.writeUint32(layerStack);
109    output.writeUint32(orientation);
110    output.write(viewport);
111    output.write(frame);
112    output.writeUint32(width);
113    output.writeUint32(height);
114    return NO_ERROR;
115}
116
117status_t DisplayState::read(const Parcel& input) {
118    token = input.readStrongBinder();
119    surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder());
120    what = input.readUint32();
121    layerStack = input.readUint32();
122    orientation = input.readUint32();
123    input.read(viewport);
124    input.read(frame);
125    width = input.readUint32();
126    height = input.readUint32();
127    return NO_ERROR;
128}
129
130
131}; // namespace android
132