blob: ba472392fafa271cf3ce79b2a5c28d7e237218dd [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"
Dan Stoza9e56aa02015-11-02 13:00:03 -080050#include "HWC2.h"
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -080051#include "ComposerHal.h"
Mathias Agopian33ceeb32013-04-01 16:54:58 -070052
53#include "../Layer.h" // needed only for debugging
54#include "../SurfaceFlinger.h"
Mathias Agopiana350ff92010-08-10 17:14:02 -070055
56namespace android {
Jesse Hall5880cc52012-06-05 23:40:32 -070057
Jesse Hall72960512013-01-10 16:19:56 -080058#define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION
Jesse Hall9eb1eb52012-08-29 10:39:38 -070059
Mathias Agopiana350ff92010-08-10 17:14:02 -070060// ---------------------------------------------------------------------------
61
Steven Thomas3cfac282017-02-06 12:29:30 -080062HWComposer::HWComposer(bool useVrComposer)
Logan Chien23429772017-05-16 10:18:17 +080063 : mHwcDevice(),
Dan Stoza9e56aa02015-11-02 13:00:03 -080064 mDisplayData(2),
65 mFreeDisplaySlots(),
66 mHwcDisplaySlots(),
67 mCBContext(),
68 mEventHandler(nullptr),
69 mVSyncCounts(),
Chia-I Wu15b27e02017-05-11 16:06:07 -070070 mRemainingHwcVirtualDisplays(0)
Mathias Agopiana350ff92010-08-10 17:14:02 -070071{
Mathias Agopianbef42c52013-08-21 17:45:46 -070072 for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
73 mLastHwVSync[i] = 0;
74 mVSyncCounts[i] = 0;
75 }
76
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -080077 loadHwcModule(useVrComposer);
Mathias Agopiana350ff92010-08-10 17:14:02 -070078}
79
Dan Stoza9e56aa02015-11-02 13:00:03 -080080HWComposer::~HWComposer() {}
81
82void HWComposer::setEventHandler(EventHandler* handler)
83{
84 if (handler == nullptr) {
85 ALOGE("setEventHandler: Rejected attempt to clear handler");
86 return;
Andy McFaddenbabba182012-09-12 13:14:51 -070087 }
Dan Stoza9e56aa02015-11-02 13:00:03 -080088
89 bool wasNull = (mEventHandler == nullptr);
90 mEventHandler = handler;
91
92 if (wasNull) {
93 auto hotplugHook = std::bind(&HWComposer::hotplug, this,
94 std::placeholders::_1, std::placeholders::_2);
95 mHwcDevice->registerHotplugCallback(hotplugHook);
96 auto invalidateHook = std::bind(&HWComposer::invalidate, this,
97 std::placeholders::_1);
98 mHwcDevice->registerRefreshCallback(invalidateHook);
99 auto vsyncHook = std::bind(&HWComposer::vsync, this,
100 std::placeholders::_1, std::placeholders::_2);
101 mHwcDevice->registerVsyncCallback(vsyncHook);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700102 }
Mathias Agopiana350ff92010-08-10 17:14:02 -0700103}
104
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700105// Load and prepare the hardware composer module. Sets mHwc.
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800106void HWComposer::loadHwcModule(bool useVrComposer)
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700107{
Dan Stoza9e56aa02015-11-02 13:00:03 -0800108 ALOGV("loadHwcModule");
109
Chia-I Wuaab99f52016-10-05 12:59:58 +0800110#ifdef BYPASS_IHWC
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800111 (void)useVrComposer; // Silence unused parameter warning.
112
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700113 hw_module_t const* module;
114
115 if (hw_get_module(HWC_HARDWARE_MODULE_ID, &module) != 0) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800116 ALOGE("%s module not found, aborting", HWC_HARDWARE_MODULE_ID);
117 abort();
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700118 }
119
Dan Stoza355f6042016-04-14 14:30:41 -0700120 hw_device_t* device = nullptr;
121 int error = module->methods->open(module, HWC_HARDWARE_COMPOSER, &device);
122 if (error != 0) {
123 ALOGE("Failed to open HWC device (%s), aborting", strerror(-error));
124 abort();
125 }
126
127 uint32_t majorVersion = (device->version >> 24) & 0xF;
128 if (majorVersion == 2) {
129 mHwcDevice = std::make_unique<HWC2::Device>(
130 reinterpret_cast<hwc2_device_t*>(device));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800131 } else {
Dan Stoza355f6042016-04-14 14:30:41 -0700132 mAdapter = std::make_unique<HWC2On1Adapter>(
133 reinterpret_cast<hwc_composer_device_1_t*>(device));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800134 uint8_t minorVersion = mAdapter->getHwc1MinorVersion();
135 if (minorVersion < 1) {
136 ALOGE("Cannot adapt to HWC version %d.%d",
137 static_cast<int32_t>((minorVersion >> 8) & 0xF),
138 static_cast<int32_t>(minorVersion & 0xF));
139 abort();
140 }
141 mHwcDevice = std::make_unique<HWC2::Device>(
142 static_cast<hwc2_device_t*>(mAdapter.get()));
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700143 }
Chia-I Wuaab99f52016-10-05 12:59:58 +0800144#else
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800145 mHwcDevice = std::make_unique<HWC2::Device>(useVrComposer);
Chia-I Wuaab99f52016-10-05 12:59:58 +0800146#endif
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700147
Dan Stoza9e56aa02015-11-02 13:00:03 -0800148 mRemainingHwcVirtualDisplays = mHwcDevice->getMaxVirtualDisplayCount();
149}
150
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700151bool HWComposer::hasCapability(HWC2::Capability capability) const
152{
153 return mHwcDevice->getCapabilities().count(capability) > 0;
154}
155
Dan Stoza9e56aa02015-11-02 13:00:03 -0800156bool HWComposer::isValidDisplay(int32_t displayId) const {
157 return static_cast<size_t>(displayId) < mDisplayData.size() &&
158 mDisplayData[displayId].hwcDisplay;
159}
160
161void HWComposer::validateChange(HWC2::Composition from, HWC2::Composition to) {
162 bool valid = true;
163 switch (from) {
164 case HWC2::Composition::Client:
165 valid = false;
166 break;
167 case HWC2::Composition::Device:
168 case HWC2::Composition::SolidColor:
169 valid = (to == HWC2::Composition::Client);
170 break;
171 case HWC2::Composition::Cursor:
172 case HWC2::Composition::Sideband:
173 valid = (to == HWC2::Composition::Client ||
174 to == HWC2::Composition::Device);
175 break;
176 default:
177 break;
178 }
179
180 if (!valid) {
181 ALOGE("Invalid layer type change: %s --> %s", to_string(from).c_str(),
182 to_string(to).c_str());
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700183 }
184}
185
Dan Stoza9e56aa02015-11-02 13:00:03 -0800186void HWComposer::hotplug(const std::shared_ptr<HWC2::Display>& display,
187 HWC2::Connection connected) {
188 ALOGV("hotplug: %" PRIu64 ", %s", display->getId(),
189 to_string(connected).c_str());
190 int32_t disp = 0;
191 if (!mDisplayData[0].hwcDisplay) {
192 ALOGE_IF(connected != HWC2::Connection::Connected, "Assumed primary"
193 " display would be connected");
194 mDisplayData[0].hwcDisplay = display;
195 mHwcDisplaySlots[display->getId()] = 0;
196 disp = DisplayDevice::DISPLAY_PRIMARY;
197 } else {
198 // Disconnect is handled through HWComposer::disconnectDisplay via
199 // SurfaceFlinger's onHotplugReceived callback handling
200 if (connected == HWC2::Connection::Connected) {
201 mDisplayData[1].hwcDisplay = display;
202 mHwcDisplaySlots[display->getId()] = 1;
203 }
204 disp = DisplayDevice::DISPLAY_EXTERNAL;
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700205 }
Stephen Kiazyk7d3dcb92017-04-05 16:46:49 -0700206 mEventHandler->onHotplugReceived(this, disp,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800207 connected == HWC2::Connection::Connected);
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700208}
209
Dan Stoza9e56aa02015-11-02 13:00:03 -0800210void HWComposer::invalidate(const std::shared_ptr<HWC2::Display>& /*display*/) {
Steven Thomas3cfac282017-02-06 12:29:30 -0800211 mEventHandler->onInvalidateReceived(this);
Mathias Agopianc7d14e22011-08-01 16:32:21 -0700212}
213
Dan Stoza9e56aa02015-11-02 13:00:03 -0800214void HWComposer::vsync(const std::shared_ptr<HWC2::Display>& display,
215 int64_t timestamp) {
216 auto displayType = HWC2::DisplayType::Invalid;
217 auto error = display->getType(&displayType);
218 if (error != HWC2::Error::None) {
219 ALOGE("vsync: Failed to determine type of display %" PRIu64,
220 display->getId());
Jesse Hall1bd20e02012-08-29 10:47:52 -0700221 return;
222 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700223
Dan Stoza9e56aa02015-11-02 13:00:03 -0800224 if (displayType == HWC2::DisplayType::Virtual) {
225 ALOGE("Virtual display %" PRIu64 " passed to vsync callback",
226 display->getId());
227 return;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700228 }
229
Dan Stoza9e56aa02015-11-02 13:00:03 -0800230 if (mHwcDisplaySlots.count(display->getId()) == 0) {
231 ALOGE("Unknown physical display %" PRIu64 " passed to vsync callback",
232 display->getId());
233 return;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700234 }
235
Dan Stoza9e56aa02015-11-02 13:00:03 -0800236 int32_t disp = mHwcDisplaySlots[display->getId()];
237 {
238 Mutex::Autolock _l(mLock);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700239
Dan Stoza9e56aa02015-11-02 13:00:03 -0800240 // There have been reports of HWCs that signal several vsync events
241 // with the same timestamp when turning the display off and on. This
242 // is a bug in the HWC implementation, but filter the extra events
243 // out here so they don't cause havoc downstream.
244 if (timestamp == mLastHwVSync[disp]) {
245 ALOGW("Ignoring duplicate VSYNC event from HWC (t=%" PRId64 ")",
246 timestamp);
247 return;
248 }
249
250 mLastHwVSync[disp] = timestamp;
Jesse Hall1c569c42013-04-05 13:44:52 -0700251 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800252
253 char tag[16];
254 snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp);
255 ATRACE_INT(tag, ++mVSyncCounts[disp] & 1);
256
Steven Thomas3cfac282017-02-06 12:29:30 -0800257 mEventHandler->onVSyncReceived(this, disp, timestamp);
Jesse Hall1c569c42013-04-05 13:44:52 -0700258}
259
Dan Stoza9e56aa02015-11-02 13:00:03 -0800260status_t HWComposer::allocateVirtualDisplay(uint32_t width, uint32_t height,
Dan Stoza5cf424b2016-05-20 14:02:39 -0700261 android_pixel_format_t* format, int32_t *outId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800262 if (mRemainingHwcVirtualDisplays == 0) {
263 ALOGE("allocateVirtualDisplay: No remaining virtual displays");
Mathias Agopiane60b0682012-08-21 23:34:09 -0700264 return NO_MEMORY;
265 }
Mathias Agopiane60b0682012-08-21 23:34:09 -0700266
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800267 if (SurfaceFlinger::maxVirtualDisplaySize != 0 &&
268 (width > SurfaceFlinger::maxVirtualDisplaySize ||
269 height > SurfaceFlinger::maxVirtualDisplaySize)) {
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800270 ALOGE("createVirtualDisplay: Can't create a virtual display with"
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800271 " a dimension > %" PRIu64 " (tried %u x %u)",
272 SurfaceFlinger::maxVirtualDisplaySize, width, height);
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800273 return INVALID_OPERATION;
274 }
275
Dan Stoza9e56aa02015-11-02 13:00:03 -0800276 std::shared_ptr<HWC2::Display> display;
Dan Stoza5cf424b2016-05-20 14:02:39 -0700277 auto error = mHwcDevice->createVirtualDisplay(width, height, format,
278 &display);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800279 if (error != HWC2::Error::None) {
280 ALOGE("allocateVirtualDisplay: Failed to create HWC virtual display");
281 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700282 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800283
284 size_t displaySlot = 0;
285 if (!mFreeDisplaySlots.empty()) {
286 displaySlot = *mFreeDisplaySlots.begin();
287 mFreeDisplaySlots.erase(displaySlot);
288 } else if (mDisplayData.size() < INT32_MAX) {
289 // Don't bother allocating a slot larger than we can return
290 displaySlot = mDisplayData.size();
291 mDisplayData.resize(displaySlot + 1);
292 } else {
293 ALOGE("allocateVirtualDisplay: Unable to allocate a display slot");
294 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700295 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800296
297 mDisplayData[displaySlot].hwcDisplay = display;
298
299 --mRemainingHwcVirtualDisplays;
300 *outId = static_cast<int32_t>(displaySlot);
301
Mathias Agopiane60b0682012-08-21 23:34:09 -0700302 return NO_ERROR;
303}
304
Dan Stoza9e56aa02015-11-02 13:00:03 -0800305std::shared_ptr<HWC2::Layer> HWComposer::createLayer(int32_t displayId) {
306 if (!isValidDisplay(displayId)) {
307 ALOGE("Failed to create layer on invalid display %d", displayId);
308 return nullptr;
309 }
310 auto display = mDisplayData[displayId].hwcDisplay;
311 std::shared_ptr<HWC2::Layer> layer;
312 auto error = display->createLayer(&layer);
313 if (error != HWC2::Error::None) {
314 ALOGE("Failed to create layer on display %d: %s (%d)", displayId,
315 to_string(error).c_str(), static_cast<int32_t>(error));
316 return nullptr;
317 }
318 return layer;
319}
320
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800321nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const {
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700322 // this returns the last refresh timestamp.
323 // if the last one is not available, we estimate it based on
324 // the refresh period and whatever closest timestamp we have.
325 Mutex::Autolock _l(mLock);
326 nsecs_t now = systemTime(CLOCK_MONOTONIC);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800327 auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod();
328 return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700329}
330
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800331bool HWComposer::isConnected(int32_t displayId) const {
332 if (!isValidDisplay(displayId)) {
333 ALOGE("isConnected: Attempted to access invalid display %d", displayId);
Mathias Agopiane60b0682012-08-21 23:34:09 -0700334 return false;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800335 }
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800336 return mDisplayData[displayId].hwcDisplay->isConnected();
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700337}
338
Dan Stoza9e56aa02015-11-02 13:00:03 -0800339std::vector<std::shared_ptr<const HWC2::Display::Config>>
340 HWComposer::getConfigs(int32_t displayId) const {
341 if (!isValidDisplay(displayId)) {
342 ALOGE("getConfigs: Attempted to access invalid display %d", displayId);
343 return {};
344 }
345 auto& displayData = mDisplayData[displayId];
346 auto configs = mDisplayData[displayId].hwcDisplay->getConfigs();
347 if (displayData.configMap.empty()) {
348 for (size_t i = 0; i < configs.size(); ++i) {
349 displayData.configMap[i] = configs[i];
Mathias Agopianda27af92012-09-13 18:17:13 -0700350 }
351 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800352 return configs;
Mathias Agopianda27af92012-09-13 18:17:13 -0700353}
354
Dan Stoza9e56aa02015-11-02 13:00:03 -0800355std::shared_ptr<const HWC2::Display::Config>
356 HWComposer::getActiveConfig(int32_t displayId) const {
357 if (!isValidDisplay(displayId)) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800358 ALOGV("getActiveConfigs: Attempted to access invalid display %d",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800359 displayId);
360 return nullptr;
Mathias Agopian58959342010-10-07 14:57:04 -0700361 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800362 std::shared_ptr<const HWC2::Display::Config> config;
363 auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config);
364 if (error == HWC2::Error::BadConfig) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800365 ALOGE("getActiveConfig: No config active, returning null");
Dan Stoza9e56aa02015-11-02 13:00:03 -0800366 return nullptr;
367 } else if (error != HWC2::Error::None) {
368 ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId,
369 to_string(error).c_str(), static_cast<int32_t>(error));
370 return nullptr;
371 } else if (!config) {
372 ALOGE("getActiveConfig returned an unknown config for display %d",
373 displayId);
374 return nullptr;
375 }
376
377 return config;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700378}
379
Michael Wright28f24d02016-07-12 13:30:53 -0700380std::vector<android_color_mode_t> HWComposer::getColorModes(int32_t displayId) const {
381 std::vector<android_color_mode_t> modes;
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600382
383 if (!isValidDisplay(displayId)) {
384 ALOGE("getColorModes: Attempted to access invalid display %d",
385 displayId);
386 return modes;
387 }
388 const std::shared_ptr<HWC2::Display>& hwcDisplay =
389 mDisplayData[displayId].hwcDisplay;
390
391 auto error = hwcDisplay->getColorModes(&modes);
392 if (error != HWC2::Error::None) {
393 ALOGE("getColorModes failed for display %d: %s (%d)", displayId,
394 to_string(error).c_str(), static_cast<int32_t>(error));
Michael Wright28f24d02016-07-12 13:30:53 -0700395 return std::vector<android_color_mode_t>();
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600396 }
397
398 return modes;
399}
400
Michael Wright28f24d02016-07-12 13:30:53 -0700401status_t HWComposer::setActiveColorMode(int32_t displayId, android_color_mode_t mode) {
402 if (!isValidDisplay(displayId)) {
403 ALOGE("setActiveColorMode: Display %d is not valid", displayId);
404 return BAD_INDEX;
405 }
406
407 auto& displayData = mDisplayData[displayId];
408 auto error = displayData.hwcDisplay->setColorMode(mode);
409 if (error != HWC2::Error::None) {
410 ALOGE("setActiveConfig: Failed to set color mode %d on display %d: "
411 "%s (%d)", mode, displayId, to_string(error).c_str(),
412 static_cast<int32_t>(error));
413 return UNKNOWN_ERROR;
414 }
415
416 return NO_ERROR;
417}
418
419
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800420void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) {
421 if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) {
422 ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800423 return;
424 }
425
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800426 if (!isValidDisplay(displayId)) {
427 ALOGE("setVsyncEnabled: Attempted to access invalid display %d",
428 displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800429 return;
430 }
431
432 // NOTE: we use our own internal lock here because we have to call
433 // into the HWC with the lock held, and we want to make sure
434 // that even if HWC blocks (which it shouldn't), it won't
435 // affect other threads.
436 Mutex::Autolock _l(mVsyncLock);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800437 auto& displayData = mDisplayData[displayId];
Dan Stoza9e56aa02015-11-02 13:00:03 -0800438 if (enabled != displayData.vsyncEnabled) {
439 ATRACE_CALL();
440 auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
441 if (error == HWC2::Error::None) {
442 displayData.vsyncEnabled = enabled;
443
444 char tag[16];
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800445 snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800446 ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700447 } else {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800448 ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800449 ": %s (%d)", to_string(enabled).c_str(), displayId,
450 mDisplayData[displayId].hwcDisplay->getId(),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800451 to_string(error).c_str(), static_cast<int32_t>(error));
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700452 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700453 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700454}
455
Chia-I Wu06d63de2017-01-04 14:58:51 +0800456status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800457 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target,
458 android_dataspace_t dataspace) {
459 if (!isValidDisplay(displayId)) {
Jesse Hall851cfe82013-03-20 13:44:00 -0700460 return BAD_INDEX;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800461 }
Jesse Hall851cfe82013-03-20 13:44:00 -0700462
Dan Stoza9e56aa02015-11-02 13:00:03 -0800463 ALOGV("setClientTarget for display %d", displayId);
464 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
Daniel Nicoara1f42e3a2017-04-10 13:27:32 -0400465 auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800466 if (error != HWC2::Error::None) {
467 ALOGE("Failed to set client target for display %d: %s (%d)", displayId,
468 to_string(error).c_str(), static_cast<int32_t>(error));
469 return BAD_VALUE;
470 }
471
Jesse Hall851cfe82013-03-20 13:44:00 -0700472 return NO_ERROR;
473}
474
Dan Stoza9e56aa02015-11-02 13:00:03 -0800475status_t HWComposer::prepare(DisplayDevice& displayDevice) {
476 ATRACE_CALL();
477
478 Mutex::Autolock _l(mDisplayLock);
479 auto displayId = displayDevice.getHwcDisplayId();
Dan Stozaec0f7172016-07-21 11:09:40 -0700480 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
481 ALOGV("Skipping HWComposer prepare for non-HWC display");
482 return NO_ERROR;
483 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800484 if (!isValidDisplay(displayId)) {
485 return BAD_INDEX;
486 }
487
488 auto& displayData = mDisplayData[displayId];
489 auto& hwcDisplay = displayData.hwcDisplay;
490 if (!hwcDisplay->isConnected()) {
491 return NO_ERROR;
492 }
493
494 uint32_t numTypes = 0;
495 uint32_t numRequests = 0;
496 auto error = hwcDisplay->validate(&numTypes, &numRequests);
497 if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) {
498 ALOGE("prepare: validate failed for display %d: %s (%d)", displayId,
499 to_string(error).c_str(), static_cast<int32_t>(error));
500 return BAD_INDEX;
501 }
502
503 std::unordered_map<std::shared_ptr<HWC2::Layer>, HWC2::Composition>
504 changedTypes;
505 changedTypes.reserve(numTypes);
506 error = hwcDisplay->getChangedCompositionTypes(&changedTypes);
507 if (error != HWC2::Error::None) {
508 ALOGE("prepare: getChangedCompositionTypes failed on display %d: "
509 "%s (%d)", displayId, to_string(error).c_str(),
510 static_cast<int32_t>(error));
511 return BAD_INDEX;
512 }
513
514
515 displayData.displayRequests = static_cast<HWC2::DisplayRequest>(0);
516 std::unordered_map<std::shared_ptr<HWC2::Layer>, HWC2::LayerRequest>
517 layerRequests;
518 layerRequests.reserve(numRequests);
519 error = hwcDisplay->getRequests(&displayData.displayRequests,
520 &layerRequests);
521 if (error != HWC2::Error::None) {
522 ALOGE("prepare: getRequests failed on display %d: %s (%d)", displayId,
523 to_string(error).c_str(), static_cast<int32_t>(error));
524 return BAD_INDEX;
525 }
526
527 displayData.hasClientComposition = false;
528 displayData.hasDeviceComposition = false;
529 for (auto& layer : displayDevice.getVisibleLayersSortedByZ()) {
530 auto hwcLayer = layer->getHwcLayer(displayId);
531
532 if (changedTypes.count(hwcLayer) != 0) {
533 // We pass false so we only update our state and don't call back
534 // into the HWC device
535 validateChange(layer->getCompositionType(displayId),
536 changedTypes[hwcLayer]);
537 layer->setCompositionType(displayId, changedTypes[hwcLayer], false);
538 }
539
540 switch (layer->getCompositionType(displayId)) {
541 case HWC2::Composition::Client:
542 displayData.hasClientComposition = true;
543 break;
544 case HWC2::Composition::Device:
545 case HWC2::Composition::SolidColor:
546 case HWC2::Composition::Cursor:
547 case HWC2::Composition::Sideband:
548 displayData.hasDeviceComposition = true;
549 break;
550 default:
551 break;
552 }
553
554 if (layerRequests.count(hwcLayer) != 0 &&
555 layerRequests[hwcLayer] ==
556 HWC2::LayerRequest::ClearClientTarget) {
557 layer->setClearClientTarget(displayId, true);
558 } else {
559 if (layerRequests.count(hwcLayer) != 0) {
560 ALOGE("prepare: Unknown layer request: %s",
561 to_string(layerRequests[hwcLayer]).c_str());
562 }
563 layer->setClearClientTarget(displayId, false);
564 }
565 }
566
567 error = hwcDisplay->acceptChanges();
568 if (error != HWC2::Error::None) {
569 ALOGE("prepare: acceptChanges failed: %s", to_string(error).c_str());
570 return BAD_INDEX;
571 }
572
573 return NO_ERROR;
574}
575
576bool HWComposer::hasDeviceComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700577 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
578 // Displays without a corresponding HWC display are never composed by
579 // the device
580 return false;
581 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800582 if (!isValidDisplay(displayId)) {
583 ALOGE("hasDeviceComposition: Invalid display %d", displayId);
584 return false;
585 }
586 return mDisplayData[displayId].hasDeviceComposition;
587}
588
589bool HWComposer::hasClientComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700590 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
591 // Displays without a corresponding HWC display are always composed by
592 // the client
593 return true;
594 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800595 if (!isValidDisplay(displayId)) {
596 ALOGE("hasClientComposition: Invalid display %d", displayId);
597 return true;
598 }
599 return mDisplayData[displayId].hasClientComposition;
600}
601
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800602sp<Fence> HWComposer::getPresentFence(int32_t displayId) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800603 if (!isValidDisplay(displayId)) {
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800604 ALOGE("getPresentFence failed for invalid display %d", displayId);
Jesse Hall851cfe82013-03-20 13:44:00 -0700605 return Fence::NO_FENCE;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800606 }
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800607 return mDisplayData[displayId].lastPresentFence;
Jesse Hall851cfe82013-03-20 13:44:00 -0700608}
609
Dan Stoza9e56aa02015-11-02 13:00:03 -0800610sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId,
611 const std::shared_ptr<HWC2::Layer>& layer) const {
612 if (!isValidDisplay(displayId)) {
613 ALOGE("getLayerReleaseFence: Invalid display");
614 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700615 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800616 auto displayFences = mDisplayData[displayId].releaseFences;
617 if (displayFences.count(layer) == 0) {
618 ALOGV("getLayerReleaseFence: Release fence not found");
619 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700620 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800621 return displayFences[layer];
Riley Andrews03414a12014-07-01 14:22:59 -0700622}
623
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800624status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800625 ATRACE_CALL();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700626
Dan Stoza9e56aa02015-11-02 13:00:03 -0800627 if (!isValidDisplay(displayId)) {
628 return BAD_INDEX;
Mathias Agopianc3973602012-08-31 17:51:25 -0700629 }
Pablo Ceballosd814cf22015-09-11 14:37:39 -0700630
Dan Stoza9e56aa02015-11-02 13:00:03 -0800631 auto& displayData = mDisplayData[displayId];
632 auto& hwcDisplay = displayData.hwcDisplay;
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800633 auto error = hwcDisplay->present(&displayData.lastPresentFence);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800634 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800635 ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)",
636 displayId, to_string(error).c_str(), static_cast<int32_t>(error));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800637 return UNKNOWN_ERROR;
638 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700639
Dan Stoza9e56aa02015-11-02 13:00:03 -0800640 std::unordered_map<std::shared_ptr<HWC2::Layer>, sp<Fence>> releaseFences;
641 error = hwcDisplay->getReleaseFences(&releaseFences);
642 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800643 ALOGE("presentAndGetReleaseFences: Failed to get release fences "
644 "for display %d: %s (%d)",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800645 displayId, to_string(error).c_str(),
646 static_cast<int32_t>(error));
647 return UNKNOWN_ERROR;
Mathias Agopianf4358632012-08-22 17:16:19 -0700648 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800649
650 displayData.releaseFences = std::move(releaseFences);
651
652 return NO_ERROR;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700653}
654
Dan Stoza9e56aa02015-11-02 13:00:03 -0800655status_t HWComposer::setPowerMode(int32_t displayId, int32_t intMode) {
656 ALOGV("setPowerMode(%d, %d)", displayId, intMode);
657 if (!isValidDisplay(displayId)) {
658 ALOGE("setPowerMode: Bad display");
659 return BAD_INDEX;
660 }
661 if (displayId >= VIRTUAL_DISPLAY_ID_BASE) {
662 ALOGE("setPowerMode: Virtual display %d passed in, returning",
663 displayId);
664 return BAD_INDEX;
665 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700666
Dan Stoza9e56aa02015-11-02 13:00:03 -0800667 auto mode = static_cast<HWC2::PowerMode>(intMode);
668 if (mode == HWC2::PowerMode::Off) {
669 setVsyncEnabled(displayId, HWC2::Vsync::Disable);
670 }
671
672 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
673 switch (mode) {
674 case HWC2::PowerMode::Off:
675 case HWC2::PowerMode::On:
676 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
677 {
678 auto error = hwcDisplay->setPowerMode(mode);
679 if (error != HWC2::Error::None) {
680 ALOGE("setPowerMode: Unable to set power mode %s for "
681 "display %d: %s (%d)", to_string(mode).c_str(),
682 displayId, to_string(error).c_str(),
683 static_cast<int32_t>(error));
Mathias Agopianda27af92012-09-13 18:17:13 -0700684 }
685 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800686 break;
687 case HWC2::PowerMode::Doze:
688 case HWC2::PowerMode::DozeSuspend:
689 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
690 {
691 bool supportsDoze = false;
692 auto error = hwcDisplay->supportsDoze(&supportsDoze);
693 if (error != HWC2::Error::None) {
694 ALOGE("setPowerMode: Unable to query doze support for "
695 "display %d: %s (%d)", displayId,
696 to_string(error).c_str(),
697 static_cast<int32_t>(error));
698 }
699 if (!supportsDoze) {
700 mode = HWC2::PowerMode::On;
701 }
702
703 error = hwcDisplay->setPowerMode(mode);
704 if (error != HWC2::Error::None) {
705 ALOGE("setPowerMode: Unable to set power mode %s for "
706 "display %d: %s (%d)", to_string(mode).c_str(),
707 displayId, to_string(error).c_str(),
708 static_cast<int32_t>(error));
709 }
710 }
711 break;
712 default:
713 ALOGV("setPowerMode: Not calling HWC");
714 break;
Mathias Agopianda27af92012-09-13 18:17:13 -0700715 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800716
717 return NO_ERROR;
718}
719
720status_t HWComposer::setActiveConfig(int32_t displayId, size_t configId) {
721 if (!isValidDisplay(displayId)) {
722 ALOGE("setActiveConfig: Display %d is not valid", displayId);
723 return BAD_INDEX;
724 }
725
726 auto& displayData = mDisplayData[displayId];
727 if (displayData.configMap.count(configId) == 0) {
728 ALOGE("setActiveConfig: Invalid config %zd", configId);
729 return BAD_INDEX;
730 }
731
732 auto error = displayData.hwcDisplay->setActiveConfig(
733 displayData.configMap[configId]);
734 if (error != HWC2::Error::None) {
735 ALOGE("setActiveConfig: Failed to set config %zu on display %d: "
736 "%s (%d)", configId, displayId, to_string(error).c_str(),
737 static_cast<int32_t>(error));
738 return UNKNOWN_ERROR;
739 }
740
741 return NO_ERROR;
742}
743
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700744status_t HWComposer::setColorTransform(int32_t displayId,
745 const mat4& transform) {
746 if (!isValidDisplay(displayId)) {
747 ALOGE("setColorTransform: Display %d is not valid", displayId);
748 return BAD_INDEX;
749 }
750
751 auto& displayData = mDisplayData[displayId];
752 bool isIdentity = transform == mat4();
753 auto error = displayData.hwcDisplay->setColorTransform(transform,
754 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY :
755 HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX);
756 if (error != HWC2::Error::None) {
757 ALOGE("setColorTransform: Failed to set transform on display %d: "
758 "%s (%d)", displayId, to_string(error).c_str(),
759 static_cast<int32_t>(error));
760 return UNKNOWN_ERROR;
761 }
762
763 return NO_ERROR;
764}
765
Dan Stoza9e56aa02015-11-02 13:00:03 -0800766void HWComposer::disconnectDisplay(int displayId) {
767 LOG_ALWAYS_FATAL_IF(displayId < 0);
768 auto& displayData = mDisplayData[displayId];
769
770 auto displayType = HWC2::DisplayType::Invalid;
771 auto error = displayData.hwcDisplay->getType(&displayType);
772 if (error != HWC2::Error::None) {
773 ALOGE("disconnectDisplay: Failed to determine type of display %d",
774 displayId);
775 return;
776 }
777
778 // If this was a virtual display, add its slot back for reuse by future
779 // virtual displays
780 if (displayType == HWC2::DisplayType::Virtual) {
781 mFreeDisplaySlots.insert(displayId);
782 ++mRemainingHwcVirtualDisplays;
783 }
784
785 auto hwcId = displayData.hwcDisplay->getId();
786 mHwcDisplaySlots.erase(hwcId);
787 displayData.reset();
788}
789
790status_t HWComposer::setOutputBuffer(int32_t displayId,
791 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) {
792 if (!isValidDisplay(displayId)) {
793 ALOGE("setOutputBuffer: Display %d is not valid", displayId);
794 return BAD_INDEX;
795 }
796
797 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
798 auto displayType = HWC2::DisplayType::Invalid;
799 auto error = hwcDisplay->getType(&displayType);
800 if (error != HWC2::Error::None) {
801 ALOGE("setOutputBuffer: Failed to determine type of display %d",
802 displayId);
803 return NAME_NOT_FOUND;
804 }
805
806 if (displayType != HWC2::DisplayType::Virtual) {
807 ALOGE("setOutputBuffer: Display %d is not virtual", displayId);
808 return INVALID_OPERATION;
809 }
810
811 error = hwcDisplay->setOutputBuffer(buffer, acquireFence);
812 if (error != HWC2::Error::None) {
813 ALOGE("setOutputBuffer: Failed to set buffer on display %d: %s (%d)",
814 displayId, to_string(error).c_str(),
815 static_cast<int32_t>(error));
816 return UNKNOWN_ERROR;
817 }
818
819 return NO_ERROR;
820}
821
822void HWComposer::clearReleaseFences(int32_t displayId) {
823 if (!isValidDisplay(displayId)) {
824 ALOGE("clearReleaseFences: Display %d is not valid", displayId);
825 return;
826 }
827 mDisplayData[displayId].releaseFences.clear();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700828}
829
Dan Stozac4f471e2016-03-24 09:31:08 -0700830std::unique_ptr<HdrCapabilities> HWComposer::getHdrCapabilities(
831 int32_t displayId) {
832 if (!isValidDisplay(displayId)) {
833 ALOGE("getHdrCapabilities: Display %d is not valid", displayId);
834 return nullptr;
835 }
836
837 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
838 std::unique_ptr<HdrCapabilities> capabilities;
839 auto error = hwcDisplay->getHdrCapabilities(&capabilities);
840 if (error != HWC2::Error::None) {
841 ALOGE("getOutputCapabilities: Failed to get capabilities on display %d:"
842 " %s (%d)", displayId, to_string(error).c_str(),
843 static_cast<int32_t>(error));
844 return nullptr;
845 }
846
847 return capabilities;
848}
849
Andy McFadden4df87bd2014-04-21 18:08:54 -0700850// Converts a PixelFormat to a human-readable string. Max 11 chars.
851// (Could use a table of prefab String8 objects.)
Dan Stoza9e56aa02015-11-02 13:00:03 -0800852/*
Andy McFadden4df87bd2014-04-21 18:08:54 -0700853static String8 getFormatStr(PixelFormat format) {
854 switch (format) {
855 case PIXEL_FORMAT_RGBA_8888: return String8("RGBA_8888");
856 case PIXEL_FORMAT_RGBX_8888: return String8("RGBx_8888");
857 case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
858 case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
859 case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
Andy McFaddenf0058ca2014-05-20 13:28:50 -0700860 case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
861 return String8("ImplDef");
Andy McFadden4df87bd2014-04-21 18:08:54 -0700862 default:
863 String8 result;
864 result.appendFormat("? %08x", format);
865 return result;
866 }
867}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800868*/
Andy McFadden4df87bd2014-04-21 18:08:54 -0700869
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800870bool HWComposer::isUsingVrComposer() const {
871#ifdef BYPASS_IHWC
872 return false;
873#else
874 return getComposer()->isUsingVrComposer();
875#endif
876}
877
Mathias Agopian74d211a2013-04-22 16:55:35 +0200878void HWComposer::dump(String8& result) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800879 // TODO: In order to provide a dump equivalent to HWC1, we need to shadow
880 // all the state going into the layers. This is probably better done in
881 // Layer itself, but it's going to take a bit of work to get there.
882 result.append(mHwcDevice->dump().c_str());
Mathias Agopian83727852010-09-23 18:13:21 -0700883}
884
Mathias Agopiana350ff92010-08-10 17:14:02 -0700885// ---------------------------------------------------------------------------
Mathias Agopian2965b262012-04-08 15:13:32 -0700886
Jesse Halla9a1b002013-02-27 16:39:25 -0800887HWComposer::DisplayData::DisplayData()
Dan Stoza9e56aa02015-11-02 13:00:03 -0800888 : hasClientComposition(false),
889 hasDeviceComposition(false),
890 hwcDisplay(),
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800891 lastPresentFence(Fence::NO_FENCE),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800892 outbufHandle(nullptr),
893 outbufAcquireFence(Fence::NO_FENCE),
894 vsyncEnabled(HWC2::Vsync::Disable) {
895 ALOGV("Created new DisplayData");
896}
Jesse Halla9a1b002013-02-27 16:39:25 -0800897
898HWComposer::DisplayData::~DisplayData() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800899}
900
901void HWComposer::DisplayData::reset() {
902 ALOGV("DisplayData reset");
903 *this = DisplayData();
Jesse Halla9a1b002013-02-27 16:39:25 -0800904}
905
Mathias Agopian2965b262012-04-08 15:13:32 -0700906// ---------------------------------------------------------------------------
Mathias Agopiana350ff92010-08-10 17:14:02 -0700907}; // namespace android