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 | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 19 | #include <gui/ISurfaceComposerClient.h> |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 20 | #include <gui/ISurfaceTexture.h> |
Mathias Agopian | 90ac799 | 2012-02-25 18:48:35 -0800 | [diff] [blame] | 21 | #include <private/gui/LayerState.h> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | |
| 23 | namespace android { |
| 24 | |
| 25 | status_t layer_state_t::write(Parcel& output) const |
| 26 | { |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 27 | 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 40 | size_t size = sizeof(layer_state_t); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | size -= sizeof(transparentRegion); |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 42 | err = output.write(this, size); |
| 43 | return err; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 44 | } |
| 45 | |
| 46 | status_t layer_state_t::read(const Parcel& input) |
| 47 | { |
Mathias Agopian | b612142 | 2010-02-17 20:22:26 -0800 | [diff] [blame] | 48 | 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | size_t size = sizeof(layer_state_t); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | size -= sizeof(transparentRegion); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 59 | input.read(this, size); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 60 | return NO_ERROR; |
| 61 | } |
| 62 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 63 | status_t ComposerState::write(Parcel& output) const { |
| 64 | output.writeStrongBinder(client->asBinder()); |
| 65 | return state.write(output); |
| 66 | } |
| 67 | |
| 68 | status_t ComposerState::read(const Parcel& input) { |
| 69 | client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); |
| 70 | return state.read(input); |
| 71 | } |
| 72 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 73 | |
| 74 | status_t DisplayState::write(Parcel& output) const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame^] | 75 | output.writeStrongBinder(token); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 76 | output.writeStrongBinder(surface->asBinder()); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame^] | 77 | output.writeInt32(what); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 78 | 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 | |
| 85 | status_t DisplayState::read(const Parcel& input) { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame^] | 86 | token = input.readStrongBinder(); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 87 | surface = interface_cast<ISurfaceTexture>(input.readStrongBinder()); |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame^] | 88 | what = input.readInt32(); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 89 | 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 Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 97 | }; // namespace android |