The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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> |
Mathias Agopian | c5b2c0b | 2009-05-19 19:08:10 -0700 | [diff] [blame] | 18 | #include <binder/Parcel.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 19 | #include <private/surfaceflinger/LayerState.h> |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 20 | #include <surfaceflinger/ISurfaceComposerClient.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 21 | |
| 22 | namespace android { |
| 23 | |
| 24 | status_t layer_state_t::write(Parcel& output) const |
| 25 | { |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 26 | status_t err; |
| 27 | |
| 28 | size_t len = transparentRegion.write(NULL, 0); |
| 29 | err = output.writeInt32(len); |
| 30 | if (err < NO_ERROR) return err; |
| 31 | |
| 32 | void* buf = output.writeInplace(len); |
| 33 | if (buf == NULL) return NO_MEMORY; |
| 34 | |
| 35 | err = transparentRegion.write(buf, len); |
| 36 | if (err < NO_ERROR) return err; |
| 37 | |
| 38 | // NOTE: regions are at the end of the structure |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 39 | size_t size = sizeof(layer_state_t); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | size -= sizeof(transparentRegion); |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 41 | err = output.write(this, size); |
| 42 | return err; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | status_t layer_state_t::read(const Parcel& input) |
| 46 | { |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 47 | status_t err; |
| 48 | size_t len = input.readInt32(); |
| 49 | void const* buf = input.readInplace(len); |
| 50 | if (buf == NULL) return NO_MEMORY; |
| 51 | |
| 52 | err = transparentRegion.read(buf); |
| 53 | if (err < NO_ERROR) return err; |
| 54 | |
| 55 | // NOTE: regions are at the end of the structure |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 56 | size_t size = sizeof(layer_state_t); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | size -= sizeof(transparentRegion); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | input.read(this, size); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | return NO_ERROR; |
| 60 | } |
| 61 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 62 | status_t ComposerState::write(Parcel& output) const { |
| 63 | output.writeStrongBinder(client->asBinder()); |
| 64 | return state.write(output); |
| 65 | } |
| 66 | |
| 67 | status_t ComposerState::read(const Parcel& input) { |
| 68 | client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); |
| 69 | return state.read(input); |
| 70 | } |
| 71 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 72 | }; // namespace android |