LayerState.cpp revision 0d48072f6047140119ff194c1194ce402fca2c0b
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.write(transparentRegion); 48 return NO_ERROR; 49} 50 51status_t layer_state_t::read(const Parcel& input) 52{ 53 surface = input.readStrongBinder(); 54 what = input.readUint32(); 55 x = input.readFloat(); 56 y = input.readFloat(); 57 z = input.readInt32(); 58 w = input.readUint32(); 59 h = input.readUint32(); 60 layerStack = input.readUint32(); 61 alpha = input.readFloat(); 62 flags = static_cast<uint8_t>(input.readUint32()); 63 mask = static_cast<uint8_t>(input.readUint32()); 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 } 70 input.read(crop); 71 input.read(finalCrop); 72 barrierHandle = input.readStrongBinder(); 73 reparentHandle = input.readStrongBinder(); 74 frameNumber = input.readUint64(); 75 overrideScalingMode = input.readInt32(); 76 barrierGbp = 77 interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 78 input.read(transparentRegion); 79 return NO_ERROR; 80} 81 82status_t ComposerState::write(Parcel& output) const { 83 output.writeStrongBinder(IInterface::asBinder(client)); 84 return state.write(output); 85} 86 87status_t ComposerState::read(const Parcel& input) { 88 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); 89 return state.read(input); 90} 91 92 93DisplayState::DisplayState() : 94 what(0), 95 layerStack(0), 96 orientation(eOrientationDefault), 97 viewport(Rect::EMPTY_RECT), 98 frame(Rect::EMPTY_RECT), 99 width(0), 100 height(0) { 101} 102 103status_t DisplayState::write(Parcel& output) const { 104 output.writeStrongBinder(token); 105 output.writeStrongBinder(IInterface::asBinder(surface)); 106 output.writeUint32(what); 107 output.writeUint32(layerStack); 108 output.writeUint32(orientation); 109 output.write(viewport); 110 output.write(frame); 111 output.writeUint32(width); 112 output.writeUint32(height); 113 return NO_ERROR; 114} 115 116status_t DisplayState::read(const Parcel& input) { 117 token = input.readStrongBinder(); 118 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 119 what = input.readUint32(); 120 layerStack = input.readUint32(); 121 orientation = input.readUint32(); 122 input.read(viewport); 123 input.read(frame); 124 width = input.readUint32(); 125 height = input.readUint32(); 126 return NO_ERROR; 127} 128 129 130}; // namespace android 131