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