blob: a16c040bc2ea810b84fefbc9e151af647abd6d71 [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
Kalle Raitaa099a242017-01-11 11:17:29 -080062HWComposer::HWComposer(const std::string& serviceName)
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(),
Dan Stoza9e56aa02015-11-02 13:00:03 -080068 mVSyncCounts(),
Chia-I Wu15b27e02017-05-11 16:06:07 -070069 mRemainingHwcVirtualDisplays(0)
Mathias Agopiana350ff92010-08-10 17:14:02 -070070{
Mathias Agopianbef42c52013-08-21 17:45:46 -070071 for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) {
72 mLastHwVSync[i] = 0;
73 mVSyncCounts[i] = 0;
74 }
75
Steven Thomasb02664d2017-07-26 18:48:28 -070076 mHwcDevice = std::make_unique<HWC2::Device>(serviceName);
77 mRemainingHwcVirtualDisplays = mHwcDevice->getMaxVirtualDisplayCount();
Mathias Agopiana350ff92010-08-10 17:14:02 -070078}
79
Dan Stoza9e56aa02015-11-02 13:00:03 -080080HWComposer::~HWComposer() {}
81
Steven Thomasb02664d2017-07-26 18:48:28 -070082void HWComposer::registerCallback(HWC2::ComposerCallback* callback,
83 int32_t sequenceId) {
84 mHwcDevice->registerCallback(callback, sequenceId);
Dan Stoza9e56aa02015-11-02 13:00:03 -080085}
86
Dan Stoza9f26a9c2016-06-22 14:51:09 -070087bool HWComposer::hasCapability(HWC2::Capability capability) const
88{
89 return mHwcDevice->getCapabilities().count(capability) > 0;
90}
91
Dan Stoza9e56aa02015-11-02 13:00:03 -080092bool HWComposer::isValidDisplay(int32_t displayId) const {
93 return static_cast<size_t>(displayId) < mDisplayData.size() &&
94 mDisplayData[displayId].hwcDisplay;
95}
96
97void HWComposer::validateChange(HWC2::Composition from, HWC2::Composition to) {
98 bool valid = true;
99 switch (from) {
100 case HWC2::Composition::Client:
101 valid = false;
102 break;
103 case HWC2::Composition::Device:
104 case HWC2::Composition::SolidColor:
105 valid = (to == HWC2::Composition::Client);
106 break;
107 case HWC2::Composition::Cursor:
108 case HWC2::Composition::Sideband:
109 valid = (to == HWC2::Composition::Client ||
110 to == HWC2::Composition::Device);
111 break;
112 default:
113 break;
114 }
115
116 if (!valid) {
117 ALOGE("Invalid layer type change: %s --> %s", to_string(from).c_str(),
118 to_string(to).c_str());
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700119 }
120}
121
Steven Thomasb02664d2017-07-26 18:48:28 -0700122void HWComposer::onHotplug(hwc2_display_t displayId,
123 HWC2::Connection connection) {
124 ALOGV("hotplug: %" PRIu64 ", %s", displayId,
125 to_string(connection).c_str());
126 mHwcDevice->onHotplug(displayId, connection);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800127 if (!mDisplayData[0].hwcDisplay) {
Steven Thomasb02664d2017-07-26 18:48:28 -0700128 ALOGE_IF(connection != HWC2::Connection::Connected, "Assumed primary"
Dan Stoza9e56aa02015-11-02 13:00:03 -0800129 " display would be connected");
Steven Thomasb02664d2017-07-26 18:48:28 -0700130 mDisplayData[0].hwcDisplay = mHwcDevice->getDisplayById(displayId);
131 mHwcDisplaySlots[displayId] = 0;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800132 } else {
133 // Disconnect is handled through HWComposer::disconnectDisplay via
134 // SurfaceFlinger's onHotplugReceived callback handling
Steven Thomasb02664d2017-07-26 18:48:28 -0700135 if (connection == HWC2::Connection::Connected) {
136 mDisplayData[1].hwcDisplay = mHwcDevice->getDisplayById(displayId);
137 mHwcDisplaySlots[displayId] = 1;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800138 }
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700139 }
Andy McFaddenb0d1dd32012-09-10 14:08:09 -0700140}
141
Steven Thomasb02664d2017-07-26 18:48:28 -0700142bool HWComposer::onVsync(hwc2_display_t displayId, int64_t timestamp,
143 int32_t* outDisplay) {
144 auto display = mHwcDevice->getDisplayById(displayId);
145 if (!display) {
146 ALOGE("onVsync Failed to find display %" PRIu64, displayId);
147 return false;
148 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800149 auto displayType = HWC2::DisplayType::Invalid;
150 auto error = display->getType(&displayType);
151 if (error != HWC2::Error::None) {
Steven Thomasb02664d2017-07-26 18:48:28 -0700152 ALOGE("onVsync: Failed to determine type of display %" PRIu64,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800153 display->getId());
Steven Thomasb02664d2017-07-26 18:48:28 -0700154 return false;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700155 }
Jesse Hall1bd20e02012-08-29 10:47:52 -0700156
Dan Stoza9e56aa02015-11-02 13:00:03 -0800157 if (displayType == HWC2::DisplayType::Virtual) {
158 ALOGE("Virtual display %" PRIu64 " passed to vsync callback",
159 display->getId());
Steven Thomasb02664d2017-07-26 18:48:28 -0700160 return false;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700161 }
162
Dan Stoza9e56aa02015-11-02 13:00:03 -0800163 if (mHwcDisplaySlots.count(display->getId()) == 0) {
164 ALOGE("Unknown physical display %" PRIu64 " passed to vsync callback",
165 display->getId());
Steven Thomasb02664d2017-07-26 18:48:28 -0700166 return false;
Jesse Hall1bd20e02012-08-29 10:47:52 -0700167 }
168
Dan Stoza9e56aa02015-11-02 13:00:03 -0800169 int32_t disp = mHwcDisplaySlots[display->getId()];
170 {
171 Mutex::Autolock _l(mLock);
Jesse Hall1bd20e02012-08-29 10:47:52 -0700172
Dan Stoza9e56aa02015-11-02 13:00:03 -0800173 // There have been reports of HWCs that signal several vsync events
174 // with the same timestamp when turning the display off and on. This
175 // is a bug in the HWC implementation, but filter the extra events
176 // out here so they don't cause havoc downstream.
177 if (timestamp == mLastHwVSync[disp]) {
178 ALOGW("Ignoring duplicate VSYNC event from HWC (t=%" PRId64 ")",
179 timestamp);
Steven Thomasb02664d2017-07-26 18:48:28 -0700180 return false;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800181 }
182
183 mLastHwVSync[disp] = timestamp;
Jesse Hall1c569c42013-04-05 13:44:52 -0700184 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800185
Steven Thomasb02664d2017-07-26 18:48:28 -0700186 if (outDisplay) {
187 *outDisplay = disp;
188 }
189
Dan Stoza9e56aa02015-11-02 13:00:03 -0800190 char tag[16];
191 snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp);
192 ATRACE_INT(tag, ++mVSyncCounts[disp] & 1);
193
Steven Thomasb02664d2017-07-26 18:48:28 -0700194 return true;
Jesse Hall1c569c42013-04-05 13:44:52 -0700195}
196
Dan Stoza9e56aa02015-11-02 13:00:03 -0800197status_t HWComposer::allocateVirtualDisplay(uint32_t width, uint32_t height,
Dan Stoza5cf424b2016-05-20 14:02:39 -0700198 android_pixel_format_t* format, int32_t *outId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800199 if (mRemainingHwcVirtualDisplays == 0) {
200 ALOGE("allocateVirtualDisplay: No remaining virtual displays");
Mathias Agopiane60b0682012-08-21 23:34:09 -0700201 return NO_MEMORY;
202 }
Mathias Agopiane60b0682012-08-21 23:34:09 -0700203
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800204 if (SurfaceFlinger::maxVirtualDisplaySize != 0 &&
205 (width > SurfaceFlinger::maxVirtualDisplaySize ||
206 height > SurfaceFlinger::maxVirtualDisplaySize)) {
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800207 ALOGE("createVirtualDisplay: Can't create a virtual display with"
Fabien Sanglardc8e387e2017-03-10 10:30:28 -0800208 " a dimension > %" PRIu64 " (tried %u x %u)",
209 SurfaceFlinger::maxVirtualDisplaySize, width, height);
Fabien Sanglarde29055f2017-03-08 11:36:46 -0800210 return INVALID_OPERATION;
211 }
212
Steven Thomasb02664d2017-07-26 18:48:28 -0700213 HWC2::Display* display;
Dan Stoza5cf424b2016-05-20 14:02:39 -0700214 auto error = mHwcDevice->createVirtualDisplay(width, height, format,
215 &display);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800216 if (error != HWC2::Error::None) {
217 ALOGE("allocateVirtualDisplay: Failed to create HWC virtual display");
218 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700219 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800220
221 size_t displaySlot = 0;
222 if (!mFreeDisplaySlots.empty()) {
223 displaySlot = *mFreeDisplaySlots.begin();
224 mFreeDisplaySlots.erase(displaySlot);
225 } else if (mDisplayData.size() < INT32_MAX) {
226 // Don't bother allocating a slot larger than we can return
227 displaySlot = mDisplayData.size();
228 mDisplayData.resize(displaySlot + 1);
229 } else {
230 ALOGE("allocateVirtualDisplay: Unable to allocate a display slot");
231 return NO_MEMORY;
Mathias Agopiane60b0682012-08-21 23:34:09 -0700232 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800233
234 mDisplayData[displaySlot].hwcDisplay = display;
235
236 --mRemainingHwcVirtualDisplays;
237 *outId = static_cast<int32_t>(displaySlot);
238
Mathias Agopiane60b0682012-08-21 23:34:09 -0700239 return NO_ERROR;
240}
241
Steven Thomasb02664d2017-07-26 18:48:28 -0700242HWC2::Layer* HWComposer::createLayer(int32_t displayId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800243 if (!isValidDisplay(displayId)) {
244 ALOGE("Failed to create layer on invalid display %d", displayId);
245 return nullptr;
246 }
247 auto display = mDisplayData[displayId].hwcDisplay;
Steven Thomasb02664d2017-07-26 18:48:28 -0700248 HWC2::Layer* layer;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800249 auto error = display->createLayer(&layer);
250 if (error != HWC2::Error::None) {
251 ALOGE("Failed to create layer on display %d: %s (%d)", displayId,
252 to_string(error).c_str(), static_cast<int32_t>(error));
253 return nullptr;
254 }
255 return layer;
256}
257
Steven Thomasb02664d2017-07-26 18:48:28 -0700258void HWComposer::destroyLayer(int32_t displayId, HWC2::Layer* layer) {
259 if (!isValidDisplay(displayId)) {
260 ALOGE("Failed to destroy layer on invalid display %d", displayId);
261 return;
262 }
263 auto display = mDisplayData[displayId].hwcDisplay;
264 auto error = display->destroyLayer(layer);
265 if (error != HWC2::Error::None) {
266 ALOGE("Failed to destroy layer on display %d: %s (%d)", displayId,
267 to_string(error).c_str(), static_cast<int32_t>(error));
268 }
269}
270
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800271nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const {
Mathias Agopiand3ee2312012-08-02 14:01:42 -0700272 // this returns the last refresh timestamp.
273 // if the last one is not available, we estimate it based on
274 // the refresh period and whatever closest timestamp we have.
275 Mutex::Autolock _l(mLock);
276 nsecs_t now = systemTime(CLOCK_MONOTONIC);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800277 auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod();
278 return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod);
Mathias Agopian3eb38cb2012-04-03 22:09:52 -0700279}
280
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800281bool HWComposer::isConnected(int32_t displayId) const {
282 if (!isValidDisplay(displayId)) {
283 ALOGE("isConnected: Attempted to access invalid display %d", displayId);
Mathias Agopiane60b0682012-08-21 23:34:09 -0700284 return false;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800285 }
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800286 return mDisplayData[displayId].hwcDisplay->isConnected();
Mathias Agopian9c6e2972011-09-20 17:21:56 -0700287}
288
Dan Stoza9e56aa02015-11-02 13:00:03 -0800289std::vector<std::shared_ptr<const HWC2::Display::Config>>
290 HWComposer::getConfigs(int32_t displayId) const {
291 if (!isValidDisplay(displayId)) {
292 ALOGE("getConfigs: Attempted to access invalid display %d", displayId);
293 return {};
294 }
295 auto& displayData = mDisplayData[displayId];
296 auto configs = mDisplayData[displayId].hwcDisplay->getConfigs();
297 if (displayData.configMap.empty()) {
298 for (size_t i = 0; i < configs.size(); ++i) {
299 displayData.configMap[i] = configs[i];
Mathias Agopianda27af92012-09-13 18:17:13 -0700300 }
301 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800302 return configs;
Mathias Agopianda27af92012-09-13 18:17:13 -0700303}
304
Dan Stoza9e56aa02015-11-02 13:00:03 -0800305std::shared_ptr<const HWC2::Display::Config>
306 HWComposer::getActiveConfig(int32_t displayId) const {
307 if (!isValidDisplay(displayId)) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800308 ALOGV("getActiveConfigs: Attempted to access invalid display %d",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800309 displayId);
310 return nullptr;
Mathias Agopian58959342010-10-07 14:57:04 -0700311 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800312 std::shared_ptr<const HWC2::Display::Config> config;
313 auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config);
314 if (error == HWC2::Error::BadConfig) {
Fabien Sanglardb7432cc2016-11-11 09:40:27 -0800315 ALOGE("getActiveConfig: No config active, returning null");
Dan Stoza9e56aa02015-11-02 13:00:03 -0800316 return nullptr;
317 } else if (error != HWC2::Error::None) {
318 ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId,
319 to_string(error).c_str(), static_cast<int32_t>(error));
320 return nullptr;
321 } else if (!config) {
322 ALOGE("getActiveConfig returned an unknown config for display %d",
323 displayId);
324 return nullptr;
325 }
326
327 return config;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700328}
329
Michael Wright28f24d02016-07-12 13:30:53 -0700330std::vector<android_color_mode_t> HWComposer::getColorModes(int32_t displayId) const {
331 std::vector<android_color_mode_t> modes;
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600332
333 if (!isValidDisplay(displayId)) {
334 ALOGE("getColorModes: Attempted to access invalid display %d",
335 displayId);
336 return modes;
337 }
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600338
Steven Thomasb02664d2017-07-26 18:48:28 -0700339 auto error = mDisplayData[displayId].hwcDisplay->getColorModes(&modes);
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600340 if (error != HWC2::Error::None) {
341 ALOGE("getColorModes failed for display %d: %s (%d)", displayId,
342 to_string(error).c_str(), static_cast<int32_t>(error));
Michael Wright28f24d02016-07-12 13:30:53 -0700343 return std::vector<android_color_mode_t>();
Courtney Goeltzenleuchterfad9d8c2016-06-23 11:49:50 -0600344 }
345
346 return modes;
347}
348
Michael Wright28f24d02016-07-12 13:30:53 -0700349status_t HWComposer::setActiveColorMode(int32_t displayId, android_color_mode_t mode) {
350 if (!isValidDisplay(displayId)) {
351 ALOGE("setActiveColorMode: Display %d is not valid", displayId);
352 return BAD_INDEX;
353 }
354
355 auto& displayData = mDisplayData[displayId];
356 auto error = displayData.hwcDisplay->setColorMode(mode);
357 if (error != HWC2::Error::None) {
358 ALOGE("setActiveConfig: Failed to set color mode %d on display %d: "
359 "%s (%d)", mode, displayId, to_string(error).c_str(),
360 static_cast<int32_t>(error));
361 return UNKNOWN_ERROR;
362 }
363
364 return NO_ERROR;
365}
366
367
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800368void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) {
369 if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) {
370 ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800371 return;
372 }
373
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800374 if (!isValidDisplay(displayId)) {
375 ALOGE("setVsyncEnabled: Attempted to access invalid display %d",
376 displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800377 return;
378 }
379
380 // NOTE: we use our own internal lock here because we have to call
381 // into the HWC with the lock held, and we want to make sure
382 // that even if HWC blocks (which it shouldn't), it won't
383 // affect other threads.
384 Mutex::Autolock _l(mVsyncLock);
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800385 auto& displayData = mDisplayData[displayId];
Dan Stoza9e56aa02015-11-02 13:00:03 -0800386 if (enabled != displayData.vsyncEnabled) {
387 ATRACE_CALL();
388 auto error = displayData.hwcDisplay->setVsyncEnabled(enabled);
389 if (error == HWC2::Error::None) {
390 displayData.vsyncEnabled = enabled;
391
392 char tag[16];
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800393 snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800394 ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0);
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700395 } else {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800396 ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64
Fabien Sanglarddf0b7052016-11-30 15:51:53 -0800397 ": %s (%d)", to_string(enabled).c_str(), displayId,
398 mDisplayData[displayId].hwcDisplay->getId(),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800399 to_string(error).c_str(), static_cast<int32_t>(error));
Prashant Malani2c9b11f2014-05-25 01:36:31 -0700400 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700401 }
Colin Cross10fbdb62012-07-12 17:56:34 -0700402}
403
Chia-I Wu06d63de2017-01-04 14:58:51 +0800404status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot,
Dan Stoza9e56aa02015-11-02 13:00:03 -0800405 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target,
406 android_dataspace_t dataspace) {
407 if (!isValidDisplay(displayId)) {
Jesse Hall851cfe82013-03-20 13:44:00 -0700408 return BAD_INDEX;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800409 }
Jesse Hall851cfe82013-03-20 13:44:00 -0700410
Dan Stoza9e56aa02015-11-02 13:00:03 -0800411 ALOGV("setClientTarget for display %d", displayId);
412 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
Daniel Nicoara1f42e3a2017-04-10 13:27:32 -0400413 auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800414 if (error != HWC2::Error::None) {
415 ALOGE("Failed to set client target for display %d: %s (%d)", displayId,
416 to_string(error).c_str(), static_cast<int32_t>(error));
417 return BAD_VALUE;
418 }
419
Jesse Hall851cfe82013-03-20 13:44:00 -0700420 return NO_ERROR;
421}
422
Dan Stoza9e56aa02015-11-02 13:00:03 -0800423status_t HWComposer::prepare(DisplayDevice& displayDevice) {
424 ATRACE_CALL();
425
426 Mutex::Autolock _l(mDisplayLock);
427 auto displayId = displayDevice.getHwcDisplayId();
Dan Stozaec0f7172016-07-21 11:09:40 -0700428 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
429 ALOGV("Skipping HWComposer prepare for non-HWC display");
430 return NO_ERROR;
431 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800432 if (!isValidDisplay(displayId)) {
433 return BAD_INDEX;
434 }
435
436 auto& displayData = mDisplayData[displayId];
437 auto& hwcDisplay = displayData.hwcDisplay;
438 if (!hwcDisplay->isConnected()) {
439 return NO_ERROR;
440 }
441
442 uint32_t numTypes = 0;
443 uint32_t numRequests = 0;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700444
445 HWC2::Error error = HWC2::Error::None;
446
Chia-I Wu41b98d42017-12-11 11:04:36 -0800447 // First try to skip validate altogether when there is no client
448 // composition. When there is client composition, since we haven't
449 // rendered to the client target yet, we should not attempt to skip
450 // validate.
451 //
452 // displayData.hasClientComposition hasn't been updated for this frame.
453 // The check below is incorrect. We actually rely on HWC here to fall
454 // back to validate when there is any client layer.
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700455 displayData.validateWasSkipped = false;
Chia-I Wu41b98d42017-12-11 11:04:36 -0800456 if (!displayData.hasClientComposition) {
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700457 sp<android::Fence> outPresentFence;
458 uint32_t state = UINT32_MAX;
459 error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state);
460 if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) {
461 ALOGV("skipValidate: Failed to Present or Validate");
462 return UNKNOWN_ERROR;
463 }
464 if (state == 1) { //Present Succeeded.
Steven Thomasb02664d2017-07-26 18:48:28 -0700465 std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700466 error = hwcDisplay->getReleaseFences(&releaseFences);
467 displayData.releaseFences = std::move(releaseFences);
468 displayData.lastPresentFence = outPresentFence;
469 displayData.validateWasSkipped = true;
470 displayData.presentError = error;
471 return NO_ERROR;
472 }
473 // Present failed but Validate ran.
474 } else {
475 error = hwcDisplay->validate(&numTypes, &numRequests);
476 }
477 ALOGV("SkipValidate failed, Falling back to SLOW validate/present");
Dan Stoza9e56aa02015-11-02 13:00:03 -0800478 if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) {
479 ALOGE("prepare: validate failed for display %d: %s (%d)", displayId,
480 to_string(error).c_str(), static_cast<int32_t>(error));
481 return BAD_INDEX;
482 }
483
Steven Thomasb02664d2017-07-26 18:48:28 -0700484 std::unordered_map<HWC2::Layer*, HWC2::Composition> changedTypes;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800485 changedTypes.reserve(numTypes);
486 error = hwcDisplay->getChangedCompositionTypes(&changedTypes);
487 if (error != HWC2::Error::None) {
488 ALOGE("prepare: getChangedCompositionTypes failed on display %d: "
489 "%s (%d)", displayId, to_string(error).c_str(),
490 static_cast<int32_t>(error));
491 return BAD_INDEX;
492 }
493
494
495 displayData.displayRequests = static_cast<HWC2::DisplayRequest>(0);
Steven Thomasb02664d2017-07-26 18:48:28 -0700496 std::unordered_map<HWC2::Layer*, HWC2::LayerRequest> layerRequests;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800497 layerRequests.reserve(numRequests);
498 error = hwcDisplay->getRequests(&displayData.displayRequests,
499 &layerRequests);
500 if (error != HWC2::Error::None) {
501 ALOGE("prepare: getRequests failed on display %d: %s (%d)", displayId,
502 to_string(error).c_str(), static_cast<int32_t>(error));
503 return BAD_INDEX;
504 }
505
506 displayData.hasClientComposition = false;
507 displayData.hasDeviceComposition = false;
508 for (auto& layer : displayDevice.getVisibleLayersSortedByZ()) {
509 auto hwcLayer = layer->getHwcLayer(displayId);
510
511 if (changedTypes.count(hwcLayer) != 0) {
512 // We pass false so we only update our state and don't call back
513 // into the HWC device
514 validateChange(layer->getCompositionType(displayId),
515 changedTypes[hwcLayer]);
516 layer->setCompositionType(displayId, changedTypes[hwcLayer], false);
517 }
518
519 switch (layer->getCompositionType(displayId)) {
520 case HWC2::Composition::Client:
521 displayData.hasClientComposition = true;
522 break;
523 case HWC2::Composition::Device:
524 case HWC2::Composition::SolidColor:
525 case HWC2::Composition::Cursor:
526 case HWC2::Composition::Sideband:
527 displayData.hasDeviceComposition = true;
528 break;
529 default:
530 break;
531 }
532
533 if (layerRequests.count(hwcLayer) != 0 &&
534 layerRequests[hwcLayer] ==
535 HWC2::LayerRequest::ClearClientTarget) {
536 layer->setClearClientTarget(displayId, true);
537 } else {
538 if (layerRequests.count(hwcLayer) != 0) {
539 ALOGE("prepare: Unknown layer request: %s",
540 to_string(layerRequests[hwcLayer]).c_str());
541 }
542 layer->setClearClientTarget(displayId, false);
543 }
544 }
545
546 error = hwcDisplay->acceptChanges();
547 if (error != HWC2::Error::None) {
548 ALOGE("prepare: acceptChanges failed: %s", to_string(error).c_str());
549 return BAD_INDEX;
550 }
551
552 return NO_ERROR;
553}
554
555bool HWComposer::hasDeviceComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700556 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
557 // Displays without a corresponding HWC display are never composed by
558 // the device
559 return false;
560 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800561 if (!isValidDisplay(displayId)) {
562 ALOGE("hasDeviceComposition: Invalid display %d", displayId);
563 return false;
564 }
565 return mDisplayData[displayId].hasDeviceComposition;
566}
567
568bool HWComposer::hasClientComposition(int32_t displayId) const {
Dan Stozaec0f7172016-07-21 11:09:40 -0700569 if (displayId == DisplayDevice::DISPLAY_ID_INVALID) {
570 // Displays without a corresponding HWC display are always composed by
571 // the client
572 return true;
573 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800574 if (!isValidDisplay(displayId)) {
575 ALOGE("hasClientComposition: Invalid display %d", displayId);
576 return true;
577 }
578 return mDisplayData[displayId].hasClientComposition;
579}
580
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800581sp<Fence> HWComposer::getPresentFence(int32_t displayId) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800582 if (!isValidDisplay(displayId)) {
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800583 ALOGE("getPresentFence failed for invalid display %d", displayId);
Jesse Hall851cfe82013-03-20 13:44:00 -0700584 return Fence::NO_FENCE;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800585 }
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800586 return mDisplayData[displayId].lastPresentFence;
Jesse Hall851cfe82013-03-20 13:44:00 -0700587}
588
Dan Stoza9e56aa02015-11-02 13:00:03 -0800589sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId,
Steven Thomasb02664d2017-07-26 18:48:28 -0700590 HWC2::Layer* layer) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800591 if (!isValidDisplay(displayId)) {
592 ALOGE("getLayerReleaseFence: Invalid display");
593 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700594 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800595 auto displayFences = mDisplayData[displayId].releaseFences;
596 if (displayFences.count(layer) == 0) {
597 ALOGV("getLayerReleaseFence: Release fence not found");
598 return Fence::NO_FENCE;
Riley Andrews03414a12014-07-01 14:22:59 -0700599 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800600 return displayFences[layer];
Riley Andrews03414a12014-07-01 14:22:59 -0700601}
602
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800603status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800604 ATRACE_CALL();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700605
Dan Stoza9e56aa02015-11-02 13:00:03 -0800606 if (!isValidDisplay(displayId)) {
607 return BAD_INDEX;
Mathias Agopianc3973602012-08-31 17:51:25 -0700608 }
Pablo Ceballosd814cf22015-09-11 14:37:39 -0700609
Dan Stoza9e56aa02015-11-02 13:00:03 -0800610 auto& displayData = mDisplayData[displayId];
611 auto& hwcDisplay = displayData.hwcDisplay;
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700612
613 if (displayData.validateWasSkipped) {
Chia-I Wu0c6ce462017-06-22 10:48:28 -0700614 hwcDisplay->discardCommands();
Fabien Sanglard249c0ae2017-06-19 19:22:36 -0700615 auto error = displayData.presentError;
616 if (error != HWC2::Error::None) {
617 ALOGE("skipValidate: failed for display %d: %s (%d)",
618 displayId, to_string(error).c_str(), static_cast<int32_t>(error));
619 return UNKNOWN_ERROR;
620 }
621 return NO_ERROR;
622 }
623
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800624 auto error = hwcDisplay->present(&displayData.lastPresentFence);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800625 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800626 ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)",
627 displayId, to_string(error).c_str(), static_cast<int32_t>(error));
Dan Stoza9e56aa02015-11-02 13:00:03 -0800628 return UNKNOWN_ERROR;
629 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700630
Steven Thomasb02664d2017-07-26 18:48:28 -0700631 std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences;
Dan Stoza9e56aa02015-11-02 13:00:03 -0800632 error = hwcDisplay->getReleaseFences(&releaseFences);
633 if (error != HWC2::Error::None) {
Fabien Sanglarda87aa7b2016-11-30 16:27:22 -0800634 ALOGE("presentAndGetReleaseFences: Failed to get release fences "
635 "for display %d: %s (%d)",
Dan Stoza9e56aa02015-11-02 13:00:03 -0800636 displayId, to_string(error).c_str(),
637 static_cast<int32_t>(error));
638 return UNKNOWN_ERROR;
Mathias Agopianf4358632012-08-22 17:16:19 -0700639 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800640
641 displayData.releaseFences = std::move(releaseFences);
642
643 return NO_ERROR;
Mathias Agopiana350ff92010-08-10 17:14:02 -0700644}
645
Dan Stoza9e56aa02015-11-02 13:00:03 -0800646status_t HWComposer::setPowerMode(int32_t displayId, int32_t intMode) {
647 ALOGV("setPowerMode(%d, %d)", displayId, intMode);
648 if (!isValidDisplay(displayId)) {
649 ALOGE("setPowerMode: Bad display");
650 return BAD_INDEX;
651 }
652 if (displayId >= VIRTUAL_DISPLAY_ID_BASE) {
653 ALOGE("setPowerMode: Virtual display %d passed in, returning",
654 displayId);
655 return BAD_INDEX;
656 }
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700657
Dan Stoza9e56aa02015-11-02 13:00:03 -0800658 auto mode = static_cast<HWC2::PowerMode>(intMode);
659 if (mode == HWC2::PowerMode::Off) {
660 setVsyncEnabled(displayId, HWC2::Vsync::Disable);
661 }
662
663 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
664 switch (mode) {
665 case HWC2::PowerMode::Off:
666 case HWC2::PowerMode::On:
667 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
668 {
669 auto error = hwcDisplay->setPowerMode(mode);
670 if (error != HWC2::Error::None) {
671 ALOGE("setPowerMode: Unable to set power mode %s for "
672 "display %d: %s (%d)", to_string(mode).c_str(),
673 displayId, to_string(error).c_str(),
674 static_cast<int32_t>(error));
Mathias Agopianda27af92012-09-13 18:17:13 -0700675 }
676 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800677 break;
678 case HWC2::PowerMode::Doze:
679 case HWC2::PowerMode::DozeSuspend:
680 ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str());
681 {
682 bool supportsDoze = false;
683 auto error = hwcDisplay->supportsDoze(&supportsDoze);
684 if (error != HWC2::Error::None) {
685 ALOGE("setPowerMode: Unable to query doze support for "
686 "display %d: %s (%d)", displayId,
687 to_string(error).c_str(),
688 static_cast<int32_t>(error));
689 }
690 if (!supportsDoze) {
691 mode = HWC2::PowerMode::On;
692 }
693
694 error = hwcDisplay->setPowerMode(mode);
695 if (error != HWC2::Error::None) {
696 ALOGE("setPowerMode: Unable to set power mode %s for "
697 "display %d: %s (%d)", to_string(mode).c_str(),
698 displayId, to_string(error).c_str(),
699 static_cast<int32_t>(error));
700 }
701 }
702 break;
703 default:
704 ALOGV("setPowerMode: Not calling HWC");
705 break;
Mathias Agopianda27af92012-09-13 18:17:13 -0700706 }
Dan Stoza9e56aa02015-11-02 13:00:03 -0800707
708 return NO_ERROR;
709}
710
711status_t HWComposer::setActiveConfig(int32_t displayId, size_t configId) {
712 if (!isValidDisplay(displayId)) {
713 ALOGE("setActiveConfig: Display %d is not valid", displayId);
714 return BAD_INDEX;
715 }
716
717 auto& displayData = mDisplayData[displayId];
718 if (displayData.configMap.count(configId) == 0) {
719 ALOGE("setActiveConfig: Invalid config %zd", configId);
720 return BAD_INDEX;
721 }
722
723 auto error = displayData.hwcDisplay->setActiveConfig(
724 displayData.configMap[configId]);
725 if (error != HWC2::Error::None) {
726 ALOGE("setActiveConfig: Failed to set config %zu on display %d: "
727 "%s (%d)", configId, displayId, to_string(error).c_str(),
728 static_cast<int32_t>(error));
729 return UNKNOWN_ERROR;
730 }
731
732 return NO_ERROR;
733}
734
Dan Stoza9f26a9c2016-06-22 14:51:09 -0700735status_t HWComposer::setColorTransform(int32_t displayId,
736 const mat4& transform) {
737 if (!isValidDisplay(displayId)) {
738 ALOGE("setColorTransform: Display %d is not valid", displayId);
739 return BAD_INDEX;
740 }
741
742 auto& displayData = mDisplayData[displayId];
743 bool isIdentity = transform == mat4();
744 auto error = displayData.hwcDisplay->setColorTransform(transform,
745 isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY :
746 HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX);
747 if (error != HWC2::Error::None) {
748 ALOGE("setColorTransform: Failed to set transform on display %d: "
749 "%s (%d)", displayId, to_string(error).c_str(),
750 static_cast<int32_t>(error));
751 return UNKNOWN_ERROR;
752 }
753
754 return NO_ERROR;
755}
756
Dan Stoza9e56aa02015-11-02 13:00:03 -0800757void HWComposer::disconnectDisplay(int displayId) {
758 LOG_ALWAYS_FATAL_IF(displayId < 0);
759 auto& displayData = mDisplayData[displayId];
760
761 auto displayType = HWC2::DisplayType::Invalid;
762 auto error = displayData.hwcDisplay->getType(&displayType);
763 if (error != HWC2::Error::None) {
764 ALOGE("disconnectDisplay: Failed to determine type of display %d",
765 displayId);
766 return;
767 }
768
769 // If this was a virtual display, add its slot back for reuse by future
770 // virtual displays
771 if (displayType == HWC2::DisplayType::Virtual) {
772 mFreeDisplaySlots.insert(displayId);
773 ++mRemainingHwcVirtualDisplays;
774 }
775
776 auto hwcId = displayData.hwcDisplay->getId();
777 mHwcDisplaySlots.erase(hwcId);
778 displayData.reset();
Steven Thomasb02664d2017-07-26 18:48:28 -0700779
780 mHwcDevice->destroyDisplay(hwcId);
Dan Stoza9e56aa02015-11-02 13:00:03 -0800781}
782
783status_t HWComposer::setOutputBuffer(int32_t displayId,
784 const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) {
785 if (!isValidDisplay(displayId)) {
786 ALOGE("setOutputBuffer: Display %d is not valid", displayId);
787 return BAD_INDEX;
788 }
789
790 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
791 auto displayType = HWC2::DisplayType::Invalid;
792 auto error = hwcDisplay->getType(&displayType);
793 if (error != HWC2::Error::None) {
794 ALOGE("setOutputBuffer: Failed to determine type of display %d",
795 displayId);
796 return NAME_NOT_FOUND;
797 }
798
799 if (displayType != HWC2::DisplayType::Virtual) {
800 ALOGE("setOutputBuffer: Display %d is not virtual", displayId);
801 return INVALID_OPERATION;
802 }
803
804 error = hwcDisplay->setOutputBuffer(buffer, acquireFence);
805 if (error != HWC2::Error::None) {
806 ALOGE("setOutputBuffer: Failed to set buffer on display %d: %s (%d)",
807 displayId, to_string(error).c_str(),
808 static_cast<int32_t>(error));
809 return UNKNOWN_ERROR;
810 }
811
812 return NO_ERROR;
813}
814
815void HWComposer::clearReleaseFences(int32_t displayId) {
816 if (!isValidDisplay(displayId)) {
817 ALOGE("clearReleaseFences: Display %d is not valid", displayId);
818 return;
819 }
820 mDisplayData[displayId].releaseFences.clear();
Mathias Agopian3e8b8532012-05-13 20:42:01 -0700821}
822
Dan Stozac4f471e2016-03-24 09:31:08 -0700823std::unique_ptr<HdrCapabilities> HWComposer::getHdrCapabilities(
824 int32_t displayId) {
825 if (!isValidDisplay(displayId)) {
826 ALOGE("getHdrCapabilities: Display %d is not valid", displayId);
827 return nullptr;
828 }
829
830 auto& hwcDisplay = mDisplayData[displayId].hwcDisplay;
831 std::unique_ptr<HdrCapabilities> capabilities;
832 auto error = hwcDisplay->getHdrCapabilities(&capabilities);
833 if (error != HWC2::Error::None) {
834 ALOGE("getOutputCapabilities: Failed to get capabilities on display %d:"
835 " %s (%d)", displayId, to_string(error).c_str(),
836 static_cast<int32_t>(error));
837 return nullptr;
838 }
839
840 return capabilities;
841}
842
Andy McFadden4df87bd2014-04-21 18:08:54 -0700843// Converts a PixelFormat to a human-readable string. Max 11 chars.
844// (Could use a table of prefab String8 objects.)
Dan Stoza9e56aa02015-11-02 13:00:03 -0800845/*
Andy McFadden4df87bd2014-04-21 18:08:54 -0700846static String8 getFormatStr(PixelFormat format) {
847 switch (format) {
848 case PIXEL_FORMAT_RGBA_8888: return String8("RGBA_8888");
849 case PIXEL_FORMAT_RGBX_8888: return String8("RGBx_8888");
850 case PIXEL_FORMAT_RGB_888: return String8("RGB_888");
851 case PIXEL_FORMAT_RGB_565: return String8("RGB_565");
852 case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888");
Andy McFaddenf0058ca2014-05-20 13:28:50 -0700853 case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED:
854 return String8("ImplDef");
Andy McFadden4df87bd2014-04-21 18:08:54 -0700855 default:
856 String8 result;
857 result.appendFormat("? %08x", format);
858 return result;
859 }
860}
Dan Stoza9e56aa02015-11-02 13:00:03 -0800861*/
Andy McFadden4df87bd2014-04-21 18:08:54 -0700862
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800863bool HWComposer::isUsingVrComposer() const {
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800864 return getComposer()->isUsingVrComposer();
Hendrik Wagenaar87670ff2017-02-01 12:10:46 -0800865}
866
Mathias Agopian74d211a2013-04-22 16:55:35 +0200867void HWComposer::dump(String8& result) const {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800868 // TODO: In order to provide a dump equivalent to HWC1, we need to shadow
869 // all the state going into the layers. This is probably better done in
870 // Layer itself, but it's going to take a bit of work to get there.
871 result.append(mHwcDevice->dump().c_str());
Mathias Agopian83727852010-09-23 18:13:21 -0700872}
873
Mathias Agopiana350ff92010-08-10 17:14:02 -0700874// ---------------------------------------------------------------------------
Mathias Agopian2965b262012-04-08 15:13:32 -0700875
Jesse Halla9a1b002013-02-27 16:39:25 -0800876HWComposer::DisplayData::DisplayData()
Dan Stoza9e56aa02015-11-02 13:00:03 -0800877 : hasClientComposition(false),
878 hasDeviceComposition(false),
Steven Thomasb02664d2017-07-26 18:48:28 -0700879 hwcDisplay(nullptr),
Fabien Sanglard11d0fc32016-12-01 15:43:01 -0800880 lastPresentFence(Fence::NO_FENCE),
Dan Stoza9e56aa02015-11-02 13:00:03 -0800881 outbufHandle(nullptr),
882 outbufAcquireFence(Fence::NO_FENCE),
883 vsyncEnabled(HWC2::Vsync::Disable) {
884 ALOGV("Created new DisplayData");
885}
Jesse Halla9a1b002013-02-27 16:39:25 -0800886
887HWComposer::DisplayData::~DisplayData() {
Dan Stoza9e56aa02015-11-02 13:00:03 -0800888}
889
890void HWComposer::DisplayData::reset() {
891 ALOGV("DisplayData reset");
892 *this = DisplayData();
Jesse Halla9a1b002013-02-27 16:39:25 -0800893}
894
Mathias Agopian2965b262012-04-08 15:13:32 -0700895// ---------------------------------------------------------------------------
Mathias Agopiana350ff92010-08-10 17:14:02 -0700896}; // namespace android