blob: 01c4c7ebfe8482b73a2c6388ce6cd06213e7b607 [file] [log] [blame]
The Android Open Source Project9066cfe2009-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 Agopian07952722009-05-19 19:08:10 -070018#include <binder/Parcel.h>
Mathias Agopian000479f2010-02-09 17:46:37 -080019#include <private/surfaceflinger/LayerState.h>
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080020
21namespace android {
22
23status_t layer_state_t::write(Parcel& output) const
24{
Mathias Agopiane59a54c2010-02-17 20:22:26 -080025 status_t err;
26
27 size_t len = transparentRegion.write(NULL, 0);
28 err = output.writeInt32(len);
29 if (err < NO_ERROR) return err;
30
31 void* buf = output.writeInplace(len);
32 if (buf == NULL) return NO_MEMORY;
33
34 err = transparentRegion.write(buf, len);
35 if (err < NO_ERROR) return err;
36
37 // NOTE: regions are at the end of the structure
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 size_t size = sizeof(layer_state_t);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080039 size -= sizeof(transparentRegion);
Mathias Agopiane59a54c2010-02-17 20:22:26 -080040 err = output.write(this, size);
41 return err;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080042}
43
44status_t layer_state_t::read(const Parcel& input)
45{
Mathias Agopiane59a54c2010-02-17 20:22:26 -080046 status_t err;
47 size_t len = input.readInt32();
48 void const* buf = input.readInplace(len);
49 if (buf == NULL) return NO_MEMORY;
50
51 err = transparentRegion.read(buf);
52 if (err < NO_ERROR) return err;
53
54 // NOTE: regions are at the end of the structure
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080055 size_t size = sizeof(layer_state_t);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080056 size -= sizeof(transparentRegion);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080057 input.read(this, size);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080058 return NO_ERROR;
59}
60
61}; // namespace android