blob: 07f62c40e8cbe5b06fd9f1c4a2d4d571306535ff [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>
Mathias Agopian8b33f032012-07-24 20:43:54 -070020#include <gui/ISurfaceTexture.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 Agopianb6121422010-02-17 20:22:26 -080027 status_t err;
28
29 size_t len = transparentRegion.write(NULL, 0);
30 err = output.writeInt32(len);
31 if (err < NO_ERROR) return err;
32
33 void* buf = output.writeInplace(len);
34 if (buf == NULL) return NO_MEMORY;
35
36 err = transparentRegion.write(buf, len);
37 if (err < NO_ERROR) return err;
38
39 // NOTE: regions are at the end of the structure
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080040 size_t size = sizeof(layer_state_t);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080041 size -= sizeof(transparentRegion);
Mathias Agopianb6121422010-02-17 20:22:26 -080042 err = output.write(this, size);
43 return err;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080044}
45
46status_t layer_state_t::read(const Parcel& input)
47{
Mathias Agopianb6121422010-02-17 20:22:26 -080048 status_t err;
49 size_t len = input.readInt32();
50 void const* buf = input.readInplace(len);
51 if (buf == NULL) return NO_MEMORY;
52
53 err = transparentRegion.read(buf);
54 if (err < NO_ERROR) return err;
55
56 // NOTE: regions are at the end of the structure
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080057 size_t size = sizeof(layer_state_t);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080058 size -= sizeof(transparentRegion);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059 input.read(this, size);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080060 return NO_ERROR;
61}
62
Mathias Agopian698c0872011-06-28 19:09:31 -070063status_t ComposerState::write(Parcel& output) const {
64 output.writeStrongBinder(client->asBinder());
65 return state.write(output);
66}
67
68status_t ComposerState::read(const Parcel& input) {
69 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
70 return state.read(input);
71}
72
Mathias Agopian8b33f032012-07-24 20:43:54 -070073
74status_t DisplayState::write(Parcel& output) const {
Mathias Agopiane57f2922012-08-09 16:29:12 -070075 output.writeStrongBinder(token);
Mathias Agopian8b33f032012-07-24 20:43:54 -070076 output.writeStrongBinder(surface->asBinder());
Mathias Agopiane57f2922012-08-09 16:29:12 -070077 output.writeInt32(what);
Mathias Agopian8b33f032012-07-24 20:43:54 -070078 output.writeInt32(layerStack);
79 output.writeInt32(orientation);
80 memcpy(output.writeInplace(sizeof(Rect)), &viewport, sizeof(Rect));
81 memcpy(output.writeInplace(sizeof(Rect)), &frame, sizeof(Rect));
82 return NO_ERROR;
83}
84
85status_t DisplayState::read(const Parcel& input) {
Mathias Agopiane57f2922012-08-09 16:29:12 -070086 token = input.readStrongBinder();
Mathias Agopian8b33f032012-07-24 20:43:54 -070087 surface = interface_cast<ISurfaceTexture>(input.readStrongBinder());
Mathias Agopiane57f2922012-08-09 16:29:12 -070088 what = input.readInt32();
Mathias Agopian8b33f032012-07-24 20:43:54 -070089 layerStack = input.readInt32();
90 orientation = input.readInt32();
91 memcpy(&viewport, input.readInplace(sizeof(Rect)), sizeof(Rect));
92 memcpy(&frame, input.readInplace(sizeof(Rect)), sizeof(Rect));
93 return NO_ERROR;
94}
95
96
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097}; // namespace android