The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 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 | |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 17 | #ifndef ANDROID_SF_LAYER_STATE_H |
| 18 | #define ANDROID_SF_LAYER_STATE_H |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <sys/types.h> |
| 22 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 23 | #include <android/native_window.h> |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 24 | #include <gui/IGraphicBufferProducer.h> |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 25 | #include <gui/ITransactionCompletedListener.h> |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 26 | #include <math/mat4.h> |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 27 | |
| 28 | #ifndef NO_INPUT |
| 29 | #include <input/InputWindow.h> |
| 30 | #endif |
| 31 | |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 32 | #include <gui/LayerMetadata.h> |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 33 | #include <math/vec3.h> |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 34 | #include <ui/GraphicTypes.h> |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 35 | #include <ui/Rect.h> |
| 36 | #include <ui/Region.h> |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 37 | #include <ui/Rotation.h> |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 38 | #include <ui/Transform.h> |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 39 | #include <utils/Errors.h> |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 40 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | namespace android { |
| 42 | |
| 43 | class Parcel; |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 44 | class ISurfaceComposerClient; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 46 | struct client_cache_t { |
| 47 | wp<IBinder> token = nullptr; |
| 48 | uint64_t id; |
| 49 | |
| 50 | bool operator==(const client_cache_t& other) const { return id == other.id; } |
| 51 | |
| 52 | bool isValid() const { return token != nullptr; } |
Marissa Wall | 78b7220 | 2019-03-15 14:58:34 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Andy McFadden | 4125a4f | 2014-01-29 17:17:11 -0800 | [diff] [blame] | 55 | /* |
| 56 | * Used to communicate layer information between SurfaceFlinger and its clients. |
| 57 | */ |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 58 | struct layer_state_t { |
Mathias Agopian | 3165cc2 | 2012-08-08 19:42:09 -0700 | [diff] [blame] | 59 | enum { |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 60 | eLayerHidden = 0x01, // SURFACE_HIDDEN in SurfaceControl.java |
| 61 | eLayerOpaque = 0x02, // SURFACE_OPAQUE |
| 62 | eLayerSecure = 0x80, // SECURE |
Mathias Agopian | 3165cc2 | 2012-08-08 19:42:09 -0700 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | enum { |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 66 | ePositionChanged = 0x00000001, |
| 67 | eLayerChanged = 0x00000002, |
| 68 | eSizeChanged = 0x00000004, |
| 69 | eAlphaChanged = 0x00000008, |
| 70 | eMatrixChanged = 0x00000010, |
| 71 | eTransparentRegionChanged = 0x00000020, |
| 72 | eFlagsChanged = 0x00000040, |
| 73 | eLayerStackChanged = 0x00000080, |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 74 | eCropChanged_legacy = 0x00000100, |
| 75 | eDeferTransaction_legacy = 0x00000200, |
Vishnu Nair | dcce0e2 | 2018-08-23 08:35:19 -0700 | [diff] [blame] | 76 | eOverrideScalingModeChanged = 0x00000400, |
Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 77 | eShadowRadiusChanged = 0x00000800, |
Vishnu Nair | dcce0e2 | 2018-08-23 08:35:19 -0700 | [diff] [blame] | 78 | eReparentChildren = 0x00001000, |
| 79 | eDetachChildren = 0x00002000, |
| 80 | eRelativeLayerChanged = 0x00004000, |
| 81 | eReparent = 0x00008000, |
| 82 | eColorChanged = 0x00010000, |
| 83 | eDestroySurface = 0x00020000, |
| 84 | eTransformChanged = 0x00040000, |
| 85 | eTransformToDisplayInverseChanged = 0x00080000, |
| 86 | eCropChanged = 0x00100000, |
| 87 | eBufferChanged = 0x00200000, |
| 88 | eAcquireFenceChanged = 0x00400000, |
| 89 | eDataspaceChanged = 0x00800000, |
| 90 | eHdrMetadataChanged = 0x01000000, |
| 91 | eSurfaceDamageRegionChanged = 0x02000000, |
| 92 | eApiChanged = 0x04000000, |
| 93 | eSidebandStreamChanged = 0x08000000, |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 94 | eColorTransformChanged = 0x10000000, |
Marissa Wall | 3dad52d | 2019-03-22 14:03:19 -0700 | [diff] [blame] | 95 | eHasListenerCallbacksChanged = 0x20000000, |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 96 | eInputInfoChanged = 0x40000000, |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 97 | eCornerRadiusChanged = 0x80000000, |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 98 | eFrameChanged = 0x1'00000000, |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 99 | eCachedBufferChanged = 0x2'00000000, |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 100 | eBackgroundColorChanged = 0x4'00000000, |
| 101 | eMetadataChanged = 0x8'00000000, |
Peiyong Lin | c502cb7 | 2019-03-01 15:00:23 -0800 | [diff] [blame] | 102 | eColorSpaceAgnosticChanged = 0x10'00000000, |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 103 | eFrameRateSelectionPriority = 0x20'00000000, |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 104 | eFrameRateChanged = 0x40'00000000, |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 105 | eBackgroundBlurRadiusChanged = 0x80'00000000, |
Valerie Hau | 871d635 | 2020-01-29 08:44:02 -0800 | [diff] [blame] | 106 | eProducerDisconnect = 0x100'00000000, |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 107 | eFixedTransformHintChanged = 0x200'00000000, |
Mathias Agopian | 3165cc2 | 2012-08-08 19:42:09 -0700 | [diff] [blame] | 108 | }; |
| 109 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 110 | layer_state_t() |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 111 | : what(0), |
| 112 | x(0), |
| 113 | y(0), |
| 114 | z(0), |
| 115 | w(0), |
| 116 | h(0), |
| 117 | layerStack(0), |
| 118 | alpha(0), |
| 119 | flags(0), |
| 120 | mask(0), |
| 121 | reserved(0), |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 122 | crop_legacy(Rect::INVALID_RECT), |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 123 | cornerRadius(0.0f), |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 124 | backgroundBlurRadius(0), |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 125 | frameNumber_legacy(0), |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 126 | overrideScalingMode(-1), |
| 127 | transform(0), |
| 128 | transformToDisplayInverse(false), |
| 129 | crop(Rect::INVALID_RECT), |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 130 | frame(Rect::INVALID_RECT), |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 131 | dataspace(ui::Dataspace::UNKNOWN), |
| 132 | surfaceDamageRegion(), |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 133 | api(-1), |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 134 | colorTransform(mat4()), |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 135 | bgColorAlpha(0), |
Peiyong Lin | c502cb7 | 2019-03-01 15:00:23 -0800 | [diff] [blame] | 136 | bgColorDataspace(ui::Dataspace::UNKNOWN), |
Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 137 | colorSpaceAgnostic(false), |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 138 | shadowRadius(0.0f), |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 139 | frameRateSelectionPriority(-1), |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 140 | frameRate(0.0f), |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 141 | frameRateCompatibility(ANATIVEWINDOW_FRAME_RATE_COMPATIBILITY_DEFAULT), |
| 142 | fixedTransformHint(ui::Transform::ROT_INVALID) { |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 143 | matrix.dsdx = matrix.dtdy = 1.0f; |
| 144 | matrix.dsdy = matrix.dtdx = 0.0f; |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 145 | hdrMetadata.validTypes = 0; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 146 | } |
| 147 | |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 148 | void merge(const layer_state_t& other); |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 149 | status_t write(Parcel& output) const; |
| 150 | status_t read(const Parcel& input); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 151 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 152 | struct matrix22_t { |
| 153 | float dsdx{0}; |
| 154 | float dtdx{0}; |
| 155 | float dtdy{0}; |
| 156 | float dsdy{0}; |
| 157 | }; |
| 158 | sp<IBinder> surface; |
Garfield Tan | 8a3083e | 2018-12-03 13:21:07 -0800 | [diff] [blame] | 159 | uint64_t what; |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 160 | float x; |
| 161 | float y; |
| 162 | int32_t z; |
| 163 | uint32_t w; |
| 164 | uint32_t h; |
| 165 | uint32_t layerStack; |
| 166 | float alpha; |
| 167 | uint8_t flags; |
| 168 | uint8_t mask; |
| 169 | uint8_t reserved; |
| 170 | matrix22_t matrix; |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 171 | Rect crop_legacy; |
Lucas Dupin | 1b6531c | 2018-07-05 17:18:21 -0700 | [diff] [blame] | 172 | float cornerRadius; |
Lucas Dupin | 19c8f0e | 2019-11-25 17:55:44 -0800 | [diff] [blame] | 173 | uint32_t backgroundBlurRadius; |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 174 | sp<IBinder> barrierHandle_legacy; |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 175 | sp<IBinder> reparentHandle; |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 176 | uint64_t frameNumber_legacy; |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 177 | int32_t overrideScalingMode; |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 178 | |
Marissa Wall | f58c14b | 2018-07-24 10:50:43 -0700 | [diff] [blame] | 179 | sp<IGraphicBufferProducer> barrierGbp_legacy; |
Robert Carr | 0d48072 | 2017-01-10 16:42:54 -0800 | [diff] [blame] | 180 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 181 | sp<IBinder> relativeLayerHandle; |
Robert Carr | db66e62 | 2017-04-10 16:55:57 -0700 | [diff] [blame] | 182 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 183 | sp<IBinder> parentHandleForChild; |
chaviw | 0617894 | 2017-07-27 10:25:59 -0700 | [diff] [blame] | 184 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 185 | half3 color; |
chaviw | 13fdc49 | 2017-06-27 12:40:18 -0700 | [diff] [blame] | 186 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 187 | // non POD must be last. see write/read |
| 188 | Region transparentRegion; |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 189 | |
| 190 | uint32_t transform; |
| 191 | bool transformToDisplayInverse; |
| 192 | Rect crop; |
Marissa Wall | 861616d | 2018-10-22 12:52:23 -0700 | [diff] [blame] | 193 | Rect frame; |
Marissa Wall | 61c5862 | 2018-07-18 10:12:20 -0700 | [diff] [blame] | 194 | sp<GraphicBuffer> buffer; |
| 195 | sp<Fence> acquireFence; |
| 196 | ui::Dataspace dataspace; |
| 197 | HdrMetadata hdrMetadata; |
| 198 | Region surfaceDamageRegion; |
| 199 | int32_t api; |
| 200 | sp<NativeHandle> sidebandStream; |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 201 | mat4 colorTransform; |
Marissa Wall | c837b5e | 2018-10-12 10:04:44 -0700 | [diff] [blame] | 202 | |
Robert Carr | 2c358bf | 2018-08-08 15:58:15 -0700 | [diff] [blame] | 203 | #ifndef NO_INPUT |
| 204 | InputWindowInfo inputInfo; |
| 205 | #endif |
Marissa Wall | ebc2c05 | 2019-01-16 19:16:55 -0800 | [diff] [blame] | 206 | |
Marissa Wall | 947d34e | 2019-03-29 14:03:53 -0700 | [diff] [blame] | 207 | client_cache_t cachedBuffer; |
Valerie Hau | ed54efa | 2019-01-11 20:03:14 -0800 | [diff] [blame] | 208 | |
Evan Rosky | 1f6d6d5 | 2018-12-06 10:47:26 -0800 | [diff] [blame] | 209 | LayerMetadata metadata; |
Valerie Hau | dd0b757 | 2019-01-29 14:59:27 -0800 | [diff] [blame] | 210 | |
| 211 | // The following refer to the alpha, and dataspace, respectively of |
| 212 | // the background color layer |
| 213 | float bgColorAlpha; |
| 214 | ui::Dataspace bgColorDataspace; |
Peiyong Lin | c502cb7 | 2019-03-01 15:00:23 -0800 | [diff] [blame] | 215 | |
| 216 | // A color space agnostic layer means the color of this layer can be |
| 217 | // interpreted in any color space. |
| 218 | bool colorSpaceAgnostic; |
Valerie Hau | 9dab973 | 2019-08-20 09:29:25 -0700 | [diff] [blame] | 219 | |
| 220 | std::vector<ListenerCallbacks> listeners; |
Vishnu Nair | c97b8db | 2019-10-29 18:19:35 -0700 | [diff] [blame] | 221 | |
| 222 | // Draws a shadow around the surface. |
| 223 | float shadowRadius; |
Ana Krulec | c84d09b | 2019-11-02 23:10:29 +0100 | [diff] [blame] | 224 | |
| 225 | // Priority of the layer assigned by Window Manager. |
| 226 | int32_t frameRateSelectionPriority; |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 227 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 228 | // Layer frame rate and compatibility. See ANativeWindow_setFrameRate(). |
Steven Thomas | 3172e20 | 2020-01-06 19:25:30 -0800 | [diff] [blame] | 229 | float frameRate; |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 230 | int8_t frameRateCompatibility; |
Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 231 | |
| 232 | // Set by window manager indicating the layer and all its children are |
| 233 | // in a different orientation than the display. The hint suggests that |
| 234 | // the graphic producers should receive a transform hint as if the |
| 235 | // display was in this orientation. When the display changes to match |
| 236 | // the layer orientation, the graphic producer may not need to allocate |
| 237 | // a buffer of a different size. -1 means the transform hint is not set, |
| 238 | // otherwise the value will be a valid ui::Rotation. |
| 239 | ui::Transform::RotationFlags fixedTransformHint; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 240 | }; |
| 241 | |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 242 | struct ComposerState { |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 243 | layer_state_t state; |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 244 | status_t write(Parcel& output) const; |
| 245 | status_t read(const Parcel& input); |
Mathias Agopian | 698c087 | 2011-06-28 19:09:31 -0700 | [diff] [blame] | 246 | }; |
| 247 | |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 248 | struct DisplayState { |
Mathias Agopian | 3165cc2 | 2012-08-08 19:42:09 -0700 | [diff] [blame] | 249 | enum { |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 250 | eSurfaceChanged = 0x01, |
| 251 | eLayerStackChanged = 0x02, |
| 252 | eDisplayProjectionChanged = 0x04, |
| 253 | eDisplaySizeChanged = 0x08 |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 254 | }; |
| 255 | |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 256 | DisplayState(); |
Robert Carr | 2c5f6d2 | 2017-09-26 12:30:35 -0700 | [diff] [blame] | 257 | void merge(const DisplayState& other); |
Pablo Ceballos | 60d6922 | 2015-08-07 14:47:20 -0700 | [diff] [blame] | 258 | |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 259 | uint32_t what; |
| 260 | sp<IBinder> token; |
Andy McFadden | 2adaf04 | 2012-12-18 09:49:45 -0800 | [diff] [blame] | 261 | sp<IGraphicBufferProducer> surface; |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 262 | uint32_t layerStack; |
Chia-I Wu | ff79ef8 | 2018-08-22 15:27:32 -0700 | [diff] [blame] | 263 | |
| 264 | // These states define how layers are projected onto the physical display. |
| 265 | // |
| 266 | // Layers are first clipped to `viewport'. They are then translated and |
| 267 | // scaled from `viewport' to `frame'. Finally, they are rotated according |
| 268 | // to `orientation', `width', and `height'. |
| 269 | // |
| 270 | // For example, assume viewport is Rect(0, 0, 200, 100), frame is Rect(20, |
| 271 | // 10, 420, 210), and the size of the display is WxH. When orientation is |
| 272 | // 0, layers will be scaled by a factor of 2 and translated by (20, 10). |
| 273 | // When orientation is 1, layers will be additionally rotated by 90 |
| 274 | // degrees around the origin clockwise and translated by (W, 0). |
Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 275 | ui::Rotation orientation = ui::ROTATION_0; |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 276 | Rect viewport; |
| 277 | Rect frame; |
Chia-I Wu | ff79ef8 | 2018-08-22 15:27:32 -0700 | [diff] [blame] | 278 | |
Michael Wright | 1f6078a | 2014-06-26 16:01:02 -0700 | [diff] [blame] | 279 | uint32_t width, height; |
Chia-I Wu | ff79ef8 | 2018-08-22 15:27:32 -0700 | [diff] [blame] | 280 | |
Mathias Agopian | e57f292 | 2012-08-09 16:29:12 -0700 | [diff] [blame] | 281 | status_t write(Parcel& output) const; |
| 282 | status_t read(const Parcel& input); |
Mathias Agopian | 8b33f03 | 2012-07-24 20:43:54 -0700 | [diff] [blame] | 283 | }; |
| 284 | |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 285 | struct InputWindowCommands { |
chaviw | 291d88a | 2019-02-14 10:33:58 -0800 | [diff] [blame] | 286 | bool syncInputWindows{false}; |
chaviw | 273171b | 2018-12-26 11:46:30 -0800 | [diff] [blame] | 287 | |
| 288 | void merge(const InputWindowCommands& other); |
| 289 | void clear(); |
| 290 | void write(Parcel& output) const; |
| 291 | void read(const Parcel& input); |
| 292 | }; |
| 293 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 294 | static inline int compare_type(const ComposerState& lhs, const ComposerState& rhs) { |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 295 | if (lhs.state.surface < rhs.state.surface) return -1; |
| 296 | if (lhs.state.surface > rhs.state.surface) return 1; |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 297 | return 0; |
| 298 | } |
| 299 | |
Marissa Wall | 1130324 | 2018-07-26 13:36:24 -0700 | [diff] [blame] | 300 | static inline int compare_type(const DisplayState& lhs, const DisplayState& rhs) { |
Robert Carr | 4cdc58f | 2017-08-23 14:22:20 -0700 | [diff] [blame] | 301 | return compare_type(lhs.token, rhs.token); |
| 302 | } |
| 303 | |
Steven Thomas | 62a4cf8 | 2020-01-31 12:04:03 -0800 | [diff] [blame] | 304 | // Returns true if the frameRate and compatibility are valid values, false |
| 305 | // othwerise. If either of the params are invalid, an error log is printed, and |
| 306 | // functionName is added to the log to indicate which function call failed. |
| 307 | // functionName can be null. |
| 308 | bool ValidateFrameRate(float frameRate, int8_t compatibility, const char* functionName); |
| 309 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 310 | }; // namespace android |
| 311 | |
Mathias Agopian | 9cce325 | 2010-02-09 17:46:37 -0800 | [diff] [blame] | 312 | #endif // ANDROID_SF_LAYER_STATE_H |