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> 18 #include <binder/Parcel.h> 19 #include <gui/ISurfaceComposerClient.h> 20 #include <gui/IGraphicBufferProducer.h> 21 #include <private/gui/LayerState.h> 22 23 namespace android { 24 write(Parcel & output) const25status_t layer_state_t::write(Parcel& output) const 26 { 27 output.writeStrongBinder(surface); 28 output.writeUint32(what); 29 output.writeFloat(x); 30 output.writeFloat(y); 31 output.writeUint32(z); 32 output.writeUint32(w); 33 output.writeUint32(h); 34 output.writeUint32(layerStack); 35 output.writeFloat(alpha); 36 output.writeUint32(flags); 37 output.writeUint32(mask); 38 *reinterpret_cast<layer_state_t::matrix22_t *>( 39 output.writeInplace(sizeof(layer_state_t::matrix22_t))) = matrix; 40 output.write(crop); 41 output.write(transparentRegion); 42 return NO_ERROR; 43 } 44 read(const Parcel & input)45status_t layer_state_t::read(const Parcel& input) 46 { 47 surface = input.readStrongBinder(); 48 what = input.readUint32(); 49 x = input.readFloat(); 50 y = input.readFloat(); 51 z = input.readUint32(); 52 w = input.readUint32(); 53 h = input.readUint32(); 54 layerStack = input.readUint32(); 55 alpha = input.readFloat(); 56 flags = static_cast<uint8_t>(input.readUint32()); 57 mask = static_cast<uint8_t>(input.readUint32()); 58 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); 59 if (matrix_data) { 60 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); 61 } else { 62 return BAD_VALUE; 63 } 64 input.read(crop); 65 input.read(transparentRegion); 66 return NO_ERROR; 67 } 68 write(Parcel & output) const69status_t ComposerState::write(Parcel& output) const { 70 output.writeStrongBinder(IInterface::asBinder(client)); 71 return state.write(output); 72 } 73 read(const Parcel & input)74status_t ComposerState::read(const Parcel& input) { 75 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); 76 return state.read(input); 77 } 78 79 write(Parcel & output) const80status_t DisplayState::write(Parcel& output) const { 81 output.writeStrongBinder(token); 82 output.writeStrongBinder(IInterface::asBinder(surface)); 83 output.writeUint32(what); 84 output.writeUint32(layerStack); 85 output.writeUint32(orientation); 86 output.write(viewport); 87 output.write(frame); 88 output.writeUint32(width); 89 output.writeUint32(height); 90 return NO_ERROR; 91 } 92 read(const Parcel & input)93status_t DisplayState::read(const Parcel& input) { 94 token = input.readStrongBinder(); 95 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 96 what = input.readUint32(); 97 layerStack = input.readUint32(); 98 orientation = input.readUint32(); 99 input.read(viewport); 100 input.read(frame); 101 width = input.readUint32(); 102 height = input.readUint32(); 103 return NO_ERROR; 104 } 105 106 107 }; // namespace android 108