OSDN Git Service

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