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/ISurfaceTexture.h>
     21 #include <private/gui/LayerState.h>
     22 
     23 namespace android {
     24 
     25 status_t layer_state_t::write(Parcel& output) const
     26 {
     27     status_t err;
     28 
     29     err = output.write(transparentRegion);
     30     if (err < NO_ERROR) return err;
     31 
     32     // NOTE: regions are at the end of the structure
     33     size_t size = sizeof(layer_state_t);
     34     size -= sizeof(transparentRegion);
     35     err = output.write(this, size);
     36     return err;
     37 }
     38 
     39 status_t layer_state_t::read(const Parcel& input)
     40 {
     41     status_t err;
     42 
     43     err = input.read(transparentRegion);
     44     if (err < NO_ERROR) return err;
     45 
     46     // NOTE: regions are at the end of the structure
     47     size_t size = sizeof(layer_state_t);
     48     size -= sizeof(transparentRegion);
     49     input.read(this, size);
     50     return NO_ERROR;
     51 }
     52 
     53 status_t ComposerState::write(Parcel& output) const {
     54     output.writeStrongBinder(client->asBinder());
     55     return state.write(output);
     56 }
     57 
     58 status_t ComposerState::read(const Parcel& input) {
     59     client = interface_cast<ISurfaceComposerClient>(input.readStrongBinder());
     60     return state.read(input);
     61 }
     62 
     63 
     64 status_t DisplayState::write(Parcel& output) const {
     65     output.writeStrongBinder(token);
     66     output.writeStrongBinder(surface->asBinder());
     67     output.writeInt32(what);
     68     output.writeInt32(layerStack);
     69     output.writeInt32(orientation);
     70     output.write(viewport);
     71     output.write(frame);
     72     return NO_ERROR;
     73 }
     74 
     75 status_t DisplayState::read(const Parcel& input) {
     76     token = input.readStrongBinder();
     77     surface = interface_cast<ISurfaceTexture>(input.readStrongBinder());
     78     what = input.readInt32();
     79     layerStack = input.readInt32();
     80     orientation = input.readInt32();
     81     input.read(viewport);
     82     input.read(frame);
     83     return NO_ERROR;
     84 }
     85 
     86 
     87 }; // namespace android
     88