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