LayerState.cpp revision 0617894190ea0c3ee50889bee1d4df0f369b0761
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 23namespace android { 24 25status_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.writeInt32(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(finalCrop); 42 output.writeStrongBinder(barrierHandle); 43 output.writeStrongBinder(reparentHandle); 44 output.writeUint64(frameNumber); 45 output.writeInt32(overrideScalingMode); 46 output.writeStrongBinder(IInterface::asBinder(barrierGbp)); 47 output.writeStrongBinder(relativeLayerHandle); 48 output.writeStrongBinder(parentHandleForChild); 49 output.writeStrongBinder(childHandle); 50 output.write(transparentRegion); 51 return NO_ERROR; 52} 53 54status_t layer_state_t::read(const Parcel& input) 55{ 56 surface = input.readStrongBinder(); 57 what = input.readUint32(); 58 x = input.readFloat(); 59 y = input.readFloat(); 60 z = input.readInt32(); 61 w = input.readUint32(); 62 h = input.readUint32(); 63 layerStack = input.readUint32(); 64 alpha = input.readFloat(); 65 flags = static_cast<uint8_t>(input.readUint32()); 66 mask = static_cast<uint8_t>(input.readUint32()); 67 const void* matrix_data = input.readInplace(sizeof(layer_state_t::matrix22_t)); 68 if (matrix_data) { 69 matrix = *reinterpret_cast<layer_state_t::matrix22_t const *>(matrix_data); 70 } else { 71 return BAD_VALUE; 72 } 73 input.read(crop); 74 input.read(finalCrop); 75 barrierHandle = input.readStrongBinder(); 76 reparentHandle = input.readStrongBinder(); 77 frameNumber = input.readUint64(); 78 overrideScalingMode = input.readInt32(); 79 barrierGbp = 80 interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 81 relativeLayerHandle = input.readStrongBinder(); 82 parentHandleForChild = input.readStrongBinder(); 83 childHandle = input.readStrongBinder(); 84 input.read(transparentRegion); 85 return NO_ERROR; 86} 87 88status_t ComposerState::write(Parcel& output) const { 89 output.writeStrongBinder(IInterface::asBinder(client)); 90 return state.write(output); 91} 92 93status_t ComposerState::read(const Parcel& input) { 94 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); 95 return state.read(input); 96} 97 98 99DisplayState::DisplayState() : 100 what(0), 101 layerStack(0), 102 orientation(eOrientationDefault), 103 viewport(Rect::EMPTY_RECT), 104 frame(Rect::EMPTY_RECT), 105 width(0), 106 height(0) { 107} 108 109status_t DisplayState::write(Parcel& output) const { 110 output.writeStrongBinder(token); 111 output.writeStrongBinder(IInterface::asBinder(surface)); 112 output.writeUint32(what); 113 output.writeUint32(layerStack); 114 output.writeUint32(orientation); 115 output.write(viewport); 116 output.write(frame); 117 output.writeUint32(width); 118 output.writeUint32(height); 119 return NO_ERROR; 120} 121 122status_t DisplayState::read(const Parcel& input) { 123 token = input.readStrongBinder(); 124 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 125 what = input.readUint32(); 126 layerStack = input.readUint32(); 127 orientation = input.readUint32(); 128 input.read(viewport); 129 input.read(frame); 130 width = input.readUint32(); 131 height = input.readUint32(); 132 return NO_ERROR; 133} 134 135 136}; // namespace android 137