LayerState.cpp revision 6cf6af0299f7e48bc5bcdcd6a6c0f5a8725e9411
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.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(finalCrop); 42 output.writeStrongBinder(handle); 43 output.writeUint64(frameNumber); 44 output.writeInt32(overrideScalingMode); 45 output.writeUint32(type); 46 output.writeUint32(appid); 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.readUint32(); 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 handle = input.readStrongBinder(); 73 frameNumber = input.readUint64(); 74 overrideScalingMode = input.readInt32(); 75 type = input.readUint32(); 76 appid = input.readUint32(); 77 input.read(transparentRegion); 78 return NO_ERROR; 79} 80 81status_t ComposerState::write(Parcel& output) const { 82 output.writeStrongBinder(IInterface::asBinder(client)); 83 return state.write(output); 84} 85 86status_t ComposerState::read(const Parcel& input) { 87 client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder()); 88 return state.read(input); 89} 90 91 92DisplayState::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 102status_t DisplayState::write(Parcel& output) const { 103 output.writeStrongBinder(token); 104 output.writeStrongBinder(IInterface::asBinder(surface)); 105 output.writeUint32(what); 106 output.writeUint32(layerStack); 107 output.writeUint32(orientation); 108 output.write(viewport); 109 output.write(frame); 110 output.writeUint32(width); 111 output.writeUint32(height); 112 return NO_ERROR; 113} 114 115status_t DisplayState::read(const Parcel& input) { 116 token = input.readStrongBinder(); 117 surface = interface_cast<IGraphicBufferProducer>(input.readStrongBinder()); 118 what = input.readUint32(); 119 layerStack = input.readUint32(); 120 orientation = input.readUint32(); 121 input.read(viewport); 122 input.read(frame); 123 width = input.readUint32(); 124 height = input.readUint32(); 125 return NO_ERROR; 126} 127 128 129}; // namespace android 130