blob: ae6965a0fc5334d9f94a3dd8941f0a515be1ee26 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
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
Mathias Agopian9cce3252010-02-09 17:46:37 -080017#ifndef ANDROID_SF_LAYER_STATE_H
18#define ANDROID_SF_LAYER_STATE_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080019
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/Errors.h>
24
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080025#include <ui/Region.h>
Jamie Gennisf15a83f2012-05-10 20:43:55 -070026#include <ui/Rect.h>
Robert Carr0d480722017-01-10 16:42:54 -080027#include <gui/IGraphicBufferProducer.h>
chaviw13fdc492017-06-27 12:40:18 -070028#include <math/vec3.h>
Mathias Agopian9cce3252010-02-09 17:46:37 -080029
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080030namespace android {
31
32class Parcel;
Mathias Agopian698c0872011-06-28 19:09:31 -070033class ISurfaceComposerClient;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080034
Andy McFadden4125a4f2014-01-29 17:17:11 -080035/*
36 * Used to communicate layer information between SurfaceFlinger and its clients.
37 */
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080038struct layer_state_t {
39
Mathias Agopian3165cc22012-08-08 19:42:09 -070040
41 enum {
Andy McFadden4125a4f2014-01-29 17:17:11 -080042 eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java
43 eLayerOpaque = 0x02, // SURFACE_OPAQUE
Dan Stoza23116082015-06-18 14:58:39 -070044 eLayerSecure = 0x80, // SECURE
Mathias Agopian3165cc22012-08-08 19:42:09 -070045 };
46
47 enum {
48 ePositionChanged = 0x00000001,
49 eLayerChanged = 0x00000002,
50 eSizeChanged = 0x00000004,
51 eAlphaChanged = 0x00000008,
52 eMatrixChanged = 0x00000010,
53 eTransparentRegionChanged = 0x00000020,
Dan Stoza23116082015-06-18 14:58:39 -070054 eFlagsChanged = 0x00000040,
Mathias Agopian3165cc22012-08-08 19:42:09 -070055 eLayerStackChanged = 0x00000080,
56 eCropChanged = 0x00000100,
Pablo Ceballosacbe6782016-03-04 17:54:21 +000057 eDeferTransaction = 0x00000200,
Robert Carrc3574f72016-03-24 12:19:32 -070058 eFinalCropChanged = 0x00000400,
Robert Carr82364e32016-05-15 11:27:47 -070059 eOverrideScalingModeChanged = 0x00000800,
Robert Carr99e27f02016-06-16 15:18:02 -070060 eGeometryAppliesWithResize = 0x00001000,
Albert Chaulk479c60c2017-01-27 14:21:34 -050061 eReparentChildren = 0x00002000,
Robert Carrdb66e622017-04-10 16:55:57 -070062 eDetachChildren = 0x00004000,
chaviw06178942017-07-27 10:25:59 -070063 eRelativeLayerChanged = 0x00008000,
chaviw13fdc492017-06-27 12:40:18 -070064 eReparent = 0x00010000,
65 eColorChanged = 0x00020000
Mathias Agopian3165cc22012-08-08 19:42:09 -070066 };
67
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080068 layer_state_t()
Mathias Agopianac9fa422013-02-11 16:40:36 -080069 : what(0),
Mathias Agopian87855782012-07-24 21:41:09 -070070 x(0), y(0), z(0), w(0), h(0), layerStack(0),
Jeff Brown6501e992012-07-16 15:38:18 -070071 alpha(0), flags(0), mask(0),
Pablo Ceballosacbe6782016-03-04 17:54:21 +000072 reserved(0), crop(Rect::INVALID_RECT),
Robert Carrc3574f72016-03-24 12:19:32 -070073 finalCrop(Rect::INVALID_RECT), frameNumber(0),
Albert Chaulk479c60c2017-01-27 14:21:34 -050074 overrideScalingMode(-1)
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080075 {
76 matrix.dsdx = matrix.dtdy = 1.0f;
77 matrix.dsdy = matrix.dtdx = 0.0f;
78 }
79
80 status_t write(Parcel& output) const;
81 status_t read(const Parcel& input);
82
83 struct matrix22_t {
Pablo Ceballosbd3577e2016-06-20 17:40:34 -070084 float dsdx{0};
85 float dtdx{0};
Pablo Ceballosbd3577e2016-06-20 17:40:34 -070086 float dtdy{0};
Robert Carrcb6e1e32017-02-21 19:48:26 -080087 float dsdy{0};
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080088 };
Mathias Agopianac9fa422013-02-11 16:40:36 -080089 sp<IBinder> surface;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080090 uint32_t what;
Mathias Agopian41b6aab2011-08-30 18:51:54 -070091 float x;
92 float y;
Robert Carrae060832016-11-28 10:51:00 -080093 int32_t z;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080094 uint32_t w;
95 uint32_t h;
Mathias Agopian87855782012-07-24 21:41:09 -070096 uint32_t layerStack;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080097 float alpha;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080098 uint8_t flags;
99 uint8_t mask;
100 uint8_t reserved;
101 matrix22_t matrix;
Jamie Gennisf15a83f2012-05-10 20:43:55 -0700102 Rect crop;
Pablo Ceballosacbe6782016-03-04 17:54:21 +0000103 Rect finalCrop;
Robert Carr0d480722017-01-10 16:42:54 -0800104 sp<IBinder> barrierHandle;
Robert Carr1db73f62016-12-21 12:58:51 -0800105 sp<IBinder> reparentHandle;
Dan Stoza7dde5992015-05-22 09:51:44 -0700106 uint64_t frameNumber;
Robert Carrc3574f72016-03-24 12:19:32 -0700107 int32_t overrideScalingMode;
Robert Carr0d480722017-01-10 16:42:54 -0800108
109 sp<IGraphicBufferProducer> barrierGbp;
110
Robert Carrdb66e622017-04-10 16:55:57 -0700111 sp<IBinder> relativeLayerHandle;
112
chaviw06178942017-07-27 10:25:59 -0700113 sp<IBinder> parentHandleForChild;
chaviw06178942017-07-27 10:25:59 -0700114
chaviw13fdc492017-06-27 12:40:18 -0700115 half3 color;
116
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800117 // non POD must be last. see write/read
118 Region transparentRegion;
119};
120
Mathias Agopian698c0872011-06-28 19:09:31 -0700121struct ComposerState {
122 sp<ISurfaceComposerClient> client;
123 layer_state_t state;
124 status_t write(Parcel& output) const;
125 status_t read(const Parcel& input);
126};
127
Mathias Agopian8b33f032012-07-24 20:43:54 -0700128struct DisplayState {
Mathias Agopian3165cc22012-08-08 19:42:09 -0700129
130 enum {
131 eOrientationDefault = 0,
132 eOrientation90 = 1,
133 eOrientation180 = 2,
134 eOrientation270 = 3,
135 eOrientationUnchanged = 4,
136 eOrientationSwapMask = 0x01
137 };
138
Mathias Agopiane57f2922012-08-09 16:29:12 -0700139 enum {
Mathias Agopian00e8c7a2012-09-04 19:30:46 -0700140 eSurfaceChanged = 0x01,
141 eLayerStackChanged = 0x02,
Michael Wright1f6078a2014-06-26 16:01:02 -0700142 eDisplayProjectionChanged = 0x04,
143 eDisplaySizeChanged = 0x08
Mathias Agopiane57f2922012-08-09 16:29:12 -0700144 };
145
Pablo Ceballos60d69222015-08-07 14:47:20 -0700146 DisplayState();
147
Mathias Agopiane57f2922012-08-09 16:29:12 -0700148 uint32_t what;
149 sp<IBinder> token;
Andy McFadden2adaf042012-12-18 09:49:45 -0800150 sp<IGraphicBufferProducer> surface;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700151 uint32_t layerStack;
152 uint32_t orientation;
153 Rect viewport;
154 Rect frame;
Michael Wright1f6078a2014-06-26 16:01:02 -0700155 uint32_t width, height;
Mathias Agopiane57f2922012-08-09 16:29:12 -0700156 status_t write(Parcel& output) const;
157 status_t read(const Parcel& input);
Mathias Agopian8b33f032012-07-24 20:43:54 -0700158};
159
Robert Carr4cdc58f2017-08-23 14:22:20 -0700160static inline
161int compare_type(const ComposerState& lhs, const ComposerState& rhs) {
162 if (lhs.client < rhs.client) return -1;
163 if (lhs.client > rhs.client) return 1;
164 if (lhs.state.surface < rhs.state.surface) return -1;
165 if (lhs.state.surface > rhs.state.surface) return 1;
166 return 0;
167}
168
169static inline
170int compare_type(const DisplayState& lhs, const DisplayState& rhs) {
171 return compare_type(lhs.token, rhs.token);
172}
173
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800174}; // namespace android
175
Mathias Agopian9cce3252010-02-09 17:46:37 -0800176#endif // ANDROID_SF_LAYER_STATE_H
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800177