| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2010 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_HWCOMPOSER_H | 
|  | 18 | #define ANDROID_SF_HWCOMPOSER_H | 
|  | 19 |  | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 20 | #include <cstdint> | 
| Dominik Laskowski | 5690bde | 2020-04-23 19:04:22 -0700 | [diff] [blame] | 21 | #include <future> | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 22 | #include <memory> | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 23 | #include <mutex> | 
| Steven Thomas | 6e8f706 | 2017-11-22 14:15:29 -0800 | [diff] [blame] | 24 | #include <optional> | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 25 | #include <unordered_map> | 
|  | 26 | #include <unordered_set> | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 27 | #include <vector> | 
|  | 28 |  | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 29 | #include <android-base/thread_annotations.h> | 
| Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 30 | #include <ui/FenceTime.h> | 
| Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 31 |  | 
|  | 32 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 33 | #pragma clang diagnostic push | 
|  | 34 | #pragma clang diagnostic ignored "-Wconversion" | 
| Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 35 | #pragma clang diagnostic ignored "-Wextra" | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 36 | #include <ui/GraphicTypes.h> | 
| Marin Shalamanov | bed7fd3 | 2020-12-21 20:02:20 +0100 | [diff] [blame] | 37 | #pragma clang diagnostic pop // ignored "-Wconversion -Wextra" | 
| Ady Abraham | 8a82ba6 | 2020-01-17 12:43:17 -0800 | [diff] [blame] | 38 |  | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 39 | #include <utils/StrongPointer.h> | 
|  | 40 | #include <utils/Timers.h> | 
|  | 41 |  | 
| Dominik Laskowski | e9ef7c4 | 2018-03-12 19:34:30 -0700 | [diff] [blame] | 42 | #include "DisplayIdentification.h" | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 43 | #include "DisplayMode.h" | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 44 | #include "HWC2.h" | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 45 | #include "Hal.h" | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 46 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 47 | namespace android { | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 48 |  | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 49 | namespace hal = hardware::graphics::composer::hal; | 
|  | 50 |  | 
| Kevin DuBois | 1d4249a | 2018-08-29 10:45:14 -0700 | [diff] [blame] | 51 | struct DisplayedFrameStats; | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 52 | class GraphicBuffer; | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 53 | class TestableSurfaceFlinger; | 
| David Sodman | fb95bcc | 2017-12-22 15:45:30 -0800 | [diff] [blame] | 54 | struct CompositionInfo; | 
| Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 55 |  | 
| Lloyd Pique | a822d52 | 2017-12-20 16:42:57 -0800 | [diff] [blame] | 56 | namespace Hwc2 { | 
|  | 57 | class Composer; | 
|  | 58 | } // namespace Hwc2 | 
|  | 59 |  | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 60 | namespace compositionengine { | 
|  | 61 | class Output; | 
|  | 62 | } // namespace compositionengine | 
|  | 63 |  | 
| Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 64 | struct KnownHWCGenericLayerMetadata { | 
|  | 65 | const char* name; | 
|  | 66 | const uint32_t id; | 
|  | 67 | }; | 
|  | 68 |  | 
| Marin Shalamanov | 1c43429 | 2020-06-12 01:47:29 +0200 | [diff] [blame] | 69 | // See the comment for SurfaceFlinger::getHwComposer for the thread safety rules for accessing | 
|  | 70 | // this class. | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 71 | class HWComposer { | 
|  | 72 | public: | 
| Peiyong Lin | dfc3f7c | 2020-05-07 20:15:50 -0700 | [diff] [blame] | 73 | struct DeviceRequestedChanges { | 
|  | 74 | using ChangedTypes = std::unordered_map<HWC2::Layer*, hal::Composition>; | 
|  | 75 | using ClientTargetProperty = hal::ClientTargetProperty; | 
|  | 76 | using DisplayRequests = hal::DisplayRequest; | 
|  | 77 | using LayerRequests = std::unordered_map<HWC2::Layer*, hal::LayerRequest>; | 
|  | 78 |  | 
|  | 79 | ChangedTypes changedTypes; | 
|  | 80 | DisplayRequests displayRequests; | 
|  | 81 | LayerRequests layerRequests; | 
|  | 82 | ClientTargetProperty clientTargetProperty; | 
|  | 83 | }; | 
|  | 84 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 85 | struct HWCDisplayMode { | 
|  | 86 | hal::HWConfigId hwcId; | 
|  | 87 | int32_t width = -1; | 
|  | 88 | int32_t height = -1; | 
|  | 89 | nsecs_t vsyncPeriod = -1; | 
|  | 90 | int32_t dpiX = -1; | 
|  | 91 | int32_t dpiY = -1; | 
|  | 92 | int32_t configGroup = -1; | 
| Marin Shalamanov | d3b5c5d | 2021-02-11 18:26:14 +0100 | [diff] [blame] | 93 |  | 
|  | 94 | friend std::ostream& operator<<(std::ostream& os, const HWCDisplayMode& mode) { | 
|  | 95 | return os << "id=" << mode.hwcId << " res=" << mode.width << "x" << mode.height | 
|  | 96 | << " vsyncPeriod=" << mode.vsyncPeriod << " dpi=" << mode.dpiX << "x" | 
|  | 97 | << mode.dpiY << " group=" << mode.configGroup; | 
|  | 98 | } | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 99 | }; | 
|  | 100 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 101 | virtual ~HWComposer(); | 
|  | 102 |  | 
| Dominik Laskowski | ebc8d3a | 2021-04-16 23:18:31 -0700 | [diff] [blame] | 103 | virtual void setCallback(HWC2::ComposerCallback*) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 104 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 105 | virtual bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 106 | DisplayIdentificationData* outData) const = 0; | 
|  | 107 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 108 | virtual bool hasCapability(hal::Capability) const = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 109 | virtual bool hasDisplayCapability(HalDisplayId, hal::DisplayCapability) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 110 |  | 
| Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 111 | virtual size_t getMaxVirtualDisplayCount() const = 0; | 
|  | 112 | virtual size_t getMaxVirtualDisplayDimension() const = 0; | 
|  | 113 |  | 
|  | 114 | // Attempts to allocate a virtual display on the HWC. The maximum number of virtual displays | 
|  | 115 | // supported by the HWC can be queried in advance, but allocation may fail for other reasons. | 
| Dominik Laskowski | 263eec4 | 2021-07-21 23:13:24 -0700 | [diff] [blame] | 116 | virtual bool allocateVirtualDisplay(HalVirtualDisplayId, ui::Size, ui::PixelFormat*) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 117 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 118 | virtual void allocatePhysicalDisplay(hal::HWDisplayId, PhysicalDisplayId) = 0; | 
| Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 119 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 120 | // Attempts to create a new layer on this display | 
| Lloyd Pique | 1b33fc3 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 121 | virtual std::shared_ptr<HWC2::Layer> createLayer(HalDisplayId) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 122 |  | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 123 | // Gets any required composition change requests from the HWC device. | 
|  | 124 | // | 
|  | 125 | // Note that frameUsesClientComposition must be set correctly based on | 
|  | 126 | // whether the current frame appears to use client composition. If it is | 
|  | 127 | // false some internal optimizations are allowed to present the display | 
|  | 128 | // with fewer handshakes, but this does not work if client composition is | 
|  | 129 | // expected. | 
|  | 130 | virtual status_t getDeviceCompositionChanges( | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 131 | HalDisplayId, bool frameUsesClientComposition, | 
| Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 132 | std::chrono::steady_clock::time_point earliestPresentTime, | 
| Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 133 | const std::shared_ptr<FenceTime>& previousPresentFence, | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 134 | std::optional<DeviceRequestedChanges>* outChanges) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 135 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 136 | virtual status_t setClientTarget(HalDisplayId, uint32_t slot, const sp<Fence>& acquireFence, | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 137 | const sp<GraphicBuffer>& target, ui::Dataspace) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 138 |  | 
|  | 139 | // Present layers to the display and read releaseFences. | 
| Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 140 | virtual status_t presentAndGetReleaseFences( | 
| Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 141 | HalDisplayId, std::chrono::steady_clock::time_point earliestPresentTime, | 
|  | 142 | const std::shared_ptr<FenceTime>& previousPresentFence) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 143 |  | 
|  | 144 | // set power mode | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 145 | virtual status_t setPowerMode(PhysicalDisplayId, hal::PowerMode) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 146 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 147 | // Sets a color transform to be applied to the result of composition | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 148 | virtual status_t setColorTransform(HalDisplayId, const mat4& transform) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 149 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 150 | // reset state when a display is disconnected | 
|  | 151 | virtual void disconnectDisplay(HalDisplayId) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 152 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 153 | // get the present fence received from the last call to present. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 154 | virtual sp<Fence> getPresentFence(HalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 155 |  | 
|  | 156 | // Get last release fence for the given layer | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 157 | virtual sp<Fence> getLayerReleaseFence(HalDisplayId, HWC2::Layer*) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 158 |  | 
|  | 159 | // Set the output buffer and acquire fence for a virtual display. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 160 | virtual status_t setOutputBuffer(HalVirtualDisplayId, const sp<Fence>& acquireFence, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 161 | const sp<GraphicBuffer>& buffer) = 0; | 
|  | 162 |  | 
|  | 163 | // After SurfaceFlinger has retrieved the release fences for all the frames, | 
|  | 164 | // it can call this to clear the shared pointers in the release fence map | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 165 | virtual void clearReleaseFences(HalDisplayId) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 166 |  | 
|  | 167 | // Fetches the HDR capabilities of the given display | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 168 | virtual status_t getHdrCapabilities(HalDisplayId, HdrCapabilities* outCapabilities) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 169 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 170 | virtual int32_t getSupportedPerFrameMetadata(HalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 171 |  | 
|  | 172 | // Returns the available RenderIntent of the given display. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 173 | virtual std::vector<ui::RenderIntent> getRenderIntents(HalDisplayId, ui::ColorMode) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 174 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 175 | virtual mat4 getDataspaceSaturationMatrix(HalDisplayId, ui::Dataspace) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 176 |  | 
|  | 177 | // Returns the attributes of the color sampling engine. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 178 | virtual status_t getDisplayedContentSamplingAttributes(HalDisplayId, ui::PixelFormat* outFormat, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 179 | ui::Dataspace* outDataspace, | 
|  | 180 | uint8_t* outComponentMask) = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 181 | virtual status_t setDisplayContentSamplingEnabled(HalDisplayId, bool enabled, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 182 | uint8_t componentMask, | 
|  | 183 | uint64_t maxFrames) = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 184 | virtual status_t getDisplayedContentSample(HalDisplayId, uint64_t maxFrames, uint64_t timestamp, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 185 | DisplayedFrameStats* outStats) = 0; | 
|  | 186 |  | 
| Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 187 | // Sets the brightness of a display. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 188 | virtual std::future<status_t> setDisplayBrightness(PhysicalDisplayId, float brightness) = 0; | 
| Dan Gittik | 57e63c5 | 2019-01-18 16:37:54 +0000 | [diff] [blame] | 189 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 190 | // Events handling --------------------------------------------------------- | 
|  | 191 |  | 
|  | 192 | // Returns stable display ID (and display name on connection of new or previously disconnected | 
|  | 193 | // display), or std::nullopt if hotplug event was ignored. | 
| Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 194 | // This function is called from SurfaceFlinger. | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 195 | virtual std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, | 
|  | 196 | hal::Connection) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 197 |  | 
| Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 198 | // If true we'll update the DeviceProductInfo on subsequent hotplug connected events. | 
|  | 199 | // TODO(b/157555476): Remove when the framework has proper support for headless mode | 
|  | 200 | virtual bool updatesDeviceProductInfoOnHotplugReconnect() const = 0; | 
|  | 201 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 202 | virtual bool onVsync(hal::HWDisplayId, int64_t timestamp) = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 203 | virtual void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 204 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 205 | virtual bool isConnected(PhysicalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 206 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 207 | virtual std::vector<HWCDisplayMode> getModes(PhysicalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 208 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 209 | virtual std::optional<hal::HWConfigId> getActiveMode(PhysicalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 210 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 211 | virtual std::vector<ui::ColorMode> getColorModes(PhysicalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 212 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 213 | virtual status_t setActiveColorMode(PhysicalDisplayId, ui::ColorMode mode, | 
|  | 214 | ui::RenderIntent) = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 215 |  | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 216 | // Composer 2.4 | 
| Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 217 | virtual ui::DisplayConnectionType getDisplayConnectionType(PhysicalDisplayId) const = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 218 | virtual bool isVsyncPeriodSwitchSupported(PhysicalDisplayId) const = 0; | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 219 | virtual status_t getDisplayVsyncPeriod(PhysicalDisplayId displayId, | 
|  | 220 | nsecs_t* outVsyncPeriod) const = 0; | 
| Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 221 | virtual status_t setActiveModeWithConstraints(PhysicalDisplayId, hal::HWConfigId, | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 222 | const hal::VsyncPeriodChangeConstraints&, | 
|  | 223 | hal::VsyncPeriodChangeTimeline* outTimeline) = 0; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 224 | virtual status_t setAutoLowLatencyMode(PhysicalDisplayId, bool on) = 0; | 
| Galia Peycheva | 5492cb5 | 2019-10-30 14:13:16 +0100 | [diff] [blame] | 225 | virtual status_t getSupportedContentTypes( | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 226 | PhysicalDisplayId, std::vector<hal::ContentType>* outSupportedContentTypes) = 0; | 
|  | 227 | virtual status_t setContentType(PhysicalDisplayId, hal::ContentType) = 0; | 
| Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 228 | virtual const std::unordered_map<std::string, bool>& getSupportedLayerGenericMetadata() | 
|  | 229 | const = 0; | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 230 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 231 | // for debugging ---------------------------------------------------------- | 
|  | 232 | virtual void dump(std::string& out) const = 0; | 
|  | 233 |  | 
|  | 234 | virtual Hwc2::Composer* getComposer() const = 0; | 
|  | 235 |  | 
|  | 236 | // TODO(b/74619554): Remove special cases for internal/external display. | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 237 | virtual std::optional<hal::HWDisplayId> getInternalHwcDisplayId() const = 0; | 
|  | 238 | virtual std::optional<hal::HWDisplayId> getExternalHwcDisplayId() const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 239 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 240 | virtual std::optional<PhysicalDisplayId> toPhysicalDisplayId(hal::HWDisplayId) const = 0; | 
|  | 241 | virtual std::optional<hal::HWDisplayId> fromPhysicalDisplayId(PhysicalDisplayId) const = 0; | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 242 | }; | 
|  | 243 |  | 
|  | 244 | namespace impl { | 
|  | 245 |  | 
|  | 246 | class HWComposer final : public android::HWComposer { | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 247 | public: | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 248 | explicit HWComposer(std::unique_ptr<Hwc2::Composer> composer); | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 249 | explicit HWComposer(const std::string& composerServiceName); | 
| Mathias Agopian | 8b736f1 | 2012-08-13 17:54:26 -0700 | [diff] [blame] | 250 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 251 | ~HWComposer() override; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 252 |  | 
| Dominik Laskowski | ebc8d3a | 2021-04-16 23:18:31 -0700 | [diff] [blame] | 253 | void setCallback(HWC2::ComposerCallback*) override; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 254 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 255 | bool getDisplayIdentificationData(hal::HWDisplayId, uint8_t* outPort, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 256 | DisplayIdentificationData* outData) const override; | 
| Dominik Laskowski | e9ef7c4 | 2018-03-12 19:34:30 -0700 | [diff] [blame] | 257 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 258 | bool hasCapability(hal::Capability) const override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 259 | bool hasDisplayCapability(HalDisplayId, hal::DisplayCapability) const override; | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 260 |  | 
| Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 261 | size_t getMaxVirtualDisplayCount() const override; | 
|  | 262 | size_t getMaxVirtualDisplayDimension() const override; | 
|  | 263 |  | 
| Dominik Laskowski | 263eec4 | 2021-07-21 23:13:24 -0700 | [diff] [blame] | 264 | bool allocateVirtualDisplay(HalVirtualDisplayId, ui::Size, ui::PixelFormat*) override; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 265 |  | 
| Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 266 | // Called from SurfaceFlinger, when the state for a new physical display needs to be recreated. | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 267 | void allocatePhysicalDisplay(hal::HWDisplayId, PhysicalDisplayId) override; | 
| Marin Shalamanov | bdd5915 | 2020-02-14 15:30:06 +0100 | [diff] [blame] | 268 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 269 | // Attempts to create a new layer on this display | 
| Lloyd Pique | 1b33fc3 | 2021-05-07 14:36:58 -0700 | [diff] [blame] | 270 | std::shared_ptr<HWC2::Layer> createLayer(HalDisplayId) override; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 271 |  | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 272 | status_t getDeviceCompositionChanges( | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 273 | HalDisplayId, bool frameUsesClientComposition, | 
| Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 274 | std::chrono::steady_clock::time_point earliestPresentTime, | 
| Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 275 | const std::shared_ptr<FenceTime>& previousPresentFence, | 
| Lloyd Pique | 66d6860 | 2019-02-13 14:23:31 -0800 | [diff] [blame] | 276 | std::optional<DeviceRequestedChanges>* outChanges) override; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 277 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 278 | status_t setClientTarget(HalDisplayId, uint32_t slot, const sp<Fence>& acquireFence, | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 279 | const sp<GraphicBuffer>& target, ui::Dataspace) override; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 280 |  | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 281 | // Present layers to the display and read releaseFences. | 
| Ady Abraham | b42cdc1 | 2021-05-11 14:31:26 -0700 | [diff] [blame] | 282 | status_t presentAndGetReleaseFences( | 
| Ady Abraham | ec7aa8a | 2021-06-28 12:37:09 -0700 | [diff] [blame] | 283 | HalDisplayId, std::chrono::steady_clock::time_point earliestPresentTime, | 
|  | 284 | const std::shared_ptr<FenceTime>& previousPresentFence) override; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 285 |  | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 286 | // set power mode | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 287 | status_t setPowerMode(PhysicalDisplayId, hal::PowerMode mode) override; | 
| Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 288 |  | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 289 | // Sets a color transform to be applied to the result of composition | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 290 | status_t setColorTransform(HalDisplayId, const mat4& transform) override; | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 291 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 292 | // reset state when a display is disconnected | 
|  | 293 | void disconnectDisplay(HalDisplayId) override; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 294 |  | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 295 | // get the present fence received from the last call to present. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 296 | sp<Fence> getPresentFence(HalDisplayId) const override; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 297 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 298 | // Get last release fence for the given layer | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 299 | sp<Fence> getLayerReleaseFence(HalDisplayId, HWC2::Layer*) const override; | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 300 |  | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 301 | // Set the output buffer and acquire fence for a virtual display. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 302 | status_t setOutputBuffer(HalVirtualDisplayId, const sp<Fence>& acquireFence, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 303 | const sp<GraphicBuffer>& buffer) override; | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 304 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 305 | // After SurfaceFlinger has retrieved the release fences for all the frames, | 
|  | 306 | // it can call this to clear the shared pointers in the release fence map | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 307 | void clearReleaseFences(HalDisplayId) override; | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 308 |  | 
| Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 309 | // Fetches the HDR capabilities of the given display | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 310 | status_t getHdrCapabilities(HalDisplayId, HdrCapabilities* outCapabilities) override; | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 311 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 312 | int32_t getSupportedPerFrameMetadata(HalDisplayId) const override; | 
| Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame] | 313 |  | 
| Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 314 | // Returns the available RenderIntent of the given display. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 315 | std::vector<ui::RenderIntent> getRenderIntents(HalDisplayId, ui::ColorMode) const override; | 
| Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 316 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 317 | mat4 getDataspaceSaturationMatrix(HalDisplayId, ui::Dataspace) override; | 
| Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 318 |  | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 319 | // Returns the attributes of the color sampling engine. | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 320 | status_t getDisplayedContentSamplingAttributes(HalDisplayId, ui::PixelFormat* outFormat, | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 321 | ui::Dataspace* outDataspace, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 322 | uint8_t* outComponentMask) override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 323 | status_t setDisplayContentSamplingEnabled(HalDisplayId, bool enabled, uint8_t componentMask, | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 324 | uint64_t maxFrames) override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 325 | status_t getDisplayedContentSample(HalDisplayId, uint64_t maxFrames, uint64_t timestamp, | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 326 | DisplayedFrameStats* outStats) override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 327 | std::future<status_t> setDisplayBrightness(PhysicalDisplayId, float brightness) override; | 
| Kevin DuBois | 9c0a176 | 2018-10-16 13:32:31 -0700 | [diff] [blame] | 328 |  | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 329 | // Events handling --------------------------------------------------------- | 
|  | 330 |  | 
| Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 331 | // Returns PhysicalDisplayId (and display name on connection of new or previously disconnected | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 332 | // display), or std::nullopt if hotplug event was ignored. | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 333 | std::optional<DisplayIdentificationInfo> onHotplug(hal::HWDisplayId, hal::Connection) override; | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 334 |  | 
| Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 335 | bool updatesDeviceProductInfoOnHotplugReconnect() const override; | 
|  | 336 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 337 | bool onVsync(hal::HWDisplayId, int64_t timestamp) override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 338 | void setVsyncEnabled(PhysicalDisplayId, hal::Vsync enabled) override; | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 339 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 340 | bool isConnected(PhysicalDisplayId) const override; | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 341 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 342 | std::vector<HWCDisplayMode> getModes(PhysicalDisplayId) const override; | 
| Dan Stoza | 7f7da32 | 2014-05-02 15:26:25 -0700 | [diff] [blame] | 343 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 344 | std::optional<hal::HWConfigId> getActiveMode(PhysicalDisplayId) const override; | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 345 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 346 | std::vector<ui::ColorMode> getColorModes(PhysicalDisplayId) const override; | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 347 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 348 | status_t setActiveColorMode(PhysicalDisplayId, ui::ColorMode, ui::RenderIntent) override; | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 349 |  | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 350 | // Composer 2.4 | 
| Marin Shalamanov | 228f46b | 2021-01-28 21:11:45 +0100 | [diff] [blame] | 351 | ui::DisplayConnectionType getDisplayConnectionType(PhysicalDisplayId) const override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 352 | bool isVsyncPeriodSwitchSupported(PhysicalDisplayId) const override; | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 353 | status_t getDisplayVsyncPeriod(PhysicalDisplayId displayId, | 
|  | 354 | nsecs_t* outVsyncPeriod) const override; | 
| Marin Shalamanov | 12c9e5a | 2021-01-07 00:25:35 +0100 | [diff] [blame] | 355 | status_t setActiveModeWithConstraints(PhysicalDisplayId, hal::HWConfigId, | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 356 | const hal::VsyncPeriodChangeConstraints&, | 
|  | 357 | hal::VsyncPeriodChangeTimeline* outTimeline) override; | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 358 | status_t setAutoLowLatencyMode(PhysicalDisplayId, bool) override; | 
|  | 359 | status_t getSupportedContentTypes(PhysicalDisplayId, std::vector<hal::ContentType>*) override; | 
|  | 360 | status_t setContentType(PhysicalDisplayId, hal::ContentType) override; | 
| Ady Abraham | 3a77a7b | 2019-12-02 18:46:59 -0800 | [diff] [blame] | 361 |  | 
| Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 362 | const std::unordered_map<std::string, bool>& getSupportedLayerGenericMetadata() const override; | 
|  | 363 |  | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 364 | // for debugging ---------------------------------------------------------- | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 365 | void dump(std::string& out) const override; | 
| Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 366 |  | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 367 | Hwc2::Composer* getComposer() const override { return mComposer.get(); } | 
| Steven Thomas | 6e8f706 | 2017-11-22 14:15:29 -0800 | [diff] [blame] | 368 |  | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 369 | // TODO(b/74619554): Remove special cases for internal/external display. | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 370 | std::optional<hal::HWDisplayId> getInternalHwcDisplayId() const override { | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 371 | return mInternalHwcDisplayId; | 
|  | 372 | } | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 373 | std::optional<hal::HWDisplayId> getExternalHwcDisplayId() const override { | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 374 | return mExternalHwcDisplayId; | 
|  | 375 | } | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 376 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 377 | std::optional<PhysicalDisplayId> toPhysicalDisplayId(hal::HWDisplayId) const override; | 
|  | 378 | std::optional<hal::HWDisplayId> fromPhysicalDisplayId(PhysicalDisplayId) const override; | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 379 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 380 | private: | 
| Lloyd Pique | e39cad2 | 2017-12-20 17:01:29 -0800 | [diff] [blame] | 381 | // For unit tests | 
|  | 382 | friend TestableSurfaceFlinger; | 
|  | 383 |  | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 384 | struct DisplayData { | 
| Dominik Laskowski | c1f18f6 | 2018-06-13 15:17:55 -0700 | [diff] [blame] | 385 | bool isVirtual = false; | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 386 | std::unique_ptr<HWC2::Display> hwcDisplay; | 
| Dominik Laskowski | f9750f2 | 2018-06-06 12:24:53 -0700 | [diff] [blame] | 387 | sp<Fence> lastPresentFence = Fence::NO_FENCE; // signals when the last set op retires | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 388 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; | 
| Dominik Laskowski | f9750f2 | 2018-06-06 12:24:53 -0700 | [diff] [blame] | 389 | buffer_handle_t outbufHandle = nullptr; | 
|  | 390 | sp<Fence> outbufAcquireFence = Fence::NO_FENCE; | 
| Jamie Gennis | 2ec3e07 | 2012-11-11 16:24:33 -0800 | [diff] [blame] | 391 |  | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 392 | bool validateWasSkipped; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 393 | hal::Error presentError; | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 394 |  | 
|  | 395 | bool vsyncTraceToggle = false; | 
|  | 396 |  | 
|  | 397 | std::mutex vsyncEnabledLock; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 398 | hal::Vsync vsyncEnabled GUARDED_BY(vsyncEnabledLock) = hal::Vsync::DISABLE; | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 399 |  | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 400 | nsecs_t lastHwVsync = 0; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 401 | }; | 
|  | 402 |  | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 403 | std::optional<DisplayIdentificationInfo> onHotplugConnect(hal::HWDisplayId); | 
|  | 404 | std::optional<DisplayIdentificationInfo> onHotplugDisconnect(hal::HWDisplayId); | 
|  | 405 | bool shouldIgnoreHotplugConnect(hal::HWDisplayId, bool hasDisplayIdentificationData) const; | 
|  | 406 |  | 
|  | 407 | int32_t getAttribute(hal::HWDisplayId hwcDisplayId, hal::HWConfigId configId, | 
| Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 408 | hal::Attribute attribute) const; | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 409 |  | 
|  | 410 | void loadCapabilities(); | 
|  | 411 | void loadLayerMetadataSupport(); | 
| Marin Shalamanov | 3ea1d60 | 2020-12-16 19:59:39 +0100 | [diff] [blame] | 412 |  | 
| Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 413 | std::unordered_map<HalDisplayId, DisplayData> mDisplayData; | 
| Dominik Laskowski | b04f98a | 2018-11-07 21:07:16 -0800 | [diff] [blame] | 414 |  | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 415 | std::unique_ptr<android::Hwc2::Composer> mComposer; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 416 | std::unordered_set<hal::Capability> mCapabilities; | 
| Lloyd Pique | 4603f3c | 2020-02-11 12:06:56 -0800 | [diff] [blame] | 417 | std::unordered_map<std::string, bool> mSupportedLayerGenericMetadata; | 
| Peiyong Lin | bdd08cc | 2019-12-17 21:35:14 -0800 | [diff] [blame] | 418 | bool mRegisteredCallback = false; | 
| Dominik Laskowski | b04f98a | 2018-11-07 21:07:16 -0800 | [diff] [blame] | 419 |  | 
| Marin Shalamanov | a524a09 | 2020-07-27 21:39:55 +0200 | [diff] [blame] | 420 | std::unordered_map<hal::HWDisplayId, PhysicalDisplayId> mPhysicalDisplayIdMap; | 
| Peiyong Lin | e9d809e | 2020-04-14 13:10:48 -0700 | [diff] [blame] | 421 | std::optional<hal::HWDisplayId> mInternalHwcDisplayId; | 
|  | 422 | std::optional<hal::HWDisplayId> mExternalHwcDisplayId; | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 423 | bool mHasMultiDisplaySupport = false; | 
|  | 424 |  | 
| Dominik Laskowski | 1394860 | 2021-03-08 20:48:28 -0800 | [diff] [blame] | 425 | const size_t mMaxVirtualDisplayDimension; | 
| Marin Shalamanov | f8c6372 | 2020-10-06 13:11:21 +0200 | [diff] [blame] | 426 | const bool mUpdateDeviceProductInfoOnHotplugReconnect; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 427 | }; | 
|  | 428 |  | 
| Lloyd Pique | 441d504 | 2018-10-18 16:49:51 -0700 | [diff] [blame] | 429 | } // namespace impl | 
| Dominik Laskowski | 1af4793 | 2018-11-12 10:20:46 -0800 | [diff] [blame] | 430 | } // namespace android | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 431 |  | 
|  | 432 | #endif // ANDROID_SF_HWCOMPOSER_H |