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 #ifndef ANDROID_SF_LAYER_STATE_H
     18 #define ANDROID_SF_LAYER_STATE_H
     19 
     20 #include <stdint.h>
     21 #include <sys/types.h>
     22 
     23 #include <utils/Errors.h>
     24 
     25 #include <ui/Region.h>
     26 #include <ui/Rect.h>
     27 #include <gui/IGraphicBufferProducer.h>
     28 
     29 namespace android {
     30 
     31 class Parcel;
     32 class ISurfaceComposerClient;
     33 
     34 /*
     35  * Used to communicate layer information between SurfaceFlinger and its clients.
     36  */
     37 struct layer_state_t {
     38 
     39 
     40     enum {
     41         eLayerHidden        = 0x01,     // SURFACE_HIDDEN in SurfaceControl.java
     42         eLayerOpaque        = 0x02,     // SURFACE_OPAQUE
     43         eLayerSecure        = 0x80,     // SECURE
     44     };
     45 
     46     enum {
     47         ePositionChanged            = 0x00000001,
     48         eLayerChanged               = 0x00000002,
     49         eSizeChanged                = 0x00000004,
     50         eAlphaChanged               = 0x00000008,
     51         eMatrixChanged              = 0x00000010,
     52         eTransparentRegionChanged   = 0x00000020,
     53         eFlagsChanged               = 0x00000040,
     54         eLayerStackChanged          = 0x00000080,
     55         eCropChanged                = 0x00000100,
     56         eDeferTransaction           = 0x00000200,
     57         eFinalCropChanged           = 0x00000400,
     58         eOverrideScalingModeChanged = 0x00000800,
     59         eGeometryAppliesWithResize  = 0x00001000,
     60         eReparentChildren           = 0x00002000,
     61         eDetachChildren             = 0x00004000,
     62         eRelativeLayerChanged       = 0x00008000
     63     };
     64 
     65     layer_state_t()
     66         :   what(0),
     67             x(0), y(0), z(0), w(0), h(0), layerStack(0),
     68             alpha(0), flags(0), mask(0),
     69             reserved(0), crop(Rect::INVALID_RECT),
     70             finalCrop(Rect::INVALID_RECT), frameNumber(0),
     71             overrideScalingMode(-1)
     72     {
     73         matrix.dsdx = matrix.dtdy = 1.0f;
     74         matrix.dsdy = matrix.dtdx = 0.0f;
     75     }
     76 
     77     status_t    write(Parcel& output) const;
     78     status_t    read(const Parcel& input);
     79 
     80             struct matrix22_t {
     81                 float   dsdx{0};
     82                 float   dtdx{0};
     83                 float   dtdy{0};
     84                 float   dsdy{0};
     85             };
     86             sp<IBinder>     surface;
     87             uint32_t        what;
     88             float           x;
     89             float           y;
     90             int32_t         z;
     91             uint32_t        w;
     92             uint32_t        h;
     93             uint32_t        layerStack;
     94             float           alpha;
     95             uint8_t         flags;
     96             uint8_t         mask;
     97             uint8_t         reserved;
     98             matrix22_t      matrix;
     99             Rect            crop;
    100             Rect            finalCrop;
    101             sp<IBinder>     barrierHandle;
    102             sp<IBinder>     reparentHandle;
    103             uint64_t        frameNumber;
    104             int32_t         overrideScalingMode;
    105 
    106             sp<IGraphicBufferProducer> barrierGbp;
    107 
    108             sp<IBinder>     relativeLayerHandle;
    109 
    110             // non POD must be last. see write/read
    111             Region          transparentRegion;
    112 };
    113 
    114 struct ComposerState {
    115     sp<ISurfaceComposerClient> client;
    116     layer_state_t state;
    117     status_t    write(Parcel& output) const;
    118     status_t    read(const Parcel& input);
    119 };
    120 
    121 struct DisplayState {
    122 
    123     enum {
    124         eOrientationDefault     = 0,
    125         eOrientation90          = 1,
    126         eOrientation180         = 2,
    127         eOrientation270         = 3,
    128         eOrientationUnchanged   = 4,
    129         eOrientationSwapMask    = 0x01
    130     };
    131 
    132     enum {
    133         eSurfaceChanged             = 0x01,
    134         eLayerStackChanged          = 0x02,
    135         eDisplayProjectionChanged   = 0x04,
    136         eDisplaySizeChanged         = 0x08
    137     };
    138 
    139     DisplayState();
    140 
    141     uint32_t what;
    142     sp<IBinder> token;
    143     sp<IGraphicBufferProducer> surface;
    144     uint32_t layerStack;
    145     uint32_t orientation;
    146     Rect viewport;
    147     Rect frame;
    148     uint32_t width, height;
    149     status_t write(Parcel& output) const;
    150     status_t read(const Parcel& input);
    151 };
    152 
    153 }; // namespace android
    154 
    155 #endif // ANDROID_SF_LAYER_STATE_H
    156 
    157