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> |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 20 | #include <gui/IGraphicBufferProducer.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 | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 27 | output.writeStrongBinder(surface); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 28 | output.writeUint32(what); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 29 | output.writeFloat(x); |
| 30 | output.writeFloat(y); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 31 | output.writeUint32(z); |
| 32 | output.writeUint32(w); |
| 33 | output.writeUint32(h); |
| 34 | output.writeUint32(layerStack); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 35 | output.writeFloat(alpha); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 36 | output.writeUint32(flags); |
| 37 | output.writeUint32(mask); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 38 | *reinterpret_cast<layer_state_t::matrix22_t *>( |
| 39 | output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix; |
| 40 | output.write(crop); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 41 | output.write(finalCrop); |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 42 | output.writeStrongBinder(handle); |
| 43 | output.writeUint64(frameNumber); |
Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 44 | output.writeInt32(overrideScalingMode); |
Albert Chaulk | 6cf6af0 | 2016-11-22 13:52:43 -0500 | [diff] [blame^] | 45 | output.writeUint32(type); |
| 46 | output.writeUint32(appid); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 47 | output.write(transparentRegion); |
| 48 | return NO_ERROR; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | status_t layer_state_t::read(const Parcel& input) |
| 52 | { |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 53 | surface = input.readStrongBinder(); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 54 | what = input.readUint32(); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 55 | x = input.readFloat(); |
| 56 | y = input.readFloat(); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 57 | z = input.readUint32(); |
| 58 | w = input.readUint32(); |
| 59 | h = input.readUint32(); |
| 60 | layerStack = input.readUint32(); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 61 | alpha = input.readFloat(); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 62 | flags = static_cast<uint8_t>(input.readUint32()); |
| 63 | mask = static_cast<uint8_t>(input.readUint32()); |
Michael Lentine | 8afa1c4 | 2014-10-31 11:10:13 -0700 | [diff] [blame] | 64 | const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); |
| 65 | if (matrix_data) { |
| 66 | matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); |
| 67 | } else { |
| 68 | return BAD_VALUE; |
| 69 | } |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 70 | input.read(crop); |
Pablo Ceballos | acbe678 | 2016-03-04 17:54:21 +0000 | [diff] [blame] | 71 | input.read(finalCrop); |
Dan Stoza | 7dde599 | 2015-05-22 09:51:44 -0700 | [diff] [blame] | 72 | handle = input.readStrongBinder(); |
| 73 | frameNumber = input.readUint64(); |
Robert Carr | c3574f7 | 2016-03-24 12:19:32 -0700 | [diff] [blame] | 74 | overrideScalingMode = input.readInt32(); |
Albert Chaulk | 6cf6af0 | 2016-11-22 13:52:43 -0500 | [diff] [blame^] | 75 | type = input.readUint32(); |
| 76 | appid = input.readUint32(); |
Mathias Agopian | ac9fa42 | 2013-02-11 16:40:36 -0800 | [diff] [blame] | 77 | input.read(transparentRegion); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 78 | return NO_ERROR; |
| 79 | } |
| 80 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 81 | status_t ComposerState::write(Parcel& output) const { |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 82 | output.writeStrongBinder(IInterface::asBinder(client)); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 83 | return state.write(output); |
| 84 | } |
| 85 | |
| 86 | status_t ComposerState::read(const Parcel& input) { |
| 87 | client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); |
| 88 | return state.read(input); |
| 89 | } |
| 90 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 91 | |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 92 | DisplayState::DisplayState() : |
| 93 | what(0), |
| 94 | layerStack(0), |
| 95 | orientation(eOrientationDefault), |
| 96 | viewport(Rect::EMPTY_RECT), |
| 97 | frame(Rect::EMPTY_RECT), |
| 98 | width(0), |
| 99 | height(0) { |
| 100 | } |
| 101 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 102 | status_t DisplayState::write(Parcel& output) const { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 103 | output.writeStrongBinder(token); |
Marco Nelissen | 2ea926b | 2014-11-14 08:01:01 -0800 | [diff] [blame] | 104 | output.writeStrongBinder(IInterface::asBinder(surface)); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 105 | output.writeUint32(what); |
| 106 | output.writeUint32(layerStack); |
| 107 | output.writeUint32(orientation); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 108 | output.write(viewport); |
| 109 | output.write(frame); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 110 | output.writeUint32(width); |
| 111 | output.writeUint32(height); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 112 | return NO_ERROR; |
| 113 | } |
| 114 | |
| 115 | status_t DisplayState::read(const Parcel& input) { |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 116 | token = input.readStrongBinder(); |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 117 | surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 118 | what = input.readUint32(); |
| 119 | layerStack = input.readUint32(); |
| 120 | orientation = input.readUint32(); |
Mathias Agopian | 8683fca | 2012-08-12 19:37:16 -0700 | [diff] [blame] | 121 | input.read(viewport); |
| 122 | input.read(frame); |
Dan Stoza | d723bd7 | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 123 | width = input.readUint32(); |
| 124 | height = input.readUint32(); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 125 | return NO_ERROR; |
| 126 | } |
| 127 | |
| 128 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 129 | }; // namespace android |