blob: ca59a2645a0febb4219aedc6658a0f90a40df043 [file] [log] [blame]
Mathias Agopiana350ff92010-08-10 17:14:02 -07001/*
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 Laskowski1af47932018-11-12 10:20:46 -080020#include <cstdint>
Dan Stoza9e56aa02015-11-02 13:00:03 -080021#include <memory>
Dominik Laskowski1af47932018-11-12 10:20:46 -080022#include <mutex>
Steven Thomas6e8f7062017-11-22 14:15:29 -080023#include <optional>
Dominik Laskowski075d3172018-05-24 15:50:06 -070024#include <unordered_map>
25#include <unordered_set>
Dan Stoza9e56aa02015-11-02 13:00:03 -080026#include <vector>
27
Dominik Laskowski1af47932018-11-12 10:20:46 -080028#include <android-base/thread_annotations.h>
29#include <ui/Fence.h>
30#include <ui/GraphicTypes.h>
31#include <utils/StrongPointer.h>
32#include <utils/Timers.h>
33
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -070034#include "DisplayIdentification.h"
Dominik Laskowski1af47932018-11-12 10:20:46 -080035#include "HWC2.h"
Dan Stoza9e56aa02015-11-02 13:00:03 -080036
Mathias Agopiana350ff92010-08-10 17:14:02 -070037namespace android {
Mathias Agopiana350ff92010-08-10 17:14:02 -070038
Kevin DuBois1d4249a2018-08-29 10:45:14 -070039struct DisplayedFrameStats;
Jesse Hall399184a2014-03-03 15:42:54 -080040class GraphicBuffer;
Lloyd Piquee39cad22017-12-20 17:01:29 -080041class TestableSurfaceFlinger;
David Sodmanfb95bcc2017-12-22 15:45:30 -080042struct CompositionInfo;
Mathias Agopian83727852010-09-23 18:13:21 -070043
Lloyd Piquea822d522017-12-20 16:42:57 -080044namespace Hwc2 {
45class Composer;
46} // namespace Hwc2
47
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080048namespace compositionengine {
49class Output;
50} // namespace compositionengine
51
Lloyd Pique441d5042018-10-18 16:49:51 -070052class HWComposer {
53public:
54 virtual ~HWComposer();
55
56 virtual void registerCallback(HWC2::ComposerCallback* callback, int32_t sequenceId) = 0;
57
58 virtual bool getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
59 DisplayIdentificationData* outData) const = 0;
60
61 virtual bool hasCapability(HWC2::Capability capability) const = 0;
62 virtual bool hasDisplayCapability(const std::optional<DisplayId>& displayId,
63 HWC2::DisplayCapability capability) const = 0;
64
65 // Attempts to allocate a virtual display and returns its ID if created on the HWC device.
66 virtual std::optional<DisplayId> allocateVirtualDisplay(uint32_t width, uint32_t height,
67 ui::PixelFormat* format) = 0;
68
69 // Attempts to create a new layer on this display
70 virtual HWC2::Layer* createLayer(DisplayId displayId) = 0;
71 // Destroy a previously created layer
72 virtual void destroyLayer(DisplayId displayId, HWC2::Layer* layer) = 0;
73
74 // Asks the HAL what it can do
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080075 virtual status_t prepare(DisplayId displayId, const compositionengine::Output&) = 0;
Lloyd Pique441d5042018-10-18 16:49:51 -070076
77 virtual status_t setClientTarget(DisplayId displayId, uint32_t slot,
78 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target,
79 ui::Dataspace dataspace) = 0;
80
81 // Present layers to the display and read releaseFences.
82 virtual status_t presentAndGetReleaseFences(DisplayId displayId) = 0;
83
84 // set power mode
85 virtual status_t setPowerMode(DisplayId displayId, int mode) = 0;
86
87 // set active config
88 virtual status_t setActiveConfig(DisplayId displayId, size_t configId) = 0;
89
90 // Sets a color transform to be applied to the result of composition
91 virtual status_t setColorTransform(DisplayId displayId, const mat4& transform) = 0;
92
93 // reset state when an external, non-virtual display is disconnected
94 virtual void disconnectDisplay(DisplayId displayId) = 0;
95
96 // does this display have layers handled by HWC
97 virtual bool hasDeviceComposition(const std::optional<DisplayId>& displayId) const = 0;
98
99 // does this display have pending request to flip client target
100 virtual bool hasFlipClientTargetRequest(const std::optional<DisplayId>& displayId) const = 0;
101
102 // does this display have layers handled by GLES
103 virtual bool hasClientComposition(const std::optional<DisplayId>& displayId) const = 0;
104
105 // get the present fence received from the last call to present.
106 virtual sp<Fence> getPresentFence(DisplayId displayId) const = 0;
107
108 // Get last release fence for the given layer
109 virtual sp<Fence> getLayerReleaseFence(DisplayId displayId, HWC2::Layer* layer) const = 0;
110
111 // Set the output buffer and acquire fence for a virtual display.
112 // Returns INVALID_OPERATION if displayId is not a virtual display.
113 virtual status_t setOutputBuffer(DisplayId displayId, const sp<Fence>& acquireFence,
114 const sp<GraphicBuffer>& buffer) = 0;
115
116 // After SurfaceFlinger has retrieved the release fences for all the frames,
117 // it can call this to clear the shared pointers in the release fence map
118 virtual void clearReleaseFences(DisplayId displayId) = 0;
119
120 // Fetches the HDR capabilities of the given display
121 virtual status_t getHdrCapabilities(DisplayId displayId, HdrCapabilities* outCapabilities) = 0;
122
123 virtual int32_t getSupportedPerFrameMetadata(DisplayId displayId) const = 0;
124
125 // Returns the available RenderIntent of the given display.
126 virtual std::vector<ui::RenderIntent> getRenderIntents(DisplayId displayId,
127 ui::ColorMode colorMode) const = 0;
128
129 virtual mat4 getDataspaceSaturationMatrix(DisplayId displayId, ui::Dataspace dataspace) = 0;
130
131 // Returns the attributes of the color sampling engine.
132 virtual status_t getDisplayedContentSamplingAttributes(DisplayId displayId,
133 ui::PixelFormat* outFormat,
134 ui::Dataspace* outDataspace,
135 uint8_t* outComponentMask) = 0;
136 virtual status_t setDisplayContentSamplingEnabled(DisplayId displayId, bool enabled,
137 uint8_t componentMask,
138 uint64_t maxFrames) = 0;
139 virtual status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames,
140 uint64_t timestamp,
141 DisplayedFrameStats* outStats) = 0;
142
143 // Events handling ---------------------------------------------------------
144
145 // Returns stable display ID (and display name on connection of new or previously disconnected
146 // display), or std::nullopt if hotplug event was ignored.
147 virtual std::optional<DisplayIdentificationInfo> onHotplug(hwc2_display_t hwcDisplayId,
148 HWC2::Connection connection) = 0;
149
150 virtual bool onVsync(hwc2_display_t hwcDisplayId, int64_t timestamp) = 0;
151 virtual void setVsyncEnabled(DisplayId displayId, HWC2::Vsync enabled) = 0;
152
153 virtual nsecs_t getRefreshTimestamp(DisplayId displayId) const = 0;
154 virtual bool isConnected(DisplayId displayId) const = 0;
155
156 // Non-const because it can update configMap inside of mDisplayData
157 virtual std::vector<std::shared_ptr<const HWC2::Display::Config>> getConfigs(
158 DisplayId displayId) const = 0;
159
160 virtual std::shared_ptr<const HWC2::Display::Config> getActiveConfig(
161 DisplayId displayId) const = 0;
162 virtual int getActiveConfigIndex(DisplayId displayId) const = 0;
163
164 virtual std::vector<ui::ColorMode> getColorModes(DisplayId displayId) const = 0;
165
166 virtual status_t setActiveColorMode(DisplayId displayId, ui::ColorMode mode,
167 ui::RenderIntent renderIntent) = 0;
168
169 virtual bool isUsingVrComposer() const = 0;
170
171 // for debugging ----------------------------------------------------------
172 virtual void dump(std::string& out) const = 0;
173
174 virtual Hwc2::Composer* getComposer() const = 0;
175
176 // TODO(b/74619554): Remove special cases for internal/external display.
177 virtual std::optional<hwc2_display_t> getInternalHwcDisplayId() const = 0;
178 virtual std::optional<hwc2_display_t> getExternalHwcDisplayId() const = 0;
179
180 virtual std::optional<DisplayId> toPhysicalDisplayId(hwc2_display_t hwcDisplayId) const = 0;
181 virtual std::optional<hwc2_display_t> fromPhysicalDisplayId(DisplayId displayId) const = 0;
182};
183
184namespace impl {
185
186class HWComposer final : public android::HWComposer {
Mathias Agopiana350ff92010-08-10 17:14:02 -0700187public:
Dominik Laskowski1af47932018-11-12 10:20:46 -0800188 explicit HWComposer(std::unique_ptr<Hwc2::Composer> composer);
Mathias Agopian8b736f12012-08-13 17:54:26 -0700189
Lloyd Pique441d5042018-10-18 16:49:51 -0700190 ~HWComposer() override;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700191
Lloyd Pique441d5042018-10-18 16:49:51 -0700192 void registerCallback(HWC2::ComposerCallback* callback, int32_t sequenceId) override;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700193
Dominik Laskowskia2edf612018-06-01 13:15:16 -0700194 bool getDisplayIdentificationData(hwc2_display_t hwcDisplayId, uint8_t* outPort,
Lloyd Pique441d5042018-10-18 16:49:51 -0700195 DisplayIdentificationData* outData) const override;
Dominik Laskowskie9ef7c42018-03-12 19:34:30 -0700196
Lloyd Pique441d5042018-10-18 16:49:51 -0700197 bool hasCapability(HWC2::Capability capability) const override;
Peiyong Lined531a32018-10-26 18:27:56 -0700198 bool hasDisplayCapability(const std::optional<DisplayId>& displayId,
Lloyd Pique441d5042018-10-18 16:49:51 -0700199 HWC2::DisplayCapability capability) const override;
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700200
Dominik Laskowski075d3172018-05-24 15:50:06 -0700201 // Attempts to allocate a virtual display and returns its ID if created on the HWC device.
202 std::optional<DisplayId> allocateVirtualDisplay(uint32_t width, uint32_t height,
Lloyd Pique441d5042018-10-18 16:49:51 -0700203 ui::PixelFormat* format) override;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700204
Dan Stoza9e56aa02015-11-02 13:00:03 -0800205 // Attempts to create a new layer on this display
Lloyd Pique441d5042018-10-18 16:49:51 -0700206 HWC2::Layer* createLayer(DisplayId displayId) override;
Steven Thomas94e35b92017-07-26 18:48:28 -0700207 // Destroy a previously created layer
Lloyd Pique441d5042018-10-18 16:49:51 -0700208 void destroyLayer(DisplayId displayId, HWC2::Layer* layer) override;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700209
Mathias Agopiana350ff92010-08-10 17:14:02 -0700210 // Asks the HAL what it can do
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800211 status_t prepare(DisplayId displayId, const compositionengine::Output&) override;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700212
Dominik Laskowski075d3172018-05-24 15:50:06 -0700213 status_t setClientTarget(DisplayId displayId, uint32_t slot, const sp<Fence>& acquireFence,
Lloyd Pique441d5042018-10-18 16:49:51 -0700214 const sp<GraphicBuffer>& target, ui::Dataspace dataspace) override;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800215
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800216 // Present layers to the display and read releaseFences.
Lloyd Pique441d5042018-10-18 16:49:51 -0700217 status_t presentAndGetReleaseFences(DisplayId displayId) override;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700218
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700219 // set power mode
Lloyd Pique441d5042018-10-18 16:49:51 -0700220 status_t setPowerMode(DisplayId displayId, int mode) override;
Colin Cross10fbdb62012-07-12 17:56:34 -0700221
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700222 // set active config
Lloyd Pique441d5042018-10-18 16:49:51 -0700223 status_t setActiveConfig(DisplayId displayId, size_t configId) override;
Michael Lentine6c9e34a2014-07-14 13:48:55 -0700224
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700225 // Sets a color transform to be applied to the result of composition
Lloyd Pique441d5042018-10-18 16:49:51 -0700226 status_t setColorTransform(DisplayId displayId, const mat4& transform) override;
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700227
Andy McFadden27ec5732012-10-02 19:04:45 -0700228 // reset state when an external, non-virtual display is disconnected
Lloyd Pique441d5042018-10-18 16:49:51 -0700229 void disconnectDisplay(DisplayId displayId) override;
Mathias Agopianda27af92012-09-13 18:17:13 -0700230
Mathias Agopiane60b0682012-08-21 23:34:09 -0700231 // does this display have layers handled by HWC
Lloyd Pique441d5042018-10-18 16:49:51 -0700232 bool hasDeviceComposition(const std::optional<DisplayId>& displayId) const override;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700233
Madhuri Athota88a905b2017-05-04 16:58:15 +0530234 // does this display have pending request to flip client target
Lloyd Pique441d5042018-10-18 16:49:51 -0700235 bool hasFlipClientTargetRequest(const std::optional<DisplayId>& displayId) const override;
Madhuri Athota88a905b2017-05-04 16:58:15 +0530236
Mathias Agopiane60b0682012-08-21 23:34:09 -0700237 // does this display have layers handled by GLES
Lloyd Pique441d5042018-10-18 16:49:51 -0700238 bool hasClientComposition(const std::optional<DisplayId>& displayId) const override;
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700239
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800240 // get the present fence received from the last call to present.
Lloyd Pique441d5042018-10-18 16:49:51 -0700241 sp<Fence> getPresentFence(DisplayId displayId) const override;
Mathias Agopianda27af92012-09-13 18:17:13 -0700242
Dan Stoza9e56aa02015-11-02 13:00:03 -0800243 // Get last release fence for the given layer
Lloyd Pique441d5042018-10-18 16:49:51 -0700244 sp<Fence> getLayerReleaseFence(DisplayId displayId, HWC2::Layer* layer) const override;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700245
Jesse Hall851cfe82013-03-20 13:44:00 -0700246 // Set the output buffer and acquire fence for a virtual display.
Dan Stoza9e56aa02015-11-02 13:00:03 -0800247 // Returns INVALID_OPERATION if displayId is not a virtual display.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700248 status_t setOutputBuffer(DisplayId displayId, const sp<Fence>& acquireFence,
Lloyd Pique441d5042018-10-18 16:49:51 -0700249 const sp<GraphicBuffer>& buffer) override;
Jesse Hall851cfe82013-03-20 13:44:00 -0700250
Dan Stoza9e56aa02015-11-02 13:00:03 -0800251 // After SurfaceFlinger has retrieved the release fences for all the frames,
252 // it can call this to clear the shared pointers in the release fence map
Lloyd Pique441d5042018-10-18 16:49:51 -0700253 void clearReleaseFences(DisplayId displayId) override;
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700254
Peiyong Lin62665892018-04-16 11:07:44 -0700255 // Fetches the HDR capabilities of the given display
Lloyd Pique441d5042018-10-18 16:49:51 -0700256 status_t getHdrCapabilities(DisplayId displayId, HdrCapabilities* outCapabilities) override;
Dan Stozac4f471e2016-03-24 09:31:08 -0700257
Lloyd Pique441d5042018-10-18 16:49:51 -0700258 int32_t getSupportedPerFrameMetadata(DisplayId displayId) const override;
Peiyong Lin0ac5f4e2018-04-19 22:06:34 -0700259
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700260 // Returns the available RenderIntent of the given display.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700261 std::vector<ui::RenderIntent> getRenderIntents(DisplayId displayId,
Lloyd Pique441d5042018-10-18 16:49:51 -0700262 ui::ColorMode colorMode) const override;
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700263
Lloyd Pique441d5042018-10-18 16:49:51 -0700264 mat4 getDataspaceSaturationMatrix(DisplayId displayId, ui::Dataspace dataspace) override;
Peiyong Lin0e7a7912018-04-05 14:36:36 -0700265
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700266 // Returns the attributes of the color sampling engine.
267 status_t getDisplayedContentSamplingAttributes(DisplayId displayId, ui::PixelFormat* outFormat,
268 ui::Dataspace* outDataspace,
Lloyd Pique441d5042018-10-18 16:49:51 -0700269 uint8_t* outComponentMask) override;
Kevin DuBois74e53772018-11-19 10:52:38 -0800270 status_t setDisplayContentSamplingEnabled(DisplayId displayId, bool enabled,
Lloyd Pique441d5042018-10-18 16:49:51 -0700271 uint8_t componentMask, uint64_t maxFrames) override;
Kevin DuBois1d4249a2018-08-29 10:45:14 -0700272 status_t getDisplayedContentSample(DisplayId displayId, uint64_t maxFrames, uint64_t timestamp,
Lloyd Pique441d5042018-10-18 16:49:51 -0700273 DisplayedFrameStats* outStats) override;
Kevin DuBois9c0a1762018-10-16 13:32:31 -0700274
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700275 // Events handling ---------------------------------------------------------
276
Dominik Laskowski075d3172018-05-24 15:50:06 -0700277 // Returns stable display ID (and display name on connection of new or previously disconnected
278 // display), or std::nullopt if hotplug event was ignored.
279 std::optional<DisplayIdentificationInfo> onHotplug(hwc2_display_t hwcDisplayId,
Lloyd Pique441d5042018-10-18 16:49:51 -0700280 HWC2::Connection connection) override;
Steven Thomas94e35b92017-07-26 18:48:28 -0700281
Lloyd Pique441d5042018-10-18 16:49:51 -0700282 bool onVsync(hwc2_display_t hwcDisplayId, int64_t timestamp) override;
283 void setVsyncEnabled(DisplayId displayId, HWC2::Vsync enabled) override;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700284
Lloyd Pique441d5042018-10-18 16:49:51 -0700285 nsecs_t getRefreshTimestamp(DisplayId displayId) const override;
286 bool isConnected(DisplayId displayId) const override;
Dan Stoza7f7da322014-05-02 15:26:25 -0700287
Dan Stoza9e56aa02015-11-02 13:00:03 -0800288 // Non-const because it can update configMap inside of mDisplayData
Lloyd Pique441d5042018-10-18 16:49:51 -0700289 std::vector<std::shared_ptr<const HWC2::Display::Config>> getConfigs(
290 DisplayId displayId) const override;
Dan Stoza7f7da322014-05-02 15:26:25 -0700291
Lloyd Pique441d5042018-10-18 16:49:51 -0700292 std::shared_ptr<const HWC2::Display::Config> getActiveConfig(
293 DisplayId displayId) const override;
294 int getActiveConfigIndex(DisplayId displayId) const override;
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700295
Lloyd Pique441d5042018-10-18 16:49:51 -0700296 std::vector<ui::ColorMode> getColorModes(DisplayId displayId) const override;
Michael Wright28f24d02016-07-12 13:30:53 -0700297
Dominik Laskowski075d3172018-05-24 15:50:06 -0700298 status_t setActiveColorMode(DisplayId displayId, ui::ColorMode mode,
Lloyd Pique441d5042018-10-18 16:49:51 -0700299 ui::RenderIntent renderIntent) override;
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600300
Lloyd Pique441d5042018-10-18 16:49:51 -0700301 bool isUsingVrComposer() const override;
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800302
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700303 // for debugging ----------------------------------------------------------
Lloyd Pique441d5042018-10-18 16:49:51 -0700304 void dump(std::string& out) const override;
Mathias Agopian83727852010-09-23 18:13:21 -0700305
Lloyd Pique441d5042018-10-18 16:49:51 -0700306 Hwc2::Composer* getComposer() const override { return mHwcDevice->getComposer(); }
Steven Thomas6e8f7062017-11-22 14:15:29 -0800307
Dominik Laskowski075d3172018-05-24 15:50:06 -0700308 // TODO(b/74619554): Remove special cases for internal/external display.
Lloyd Pique441d5042018-10-18 16:49:51 -0700309 std::optional<hwc2_display_t> getInternalHwcDisplayId() const override {
310 return mInternalHwcDisplayId;
311 }
312 std::optional<hwc2_display_t> getExternalHwcDisplayId() const override {
313 return mExternalHwcDisplayId;
314 }
Dominik Laskowski075d3172018-05-24 15:50:06 -0700315
Lloyd Pique441d5042018-10-18 16:49:51 -0700316 std::optional<DisplayId> toPhysicalDisplayId(hwc2_display_t hwcDisplayId) const override;
317 std::optional<hwc2_display_t> fromPhysicalDisplayId(DisplayId displayId) const override;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700318
Mathias Agopiana350ff92010-08-10 17:14:02 -0700319private:
Lloyd Piquee39cad22017-12-20 17:01:29 -0800320 // For unit tests
321 friend TestableSurfaceFlinger;
322
Dominik Laskowski075d3172018-05-24 15:50:06 -0700323 std::optional<DisplayIdentificationInfo> onHotplugConnect(hwc2_display_t hwcDisplayId);
324
Dan Stoza9e56aa02015-11-02 13:00:03 -0800325 static void validateChange(HWC2::Composition from, HWC2::Composition to);
Mathias Agopian31d28432012-04-03 16:31:39 -0700326
Mathias Agopiane60b0682012-08-21 23:34:09 -0700327 struct DisplayData {
Dominik Laskowskic1f18f62018-06-13 15:17:55 -0700328 bool isVirtual = false;
Dominik Laskowskif9750f22018-06-06 12:24:53 -0700329 bool hasClientComposition = false;
330 bool hasDeviceComposition = false;
331 HWC2::Display* hwcDisplay = nullptr;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800332 HWC2::DisplayRequest displayRequests;
Dominik Laskowskif9750f22018-06-06 12:24:53 -0700333 sp<Fence> lastPresentFence = Fence::NO_FENCE; // signals when the last set op retires
Steven Thomas94e35b92017-07-26 18:48:28 -0700334 std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
Dominik Laskowskif9750f22018-06-06 12:24:53 -0700335 buffer_handle_t outbufHandle = nullptr;
336 sp<Fence> outbufAcquireFence = Fence::NO_FENCE;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800337 mutable std::unordered_map<int32_t,
338 std::shared_ptr<const HWC2::Display::Config>> configMap;
Jamie Gennis2ec3e072012-11-11 16:24:33 -0800339
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700340 bool validateWasSkipped;
341 HWC2::Error presentError;
Dominik Laskowski1af47932018-11-12 10:20:46 -0800342
343 bool vsyncTraceToggle = false;
344
345 std::mutex vsyncEnabledLock;
346 HWC2::Vsync vsyncEnabled GUARDED_BY(vsyncEnabledLock) = HWC2::Vsync::Disable;
347
348 mutable std::mutex lastHwVsyncLock;
349 nsecs_t lastHwVsync GUARDED_BY(lastHwVsyncLock) = 0;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700350 };
351
Dominik Laskowski075d3172018-05-24 15:50:06 -0700352 std::unordered_map<DisplayId, DisplayData> mDisplayData;
Dominik Laskowskib04f98a2018-11-07 21:07:16 -0800353
354 // This must be destroyed before mDisplayData, because destructor may call back into HWComposer
355 // and look up DisplayData.
356 std::unique_ptr<HWC2::Device> mHwcDevice;
357
Dominik Laskowski075d3172018-05-24 15:50:06 -0700358 std::unordered_map<hwc2_display_t, DisplayId> mPhysicalDisplayIdMap;
359 std::optional<hwc2_display_t> mInternalHwcDisplayId;
360 std::optional<hwc2_display_t> mExternalHwcDisplayId;
361 bool mHasMultiDisplaySupport = false;
362
Dominik Laskowski34157762018-10-31 13:07:19 -0700363 std::unordered_set<DisplayId> mFreeVirtualDisplayIds;
Dominik Laskowski075d3172018-05-24 15:50:06 -0700364 uint32_t mNextVirtualDisplayId = 0;
Lloyd Piquea822d522017-12-20 16:42:57 -0800365 uint32_t mRemainingHwcVirtualDisplays{mHwcDevice->getMaxVirtualDisplayCount()};
Mathias Agopiana350ff92010-08-10 17:14:02 -0700366};
367
Lloyd Pique441d5042018-10-18 16:49:51 -0700368} // namespace impl
Dominik Laskowski1af47932018-11-12 10:20:46 -0800369} // namespace android
Mathias Agopiana350ff92010-08-10 17:14:02 -0700370
371#endif // ANDROID_SF_HWCOMPOSER_H