blob: fb6c8171331d59aa35b363aa1b2ce5c8e587bb24 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
2 * Copyright (C) 2007 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
Dominik Laskowski718f9602019-11-09 20:01:35 -080017#pragma once
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080018
Peiyong Linefefaac2018-08-17 12:27:51 -070019#include <memory>
Dominik Laskowski075d3172018-05-24 15:50:06 -070020#include <optional>
Peiyong Linefefaac2018-08-17 12:27:51 -070021#include <string>
Peiyong Lin136fbbc2018-04-17 15:09:44 -070022#include <unordered_map>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023
Alec Mourif6fd29e2018-11-17 04:56:41 +000024#include <android/native_window.h>
Dan Stoza9e56aa02015-11-02 13:00:03 -080025#include <binder/IBinder.h>
Chia-I Wuf2aa3112018-08-27 14:54:37 -070026#include <gui/LayerState.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070027#include <hardware/hwcomposer_defs.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070028#include <math/mat4.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080029#include <renderengine/RenderEngine.h>
Alec Mourif6fd29e2018-11-17 04:56:41 +000030#include <system/window.h>
Dominik Laskowski55c85402020-01-21 16:25:47 -080031#include <ui/DisplayInfo.h>
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080032#include <ui/DisplayState.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070033#include <ui/GraphicTypes.h>
Peiyong Linfb069302018-04-25 14:34:31 -070034#include <ui/HdrCapabilities.h>
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -070035#include <ui/Region.h>
Peiyong Linefefaac2018-08-17 12:27:51 -070036#include <ui/Transform.h>
Alec Mouri8d4f90a2018-11-14 22:33:24 +000037#include <utils/Mutex.h>
Alec Mouri0a9c7b82018-11-16 13:05:25 -080038#include <utils/RefBase.h>
Mathias Agopian86303202012-07-24 22:46:10 -070039#include <utils/Timers.h>
40
Dominik Laskowski075d3172018-05-24 15:50:06 -070041#include "DisplayHardware/DisplayIdentification.h"
Lloyd Pique688abd42019-02-15 15:42:24 -080042#include "DisplayHardware/PowerAdvisor.h"
chaviwa76b2712017-09-20 12:02:26 -070043#include "RenderArea.h"
Ady Abraham2139f732019-11-13 18:56:40 -080044#include "Scheduler/HwcStrongTypes.h"
Mathias Agopianf4358632012-08-22 17:16:19 -070045
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080046namespace android {
47
Dan Stoza9e56aa02015-11-02 13:00:03 -080048class Fence;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070049class HWComposer;
Jesse Hall9e663de2013-08-16 14:28:37 -070050class IGraphicBufferProducer;
Mathias Agopian13127d82013-03-05 17:47:11 -080051class Layer;
Mathias Agopian86303202012-07-24 22:46:10 -070052class SurfaceFlinger;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070053
David Sodmanfb95bcc2017-12-22 15:45:30 -080054struct CompositionInfo;
Lloyd Pique2eef1d22018-09-18 21:30:04 -070055struct DisplayDeviceCreationArgs;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080056
Lloyd Pique45a165a2018-10-19 11:54:47 -070057namespace compositionengine {
58class Display;
Lloyd Pique542307f2018-10-19 13:24:08 -070059class DisplaySurface;
Lloyd Pique45a165a2018-10-19 11:54:47 -070060} // namespace compositionengine
61
62class DisplayDevice : public LightRefBase<DisplayDevice> {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063public:
Peiyong Linfb069302018-04-25 14:34:31 -070064 constexpr static float sDefaultMinLumiance = 0.0;
65 constexpr static float sDefaultMaxLumiance = 500.0;
66
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -070067 explicit DisplayDevice(DisplayDeviceCreationArgs& args);
Lloyd Pique45a165a2018-10-19 11:54:47 -070068 virtual ~DisplayDevice();
69
70 std::shared_ptr<compositionengine::Display> getCompositionDisplay() const {
71 return mCompositionDisplay;
72 }
Mathias Agopian92a979a2012-08-02 18:32:23 -070073
Dominik Laskowski55c85402020-01-21 16:25:47 -080074 std::optional<DisplayConnectionType> getConnectionType() const { return mConnectionType; }
75
76 bool isVirtual() const { return !mConnectionType; }
Dominik Laskowski075d3172018-05-24 15:50:06 -070077 bool isPrimary() const { return mIsPrimary; }
Mathias Agopian92a979a2012-08-02 18:32:23 -070078
Jamie Gennisdd3cb842012-10-19 18:19:11 -070079 // isSecure indicates whether this display can be trusted to display
80 // secure surfaces.
Lloyd Pique45a165a2018-10-19 11:54:47 -070081 bool isSecure() const;
Jamie Gennisdd3cb842012-10-19 18:19:11 -070082
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080083 int getWidth() const;
84 int getHeight() const;
85 ui::Size getSize() const { return {getWidth(), getHeight()}; }
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070086
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -080087 void setLayerStack(ui::LayerStack);
88 void setDisplaySize(int width, int height);
Dominik Laskowski718f9602019-11-09 20:01:35 -080089 void setProjection(ui::Rotation orientation, Rect viewport, Rect frame);
90
91 ui::Rotation getPhysicalOrientation() const { return mPhysicalOrientation; }
92 ui::Rotation getOrientation() const { return mOrientation; }
93
94 static ui::Transform::RotationFlags getPrimaryDisplayRotationFlags();
95
Lloyd Pique32cbe282018-10-19 13:09:22 -070096 const ui::Transform& getTransform() const;
97 const Rect& getViewport() const;
98 const Rect& getFrame() const;
Lloyd Piquee8fe4742020-01-21 15:26:18 -080099 const Rect& getSourceClip() const;
Lloyd Pique32cbe282018-10-19 13:09:22 -0700100 bool needsFiltering() const;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800101 ui::LayerStack getLayerStack() const;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700102
Lloyd Pique45a165a2018-10-19 11:54:47 -0700103 const std::optional<DisplayId>& getId() const;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700104 const wp<IBinder>& getDisplayToken() const { return mDisplayToken; }
Dominik Laskowskie9774092018-12-11 10:04:24 -0800105 int32_t getSequenceId() const { return mSequenceId; }
Mathias Agopian87baae12012-07-31 12:38:26 -0700106
Lloyd Pique32cbe282018-10-19 13:09:22 -0700107 const Region& getUndefinedRegion() const;
108
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700109 int32_t getSupportedPerFrameMetadata() const;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700110
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700111 bool hasWideColorGamut() const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700112 // Whether h/w composer has native support for specific HDR type.
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700113 bool hasHDR10PlusSupport() const;
114 bool hasHDR10Support() const;
115 bool hasHLGSupport() const;
116 bool hasDolbyVisionSupport() const;
Chia-I Wube02ec02018-05-18 10:59:36 -0700117
Peiyong Linfb069302018-04-25 14:34:31 -0700118 // The returned HdrCapabilities is the combination of HDR capabilities from
119 // hardware composer and RenderEngine. When the DisplayDevice supports wide
120 // color gamut, RenderEngine is able to simulate HDR support in Display P3
121 // color space for both PQ and HLG HDR contents. The minimum and maximum
122 // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance
123 // respectively if hardware composer doesn't return meaningful values.
Lloyd Pique3d0c02e2018-10-19 18:38:12 -0700124 const HdrCapabilities& getHdrCapabilities() const;
Jesse Hall38efe862013-04-06 23:12:29 -0700125
Chia-I Wube02ec02018-05-18 10:59:36 -0700126 // Return true if intent is supported by the display.
127 bool hasRenderIntent(ui::RenderIntent intent) const;
Peiyong Lin136fbbc2018-04-17 15:09:44 -0700128
Lloyd Pique32cbe282018-10-19 13:09:22 -0700129 const Rect& getBounds() const;
130 const Rect& bounds() const { return getBounds(); }
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800131
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700132 void setDisplayName(const std::string& displayName);
133 const std::string& getDisplayName() const { return mDisplayName; }
Andy McFadden8dfa92f2012-09-17 18:27:17 -0700134
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700135 /* ------------------------------------------------------------------------
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700136 * Display power mode management.
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700137 */
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700138 int getPowerMode() const;
139 void setPowerMode(int mode);
Dominik Laskowskieecd6592018-05-29 10:25:41 -0700140 bool isPoweredOn() const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700141
Peiyong Lindd9b2ae2018-03-01 16:22:45 -0800142 ui::Dataspace getCompositionDataSpace() const;
Michael Wright28f24d02016-07-12 13:30:53 -0700143
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700144 /* ------------------------------------------------------------------------
145 * Display active config management.
146 */
Ady Abraham2139f732019-11-13 18:56:40 -0800147 HwcConfigIndexType getActiveConfig() const;
148 void setActiveConfig(HwcConfigIndexType mode);
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700149
Jesse Hall02d86562013-03-25 14:43:23 -0700150 // release HWC resources (if any) for removable displays
Lloyd Pique45a165a2018-10-19 11:54:47 -0700151 void disconnect();
Jesse Hall02d86562013-03-25 14:43:23 -0700152
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700153 /* ------------------------------------------------------------------------
154 * Debugging
155 */
156 uint32_t getPageFlipCount() const;
Dominik Laskowski9b17b2c22018-11-01 14:49:03 -0700157 std::string getDebugName() const;
Yiwei Zhang5434a782018-12-05 18:06:32 -0800158 void dump(std::string& result) const;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700159
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800160private:
Dominik Laskowski075d3172018-05-24 15:50:06 -0700161 const sp<SurfaceFlinger> mFlinger;
162 const wp<IBinder> mDisplayToken;
Dominik Laskowskie9774092018-12-11 10:04:24 -0800163 const int32_t mSequenceId;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800164 const std::optional<DisplayConnectionType> mConnectionType;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700165
Lloyd Pique45a165a2018-10-19 11:54:47 -0700166 const std::shared_ptr<compositionengine::Display> mCompositionDisplay;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700167
Lloyd Pique31cb2942018-10-19 17:23:03 -0700168 std::string mDisplayName;
Mathias Agopian03e40722012-04-26 16:11:59 -0700169
Dominik Laskowski718f9602019-11-09 20:01:35 -0800170 const ui::Rotation mPhysicalOrientation;
171 ui::Rotation mOrientation = ui::ROTATION_0;
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700172
Dominik Laskowski718f9602019-11-09 20:01:35 -0800173 static ui::Transform::RotationFlags sPrimaryDisplayRotationFlags;
Mathias Agopianda8d0a52012-09-04 15:05:38 -0700174
Dominik Laskowski718f9602019-11-09 20:01:35 -0800175 int mPowerMode = HWC_POWER_MODE_OFF;
Ady Abraham2139f732019-11-13 18:56:40 -0800176 HwcConfigIndexType mActiveConfig;
Courtney Goeltzenleuchter5d943892017-03-22 13:46:46 -0600177
Dominik Laskowski075d3172018-05-24 15:50:06 -0700178 // TODO(b/74619554): Remove special cases for primary display.
179 const bool mIsPrimary;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -0800180};
181
Irvelffc9efc2016-07-27 15:16:37 -0700182struct DisplayDeviceState {
Dominik Laskowski55c85402020-01-21 16:25:47 -0800183 struct Physical {
184 DisplayId id;
185 DisplayConnectionType type;
186
187 bool operator==(const Physical& other) const {
188 return id == other.id && type == other.type;
189 }
190 };
191
192 bool isVirtual() const { return !physical; }
Irvelffc9efc2016-07-27 15:16:37 -0700193
Dominik Laskowski663bd282018-04-19 15:26:54 -0700194 int32_t sequenceId = sNextSequenceId++;
Dominik Laskowski55c85402020-01-21 16:25:47 -0800195 std::optional<Physical> physical;
Irvelffc9efc2016-07-27 15:16:37 -0700196 sp<IGraphicBufferProducer> surface;
Dominik Laskowski3cb3d4e2019-11-21 11:14:45 -0800197 ui::LayerStack layerStack = ui::NO_LAYER_STACK;
Irvelffc9efc2016-07-27 15:16:37 -0700198 Rect viewport;
199 Rect frame;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800200 ui::Rotation orientation = ui::ROTATION_0;
Irvelffc9efc2016-07-27 15:16:37 -0700201 uint32_t width = 0;
202 uint32_t height = 0;
Dominik Laskowskibf170d92018-04-19 15:08:05 -0700203 std::string displayName;
Irvelffc9efc2016-07-27 15:16:37 -0700204 bool isSecure = false;
Dominik Laskowski663bd282018-04-19 15:26:54 -0700205
206private:
207 static std::atomic<int32_t> sNextSequenceId;
Irvelffc9efc2016-07-27 15:16:37 -0700208};
209
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700210struct DisplayDeviceCreationArgs {
211 // We use a constructor to ensure some of the values are set, without
212 // assuming a default value.
Dominik Laskowski55c85402020-01-21 16:25:47 -0800213 DisplayDeviceCreationArgs(const sp<SurfaceFlinger>&, const wp<IBinder>& displayToken,
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700214 std::shared_ptr<compositionengine::Display>);
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700215 const sp<SurfaceFlinger> flinger;
216 const wp<IBinder> displayToken;
Lloyd Piqueaad4ebf2019-10-03 17:58:30 -0700217 const std::shared_ptr<compositionengine::Display> compositionDisplay;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700218
Dominik Laskowskie9774092018-12-11 10:04:24 -0800219 int32_t sequenceId{0};
Dominik Laskowski55c85402020-01-21 16:25:47 -0800220 std::optional<DisplayConnectionType> connectionType;
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700221 bool isSecure{false};
222 sp<ANativeWindow> nativeWindow;
Lloyd Pique542307f2018-10-19 13:24:08 -0700223 sp<compositionengine::DisplaySurface> displaySurface;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800224 ui::Rotation physicalOrientation{ui::ROTATION_0};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700225 bool hasWideColorGamut{false};
226 HdrCapabilities hdrCapabilities;
227 int32_t supportedPerFrameMetadata{0};
228 std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>> hwcColorModes;
229 int initialPowerMode{HWC_POWER_MODE_NORMAL};
Dominik Laskowski075d3172018-05-24 15:50:06 -0700230 bool isPrimary{false};
Lloyd Pique2eef1d22018-09-18 21:30:04 -0700231};
232
chaviwa76b2712017-09-20 12:02:26 -0700233class DisplayRenderArea : public RenderArea {
234public:
Dominik Laskowski718f9602019-11-09 20:01:35 -0800235 DisplayRenderArea(const sp<const DisplayDevice>& display,
236 RotationFlags rotation = ui::Transform::ROT_0)
Ady Abraham8a82ba62020-01-17 12:43:17 -0800237 : DisplayRenderArea(display, display->getBounds(),
238 static_cast<uint32_t>(display->getWidth()),
239 static_cast<uint32_t>(display->getHeight()),
240 display->getCompositionDataSpace(), rotation) {}
Dominik Laskowski718f9602019-11-09 20:01:35 -0800241
242 DisplayRenderArea(sp<const DisplayDevice> display, const Rect& sourceCrop, uint32_t reqWidth,
243 uint32_t reqHeight, ui::Dataspace reqDataSpace, RotationFlags rotation,
244 bool allowSecureLayers = true)
Peiyong Lin0e003c92018-09-17 11:09:51 -0700245 : RenderArea(reqWidth, reqHeight, CaptureFill::OPAQUE, reqDataSpace,
Dominik Laskowski718f9602019-11-09 20:01:35 -0800246 display->getViewport(),
247 applyInversePhysicalOrientation(rotation,
248 display->getPhysicalOrientation())),
249 mDisplay(std::move(display)),
Robert Carrfa8855f2019-02-19 10:05:00 -0800250 mSourceCrop(sourceCrop),
251 mAllowSecureLayers(allowSecureLayers) {}
chaviwa76b2712017-09-20 12:02:26 -0700252
Dominik Laskowski718f9602019-11-09 20:01:35 -0800253 const ui::Transform& getTransform() const override { return mDisplay->getTransform(); }
254 Rect getBounds() const override { return mDisplay->getBounds(); }
255 int getHeight() const override { return mDisplay->getHeight(); }
256 int getWidth() const override { return mDisplay->getWidth(); }
257 bool isSecure() const override { return mAllowSecureLayers && mDisplay->isSecure(); }
258 sp<const DisplayDevice> getDisplayDevice() const override { return mDisplay; }
Chia-I Wu5f6664c2018-08-28 11:01:44 -0700259
260 bool needsFiltering() const override {
Chia-I Wu8730ba82018-08-29 09:25:59 -0700261 // check if the projection from the logical display to the physical
262 // display needs filtering
Dominik Laskowski718f9602019-11-09 20:01:35 -0800263 if (mDisplay->needsFiltering()) {
Chia-I Wu5f6664c2018-08-28 11:01:44 -0700264 return true;
265 }
266
Chia-I Wu8730ba82018-08-29 09:25:59 -0700267 // check if the projection from the logical render area (i.e., the
268 // physical display) to the physical render area requires filtering
Chia-I Wu5f6664c2018-08-28 11:01:44 -0700269 const Rect sourceCrop = getSourceCrop();
270 int width = sourceCrop.width();
271 int height = sourceCrop.height();
272 if (getRotationFlags() & ui::Transform::ROT_90) {
273 std::swap(width, height);
274 }
275 return width != getReqWidth() || height != getReqHeight();
276 }
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700277
278 Rect getSourceCrop() const override {
Alec Mouriadb75f42019-03-28 21:42:24 -0700279 // use the projected display viewport by default.
Chia-I Wu8730ba82018-08-29 09:25:59 -0700280 if (mSourceCrop.isEmpty()) {
Lloyd Piquee8fe4742020-01-21 15:26:18 -0800281 return mDisplay->getSourceClip();
Chia-I Wu8730ba82018-08-29 09:25:59 -0700282 }
283
Alec Mouriadb75f42019-03-28 21:42:24 -0700284 // Recompute the device transformation for the source crop.
285 ui::Transform rotation;
286 ui::Transform translatePhysical;
287 ui::Transform translateLogical;
288 ui::Transform scale;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800289 const Rect& viewport = mDisplay->getViewport();
Lloyd Piquee8fe4742020-01-21 15:26:18 -0800290 const Rect& sourceClip = mDisplay->getSourceClip();
Dominik Laskowski718f9602019-11-09 20:01:35 -0800291 const Rect& frame = mDisplay->getFrame();
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700292
Dominik Laskowski718f9602019-11-09 20:01:35 -0800293 const auto flags = ui::Transform::toRotationFlags(mDisplay->getPhysicalOrientation());
Alec Mouriadb75f42019-03-28 21:42:24 -0700294 rotation.set(flags, getWidth(), getHeight());
Dominik Laskowski718f9602019-11-09 20:01:35 -0800295
Alec Mouriadb75f42019-03-28 21:42:24 -0700296 translateLogical.set(-viewport.left, -viewport.top);
Lloyd Piquee8fe4742020-01-21 15:26:18 -0800297 translatePhysical.set(sourceClip.left, sourceClip.top);
Alec Mouriadb75f42019-03-28 21:42:24 -0700298 scale.set(frame.getWidth() / float(viewport.getWidth()), 0, 0,
299 frame.getHeight() / float(viewport.getHeight()));
300 const ui::Transform finalTransform =
301 rotation * translatePhysical * scale * translateLogical;
302 return finalTransform.transform(mSourceCrop);
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700303 }
chaviwa76b2712017-09-20 12:02:26 -0700304
305private:
Dominik Laskowski718f9602019-11-09 20:01:35 -0800306 static RotationFlags applyInversePhysicalOrientation(RotationFlags orientation,
307 ui::Rotation physicalOrientation) {
308 uint32_t inverseRotate90 = 0;
309 uint32_t inverseReflect = 0;
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700310
Dominik Laskowski718f9602019-11-09 20:01:35 -0800311 switch (physicalOrientation) {
312 case ui::ROTATION_0:
313 return orientation;
314
315 case ui::ROTATION_90:
316 inverseRotate90 = ui::Transform::ROT_90;
317 inverseReflect = ui::Transform::ROT_180;
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700318 break;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800319
320 case ui::ROTATION_180:
321 inverseReflect = ui::Transform::ROT_180;
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700322 break;
Dominik Laskowski718f9602019-11-09 20:01:35 -0800323
324 case ui::ROTATION_270:
325 inverseRotate90 = ui::Transform::ROT_90;
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700326 break;
327 }
328
Dominik Laskowski718f9602019-11-09 20:01:35 -0800329 const uint32_t rotate90 = orientation & ui::Transform::ROT_90;
330 uint32_t reflect = orientation & ui::Transform::ROT_180;
331
332 // Apply reflection for double rotation.
333 if (rotate90 & inverseRotate90) {
334 reflect = ~reflect & ui::Transform::ROT_180;
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700335 }
336
Dominik Laskowski718f9602019-11-09 20:01:35 -0800337 return static_cast<RotationFlags>((rotate90 ^ inverseRotate90) |
338 (reflect ^ inverseReflect));
Chia-I Wuf2aa3112018-08-27 14:54:37 -0700339 }
340
Dominik Laskowski718f9602019-11-09 20:01:35 -0800341 const sp<const DisplayDevice> mDisplay;
chaviwa76b2712017-09-20 12:02:26 -0700342 const Rect mSourceCrop;
Robert Carrfa8855f2019-02-19 10:05:00 -0800343 const bool mAllowSecureLayers;
chaviwa76b2712017-09-20 12:02:26 -0700344};
345
Dominik Laskowski718f9602019-11-09 20:01:35 -0800346} // namespace android