blob: 7314127239d69c288e4030e67d37c98b85286712 [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
Dan Stoza9e56aa02015-11-02 13:00:03 -080017// #define LOG_NDEBUG 0
18
19#undef LOG_TAG
20#define LOG_TAG "HWComposer"
Mathias Agopian2965b262012-04-08 15:13:32 -070021#define ATRACE_TAG ATRACE_TAG_GRAPHICS
22
Mark Salyzyn92dc3fc2014-03-12 13:12:44 -070023#include <inttypes.h>
24#include <math.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070025#include <stdint.h>
Mathias Agopianf1352df2010-08-11 17:31:33 -070026#include <stdio.h>
27#include <stdlib.h>
28#include <string.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070029#include <sys/types.h>
30
31#include <utils/Errors.h>
Mathias Agopianda27af92012-09-13 18:17:13 -070032#include <utils/misc.h>
Jesse Hall399184a2014-03-03 15:42:54 -080033#include <utils/NativeHandle.h>
Mathias Agopian83727852010-09-23 18:13:21 -070034#include <utils/String8.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070035#include <utils/Thread.h>
Mathias Agopian2965b262012-04-08 15:13:32 -070036#include <utils/Trace.h>
Mathias Agopian22da60c2011-09-09 00:49:11 -070037#include <utils/Vector.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070038
Mathias Agopian921e6ac2012-07-23 23:11:29 -070039#include <ui/GraphicBuffer.h>
40
Mathias Agopiana350ff92010-08-10 17:14:02 -070041#include <hardware/hardware.h>
Mathias Agopian3eb38cb2012-04-03 22:09:52 -070042#include <hardware/hwcomposer.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070043
Jesse Hall1c569c42013-04-05 13:44:52 -070044#include <android/configuration.h>
45
Mathias Agopiane2c4f4e2012-04-10 18:25:31 -070046#include <cutils/properties.h>
Mark Salyzyn7823e122016-09-29 08:08:05 -070047#include <log/log.h>
Mathias Agopiana350ff92010-08-10 17:14:02 -070048
Mathias Agopiana350ff92010-08-10 17:14:02 -070049#include "HWComposer.h"
Fabien Sanglarde29055f2017-03-08 11:36:46 -080050#include "hwc2on1adapter/HWC2On1Adapter.h"
Dan Stoza9e56aa02015-11-02 13:00:03 -080051#include "HWC2.h"
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -080052#include "ComposerHal.h"
Mathias Agopian33ceeb32013-04-01 16:54:58 -070053
54#include "../Layer.h" // needed only for debugging
55#include "../SurfaceFlinger.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070056
57namespace android {
Jesse Hall5880cc52012-06-05 23:40:32 -070058
Jesse Hall72960512013-01-10 16:19:56 -080059#define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION
Jesse Hall9eb1eb52012-08-29 10:39:38 -070060
Mathias Agopiana350ff92010-08-10 17:14:02 -070061// ---------------------------------------------------------------------------
62
Steven Thomas3cfac282017-02-06 12:29:30 -080063HWComposer::HWComposer(bool useVrComposer)
64 : mAdapter(),
Dan Stoza9e56aa02015-11-02 13:00:03 -080065 mHwcDevice(),
66 mDisplayData(2),
67 mFreeDisplaySlots(),
68 mHwcDisplaySlots(),
69 mCBContext(),
70 mEventHandler(nullptr),
71 mVSyncCounts(),
Chia-I Wu843460d2017-03-01 16:08:51 -080072 mRemainingHwcVirtualDisplays(0),
73 mDumpMayLockUp(false)
Mathias Agopiana350ff92010-08-10 17:14:02 -070074{
Mathias Agopianbef42c52013-08-21 17:45:46 -070075 for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
76 mLastHwVSync[i] = 0;
77 mVSyncCounts[i] = 0;
78 }
79
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -080080 loadHwcModule(useVrComposer);
Mathias Agopiana350ff92010-08-10 17:14:02 -070081}
82
Dan Stoza9e56aa02015-11-02 13:00:03 -080083HWComposer::~HWComposer() {}
84
85void HWComposer::setEventHandler(EventHandler* handler)
86{
87 if (handler == nullptr) {
88 ALOGE("setEventHandler: Rejected attempt to clear handler");
89 return;
Andy McFaddenbabba182012-09-12 13:14:51 -070090 }
Dan Stoza9e56aa02015-11-02 13:00:03 -080091
92 bool wasNull = (mEventHandler == nullptr);
93 mEventHandler = handler;
94
95 if (wasNull) {
96 auto hotplugHook = std::bind(&HWComposer::hotplug, this,
97 std::placeholders::_1, std::placeholders::_2);
98 mHwcDevice->registerHotplugCallback(hotplugHook);
99 auto invalidateHook = std::bind(&HWComposer::invalidate, this,
100 std::placeholders::_1);
101 mHwcDevice->registerRefreshCallback(invalidateHook);
102 auto vsyncHook = std::bind(&HWComposer::vsync, this,
103 std::placeholders::_1, std::placeholders::_2);
104 mHwcDevice->registerVsyncCallback(vsyncHook);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700105 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700106}
107
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700108// Load and prepare the hardware composer module. Sets mHwc.
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800109void HWComposer::loadHwcModule(bool useVrComposer)
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700110{
Dan Stoza9e56aa02015-11-02 13:00:03 -0800111 ALOGV("loadHwcModule");
112
Chia-I Wuaab99f52016-10-05 12:59:58 +0800113#ifdef BYPASS_IHWC
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800114 (void)useVrComposer; // Silence unused parameter warning.
115
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700116 hw_module_t const* module;
117
118 if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800119 ALOGE("%s module not found, aborting", HWC_HARDWARE_MODULE_ID);
120 abort();
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700121 }
122
Dan Stoza355f6042016-04-14 14:30:41 -0700123 hw_device_t* device = nullptr;
124 int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
125 if (error != 0) {
126 ALOGE("Failed to open HWC device (%s), aborting", strerror(-error));
127 abort();
128 }
129
130 uint32_t majorVersion = (device->version >> 24) & 0xF;
131 if (majorVersion == 2) {
132 mHwcDevice = std::make_unique<HWC2::Device>(
133 reinterpret_cast<hwc2_device_t*>(device));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800134 } else {
Dan Stoza355f6042016-04-14 14:30:41 -0700135 mAdapter = std::make_unique<HWC2On1Adapter>(
136 reinterpret_cast<hwc_composer_device_1_t*>(device));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800137 uint8_t minorVersion = mAdapter->getHwc1MinorVersion();
138 if (minorVersion < 1) {
139 ALOGE("Cannot adapt to HWC version %d.%d",
140 static_cast<int32_t>((minorVersion >> 8) & 0xF),
141 static_cast<int32_t>(minorVersion & 0xF));
142 abort();
143 }
144 mHwcDevice = std::make_unique<HWC2::Device>(
145 static_cast<hwc2_device_t*>(mAdapter.get()));
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700146 }
Chia-I Wuaab99f52016-10-05 12:59:58 +0800147#else
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800148 mHwcDevice = std::make_unique<HWC2::Device>(useVrComposer);
Chia-I Wuaab99f52016-10-05 12:59:58 +0800149#endif
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700150
Dan Stoza9e56aa02015-11-02 13:00:03 -0800151 mRemainingHwcVirtualDisplays = mHwcDevice->getMaxVirtualDisplayCount();
152}
153
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700154bool HWComposer::hasCapability(HWC2::Capability capability) const
155{
156 return mHwcDevice->getCapabilities().count(capability) > 0;
157}
158
Dan Stoza9e56aa02015-11-02 13:00:03 -0800159bool HWComposer::isValidDisplay(int32_t displayId) const {
160 return static_cast<size_t>(displayId) < mDisplayData.size() &&
161 mDisplayData[displayId].hwcDisplay;
162}
163
164void HWComposer::validateChange(HWC2::Composition from, HWC2::Composition to) {
165 bool valid = true;
166 switch (from) {
167 case HWC2::Composition::Client:
168 valid = false;
169 break;
170 case HWC2::Composition::Device:
171 case HWC2::Composition::SolidColor:
172 valid = (to == HWC2::Composition::Client);
173 break;
174 case HWC2::Composition::Cursor:
175 case HWC2::Composition::Sideband:
176 valid = (to == HWC2::Composition::Client ||
177 to == HWC2::Composition::Device);
178 break;
179 default:
180 break;
181 }
182
183 if (!valid) {
184 ALOGE("Invalid layer type change: %s --> %s", to_string(from).c_str(),
185 to_string(to).c_str());
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700186 }
187}
188
Dan Stoza9e56aa02015-11-02 13:00:03 -0800189void HWComposer::hotplug(const std::shared_ptr<HWC2::Display>& display,
190 HWC2::Connection connected) {
191 ALOGV("hotplug: %" PRIu64 ", %s", display->getId(),
192 to_string(connected).c_str());
193 int32_t disp = 0;
194 if (!mDisplayData[0].hwcDisplay) {
195 ALOGE_IF(connected != HWC2::Connection::Connected, "Assumed primary"
196 " display would be connected");
197 mDisplayData[0].hwcDisplay = display;
198 mHwcDisplaySlots[display->getId()] = 0;
199 disp = DisplayDevice::DISPLAY_PRIMARY;
200 } else {
201 // Disconnect is handled through HWComposer::disconnectDisplay via
202 // SurfaceFlinger's onHotplugReceived callback handling
203 if (connected == HWC2::Connection::Connected) {
204 mDisplayData[1].hwcDisplay = display;
205 mHwcDisplaySlots[display->getId()] = 1;
206 }
207 disp = DisplayDevice::DISPLAY_EXTERNAL;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700208 }
Polina Bondarenko80c02322017-04-10 10:15:42 +0000209 mEventHandler->onHotplugReceived(disp,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800210 connected == HWC2::Connection::Connected);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700211}
212
Dan Stoza9e56aa02015-11-02 13:00:03 -0800213void HWComposer::invalidate(const std::shared_ptr<HWC2::Display>& /*display*/) {
Steven Thomas3cfac282017-02-06 12:29:30 -0800214 mEventHandler->onInvalidateReceived(this);
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700215}
216
Dan Stoza9e56aa02015-11-02 13:00:03 -0800217void HWComposer::vsync(const std::shared_ptr<HWC2::Display>& display,
218 int64_t timestamp) {
219 auto displayType = HWC2::DisplayType::Invalid;
220 auto error = display->getType(&displayType);
221 if (error != HWC2::Error::None) {
222 ALOGE("vsync: Failed to determine type of display %" PRIu64,
223 display->getId());
Jesse Hall1bd20e02012-08-29 10:47:52 -0700224 return;
225 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700226
Dan Stoza9e56aa02015-11-02 13:00:03 -0800227 if (displayType == HWC2::DisplayType::Virtual) {
228 ALOGE("Virtual display %" PRIu64 " passed to vsync callback",
229 display->getId());
230 return;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700231 }
232
Dan Stoza9e56aa02015-11-02 13:00:03 -0800233 if (mHwcDisplaySlots.count(display->getId()) == 0) {
234 ALOGE("Unknown physical display %" PRIu64 " passed to vsync callback",
235 display->getId());
236 return;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700237 }
238
Dan Stoza9e56aa02015-11-02 13:00:03 -0800239 int32_t disp = mHwcDisplaySlots[display->getId()];
240 {
241 Mutex::Autolock _l(mLock);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700242
Dan Stoza9e56aa02015-11-02 13:00:03 -0800243 // There have been reports of HWCs that signal several vsync events
244 // with the same timestamp when turning the display off and on. This
245 // is a bug in the HWC implementation, but filter the extra events
246 // out here so they don't cause havoc downstream.
247 if (timestamp == mLastHwVSync[disp]) {
248 ALOGW("Ignoring duplicate VSYNC event from HWC (t=%" PRId64 ")",
249 timestamp);
250 return;
251 }
252
253 mLastHwVSync[disp] = timestamp;
Jesse Hall1c569c42013-04-05 13:44:52 -0700254 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800255
256 char tag[16];
257 snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp);
258 ATRACE_INT(tag, ++mVSyncCounts[disp] & 1);
259
Steven Thomas3cfac282017-02-06 12:29:30 -0800260 mEventHandler->onVSyncReceived(this, disp, timestamp);
Jesse Hall1c569c42013-04-05 13:44:52 -0700261}
262
Dan Stoza9e56aa02015-11-02 13:00:03 -0800263status_t HWComposer::allocateVirtualDisplay(uint32_t width, uint32_t height,
Dan Stoza5cf424b2016-05-20 14:02:39 -0700264 android_pixel_format_t* format, int32_t *outId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800265 if (mRemainingHwcVirtualDisplays == 0) {
266 ALOGE("allocateVirtualDisplay: No remaining virtual displays");
Mathias Agopiane60b0682012-08-21 23:34:09 -0700267 return NO_MEMORY;
268 }
Mathias Agopiane60b0682012-08-21 23:34:09 -0700269
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800270 if (SurfaceFlinger::maxVirtualDisplaySize != 0 &&
271 (width > SurfaceFlinger::maxVirtualDisplaySize ||
272 height > SurfaceFlinger::maxVirtualDisplaySize)) {
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800273 ALOGE("createVirtualDisplay: Can't create a virtual display with"
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800274 " a dimension > %" PRIu64 " (tried %u x %u)",
275 SurfaceFlinger::maxVirtualDisplaySize, width, height);
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800276 return INVALID_OPERATION;
277 }
278
Dan Stoza9e56aa02015-11-02 13:00:03 -0800279 std::shared_ptr<HWC2::Display> display;
Dan Stoza5cf424b2016-05-20 14:02:39 -0700280 auto error = mHwcDevice->createVirtualDisplay(width, height, format,
281 &display);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800282 if (error != HWC2::Error::None) {
283 ALOGE("allocateVirtualDisplay: Failed to create HWC virtual display");
284 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700285 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800286
287 size_t displaySlot = 0;
288 if (!mFreeDisplaySlots.empty()) {
289 displaySlot = *mFreeDisplaySlots.begin();
290 mFreeDisplaySlots.erase(displaySlot);
291 } else if (mDisplayData.size() < INT32_MAX) {
292 // Don't bother allocating a slot larger than we can return
293 displaySlot = mDisplayData.size();
294 mDisplayData.resize(displaySlot + 1);
295 } else {
296 ALOGE("allocateVirtualDisplay: Unable to allocate a display slot");
297 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700298 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800299
300 mDisplayData[displaySlot].hwcDisplay = display;
301
302 --mRemainingHwcVirtualDisplays;
303 *outId = static_cast<int32_t>(displaySlot);
304
Mathias Agopiane60b0682012-08-21 23:34:09 -0700305 return NO_ERROR;
306}
307
Dan Stoza9e56aa02015-11-02 13:00:03 -0800308std::shared_ptr<HWC2::Layer> HWComposer::createLayer(int32_t displayId) {
309 if (!isValidDisplay(displayId)) {
310 ALOGE("Failed to create layer on invalid display %d", displayId);
311 return nullptr;
312 }
313 auto display = mDisplayData[displayId].hwcDisplay;
314 std::shared_ptr<HWC2::Layer> layer;
315 auto error = display->createLayer(&layer);
316 if (error != HWC2::Error::None) {
317 ALOGE("Failed to create layer on display %d: %s (%d)", displayId,
318 to_string(error).c_str(), static_cast<int32_t>(error));
319 return nullptr;
320 }
321 return layer;
322}
323
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800324nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const {
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700325 // this returns the last refresh timestamp.
326 // if the last one is not available, we estimate it based on
327 // the refresh period and whatever closest timestamp we have.
328 Mutex::Autolock _l(mLock);
329 nsecs_t now = systemTime(CLOCK_MONOTONIC);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800330 auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod();
331 return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700332}
333
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800334bool HWComposer::isConnected(int32_t displayId) const {
335 if (!isValidDisplay(displayId)) {
336 ALOGE("isConnected: Attempted to access invalid display %d", displayId);
Mathias Agopiane60b0682012-08-21 23:34:09 -0700337 return false;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800338 }
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800339 return mDisplayData[displayId].hwcDisplay->isConnected();
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700340}
341
Dan Stoza9e56aa02015-11-02 13:00:03 -0800342std::vector<std::shared_ptr<const HWC2::Display::Config>>
343 HWComposer::getConfigs(int32_t displayId) const {
344 if (!isValidDisplay(displayId)) {
345 ALOGE("getConfigs: Attempted to access invalid display %d", displayId);
346 return {};
347 }
348 auto& displayData = mDisplayData[displayId];
349 auto configs = mDisplayData[displayId].hwcDisplay->getConfigs();
350 if (displayData.configMap.empty()) {
351 for (size_t i = 0; i < configs.size(); ++i) {
352 displayData.configMap[i] = configs[i];
Mathias Agopianda27af92012-09-13 18:17:13 -0700353 }
354 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800355 return configs;
Mathias Agopianda27af92012-09-13 18:17:13 -0700356}
357
Dan Stoza9e56aa02015-11-02 13:00:03 -0800358std::shared_ptr<const HWC2::Display::Config>
359 HWComposer::getActiveConfig(int32_t displayId) const {
360 if (!isValidDisplay(displayId)) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800361 ALOGV("getActiveConfigs: Attempted to access invalid display %d",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800362 displayId);
363 return nullptr;
Mathias Agopian58959342010-10-07 14:57:04 -0700364 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800365 std::shared_ptr<const HWC2::Display::Config> config;
366 auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config);
367 if (error == HWC2::Error::BadConfig) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800368 ALOGE("getActiveConfig: No config active, returning null");
Dan Stoza9e56aa02015-11-02 13:00:03 -0800369 return nullptr;
370 } else if (error != HWC2::Error::None) {
371 ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId,
372 to_string(error).c_str(), static_cast<int32_t>(error));
373 return nullptr;
374 } else if (!config) {
375 ALOGE("getActiveConfig returned an unknown config for display %d",
376 displayId);
377 return nullptr;
378 }
379
380 return config;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700381}
382
Michael Wright28f24d02016-07-12 13:30:53 -0700383std::vector<android_color_mode_t> HWComposer::getColorModes(int32_t displayId) const {
384 std::vector<android_color_mode_t> modes;
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600385
386 if (!isValidDisplay(displayId)) {
387 ALOGE("getColorModes: Attempted to access invalid display %d",
388 displayId);
389 return modes;
390 }
391 const std::shared_ptr<HWC2::Display>& hwcDisplay =
392 mDisplayData[displayId].hwcDisplay;
393
394 auto error = hwcDisplay->getColorModes(&modes);
395 if (error != HWC2::Error::None) {
396 ALOGE("getColorModes failed for display %d: %s (%d)", displayId,
397 to_string(error).c_str(), static_cast<int32_t>(error));
Michael Wright28f24d02016-07-12 13:30:53 -0700398 return std::vector<android_color_mode_t>();
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600399 }
400
401 return modes;
402}
403
Michael Wright28f24d02016-07-12 13:30:53 -0700404status_t HWComposer::setActiveColorMode(int32_t displayId, android_color_mode_t mode) {
405 if (!isValidDisplay(displayId)) {
406 ALOGE("setActiveColorMode: Display %d is not valid", displayId);
407 return BAD_INDEX;
408 }
409
410 auto& displayData = mDisplayData[displayId];
411 auto error = displayData.hwcDisplay->setColorMode(mode);
412 if (error != HWC2::Error::None) {
413 ALOGE("setActiveConfig: Failed to set color mode %d on display %d: "
414 "%s (%d)", mode, displayId, to_string(error).c_str(),
415 static_cast<int32_t>(error));
416 return UNKNOWN_ERROR;
417 }
418
419 return NO_ERROR;
420}
421
422
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800423void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) {
424 if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) {
425 ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800426 return;
427 }
428
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800429 if (!isValidDisplay(displayId)) {
430 ALOGE("setVsyncEnabled: Attempted to access invalid display %d",
431 displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800432 return;
433 }
434
435 // NOTE: we use our own internal lock here because we have to call
436 // into the HWC with the lock held, and we want to make sure
437 // that even if HWC blocks (which it shouldn't), it won't
438 // affect other threads.
439 Mutex::Autolock _l(mVsyncLock);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800440 auto& displayData = mDisplayData[displayId];
Dan Stoza9e56aa02015-11-02 13:00:03 -0800441 if (enabled != displayData.vsyncEnabled) {
442 ATRACE_CALL();
443 auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
444 if (error == HWC2::Error::None) {
445 displayData.vsyncEnabled = enabled;
446
447 char tag[16];
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800448 snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800449 ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700450 } else {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800451 ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800452 ": %s (%d)", to_string(enabled).c_str(), displayId,
453 mDisplayData[displayId].hwcDisplay->getId(),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800454 to_string(error).c_str(), static_cast<int32_t>(error));
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700455 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700456 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700457}
458
Chia-I Wu06d63de2017-01-04 14:58:51 +0800459status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800460 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target,
461 android_dataspace_t dataspace) {
462 if (!isValidDisplay(displayId)) {
Jesse Hall851cfe82013-03-20 13:44:00 -0700463 return BAD_INDEX;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800464 }
Jesse Hall851cfe82013-03-20 13:44:00 -0700465
Dan Stoza9e56aa02015-11-02 13:00:03 -0800466 ALOGV("setClientTarget for display %d", displayId);
467 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
Daniel Nicoara1f42e3a2017-04-10 13:27:32 -0400468 auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800469 if (error != HWC2::Error::None) {
470 ALOGE("Failed to set client target for display %d: %s (%d)", displayId,
471 to_string(error).c_str(), static_cast<int32_t>(error));
472 return BAD_VALUE;
473 }
474
Jesse Hall851cfe82013-03-20 13:44:00 -0700475 return NO_ERROR;
476}
477
Dan Stoza9e56aa02015-11-02 13:00:03 -0800478status_t HWComposer::prepare(DisplayDevice& displayDevice) {
479 ATRACE_CALL();
480
481 Mutex::Autolock _l(mDisplayLock);
482 auto displayId = displayDevice.getHwcDisplayId();
Dan Stozaec0f7172016-07-21 11:09:40 -0700483 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
484 ALOGV("Skipping HWComposer prepare for non-HWC display");
485 return NO_ERROR;
486 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800487 if (!isValidDisplay(displayId)) {
488 return BAD_INDEX;
489 }
490
491 auto& displayData = mDisplayData[displayId];
492 auto& hwcDisplay = displayData.hwcDisplay;
493 if (!hwcDisplay->isConnected()) {
494 return NO_ERROR;
495 }
496
Chia-I Wu843460d2017-03-01 16:08:51 -0800497 mDumpMayLockUp = true;
498
Dan Stoza9e56aa02015-11-02 13:00:03 -0800499 uint32_t numTypes = 0;
500 uint32_t numRequests = 0;
501 auto error = hwcDisplay->validate(&numTypes, &numRequests);
502 if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) {
503 ALOGE("prepare: validate failed for display %d: %s (%d)", displayId,
504 to_string(error).c_str(), static_cast<int32_t>(error));
505 return BAD_INDEX;
506 }
507
508 std::unordered_map<std::shared_ptr<HWC2::Layer>, HWC2::Composition>
509 changedTypes;
510 changedTypes.reserve(numTypes);
511 error = hwcDisplay->getChangedCompositionTypes(&changedTypes);
512 if (error != HWC2::Error::None) {
513 ALOGE("prepare: getChangedCompositionTypes failed on display %d: "
514 "%s (%d)", displayId, to_string(error).c_str(),
515 static_cast<int32_t>(error));
516 return BAD_INDEX;
517 }
518
519
520 displayData.displayRequests = static_cast<HWC2::DisplayRequest>(0);
521 std::unordered_map<std::shared_ptr<HWC2::Layer>, HWC2::LayerRequest>
522 layerRequests;
523 layerRequests.reserve(numRequests);
524 error = hwcDisplay->getRequests(&displayData.displayRequests,
525 &layerRequests);
526 if (error != HWC2::Error::None) {
527 ALOGE("prepare: getRequests failed on display %d: %s (%d)", displayId,
528 to_string(error).c_str(), static_cast<int32_t>(error));
529 return BAD_INDEX;
530 }
531
532 displayData.hasClientComposition = false;
533 displayData.hasDeviceComposition = false;
534 for (auto& layer : displayDevice.getVisibleLayersSortedByZ()) {
535 auto hwcLayer = layer->getHwcLayer(displayId);
536
537 if (changedTypes.count(hwcLayer) != 0) {
538 // We pass false so we only update our state and don't call back
539 // into the HWC device
540 validateChange(layer->getCompositionType(displayId),
541 changedTypes[hwcLayer]);
542 layer->setCompositionType(displayId, changedTypes[hwcLayer], false);
543 }
544
545 switch (layer->getCompositionType(displayId)) {
546 case HWC2::Composition::Client:
547 displayData.hasClientComposition = true;
548 break;
549 case HWC2::Composition::Device:
550 case HWC2::Composition::SolidColor:
551 case HWC2::Composition::Cursor:
552 case HWC2::Composition::Sideband:
553 displayData.hasDeviceComposition = true;
554 break;
555 default:
556 break;
557 }
558
559 if (layerRequests.count(hwcLayer) != 0 &&
560 layerRequests[hwcLayer] ==
561 HWC2::LayerRequest::ClearClientTarget) {
562 layer->setClearClientTarget(displayId, true);
563 } else {
564 if (layerRequests.count(hwcLayer) != 0) {
565 ALOGE("prepare: Unknown layer request: %s",
566 to_string(layerRequests[hwcLayer]).c_str());
567 }
568 layer->setClearClientTarget(displayId, false);
569 }
570 }
571
572 error = hwcDisplay->acceptChanges();
573 if (error != HWC2::Error::None) {
574 ALOGE("prepare: acceptChanges failed: %s", to_string(error).c_str());
575 return BAD_INDEX;
576 }
577
578 return NO_ERROR;
579}
580
581bool HWComposer::hasDeviceComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700582 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
583 // Displays without a corresponding HWC display are never composed by
584 // the device
585 return false;
586 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800587 if (!isValidDisplay(displayId)) {
588 ALOGE("hasDeviceComposition: Invalid display %d", displayId);
589 return false;
590 }
591 return mDisplayData[displayId].hasDeviceComposition;
592}
593
594bool HWComposer::hasClientComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700595 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
596 // Displays without a corresponding HWC display are always composed by
597 // the client
598 return true;
599 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800600 if (!isValidDisplay(displayId)) {
601 ALOGE("hasClientComposition: Invalid display %d", displayId);
602 return true;
603 }
604 return mDisplayData[displayId].hasClientComposition;
605}
606
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800607sp<Fence> HWComposer::getPresentFence(int32_t displayId) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800608 if (!isValidDisplay(displayId)) {
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800609 ALOGE("getPresentFence failed for invalid display %d", displayId);
Jesse Hall851cfe82013-03-20 13:44:00 -0700610 return Fence::NO_FENCE;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800611 }
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800612 return mDisplayData[displayId].lastPresentFence;
Jesse Hall851cfe82013-03-20 13:44:00 -0700613}
614
Dan Stoza9e56aa02015-11-02 13:00:03 -0800615sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId,
616 const std::shared_ptr<HWC2::Layer>& layer) const {
617 if (!isValidDisplay(displayId)) {
618 ALOGE("getLayerReleaseFence: Invalid display");
619 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700620 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800621 auto displayFences = mDisplayData[displayId].releaseFences;
622 if (displayFences.count(layer) == 0) {
623 ALOGV("getLayerReleaseFence: Release fence not found");
624 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700625 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800626 return displayFences[layer];
Riley Andrews03414a12014-07-01 14:22:59 -0700627}
628
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800629status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800630 ATRACE_CALL();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700631
Dan Stoza9e56aa02015-11-02 13:00:03 -0800632 if (!isValidDisplay(displayId)) {
633 return BAD_INDEX;
Mathias Agopianc3973602012-08-31 17:51:25 -0700634 }
Pablo Ceballosd814cf22015-09-11 14:37:39 -0700635
Dan Stoza9e56aa02015-11-02 13:00:03 -0800636 auto& displayData = mDisplayData[displayId];
637 auto& hwcDisplay = displayData.hwcDisplay;
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800638 auto error = hwcDisplay->present(&displayData.lastPresentFence);
Chia-I Wu843460d2017-03-01 16:08:51 -0800639
640 mDumpMayLockUp = false;
641
Dan Stoza9e56aa02015-11-02 13:00:03 -0800642 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800643 ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)",
644 displayId, to_string(error).c_str(), static_cast<int32_t>(error));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800645 return UNKNOWN_ERROR;
646 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700647
Dan Stoza9e56aa02015-11-02 13:00:03 -0800648 std::unordered_map<std::shared_ptr<HWC2::Layer>, sp<Fence>> releaseFences;
649 error = hwcDisplay->getReleaseFences(&releaseFences);
650 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800651 ALOGE("presentAndGetReleaseFences: Failed to get release fences "
652 "for display %d: %s (%d)",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800653 displayId, to_string(error).c_str(),
654 static_cast<int32_t>(error));
655 return UNKNOWN_ERROR;
Mathias Agopianf4358632012-08-22 17:16:19 -0700656 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800657
658 displayData.releaseFences = std::move(releaseFences);
659
660 return NO_ERROR;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700661}
662
Dan Stoza9e56aa02015-11-02 13:00:03 -0800663status_t HWComposer::setPowerMode(int32_t displayId, int32_t intMode) {
664 ALOGV("setPowerMode(%d, %d)", displayId, intMode);
665 if (!isValidDisplay(displayId)) {
666 ALOGE("setPowerMode: Bad display");
667 return BAD_INDEX;
668 }
669 if (displayId >= VIRTUAL_DISPLAY_ID_BASE) {
670 ALOGE("setPowerMode: Virtual display %d passed in, returning",
671 displayId);
672 return BAD_INDEX;
673 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700674
Dan Stoza9e56aa02015-11-02 13:00:03 -0800675 auto mode = static_cast<HWC2::PowerMode>(intMode);
676 if (mode == HWC2::PowerMode::Off) {
677 setVsyncEnabled(displayId, HWC2::Vsync::Disable);
678 }
679
680 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
681 switch (mode) {
682 case HWC2::PowerMode::Off:
683 case HWC2::PowerMode::On:
684 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
685 {
686 auto error = hwcDisplay->setPowerMode(mode);
687 if (error != HWC2::Error::None) {
688 ALOGE("setPowerMode: Unable to set power mode %s for "
689 "display %d: %s (%d)", to_string(mode).c_str(),
690 displayId, to_string(error).c_str(),
691 static_cast<int32_t>(error));
Mathias Agopianda27af92012-09-13 18:17:13 -0700692 }
693 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800694 break;
695 case HWC2::PowerMode::Doze:
696 case HWC2::PowerMode::DozeSuspend:
697 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
698 {
699 bool supportsDoze = false;
700 auto error = hwcDisplay->supportsDoze(&supportsDoze);
701 if (error != HWC2::Error::None) {
702 ALOGE("setPowerMode: Unable to query doze support for "
703 "display %d: %s (%d)", displayId,
704 to_string(error).c_str(),
705 static_cast<int32_t>(error));
706 }
707 if (!supportsDoze) {
708 mode = HWC2::PowerMode::On;
709 }
710
711 error = hwcDisplay->setPowerMode(mode);
712 if (error != HWC2::Error::None) {
713 ALOGE("setPowerMode: Unable to set power mode %s for "
714 "display %d: %s (%d)", to_string(mode).c_str(),
715 displayId, to_string(error).c_str(),
716 static_cast<int32_t>(error));
717 }
718 }
719 break;
720 default:
721 ALOGV("setPowerMode: Not calling HWC");
722 break;
Mathias Agopianda27af92012-09-13 18:17:13 -0700723 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800724
725 return NO_ERROR;
726}
727
728status_t HWComposer::setActiveConfig(int32_t displayId, size_t configId) {
729 if (!isValidDisplay(displayId)) {
730 ALOGE("setActiveConfig: Display %d is not valid", displayId);
731 return BAD_INDEX;
732 }
733
734 auto& displayData = mDisplayData[displayId];
735 if (displayData.configMap.count(configId) == 0) {
736 ALOGE("setActiveConfig: Invalid config %zd", configId);
737 return BAD_INDEX;
738 }
739
740 auto error = displayData.hwcDisplay->setActiveConfig(
741 displayData.configMap[configId]);
742 if (error != HWC2::Error::None) {
743 ALOGE("setActiveConfig: Failed to set config %zu on display %d: "
744 "%s (%d)", configId, displayId, to_string(error).c_str(),
745 static_cast<int32_t>(error));
746 return UNKNOWN_ERROR;
747 }
748
749 return NO_ERROR;
750}
751
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700752status_t HWComposer::setColorTransform(int32_t displayId,
753 const mat4& transform) {
754 if (!isValidDisplay(displayId)) {
755 ALOGE("setColorTransform: Display %d is not valid", displayId);
756 return BAD_INDEX;
757 }
758
759 auto& displayData = mDisplayData[displayId];
760 bool isIdentity = transform == mat4();
761 auto error = displayData.hwcDisplay->setColorTransform(transform,
762 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY :
763 HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX);
764 if (error != HWC2::Error::None) {
765 ALOGE("setColorTransform: Failed to set transform on display %d: "
766 "%s (%d)", displayId, to_string(error).c_str(),
767 static_cast<int32_t>(error));
768 return UNKNOWN_ERROR;
769 }
770
771 return NO_ERROR;
772}
773
Dan Stoza9e56aa02015-11-02 13:00:03 -0800774void HWComposer::disconnectDisplay(int displayId) {
775 LOG_ALWAYS_FATAL_IF(displayId < 0);
776 auto& displayData = mDisplayData[displayId];
777
778 auto displayType = HWC2::DisplayType::Invalid;
779 auto error = displayData.hwcDisplay->getType(&displayType);
780 if (error != HWC2::Error::None) {
781 ALOGE("disconnectDisplay: Failed to determine type of display %d",
782 displayId);
783 return;
784 }
785
786 // If this was a virtual display, add its slot back for reuse by future
787 // virtual displays
788 if (displayType == HWC2::DisplayType::Virtual) {
789 mFreeDisplaySlots.insert(displayId);
790 ++mRemainingHwcVirtualDisplays;
791 }
792
793 auto hwcId = displayData.hwcDisplay->getId();
794 mHwcDisplaySlots.erase(hwcId);
795 displayData.reset();
796}
797
798status_t HWComposer::setOutputBuffer(int32_t displayId,
799 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) {
800 if (!isValidDisplay(displayId)) {
801 ALOGE("setOutputBuffer: Display %d is not valid", displayId);
802 return BAD_INDEX;
803 }
804
805 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
806 auto displayType = HWC2::DisplayType::Invalid;
807 auto error = hwcDisplay->getType(&displayType);
808 if (error != HWC2::Error::None) {
809 ALOGE("setOutputBuffer: Failed to determine type of display %d",
810 displayId);
811 return NAME_NOT_FOUND;
812 }
813
814 if (displayType != HWC2::DisplayType::Virtual) {
815 ALOGE("setOutputBuffer: Display %d is not virtual", displayId);
816 return INVALID_OPERATION;
817 }
818
819 error = hwcDisplay->setOutputBuffer(buffer, acquireFence);
820 if (error != HWC2::Error::None) {
821 ALOGE("setOutputBuffer: Failed to set buffer on display %d: %s (%d)",
822 displayId, to_string(error).c_str(),
823 static_cast<int32_t>(error));
824 return UNKNOWN_ERROR;
825 }
826
827 return NO_ERROR;
828}
829
830void HWComposer::clearReleaseFences(int32_t displayId) {
831 if (!isValidDisplay(displayId)) {
832 ALOGE("clearReleaseFences: Display %d is not valid", displayId);
833 return;
834 }
835 mDisplayData[displayId].releaseFences.clear();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700836}
837
Dan Stozac4f471e2016-03-24 09:31:08 -0700838std::unique_ptr<HdrCapabilities> HWComposer::getHdrCapabilities(
839 int32_t displayId) {
840 if (!isValidDisplay(displayId)) {
841 ALOGE("getHdrCapabilities: Display %d is not valid", displayId);
842 return nullptr;
843 }
844
845 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
846 std::unique_ptr<HdrCapabilities> capabilities;
847 auto error = hwcDisplay->getHdrCapabilities(&capabilities);
848 if (error != HWC2::Error::None) {
849 ALOGE("getOutputCapabilities: Failed to get capabilities on display %d:"
850 " %s (%d)", displayId, to_string(error).c_str(),
851 static_cast<int32_t>(error));
852 return nullptr;
853 }
854
855 return capabilities;
856}
857
Andy McFadden4df87bd2014-04-21 18:08:54 -0700858// Converts a PixelFormat to a human-readable string. Max 11 chars.
859// (Could use a table of prefab String8 objects.)
Dan Stoza9e56aa02015-11-02 13:00:03 -0800860/*
Andy McFadden4df87bd2014-04-21 18:08:54 -0700861static String8 getFormatStr(PixelFormat format) {
862 switch (format) {
863 case PIXEL_FORMAT_RGBA_8888: return String8("RGBA_8888");
864 case PIXEL_FORMAT_RGBX_8888: return String8("RGBx_8888");
865 case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
866 case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
867 case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
Andy McFaddenf0058ca2014-05-20 13:28:50 -0700868 case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
869 return String8("ImplDef");
Andy McFadden4df87bd2014-04-21 18:08:54 -0700870 default:
871 String8 result;
872 result.appendFormat("? %08x", format);
873 return result;
874 }
875}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800876*/
Andy McFadden4df87bd2014-04-21 18:08:54 -0700877
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800878bool HWComposer::isUsingVrComposer() const {
879#ifdef BYPASS_IHWC
880 return false;
881#else
882 return getComposer()->isUsingVrComposer();
883#endif
884}
885
Mathias Agopian74d211a2013-04-22 16:55:35 +0200886void HWComposer::dump(String8& result) const {
Chia-I Wu843460d2017-03-01 16:08:51 -0800887 if (mDumpMayLockUp) {
888 result.append("HWComposer dump skipped because present in progress");
889 return;
890 }
891
Dan Stoza9e56aa02015-11-02 13:00:03 -0800892 // TODO: In order to provide a dump equivalent to HWC1, we need to shadow
893 // all the state going into the layers. This is probably better done in
894 // Layer itself, but it's going to take a bit of work to get there.
895 result.append(mHwcDevice->dump().c_str());
Mathias Agopian83727852010-09-23 18:13:21 -0700896}
897
Mathias Agopiana350ff92010-08-10 17:14:02 -0700898// ---------------------------------------------------------------------------
Mathias Agopian2965b262012-04-08 15:13:32 -0700899
Jesse Halla9a1b002013-02-27 16:39:25 -0800900HWComposer::DisplayData::DisplayData()
Dan Stoza9e56aa02015-11-02 13:00:03 -0800901 : hasClientComposition(false),
902 hasDeviceComposition(false),
903 hwcDisplay(),
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800904 lastPresentFence(Fence::NO_FENCE),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800905 outbufHandle(nullptr),
906 outbufAcquireFence(Fence::NO_FENCE),
907 vsyncEnabled(HWC2::Vsync::Disable) {
908 ALOGV("Created new DisplayData");
909}
Jesse Halla9a1b002013-02-27 16:39:25 -0800910
911HWComposer::DisplayData::~DisplayData() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800912}
913
914void HWComposer::DisplayData::reset() {
915 ALOGV("DisplayData reset");
916 *this = DisplayData();
Jesse Halla9a1b002013-02-27 16:39:25 -0800917}
918
Mathias Agopian2965b262012-04-08 15:13:32 -0700919// ---------------------------------------------------------------------------
Mathias Agopiana350ff92010-08-10 17:14:02 -0700920}; // namespace android