The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_DISPLAY_DEVICE_H |
| 18 | #define ANDROID_DISPLAY_DEVICE_H |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 19 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 20 | #include "Transform.h" |
| 21 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 22 | #include <stdlib.h> |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 23 | #include <unordered_map> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 24 | |
Yiwei Zhang | 7c64f17 | 2018-03-07 14:52:28 -0800 | [diff] [blame] | 25 | #include <math/mat4.h> |
| 26 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 27 | #include <binder/IBinder.h> |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 28 | #include <gui/ISurfaceComposer.h> |
| 29 | #include <hardware/hwcomposer_defs.h> |
| 30 | #include <ui/GraphicTypes.h> |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 31 | #include <ui/HdrCapabilities.h> |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 32 | #include <ui/Region.h> |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 33 | #include <utils/RefBase.h> |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 34 | #include <utils/Mutex.h> |
Mathias Agopian | 4f4f094 | 2013-08-19 17:26:18 -0700 | [diff] [blame] | 35 | #include <utils/String8.h> |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 36 | #include <utils/Timers.h> |
| 37 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 38 | #include "RenderArea.h" |
Chia-I Wu | f846a35 | 2017-11-10 09:22:52 -0800 | [diff] [blame] | 39 | #include "RenderEngine/Surface.h" |
Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 40 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 41 | #include <memory> |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 42 | #include <string> |
Mathias Agopian | 1f7bec6 | 2010-06-25 18:02:21 -0700 | [diff] [blame] | 43 | |
Mathias Agopian | d8552d7 | 2012-08-04 21:39:11 -0700 | [diff] [blame] | 44 | struct ANativeWindow; |
| 45 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 46 | namespace android { |
| 47 | |
Jesse Hall | 646f541 | 2014-08-07 22:19:07 -0700 | [diff] [blame] | 48 | struct DisplayInfo; |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 49 | class DisplaySurface; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 50 | class Fence; |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 51 | class IGraphicBufferProducer; |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 52 | class Layer; |
Mathias Agopian | 8630320 | 2012-07-24 22:46:10 -0700 | [diff] [blame] | 53 | class SurfaceFlinger; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 54 | class HWComposer; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 55 | |
Mathias Agopian | 028a757 | 2012-08-05 01:23:51 -0700 | [diff] [blame] | 56 | class DisplayDevice : public LightRefBase<DisplayDevice> |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 57 | { |
| 58 | public: |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 59 | constexpr static float sDefaultMinLumiance = 0.0; |
| 60 | constexpr static float sDefaultMaxLumiance = 500.0; |
| 61 | |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 62 | // region in layer-stack space |
| 63 | mutable Region dirtyRegion; |
| 64 | // region in screen space |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 65 | Region undefinedRegion; |
Jesse Hall | b7a0549 | 2014-08-14 15:45:06 -0700 | [diff] [blame] | 66 | bool lastCompositionHadVisibleLayers; |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 67 | |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame] | 68 | enum DisplayType { |
| 69 | DISPLAY_ID_INVALID = -1, |
| 70 | DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, |
| 71 | DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, |
Jesse Hall | 9e663de | 2013-08-16 14:28:37 -0700 | [diff] [blame] | 72 | DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, |
| 73 | NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES, |
Mathias Agopian | 92a979a | 2012-08-02 18:32:23 -0700 | [diff] [blame] | 74 | }; |
| 75 | |
| 76 | enum { |
Jesse Hall | 01e2905 | 2013-02-19 16:13:35 -0800 | [diff] [blame] | 77 | NO_LAYER_STACK = 0xFFFFFFFF, |
| 78 | }; |
| 79 | |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 80 | // clang-format off |
Mathias Agopian | 0f2f5ff | 2012-07-31 23:09:07 -0700 | [diff] [blame] | 81 | DisplayDevice( |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 82 | const sp<SurfaceFlinger>& flinger, |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 83 | DisplayType type, |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 84 | int32_t hwcId, |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 85 | bool isSecure, |
| 86 | const wp<IBinder>& displayToken, |
Lloyd Pique | 0959483 | 2018-01-22 17:48:03 -0800 | [diff] [blame] | 87 | const sp<ANativeWindow>& nativeWindow, |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 88 | const sp<DisplaySurface>& displaySurface, |
Lloyd Pique | 0959483 | 2018-01-22 17:48:03 -0800 | [diff] [blame] | 89 | std::unique_ptr<RE::Surface> renderSurface, |
| 90 | int displayWidth, |
| 91 | int displayHeight, |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 92 | bool hasWideColorGamut, |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 93 | const HdrCapabilities& hdrCapabilities, |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 94 | const int32_t supportedPerFrameMetadata, |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 95 | const std::unordered_map<ui::ColorMode, std::vector<ui::RenderIntent>>& hdrAndRenderIntents, |
Lloyd Pique | 0959483 | 2018-01-22 17:48:03 -0800 | [diff] [blame] | 96 | int initialPowerMode); |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 97 | // clang-format on |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 98 | |
Mathias Agopian | 028a757 | 2012-08-05 01:23:51 -0700 | [diff] [blame] | 99 | ~DisplayDevice(); |
Mathias Agopian | 92a979a | 2012-08-02 18:32:23 -0700 | [diff] [blame] | 100 | |
| 101 | // whether this is a valid object. An invalid DisplayDevice is returned |
| 102 | // when an non existing id is requested |
| 103 | bool isValid() const; |
| 104 | |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 105 | // isSecure indicates whether this display can be trusted to display |
| 106 | // secure surfaces. |
| 107 | bool isSecure() const { return mIsSecure; } |
| 108 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 109 | // Flip the front and back buffers if the back buffer is "dirty". Might |
| 110 | // be instantaneous, might involve copying the frame buffer around. |
Chia-I Wu | b02087d | 2017-11-09 10:19:54 -0800 | [diff] [blame] | 111 | void flip() const; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 112 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 113 | int getWidth() const; |
| 114 | int getHeight() const; |
Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 115 | |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 116 | void setVisibleLayersSortedByZ(const Vector< sp<Layer> >& layers); |
| 117 | const Vector< sp<Layer> >& getVisibleLayersSortedByZ() const; |
Chia-I Wu | 8380689 | 2017-11-16 10:50:20 -0800 | [diff] [blame] | 118 | void setLayersNeedingFences(const Vector< sp<Layer> >& layers); |
| 119 | const Vector< sp<Layer> >& getLayersNeedingFences() const; |
Mathias Agopian | cd60f99 | 2012-08-16 16:28:27 -0700 | [diff] [blame] | 120 | Region getDirtyRegion(bool repaintEverything) const; |
Mathias Agopian | 3b1d2b6 | 2012-07-11 13:48:17 -0700 | [diff] [blame] | 121 | |
Mathias Agopian | 28947d7 | 2012-08-08 18:51:15 -0700 | [diff] [blame] | 122 | void setLayerStack(uint32_t stack); |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 123 | void setDisplaySize(const int newWidth, const int newHeight); |
Mathias Agopian | 00e8c7a | 2012-09-04 19:30:46 -0700 | [diff] [blame] | 124 | void setProjection(int orientation, const Rect& viewport, const Rect& frame); |
Mathias Agopian | 28947d7 | 2012-08-08 18:51:15 -0700 | [diff] [blame] | 125 | |
Mathias Agopian | 1b03149 | 2012-06-20 17:51:20 -0700 | [diff] [blame] | 126 | int getOrientation() const { return mOrientation; } |
Mathias Agopian | c1c05de | 2013-09-17 23:45:22 -0700 | [diff] [blame] | 127 | uint32_t getOrientationTransform() const; |
Pablo Ceballos | 021623b | 2016-04-15 17:31:51 -0700 | [diff] [blame] | 128 | static uint32_t getPrimaryDisplayOrientationTransform(); |
Mathias Agopian | 1b03149 | 2012-06-20 17:51:20 -0700 | [diff] [blame] | 129 | const Transform& getTransform() const { return mGlobalTransform; } |
Mathias Agopian | f5f714a | 2013-02-26 16:54:05 -0800 | [diff] [blame] | 130 | const Rect getViewport() const { return mViewport; } |
| 131 | const Rect getFrame() const { return mFrame; } |
Mathias Agopian | 766dc49 | 2012-10-30 18:08:06 -0700 | [diff] [blame] | 132 | const Rect& getScissor() const { return mScissor; } |
Mathias Agopian | eba8c68 | 2012-09-19 23:14:45 -0700 | [diff] [blame] | 133 | bool needsFiltering() const { return mNeedsFiltering; } |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 134 | |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 135 | uint32_t getLayerStack() const { return mLayerStack; } |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame] | 136 | int32_t getDisplayType() const { return mType; } |
Chia-I Wu | ab0c319 | 2017-08-01 11:29:00 -0700 | [diff] [blame] | 137 | bool isPrimary() const { return mType == DISPLAY_PRIMARY; } |
Dominik Laskowski | 281644e | 2018-04-19 15:47:35 -0700 | [diff] [blame] | 138 | bool isVirtual() const { return mType == DISPLAY_VIRTUAL; } |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 139 | int32_t getHwcDisplayId() const { return mHwcDisplayId; } |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame] | 140 | const wp<IBinder>& getDisplayToken() const { return mDisplayToken; } |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 141 | |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 142 | int32_t getSupportedPerFrameMetadata() const { return mSupportedPerFrameMetadata; } |
| 143 | |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 144 | // We pass in mustRecompose so we can keep VirtualDisplaySurface's state |
| 145 | // machine happy without actually queueing a buffer if nothing has changed |
| 146 | status_t beginFrame(bool mustRecompose) const; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 147 | status_t prepareFrame(HWComposer& hwc); |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 148 | bool hasWideColorGamut() const { return mHasWideColorGamut; } |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 149 | // Whether h/w composer has native support for specific HDR type. |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 150 | bool hasHDR10Support() const { return mHasHdr10; } |
| 151 | bool hasHLGSupport() const { return mHasHLG; } |
| 152 | bool hasDolbyVisionSupport() const { return mHasDolbyVision; } |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 153 | // The returned HdrCapabilities is the combination of HDR capabilities from |
| 154 | // hardware composer and RenderEngine. When the DisplayDevice supports wide |
| 155 | // color gamut, RenderEngine is able to simulate HDR support in Display P3 |
| 156 | // color space for both PQ and HLG HDR contents. The minimum and maximum |
| 157 | // luminance will be set to sDefaultMinLumiance and sDefaultMaxLumiance |
| 158 | // respectively if hardware composer doesn't return meaningful values. |
| 159 | const HdrCapabilities& getHdrCapabilities() const { return mHdrCapabilities; } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 160 | |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 161 | // Whether h/w composer has BT2100_PQ color mode. |
| 162 | bool hasBT2100PQColorimetricSupport() const { return mHasBT2100PQColorimetric; } |
| 163 | bool hasBT2100PQEnhanceSupport() const { return mHasBT2100PQEnhance; } |
| 164 | |
| 165 | // Whether h/w composer has BT2100_HLG color mode. |
| 166 | bool hasBT2100HLGColorimetricSupport() const { return mHasBT2100HLGColorimetric; } |
| 167 | bool hasBT2100HLGEnhanceSupport() const { return mHasBT2100HLGEnhance; } |
| 168 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 169 | void swapBuffers(HWComposer& hwc) const; |
Jesse Hall | 01e2905 | 2013-02-19 16:13:35 -0800 | [diff] [blame] | 170 | |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 171 | // called after h/w composer has completed its set() call |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 172 | void onSwapBuffersCompleted() const; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 173 | |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 174 | Rect getBounds() const { |
Mathias Agopian | 1b03149 | 2012-06-20 17:51:20 -0700 | [diff] [blame] | 175 | return Rect(mDisplayWidth, mDisplayHeight); |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 176 | } |
Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 177 | inline Rect bounds() const { return getBounds(); } |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 178 | |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 179 | void setDisplayName(const std::string& displayName); |
| 180 | const std::string& getDisplayName() const { return mDisplayName; } |
Andy McFadden | 8dfa92f | 2012-09-17 18:27:17 -0700 | [diff] [blame] | 181 | |
Chia-I Wu | f846a35 | 2017-11-10 09:22:52 -0800 | [diff] [blame] | 182 | bool makeCurrent() const; |
Mathias Agopian | 875d8e1 | 2013-06-07 15:35:48 -0700 | [diff] [blame] | 183 | void setViewportAndProjection() const; |
Mathias Agopian | bae92d0 | 2012-09-28 01:00:47 -0700 | [diff] [blame] | 184 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 185 | const sp<Fence>& getClientTargetAcquireFence() const; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 186 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 187 | /* ------------------------------------------------------------------------ |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 188 | * Display power mode management. |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 189 | */ |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 190 | int getPowerMode() const; |
| 191 | void setPowerMode(int mode); |
| 192 | bool isDisplayOn() const; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 193 | |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 194 | ui::ColorMode getActiveColorMode() const; |
| 195 | void setActiveColorMode(ui::ColorMode mode); |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 196 | ui::RenderIntent getActiveRenderIntent() const; |
| 197 | void setActiveRenderIntent(ui::RenderIntent renderIntent); |
Yiwei Zhang | 7c64f17 | 2018-03-07 14:52:28 -0800 | [diff] [blame] | 198 | android_color_transform_t getColorTransform() const; |
| 199 | void setColorTransform(const mat4& transform); |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 200 | void setCompositionDataSpace(ui::Dataspace dataspace); |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 201 | ui::Dataspace getCompositionDataSpace() const; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 202 | |
Michael Lentine | 6c9e34a | 2014-07-14 13:48:55 -0700 | [diff] [blame] | 203 | /* ------------------------------------------------------------------------ |
| 204 | * Display active config management. |
| 205 | */ |
| 206 | int getActiveConfig() const; |
| 207 | void setActiveConfig(int mode); |
| 208 | |
Jesse Hall | 02d8656 | 2013-03-25 14:43:23 -0700 | [diff] [blame] | 209 | // release HWC resources (if any) for removable displays |
| 210 | void disconnect(HWComposer& hwc); |
| 211 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 212 | /* ------------------------------------------------------------------------ |
| 213 | * Debugging |
| 214 | */ |
| 215 | uint32_t getPageFlipCount() const; |
Mathias Agopian | 74d211a | 2013-04-22 16:55:35 +0200 | [diff] [blame] | 216 | void dump(String8& result) const; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 217 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 218 | private: |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 219 | void hasToneMapping(const std::vector<ui::RenderIntent>& renderIntents, |
| 220 | bool* outColorimetric, bool *outEnhance); |
| 221 | |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 222 | /* |
| 223 | * Constants, set during initialization |
| 224 | */ |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 225 | sp<SurfaceFlinger> mFlinger; |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame] | 226 | DisplayType mType; |
Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 227 | int32_t mHwcDisplayId; |
Mathias Agopian | 3ee454a | 2012-08-27 16:28:24 -0700 | [diff] [blame] | 228 | wp<IBinder> mDisplayToken; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 229 | |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 230 | // ANativeWindow this display is rendering into |
Mathias Agopian | d8552d7 | 2012-08-04 21:39:11 -0700 | [diff] [blame] | 231 | sp<ANativeWindow> mNativeWindow; |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 232 | sp<DisplaySurface> mDisplaySurface; |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 233 | |
Lloyd Pique | 144e116 | 2017-12-20 16:44:52 -0800 | [diff] [blame] | 234 | std::unique_ptr<RE::Surface> mSurface; |
Mathias Agopian | 1b03149 | 2012-06-20 17:51:20 -0700 | [diff] [blame] | 235 | int mDisplayWidth; |
| 236 | int mDisplayHeight; |
Mathias Agopian | 076b1cc | 2009-04-10 14:24:30 -0700 | [diff] [blame] | 237 | mutable uint32_t mPageFlipCount; |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 238 | std::string mDisplayName; |
Jamie Gennis | dd3cb84 | 2012-10-19 18:19:11 -0700 | [diff] [blame] | 239 | bool mIsSecure; |
Mathias Agopian | 03e4072 | 2012-04-26 16:11:59 -0700 | [diff] [blame] | 240 | |
Mathias Agopian | a491260 | 2012-07-12 14:25:33 -0700 | [diff] [blame] | 241 | /* |
| 242 | * Can only accessed from the main thread, these members |
| 243 | * don't need synchronization. |
| 244 | */ |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 245 | |
Mathias Agopian | 3b1d2b6 | 2012-07-11 13:48:17 -0700 | [diff] [blame] | 246 | // list of visible layers on that display |
Mathias Agopian | 13127d8 | 2013-03-05 17:47:11 -0800 | [diff] [blame] | 247 | Vector< sp<Layer> > mVisibleLayersSortedByZ; |
Chia-I Wu | 8380689 | 2017-11-16 10:50:20 -0800 | [diff] [blame] | 248 | // list of layers needing fences |
| 249 | Vector< sp<Layer> > mLayersNeedingFences; |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 250 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 251 | /* |
| 252 | * Transaction state |
| 253 | */ |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 254 | static status_t orientationToTransfrom(int orientation, |
| 255 | int w, int h, Transform* tr); |
| 256 | |
Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 257 | // The identifier of the active layer stack for this display. Several displays |
| 258 | // can use the same layer stack: A z-ordered group of layers (sometimes called |
| 259 | // "surfaces"). Any given layer can only be on a single layer stack. |
Mathias Agopian | 87baae1 | 2012-07-31 12:38:26 -0700 | [diff] [blame] | 260 | uint32_t mLayerStack; |
Fabien Sanglard | f0c53d6 | 2017-03-03 18:58:50 -0800 | [diff] [blame] | 261 | |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 262 | int mOrientation; |
Pablo Ceballos | 021623b | 2016-04-15 17:31:51 -0700 | [diff] [blame] | 263 | static uint32_t sPrimaryDisplayOrientation; |
Mathias Agopian | 766dc49 | 2012-10-30 18:08:06 -0700 | [diff] [blame] | 264 | // user-provided visible area of the layer stack |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 265 | Rect mViewport; |
Mathias Agopian | 766dc49 | 2012-10-30 18:08:06 -0700 | [diff] [blame] | 266 | // user-provided rectangle where mViewport gets mapped to |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 267 | Rect mFrame; |
Mathias Agopian | 766dc49 | 2012-10-30 18:08:06 -0700 | [diff] [blame] | 268 | // pre-computed scissor to apply to the display |
| 269 | Rect mScissor; |
Mathias Agopian | da8d0a5 | 2012-09-04 15:05:38 -0700 | [diff] [blame] | 270 | Transform mGlobalTransform; |
Mathias Agopian | eba8c68 | 2012-09-19 23:14:45 -0700 | [diff] [blame] | 271 | bool mNeedsFiltering; |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 272 | // Current power mode |
| 273 | int mPowerMode; |
Michael Lentine | 6c9e34a | 2014-07-14 13:48:55 -0700 | [diff] [blame] | 274 | // Current active config |
| 275 | int mActiveConfig; |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 276 | // current active color mode |
Chia-I Wu | 614e142 | 2018-05-23 02:17:03 -0700 | [diff] [blame^] | 277 | ui::ColorMode mActiveColorMode = ui::ColorMode::NATIVE; |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 278 | // Current active render intent. |
Chia-I Wu | 614e142 | 2018-05-23 02:17:03 -0700 | [diff] [blame^] | 279 | ui::RenderIntent mActiveRenderIntent = ui::RenderIntent::COLORIMETRIC; |
| 280 | ui::Dataspace mCompositionDataSpace = ui::Dataspace::UNKNOWN; |
Yiwei Zhang | 7c64f17 | 2018-03-07 14:52:28 -0800 | [diff] [blame] | 281 | // Current color transform |
| 282 | android_color_transform_t mColorTransform; |
Courtney Goeltzenleuchter | 5d94389 | 2017-03-22 13:46:46 -0600 | [diff] [blame] | 283 | |
| 284 | // Need to know if display is wide-color capable or not. |
| 285 | // Initialized by SurfaceFlinger when the DisplayDevice is created. |
| 286 | // Fed to RenderEngine during composition. |
Peiyong Lin | dd9b2ae | 2018-03-01 16:22:45 -0800 | [diff] [blame] | 287 | bool mHasWideColorGamut; |
| 288 | bool mHasHdr10; |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 289 | bool mHasHLG; |
| 290 | bool mHasDolbyVision; |
Peiyong Lin | fb06930 | 2018-04-25 14:34:31 -0700 | [diff] [blame] | 291 | HdrCapabilities mHdrCapabilities; |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 292 | const int32_t mSupportedPerFrameMetadata; |
Peiyong Lin | 136fbbc | 2018-04-17 15:09:44 -0700 | [diff] [blame] | 293 | // Whether h/w composer has BT2100_PQ and BT2100_HLG color mode with |
| 294 | // colorimetrical tone mapping or enhanced tone mapping. |
| 295 | bool mHasBT2100PQColorimetric; |
| 296 | bool mHasBT2100PQEnhance; |
| 297 | bool mHasBT2100HLGColorimetric; |
| 298 | bool mHasBT2100HLGEnhance; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 299 | }; |
| 300 | |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 301 | struct DisplayDeviceState { |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 302 | bool isValid() const { return type >= 0; } |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 303 | bool isVirtual() const { return type >= DisplayDevice::DISPLAY_VIRTUAL; } |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 304 | |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 305 | int32_t sequenceId = sNextSequenceId++; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 306 | DisplayDevice::DisplayType type = DisplayDevice::DISPLAY_ID_INVALID; |
| 307 | sp<IGraphicBufferProducer> surface; |
| 308 | uint32_t layerStack = DisplayDevice::NO_LAYER_STACK; |
| 309 | Rect viewport; |
| 310 | Rect frame; |
| 311 | uint8_t orientation = 0; |
| 312 | uint32_t width = 0; |
| 313 | uint32_t height = 0; |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 314 | std::string displayName; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 315 | bool isSecure = false; |
Dominik Laskowski | 663bd28 | 2018-04-19 15:26:54 -0700 | [diff] [blame] | 316 | |
| 317 | private: |
| 318 | static std::atomic<int32_t> sNextSequenceId; |
Irvel | ffc9efc | 2016-07-27 15:16:37 -0700 | [diff] [blame] | 319 | }; |
| 320 | |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 321 | class DisplayRenderArea : public RenderArea { |
| 322 | public: |
| 323 | DisplayRenderArea(const sp<const DisplayDevice> device, |
| 324 | ISurfaceComposer::Rotation rotation = ISurfaceComposer::eRotateNone) |
| 325 | : DisplayRenderArea(device, device->getBounds(), device->getHeight(), device->getWidth(), |
| 326 | rotation) {} |
| 327 | DisplayRenderArea(const sp<const DisplayDevice> device, Rect sourceCrop, uint32_t reqHeight, |
| 328 | uint32_t reqWidth, ISurfaceComposer::Rotation rotation) |
chaviw | 50da504 | 2018-04-09 13:49:37 -0700 | [diff] [blame] | 329 | : RenderArea(reqHeight, reqWidth, CaptureFill::OPAQUE, rotation), mDevice(device), |
| 330 | mSourceCrop(sourceCrop) {} |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 331 | |
| 332 | const Transform& getTransform() const override { return mDevice->getTransform(); } |
| 333 | Rect getBounds() const override { return mDevice->getBounds(); } |
| 334 | int getHeight() const override { return mDevice->getHeight(); } |
| 335 | int getWidth() const override { return mDevice->getWidth(); } |
| 336 | bool isSecure() const override { return mDevice->isSecure(); } |
| 337 | bool needsFiltering() const override { return mDevice->needsFiltering(); } |
| 338 | Rect getSourceCrop() const override { return mSourceCrop; } |
chaviw | a76b271 | 2017-09-20 12:02:26 -0700 | [diff] [blame] | 339 | |
| 340 | private: |
| 341 | const sp<const DisplayDevice> mDevice; |
| 342 | const Rect mSourceCrop; |
| 343 | }; |
| 344 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 345 | }; // namespace android |
| 346 | |
Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 347 | #endif // ANDROID_DISPLAY_DEVICE_H |