| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 1 | /* | 
|  | 2 | * Copyright (C) 2010 The Android Open Source Project | 
|  | 3 | * | 
|  | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | * you may not use this file except in compliance with the License. | 
|  | 6 | * You may obtain a copy of the License at | 
|  | 7 | * | 
|  | 8 | *      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | * | 
|  | 10 | * Unless required by applicable law or agreed to in writing, software | 
|  | 11 | * distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | * See the License for the specific language governing permissions and | 
|  | 14 | * limitations under the License. | 
|  | 15 | */ | 
|  | 16 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 17 | // #define LOG_NDEBUG 0 | 
|  | 18 |  | 
|  | 19 | #undef LOG_TAG | 
|  | 20 | #define LOG_TAG "HWComposer" | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 21 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS | 
|  | 22 |  | 
| Mark Salyzyn | 92dc3fc | 2014-03-12 13:12:44 -0700 | [diff] [blame] | 23 | #include <inttypes.h> | 
|  | 24 | #include <math.h> | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 25 | #include <stdint.h> | 
| Mathias Agopian | f1352df | 2010-08-11 17:31:33 -0700 | [diff] [blame] | 26 | #include <stdio.h> | 
|  | 27 | #include <stdlib.h> | 
|  | 28 | #include <string.h> | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 29 | #include <sys/types.h> | 
|  | 30 |  | 
|  | 31 | #include <utils/Errors.h> | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 32 | #include <utils/misc.h> | 
| Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 33 | #include <utils/NativeHandle.h> | 
| Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 34 | #include <utils/String8.h> | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 35 | #include <utils/Thread.h> | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 36 | #include <utils/Trace.h> | 
| Mathias Agopian | 22da60c | 2011-09-09 00:49:11 -0700 | [diff] [blame] | 37 | #include <utils/Vector.h> | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 38 |  | 
| Mathias Agopian | 921e6ac | 2012-07-23 23:11:29 -0700 | [diff] [blame] | 39 | #include <ui/GraphicBuffer.h> | 
|  | 40 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 41 | #include <hardware/hardware.h> | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 42 | #include <hardware/hwcomposer.h> | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 43 |  | 
| Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 44 | #include <android/configuration.h> | 
|  | 45 |  | 
| Mathias Agopian | e2c4f4e | 2012-04-10 18:25:31 -0700 | [diff] [blame] | 46 | #include <cutils/properties.h> | 
| Mark Salyzyn | 7823e12 | 2016-09-29 08:08:05 -0700 | [diff] [blame] | 47 | #include <log/log.h> | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 48 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 49 | #include "HWComposer.h" | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 50 | #include "HWC2.h" | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 51 | #include "ComposerHal.h" | 
| Mathias Agopian | 33ceeb3 | 2013-04-01 16:54:58 -0700 | [diff] [blame] | 52 |  | 
|  | 53 | #include "../Layer.h"           // needed only for debugging | 
|  | 54 | #include "../SurfaceFlinger.h" | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 55 |  | 
|  | 56 | namespace android { | 
| Jesse Hall | 5880cc5 | 2012-06-05 23:40:32 -0700 | [diff] [blame] | 57 |  | 
| Jesse Hall | 7296051 | 2013-01-10 16:19:56 -0800 | [diff] [blame] | 58 | #define MIN_HWC_HEADER_VERSION HWC_HEADER_VERSION | 
| Jesse Hall | 9eb1eb5 | 2012-08-29 10:39:38 -0700 | [diff] [blame] | 59 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 60 | // --------------------------------------------------------------------------- | 
|  | 61 |  | 
| Lloyd Pique | a822d52 | 2017-12-20 16:42:57 -0800 | [diff] [blame] | 62 | HWComposer::HWComposer(std::unique_ptr<android::Hwc2::Composer> composer) | 
|  | 63 | : mHwcDevice(std::make_unique<HWC2::Device>(std::move(composer))) {} | 
| Mathias Agopian | bef42c5 | 2013-08-21 17:45:46 -0700 | [diff] [blame] | 64 |  | 
| Lloyd Pique | a822d52 | 2017-12-20 16:42:57 -0800 | [diff] [blame] | 65 | HWComposer::~HWComposer() = default; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 66 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 67 | void HWComposer::registerCallback(HWC2::ComposerCallback* callback, | 
|  | 68 | int32_t sequenceId) { | 
|  | 69 | mHwcDevice->registerCallback(callback, sequenceId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 70 | } | 
|  | 71 |  | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 72 | bool HWComposer::hasCapability(HWC2::Capability capability) const | 
|  | 73 | { | 
|  | 74 | return mHwcDevice->getCapabilities().count(capability) > 0; | 
|  | 75 | } | 
|  | 76 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 77 | bool HWComposer::isValidDisplay(int32_t displayId) const { | 
|  | 78 | return static_cast<size_t>(displayId) < mDisplayData.size() && | 
|  | 79 | mDisplayData[displayId].hwcDisplay; | 
|  | 80 | } | 
|  | 81 |  | 
|  | 82 | void HWComposer::validateChange(HWC2::Composition from, HWC2::Composition to) { | 
|  | 83 | bool valid = true; | 
|  | 84 | switch (from) { | 
|  | 85 | case HWC2::Composition::Client: | 
|  | 86 | valid = false; | 
|  | 87 | break; | 
|  | 88 | case HWC2::Composition::Device: | 
|  | 89 | case HWC2::Composition::SolidColor: | 
|  | 90 | valid = (to == HWC2::Composition::Client); | 
|  | 91 | break; | 
|  | 92 | case HWC2::Composition::Cursor: | 
|  | 93 | case HWC2::Composition::Sideband: | 
|  | 94 | valid = (to == HWC2::Composition::Client || | 
|  | 95 | to == HWC2::Composition::Device); | 
|  | 96 | break; | 
|  | 97 | default: | 
|  | 98 | break; | 
|  | 99 | } | 
|  | 100 |  | 
|  | 101 | if (!valid) { | 
|  | 102 | ALOGE("Invalid layer type change: %s --> %s", to_string(from).c_str(), | 
|  | 103 | to_string(to).c_str()); | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 104 | } | 
|  | 105 | } | 
|  | 106 |  | 
| Lloyd Pique | 715a2c1 | 2017-12-14 17:18:08 -0800 | [diff] [blame] | 107 | void HWComposer::onHotplug(hwc2_display_t displayId, int32_t displayType, | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 108 | HWC2::Connection connection) { | 
| Lloyd Pique | 715a2c1 | 2017-12-14 17:18:08 -0800 | [diff] [blame] | 109 | if (displayType >= HWC_NUM_PHYSICAL_DISPLAY_TYPES) { | 
|  | 110 | ALOGE("Invalid display type of %d", displayType); | 
|  | 111 | return; | 
|  | 112 | } | 
|  | 113 |  | 
|  | 114 | ALOGV("hotplug: %" PRIu64 ", %s %s", displayId, | 
|  | 115 | displayType == DisplayDevice::DISPLAY_PRIMARY ? "primary" : "external", | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 116 | to_string(connection).c_str()); | 
|  | 117 | mHwcDevice->onHotplug(displayId, connection); | 
| Lloyd Pique | 715a2c1 | 2017-12-14 17:18:08 -0800 | [diff] [blame] | 118 | // Disconnect is handled through HWComposer::disconnectDisplay via | 
|  | 119 | // SurfaceFlinger's onHotplugReceived callback handling | 
|  | 120 | if (connection == HWC2::Connection::Connected) { | 
|  | 121 | mDisplayData[displayType].hwcDisplay = mHwcDevice->getDisplayById(displayId); | 
|  | 122 | mHwcDisplaySlots[displayId] = displayType; | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 123 | } | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 124 | } | 
|  | 125 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 126 | bool HWComposer::onVsync(hwc2_display_t displayId, int64_t timestamp, | 
|  | 127 | int32_t* outDisplay) { | 
|  | 128 | auto display = mHwcDevice->getDisplayById(displayId); | 
|  | 129 | if (!display) { | 
|  | 130 | ALOGE("onVsync Failed to find display %" PRIu64, displayId); | 
|  | 131 | return false; | 
|  | 132 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 133 | auto displayType = HWC2::DisplayType::Invalid; | 
|  | 134 | auto error = display->getType(&displayType); | 
|  | 135 | if (error != HWC2::Error::None) { | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 136 | ALOGE("onVsync: Failed to determine type of display %" PRIu64, | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 137 | display->getId()); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 138 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 139 | } | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 140 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 141 | if (displayType == HWC2::DisplayType::Virtual) { | 
|  | 142 | ALOGE("Virtual display %" PRIu64 " passed to vsync callback", | 
|  | 143 | display->getId()); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 144 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 145 | } | 
|  | 146 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 147 | if (mHwcDisplaySlots.count(display->getId()) == 0) { | 
|  | 148 | ALOGE("Unknown physical display %" PRIu64 " passed to vsync callback", | 
|  | 149 | display->getId()); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 150 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 151 | } | 
|  | 152 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 153 | int32_t disp = mHwcDisplaySlots[display->getId()]; | 
|  | 154 | { | 
|  | 155 | Mutex::Autolock _l(mLock); | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 156 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 157 | // There have been reports of HWCs that signal several vsync events | 
|  | 158 | // with the same timestamp when turning the display off and on. This | 
|  | 159 | // is a bug in the HWC implementation, but filter the extra events | 
|  | 160 | // out here so they don't cause havoc downstream. | 
|  | 161 | if (timestamp == mLastHwVSync[disp]) { | 
|  | 162 | ALOGW("Ignoring duplicate VSYNC event from HWC (t=%" PRId64 ")", | 
|  | 163 | timestamp); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 164 | return false; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 165 | } | 
|  | 166 |  | 
|  | 167 | mLastHwVSync[disp] = timestamp; | 
| Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 168 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 169 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 170 | if (outDisplay) { | 
|  | 171 | *outDisplay = disp; | 
|  | 172 | } | 
|  | 173 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 174 | char tag[16]; | 
|  | 175 | snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp); | 
|  | 176 | ATRACE_INT(tag, ++mVSyncCounts[disp] & 1); | 
|  | 177 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 178 | return true; | 
| Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 179 | } | 
|  | 180 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 181 | status_t HWComposer::allocateVirtualDisplay(uint32_t width, uint32_t height, | 
| Dan Stoza | 5cf424b | 2016-05-20 14:02:39 -0700 | [diff] [blame] | 182 | android_pixel_format_t* format, int32_t *outId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 183 | if (mRemainingHwcVirtualDisplays == 0) { | 
|  | 184 | ALOGE("allocateVirtualDisplay: No remaining virtual displays"); | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 185 | return NO_MEMORY; | 
|  | 186 | } | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 187 |  | 
| Fabien Sanglard | c8e387e | 2017-03-10 10:30:28 -0800 | [diff] [blame] | 188 | if (SurfaceFlinger::maxVirtualDisplaySize != 0 && | 
|  | 189 | (width > SurfaceFlinger::maxVirtualDisplaySize || | 
|  | 190 | height > SurfaceFlinger::maxVirtualDisplaySize)) { | 
| Fabien Sanglard | e29055f | 2017-03-08 11:36:46 -0800 | [diff] [blame] | 191 | ALOGE("createVirtualDisplay: Can't create a virtual display with" | 
| Fabien Sanglard | c8e387e | 2017-03-10 10:30:28 -0800 | [diff] [blame] | 192 | " a dimension > %" PRIu64 " (tried %u x %u)", | 
|  | 193 | SurfaceFlinger::maxVirtualDisplaySize, width, height); | 
| Fabien Sanglard | e29055f | 2017-03-08 11:36:46 -0800 | [diff] [blame] | 194 | return INVALID_OPERATION; | 
|  | 195 | } | 
|  | 196 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 197 | HWC2::Display* display; | 
| Dan Stoza | 5cf424b | 2016-05-20 14:02:39 -0700 | [diff] [blame] | 198 | auto error = mHwcDevice->createVirtualDisplay(width, height, format, | 
|  | 199 | &display); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 200 | if (error != HWC2::Error::None) { | 
|  | 201 | ALOGE("allocateVirtualDisplay: Failed to create HWC virtual display"); | 
|  | 202 | return NO_MEMORY; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 203 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 204 |  | 
|  | 205 | size_t displaySlot = 0; | 
|  | 206 | if (!mFreeDisplaySlots.empty()) { | 
|  | 207 | displaySlot = *mFreeDisplaySlots.begin(); | 
|  | 208 | mFreeDisplaySlots.erase(displaySlot); | 
|  | 209 | } else if (mDisplayData.size() < INT32_MAX) { | 
|  | 210 | // Don't bother allocating a slot larger than we can return | 
|  | 211 | displaySlot = mDisplayData.size(); | 
|  | 212 | mDisplayData.resize(displaySlot + 1); | 
|  | 213 | } else { | 
|  | 214 | ALOGE("allocateVirtualDisplay: Unable to allocate a display slot"); | 
|  | 215 | return NO_MEMORY; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 216 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 217 |  | 
|  | 218 | mDisplayData[displaySlot].hwcDisplay = display; | 
|  | 219 |  | 
|  | 220 | --mRemainingHwcVirtualDisplays; | 
|  | 221 | *outId = static_cast<int32_t>(displaySlot); | 
|  | 222 |  | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 223 | return NO_ERROR; | 
|  | 224 | } | 
|  | 225 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 226 | HWC2::Layer* HWComposer::createLayer(int32_t displayId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 227 | if (!isValidDisplay(displayId)) { | 
|  | 228 | ALOGE("Failed to create layer on invalid display %d", displayId); | 
|  | 229 | return nullptr; | 
|  | 230 | } | 
|  | 231 | auto display = mDisplayData[displayId].hwcDisplay; | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 232 | HWC2::Layer* layer; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 233 | auto error = display->createLayer(&layer); | 
|  | 234 | if (error != HWC2::Error::None) { | 
|  | 235 | ALOGE("Failed to create layer on display %d: %s (%d)", displayId, | 
|  | 236 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 237 | return nullptr; | 
|  | 238 | } | 
|  | 239 | return layer; | 
|  | 240 | } | 
|  | 241 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 242 | void HWComposer::destroyLayer(int32_t displayId, HWC2::Layer* layer) { | 
|  | 243 | if (!isValidDisplay(displayId)) { | 
|  | 244 | ALOGE("Failed to destroy layer on invalid display %d", displayId); | 
|  | 245 | return; | 
|  | 246 | } | 
|  | 247 | auto display = mDisplayData[displayId].hwcDisplay; | 
|  | 248 | auto error = display->destroyLayer(layer); | 
|  | 249 | if (error != HWC2::Error::None) { | 
|  | 250 | ALOGE("Failed to destroy layer on display %d: %s (%d)", displayId, | 
|  | 251 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 252 | } | 
|  | 253 | } | 
|  | 254 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 255 | nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const { | 
| Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 256 | // this returns the last refresh timestamp. | 
|  | 257 | // if the last one is not available, we estimate it based on | 
|  | 258 | // the refresh period and whatever closest timestamp we have. | 
|  | 259 | Mutex::Autolock _l(mLock); | 
|  | 260 | nsecs_t now = systemTime(CLOCK_MONOTONIC); | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 261 | auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod(); | 
|  | 262 | return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod); | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 263 | } | 
|  | 264 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 265 | bool HWComposer::isConnected(int32_t displayId) const { | 
|  | 266 | if (!isValidDisplay(displayId)) { | 
|  | 267 | ALOGE("isConnected: Attempted to access invalid display %d", displayId); | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 268 | return false; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 269 | } | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 270 | return mDisplayData[displayId].hwcDisplay->isConnected(); | 
| Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 271 | } | 
|  | 272 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 273 | std::vector<std::shared_ptr<const HWC2::Display::Config>> | 
|  | 274 | HWComposer::getConfigs(int32_t displayId) const { | 
|  | 275 | if (!isValidDisplay(displayId)) { | 
|  | 276 | ALOGE("getConfigs: Attempted to access invalid display %d", displayId); | 
|  | 277 | return {}; | 
|  | 278 | } | 
|  | 279 | auto& displayData = mDisplayData[displayId]; | 
|  | 280 | auto configs = mDisplayData[displayId].hwcDisplay->getConfigs(); | 
|  | 281 | if (displayData.configMap.empty()) { | 
|  | 282 | for (size_t i = 0; i < configs.size(); ++i) { | 
|  | 283 | displayData.configMap[i] = configs[i]; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 284 | } | 
|  | 285 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 286 | return configs; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 287 | } | 
|  | 288 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 289 | std::shared_ptr<const HWC2::Display::Config> | 
|  | 290 | HWComposer::getActiveConfig(int32_t displayId) const { | 
|  | 291 | if (!isValidDisplay(displayId)) { | 
| Fabien Sanglard | b7432cc | 2016-11-11 09:40:27 -0800 | [diff] [blame] | 292 | ALOGV("getActiveConfigs: Attempted to access invalid display %d", | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 293 | displayId); | 
|  | 294 | return nullptr; | 
| Mathias Agopian | 5895934 | 2010-10-07 14:57:04 -0700 | [diff] [blame] | 295 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 296 | std::shared_ptr<const HWC2::Display::Config> config; | 
|  | 297 | auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config); | 
|  | 298 | if (error == HWC2::Error::BadConfig) { | 
| Fabien Sanglard | b7432cc | 2016-11-11 09:40:27 -0800 | [diff] [blame] | 299 | ALOGE("getActiveConfig: No config active, returning null"); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 300 | return nullptr; | 
|  | 301 | } else if (error != HWC2::Error::None) { | 
|  | 302 | ALOGE("getActiveConfig failed for display %d: %s (%d)", displayId, | 
|  | 303 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 304 | return nullptr; | 
|  | 305 | } else if (!config) { | 
|  | 306 | ALOGE("getActiveConfig returned an unknown config for display %d", | 
|  | 307 | displayId); | 
|  | 308 | return nullptr; | 
|  | 309 | } | 
|  | 310 |  | 
|  | 311 | return config; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 312 | } | 
|  | 313 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 314 | std::vector<android_color_mode_t> HWComposer::getColorModes(int32_t displayId) const { | 
|  | 315 | std::vector<android_color_mode_t> modes; | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 316 |  | 
|  | 317 | if (!isValidDisplay(displayId)) { | 
|  | 318 | ALOGE("getColorModes: Attempted to access invalid display %d", | 
|  | 319 | displayId); | 
|  | 320 | return modes; | 
|  | 321 | } | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 322 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 323 | auto error = mDisplayData[displayId].hwcDisplay->getColorModes(&modes); | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 324 | if (error != HWC2::Error::None) { | 
|  | 325 | ALOGE("getColorModes failed for display %d: %s (%d)", displayId, | 
|  | 326 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 327 | return std::vector<android_color_mode_t>(); | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 328 | } | 
|  | 329 |  | 
|  | 330 | return modes; | 
|  | 331 | } | 
|  | 332 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 333 | status_t HWComposer::setActiveColorMode(int32_t displayId, android_color_mode_t mode) { | 
|  | 334 | if (!isValidDisplay(displayId)) { | 
|  | 335 | ALOGE("setActiveColorMode: Display %d is not valid", displayId); | 
|  | 336 | return BAD_INDEX; | 
|  | 337 | } | 
|  | 338 |  | 
|  | 339 | auto& displayData = mDisplayData[displayId]; | 
|  | 340 | auto error = displayData.hwcDisplay->setColorMode(mode); | 
|  | 341 | if (error != HWC2::Error::None) { | 
|  | 342 | ALOGE("setActiveConfig: Failed to set color mode %d on display %d: " | 
|  | 343 | "%s (%d)", mode, displayId, to_string(error).c_str(), | 
|  | 344 | static_cast<int32_t>(error)); | 
|  | 345 | return UNKNOWN_ERROR; | 
|  | 346 | } | 
|  | 347 |  | 
|  | 348 | return NO_ERROR; | 
|  | 349 | } | 
|  | 350 |  | 
|  | 351 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 352 | void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) { | 
|  | 353 | if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) { | 
|  | 354 | ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 355 | return; | 
|  | 356 | } | 
|  | 357 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 358 | if (!isValidDisplay(displayId)) { | 
|  | 359 | ALOGE("setVsyncEnabled: Attempted to access invalid display %d", | 
|  | 360 | displayId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 361 | return; | 
|  | 362 | } | 
|  | 363 |  | 
|  | 364 | // NOTE: we use our own internal lock here because we have to call | 
|  | 365 | // into the HWC with the lock held, and we want to make sure | 
|  | 366 | // that even if HWC blocks (which it shouldn't), it won't | 
|  | 367 | // affect other threads. | 
|  | 368 | Mutex::Autolock _l(mVsyncLock); | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 369 | auto& displayData = mDisplayData[displayId]; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 370 | if (enabled != displayData.vsyncEnabled) { | 
|  | 371 | ATRACE_CALL(); | 
|  | 372 | auto error = displayData.hwcDisplay->setVsyncEnabled(enabled); | 
|  | 373 | if (error == HWC2::Error::None) { | 
|  | 374 | displayData.vsyncEnabled = enabled; | 
|  | 375 |  | 
|  | 376 | char tag[16]; | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 377 | snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 378 | ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0); | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 379 | } else { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 380 | ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64 | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 381 | ": %s (%d)", to_string(enabled).c_str(), displayId, | 
|  | 382 | mDisplayData[displayId].hwcDisplay->getId(), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 383 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 384 | } | 
| Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 385 | } | 
| Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 386 | } | 
|  | 387 |  | 
| Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 388 | status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot, | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 389 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target, | 
|  | 390 | android_dataspace_t dataspace) { | 
|  | 391 | if (!isValidDisplay(displayId)) { | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 392 | return BAD_INDEX; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 393 | } | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 394 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 395 | ALOGV("setClientTarget for display %d", displayId); | 
|  | 396 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 397 | auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 398 | if (error != HWC2::Error::None) { | 
|  | 399 | ALOGE("Failed to set client target for display %d: %s (%d)", displayId, | 
|  | 400 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 401 | return BAD_VALUE; | 
|  | 402 | } | 
|  | 403 |  | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 404 | return NO_ERROR; | 
|  | 405 | } | 
|  | 406 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 407 | status_t HWComposer::prepare(DisplayDevice& displayDevice) { | 
|  | 408 | ATRACE_CALL(); | 
|  | 409 |  | 
|  | 410 | Mutex::Autolock _l(mDisplayLock); | 
|  | 411 | auto displayId = displayDevice.getHwcDisplayId(); | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 412 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { | 
|  | 413 | ALOGV("Skipping HWComposer prepare for non-HWC display"); | 
|  | 414 | return NO_ERROR; | 
|  | 415 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 416 | if (!isValidDisplay(displayId)) { | 
|  | 417 | return BAD_INDEX; | 
|  | 418 | } | 
|  | 419 |  | 
|  | 420 | auto& displayData = mDisplayData[displayId]; | 
|  | 421 | auto& hwcDisplay = displayData.hwcDisplay; | 
|  | 422 | if (!hwcDisplay->isConnected()) { | 
|  | 423 | return NO_ERROR; | 
|  | 424 | } | 
|  | 425 |  | 
|  | 426 | uint32_t numTypes = 0; | 
|  | 427 | uint32_t numRequests = 0; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 428 |  | 
|  | 429 | HWC2::Error error = HWC2::Error::None; | 
|  | 430 |  | 
| Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 431 | // First try to skip validate altogether when there is no client | 
|  | 432 | // composition.  When there is client composition, since we haven't | 
|  | 433 | // rendered to the client target yet, we should not attempt to skip | 
|  | 434 | // validate. | 
|  | 435 | // | 
|  | 436 | // displayData.hasClientComposition hasn't been updated for this frame. | 
|  | 437 | // The check below is incorrect.  We actually rely on HWC here to fall | 
|  | 438 | // back to validate when there is any client layer. | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 439 | displayData.validateWasSkipped = false; | 
| Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 440 | if (!displayData.hasClientComposition) { | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 441 | sp<android::Fence> outPresentFence; | 
|  | 442 | uint32_t state = UINT32_MAX; | 
|  | 443 | error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state); | 
|  | 444 | if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) { | 
|  | 445 | ALOGV("skipValidate: Failed to Present or Validate"); | 
|  | 446 | return UNKNOWN_ERROR; | 
|  | 447 | } | 
|  | 448 | if (state == 1) { //Present Succeeded. | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 449 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 450 | error = hwcDisplay->getReleaseFences(&releaseFences); | 
|  | 451 | displayData.releaseFences = std::move(releaseFences); | 
|  | 452 | displayData.lastPresentFence = outPresentFence; | 
|  | 453 | displayData.validateWasSkipped = true; | 
|  | 454 | displayData.presentError = error; | 
|  | 455 | return NO_ERROR; | 
|  | 456 | } | 
|  | 457 | // Present failed but Validate ran. | 
|  | 458 | } else { | 
|  | 459 | error = hwcDisplay->validate(&numTypes, &numRequests); | 
|  | 460 | } | 
|  | 461 | ALOGV("SkipValidate failed, Falling back to SLOW validate/present"); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 462 | if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) { | 
|  | 463 | ALOGE("prepare: validate failed for display %d: %s (%d)", displayId, | 
|  | 464 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 465 | return BAD_INDEX; | 
|  | 466 | } | 
|  | 467 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 468 | std::unordered_map<HWC2::Layer*, HWC2::Composition> changedTypes; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 469 | changedTypes.reserve(numTypes); | 
|  | 470 | error = hwcDisplay->getChangedCompositionTypes(&changedTypes); | 
|  | 471 | if (error != HWC2::Error::None) { | 
|  | 472 | ALOGE("prepare: getChangedCompositionTypes failed on display %d: " | 
|  | 473 | "%s (%d)", displayId, to_string(error).c_str(), | 
|  | 474 | static_cast<int32_t>(error)); | 
|  | 475 | return BAD_INDEX; | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 |  | 
|  | 479 | displayData.displayRequests = static_cast<HWC2::DisplayRequest>(0); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 480 | std::unordered_map<HWC2::Layer*, HWC2::LayerRequest> layerRequests; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 481 | layerRequests.reserve(numRequests); | 
|  | 482 | error = hwcDisplay->getRequests(&displayData.displayRequests, | 
|  | 483 | &layerRequests); | 
|  | 484 | if (error != HWC2::Error::None) { | 
|  | 485 | ALOGE("prepare: getRequests failed on display %d: %s (%d)", displayId, | 
|  | 486 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 487 | return BAD_INDEX; | 
|  | 488 | } | 
|  | 489 |  | 
|  | 490 | displayData.hasClientComposition = false; | 
|  | 491 | displayData.hasDeviceComposition = false; | 
|  | 492 | for (auto& layer : displayDevice.getVisibleLayersSortedByZ()) { | 
|  | 493 | auto hwcLayer = layer->getHwcLayer(displayId); | 
|  | 494 |  | 
|  | 495 | if (changedTypes.count(hwcLayer) != 0) { | 
|  | 496 | // We pass false so we only update our state and don't call back | 
|  | 497 | // into the HWC device | 
|  | 498 | validateChange(layer->getCompositionType(displayId), | 
|  | 499 | changedTypes[hwcLayer]); | 
|  | 500 | layer->setCompositionType(displayId, changedTypes[hwcLayer], false); | 
|  | 501 | } | 
|  | 502 |  | 
|  | 503 | switch (layer->getCompositionType(displayId)) { | 
|  | 504 | case HWC2::Composition::Client: | 
|  | 505 | displayData.hasClientComposition = true; | 
|  | 506 | break; | 
|  | 507 | case HWC2::Composition::Device: | 
|  | 508 | case HWC2::Composition::SolidColor: | 
|  | 509 | case HWC2::Composition::Cursor: | 
|  | 510 | case HWC2::Composition::Sideband: | 
|  | 511 | displayData.hasDeviceComposition = true; | 
|  | 512 | break; | 
|  | 513 | default: | 
|  | 514 | break; | 
|  | 515 | } | 
|  | 516 |  | 
|  | 517 | if (layerRequests.count(hwcLayer) != 0 && | 
|  | 518 | layerRequests[hwcLayer] == | 
|  | 519 | HWC2::LayerRequest::ClearClientTarget) { | 
|  | 520 | layer->setClearClientTarget(displayId, true); | 
|  | 521 | } else { | 
|  | 522 | if (layerRequests.count(hwcLayer) != 0) { | 
|  | 523 | ALOGE("prepare: Unknown layer request: %s", | 
|  | 524 | to_string(layerRequests[hwcLayer]).c_str()); | 
|  | 525 | } | 
|  | 526 | layer->setClearClientTarget(displayId, false); | 
|  | 527 | } | 
|  | 528 | } | 
|  | 529 |  | 
|  | 530 | error = hwcDisplay->acceptChanges(); | 
|  | 531 | if (error != HWC2::Error::None) { | 
|  | 532 | ALOGE("prepare: acceptChanges failed: %s", to_string(error).c_str()); | 
|  | 533 | return BAD_INDEX; | 
|  | 534 | } | 
|  | 535 |  | 
|  | 536 | return NO_ERROR; | 
|  | 537 | } | 
|  | 538 |  | 
|  | 539 | bool HWComposer::hasDeviceComposition(int32_t displayId) const { | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 540 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { | 
|  | 541 | // Displays without a corresponding HWC display are never composed by | 
|  | 542 | // the device | 
|  | 543 | return false; | 
|  | 544 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 545 | if (!isValidDisplay(displayId)) { | 
|  | 546 | ALOGE("hasDeviceComposition: Invalid display %d", displayId); | 
|  | 547 | return false; | 
|  | 548 | } | 
|  | 549 | return mDisplayData[displayId].hasDeviceComposition; | 
|  | 550 | } | 
|  | 551 |  | 
| Madhuri Athota | 88a905b | 2017-05-04 16:58:15 +0530 | [diff] [blame] | 552 | bool HWComposer::hasFlipClientTargetRequest(int32_t displayId) const { | 
|  | 553 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { | 
|  | 554 | // Displays without a corresponding HWC display are never composed by | 
|  | 555 | // the device | 
|  | 556 | return false; | 
|  | 557 | } | 
|  | 558 | if (!isValidDisplay(displayId)) { | 
|  | 559 | ALOGE("hasFlipClientTargetRequest: Invalid display %d", displayId); | 
|  | 560 | return false; | 
|  | 561 | } | 
|  | 562 | return ((static_cast<uint32_t>(mDisplayData[displayId].displayRequests) & | 
|  | 563 | static_cast<uint32_t>(HWC2::DisplayRequest::FlipClientTarget)) != 0); | 
|  | 564 | } | 
|  | 565 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 566 | bool HWComposer::hasClientComposition(int32_t displayId) const { | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 567 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { | 
|  | 568 | // Displays without a corresponding HWC display are always composed by | 
|  | 569 | // the client | 
|  | 570 | return true; | 
|  | 571 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 572 | if (!isValidDisplay(displayId)) { | 
|  | 573 | ALOGE("hasClientComposition: Invalid display %d", displayId); | 
|  | 574 | return true; | 
|  | 575 | } | 
|  | 576 | return mDisplayData[displayId].hasClientComposition; | 
|  | 577 | } | 
|  | 578 |  | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 579 | sp<Fence> HWComposer::getPresentFence(int32_t displayId) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 580 | if (!isValidDisplay(displayId)) { | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 581 | ALOGE("getPresentFence failed for invalid display %d", displayId); | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 582 | return Fence::NO_FENCE; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 583 | } | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 584 | return mDisplayData[displayId].lastPresentFence; | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 585 | } | 
|  | 586 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 587 | sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId, | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 588 | HWC2::Layer* layer) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 589 | if (!isValidDisplay(displayId)) { | 
|  | 590 | ALOGE("getLayerReleaseFence: Invalid display"); | 
|  | 591 | return Fence::NO_FENCE; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 592 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 593 | auto displayFences = mDisplayData[displayId].releaseFences; | 
|  | 594 | if (displayFences.count(layer) == 0) { | 
|  | 595 | ALOGV("getLayerReleaseFence: Release fence not found"); | 
|  | 596 | return Fence::NO_FENCE; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 597 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 598 | return displayFences[layer]; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 599 | } | 
|  | 600 |  | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 601 | status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 602 | ATRACE_CALL(); | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 603 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 604 | if (!isValidDisplay(displayId)) { | 
|  | 605 | return BAD_INDEX; | 
| Mathias Agopian | c397360 | 2012-08-31 17:51:25 -0700 | [diff] [blame] | 606 | } | 
| Pablo Ceballos | d814cf2 | 2015-09-11 14:37:39 -0700 | [diff] [blame] | 607 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 608 | auto& displayData = mDisplayData[displayId]; | 
|  | 609 | auto& hwcDisplay = displayData.hwcDisplay; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 610 |  | 
|  | 611 | if (displayData.validateWasSkipped) { | 
| Chia-I Wu | ae5a6b8 | 2017-10-10 09:09:22 -0700 | [diff] [blame] | 612 | // explicitly flush all pending commands | 
|  | 613 | auto error = mHwcDevice->flushCommands(); | 
|  | 614 | if (displayData.presentError != HWC2::Error::None) { | 
|  | 615 | error = displayData.presentError; | 
|  | 616 | } | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 617 | if (error != HWC2::Error::None) { | 
|  | 618 | ALOGE("skipValidate: failed for display %d: %s (%d)", | 
|  | 619 | displayId, to_string(error).c_str(), static_cast<int32_t>(error)); | 
|  | 620 | return UNKNOWN_ERROR; | 
|  | 621 | } | 
|  | 622 | return NO_ERROR; | 
|  | 623 | } | 
|  | 624 |  | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 625 | auto error = hwcDisplay->present(&displayData.lastPresentFence); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 626 | if (error != HWC2::Error::None) { | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 627 | ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)", | 
|  | 628 | displayId, to_string(error).c_str(), static_cast<int32_t>(error)); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 629 | return UNKNOWN_ERROR; | 
|  | 630 | } | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 631 |  | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 632 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 633 | error = hwcDisplay->getReleaseFences(&releaseFences); | 
|  | 634 | if (error != HWC2::Error::None) { | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 635 | ALOGE("presentAndGetReleaseFences: Failed to get release fences " | 
|  | 636 | "for display %d: %s (%d)", | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 637 | displayId, to_string(error).c_str(), | 
|  | 638 | static_cast<int32_t>(error)); | 
|  | 639 | return UNKNOWN_ERROR; | 
| Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 640 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 641 |  | 
|  | 642 | displayData.releaseFences = std::move(releaseFences); | 
|  | 643 |  | 
|  | 644 | return NO_ERROR; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 645 | } | 
|  | 646 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 647 | status_t HWComposer::setPowerMode(int32_t displayId, int32_t intMode) { | 
|  | 648 | ALOGV("setPowerMode(%d, %d)", displayId, intMode); | 
|  | 649 | if (!isValidDisplay(displayId)) { | 
|  | 650 | ALOGE("setPowerMode: Bad display"); | 
|  | 651 | return BAD_INDEX; | 
|  | 652 | } | 
|  | 653 | if (displayId >= VIRTUAL_DISPLAY_ID_BASE) { | 
|  | 654 | ALOGE("setPowerMode: Virtual display %d passed in, returning", | 
|  | 655 | displayId); | 
|  | 656 | return BAD_INDEX; | 
|  | 657 | } | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 658 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 659 | auto mode = static_cast<HWC2::PowerMode>(intMode); | 
|  | 660 | if (mode == HWC2::PowerMode::Off) { | 
|  | 661 | setVsyncEnabled(displayId, HWC2::Vsync::Disable); | 
|  | 662 | } | 
|  | 663 |  | 
|  | 664 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; | 
|  | 665 | switch (mode) { | 
|  | 666 | case HWC2::PowerMode::Off: | 
|  | 667 | case HWC2::PowerMode::On: | 
|  | 668 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); | 
|  | 669 | { | 
|  | 670 | auto error = hwcDisplay->setPowerMode(mode); | 
|  | 671 | if (error != HWC2::Error::None) { | 
|  | 672 | ALOGE("setPowerMode: Unable to set power mode %s for " | 
|  | 673 | "display %d: %s (%d)", to_string(mode).c_str(), | 
|  | 674 | displayId, to_string(error).c_str(), | 
|  | 675 | static_cast<int32_t>(error)); | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 676 | } | 
|  | 677 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 678 | break; | 
|  | 679 | case HWC2::PowerMode::Doze: | 
|  | 680 | case HWC2::PowerMode::DozeSuspend: | 
|  | 681 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); | 
|  | 682 | { | 
|  | 683 | bool supportsDoze = false; | 
|  | 684 | auto error = hwcDisplay->supportsDoze(&supportsDoze); | 
|  | 685 | if (error != HWC2::Error::None) { | 
|  | 686 | ALOGE("setPowerMode: Unable to query doze support for " | 
|  | 687 | "display %d: %s (%d)", displayId, | 
|  | 688 | to_string(error).c_str(), | 
|  | 689 | static_cast<int32_t>(error)); | 
|  | 690 | } | 
|  | 691 | if (!supportsDoze) { | 
|  | 692 | mode = HWC2::PowerMode::On; | 
|  | 693 | } | 
|  | 694 |  | 
|  | 695 | error = hwcDisplay->setPowerMode(mode); | 
|  | 696 | if (error != HWC2::Error::None) { | 
|  | 697 | ALOGE("setPowerMode: Unable to set power mode %s for " | 
|  | 698 | "display %d: %s (%d)", to_string(mode).c_str(), | 
|  | 699 | displayId, to_string(error).c_str(), | 
|  | 700 | static_cast<int32_t>(error)); | 
|  | 701 | } | 
|  | 702 | } | 
|  | 703 | break; | 
|  | 704 | default: | 
|  | 705 | ALOGV("setPowerMode: Not calling HWC"); | 
|  | 706 | break; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 707 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 708 |  | 
|  | 709 | return NO_ERROR; | 
|  | 710 | } | 
|  | 711 |  | 
|  | 712 | status_t HWComposer::setActiveConfig(int32_t displayId, size_t configId) { | 
|  | 713 | if (!isValidDisplay(displayId)) { | 
|  | 714 | ALOGE("setActiveConfig: Display %d is not valid", displayId); | 
|  | 715 | return BAD_INDEX; | 
|  | 716 | } | 
|  | 717 |  | 
|  | 718 | auto& displayData = mDisplayData[displayId]; | 
|  | 719 | if (displayData.configMap.count(configId) == 0) { | 
|  | 720 | ALOGE("setActiveConfig: Invalid config %zd", configId); | 
|  | 721 | return BAD_INDEX; | 
|  | 722 | } | 
|  | 723 |  | 
|  | 724 | auto error = displayData.hwcDisplay->setActiveConfig( | 
|  | 725 | displayData.configMap[configId]); | 
|  | 726 | if (error != HWC2::Error::None) { | 
|  | 727 | ALOGE("setActiveConfig: Failed to set config %zu on display %d: " | 
|  | 728 | "%s (%d)", configId, displayId, to_string(error).c_str(), | 
|  | 729 | static_cast<int32_t>(error)); | 
|  | 730 | return UNKNOWN_ERROR; | 
|  | 731 | } | 
|  | 732 |  | 
|  | 733 | return NO_ERROR; | 
|  | 734 | } | 
|  | 735 |  | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 736 | status_t HWComposer::setColorTransform(int32_t displayId, | 
|  | 737 | const mat4& transform) { | 
|  | 738 | if (!isValidDisplay(displayId)) { | 
|  | 739 | ALOGE("setColorTransform: Display %d is not valid", displayId); | 
|  | 740 | return BAD_INDEX; | 
|  | 741 | } | 
|  | 742 |  | 
|  | 743 | auto& displayData = mDisplayData[displayId]; | 
|  | 744 | bool isIdentity = transform == mat4(); | 
|  | 745 | auto error = displayData.hwcDisplay->setColorTransform(transform, | 
|  | 746 | isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : | 
|  | 747 | HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX); | 
|  | 748 | if (error != HWC2::Error::None) { | 
|  | 749 | ALOGE("setColorTransform: Failed to set transform on display %d: " | 
|  | 750 | "%s (%d)", displayId, to_string(error).c_str(), | 
|  | 751 | static_cast<int32_t>(error)); | 
|  | 752 | return UNKNOWN_ERROR; | 
|  | 753 | } | 
|  | 754 |  | 
|  | 755 | return NO_ERROR; | 
|  | 756 | } | 
|  | 757 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 758 | void HWComposer::disconnectDisplay(int displayId) { | 
|  | 759 | LOG_ALWAYS_FATAL_IF(displayId < 0); | 
|  | 760 | auto& displayData = mDisplayData[displayId]; | 
|  | 761 |  | 
|  | 762 | auto displayType = HWC2::DisplayType::Invalid; | 
|  | 763 | auto error = displayData.hwcDisplay->getType(&displayType); | 
|  | 764 | if (error != HWC2::Error::None) { | 
|  | 765 | ALOGE("disconnectDisplay: Failed to determine type of display %d", | 
|  | 766 | displayId); | 
|  | 767 | return; | 
|  | 768 | } | 
|  | 769 |  | 
|  | 770 | // If this was a virtual display, add its slot back for reuse by future | 
|  | 771 | // virtual displays | 
|  | 772 | if (displayType == HWC2::DisplayType::Virtual) { | 
|  | 773 | mFreeDisplaySlots.insert(displayId); | 
|  | 774 | ++mRemainingHwcVirtualDisplays; | 
|  | 775 | } | 
|  | 776 |  | 
|  | 777 | auto hwcId = displayData.hwcDisplay->getId(); | 
|  | 778 | mHwcDisplaySlots.erase(hwcId); | 
|  | 779 | displayData.reset(); | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 780 |  | 
|  | 781 | mHwcDevice->destroyDisplay(hwcId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 782 | } | 
|  | 783 |  | 
|  | 784 | status_t HWComposer::setOutputBuffer(int32_t displayId, | 
|  | 785 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) { | 
|  | 786 | if (!isValidDisplay(displayId)) { | 
|  | 787 | ALOGE("setOutputBuffer: Display %d is not valid", displayId); | 
|  | 788 | return BAD_INDEX; | 
|  | 789 | } | 
|  | 790 |  | 
|  | 791 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; | 
|  | 792 | auto displayType = HWC2::DisplayType::Invalid; | 
|  | 793 | auto error = hwcDisplay->getType(&displayType); | 
|  | 794 | if (error != HWC2::Error::None) { | 
|  | 795 | ALOGE("setOutputBuffer: Failed to determine type of display %d", | 
|  | 796 | displayId); | 
|  | 797 | return NAME_NOT_FOUND; | 
|  | 798 | } | 
|  | 799 |  | 
|  | 800 | if (displayType != HWC2::DisplayType::Virtual) { | 
|  | 801 | ALOGE("setOutputBuffer: Display %d is not virtual", displayId); | 
|  | 802 | return INVALID_OPERATION; | 
|  | 803 | } | 
|  | 804 |  | 
|  | 805 | error = hwcDisplay->setOutputBuffer(buffer, acquireFence); | 
|  | 806 | if (error != HWC2::Error::None) { | 
|  | 807 | ALOGE("setOutputBuffer: Failed to set buffer on display %d: %s (%d)", | 
|  | 808 | displayId, to_string(error).c_str(), | 
|  | 809 | static_cast<int32_t>(error)); | 
|  | 810 | return UNKNOWN_ERROR; | 
|  | 811 | } | 
|  | 812 |  | 
|  | 813 | return NO_ERROR; | 
|  | 814 | } | 
|  | 815 |  | 
|  | 816 | void HWComposer::clearReleaseFences(int32_t displayId) { | 
|  | 817 | if (!isValidDisplay(displayId)) { | 
|  | 818 | ALOGE("clearReleaseFences: Display %d is not valid", displayId); | 
|  | 819 | return; | 
|  | 820 | } | 
|  | 821 | mDisplayData[displayId].releaseFences.clear(); | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 822 | } | 
|  | 823 |  | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 824 | std::unique_ptr<HdrCapabilities> HWComposer::getHdrCapabilities( | 
|  | 825 | int32_t displayId) { | 
|  | 826 | if (!isValidDisplay(displayId)) { | 
|  | 827 | ALOGE("getHdrCapabilities: Display %d is not valid", displayId); | 
|  | 828 | return nullptr; | 
|  | 829 | } | 
|  | 830 |  | 
|  | 831 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; | 
|  | 832 | std::unique_ptr<HdrCapabilities> capabilities; | 
|  | 833 | auto error = hwcDisplay->getHdrCapabilities(&capabilities); | 
|  | 834 | if (error != HWC2::Error::None) { | 
|  | 835 | ALOGE("getOutputCapabilities: Failed to get capabilities on display %d:" | 
|  | 836 | " %s (%d)", displayId, to_string(error).c_str(), | 
|  | 837 | static_cast<int32_t>(error)); | 
|  | 838 | return nullptr; | 
|  | 839 | } | 
|  | 840 |  | 
|  | 841 | return capabilities; | 
|  | 842 | } | 
|  | 843 |  | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 844 | // Converts a PixelFormat to a human-readable string.  Max 11 chars. | 
|  | 845 | // (Could use a table of prefab String8 objects.) | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 846 | /* | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 847 | static String8 getFormatStr(PixelFormat format) { | 
|  | 848 | switch (format) { | 
|  | 849 | case PIXEL_FORMAT_RGBA_8888:    return String8("RGBA_8888"); | 
|  | 850 | case PIXEL_FORMAT_RGBX_8888:    return String8("RGBx_8888"); | 
|  | 851 | case PIXEL_FORMAT_RGB_888:      return String8("RGB_888"); | 
|  | 852 | case PIXEL_FORMAT_RGB_565:      return String8("RGB_565"); | 
|  | 853 | case PIXEL_FORMAT_BGRA_8888:    return String8("BGRA_8888"); | 
| Andy McFadden | f0058ca | 2014-05-20 13:28:50 -0700 | [diff] [blame] | 854 | case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: | 
|  | 855 | return String8("ImplDef"); | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 856 | default: | 
|  | 857 | String8 result; | 
|  | 858 | result.appendFormat("? %08x", format); | 
|  | 859 | return result; | 
|  | 860 | } | 
|  | 861 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 862 | */ | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 863 |  | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 864 | bool HWComposer::isUsingVrComposer() const { | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 865 | return getComposer()->isUsingVrComposer(); | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 866 | } | 
|  | 867 |  | 
| Mathias Agopian | 74d211a | 2013-04-22 16:55:35 +0200 | [diff] [blame] | 868 | void HWComposer::dump(String8& result) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 869 | // TODO: In order to provide a dump equivalent to HWC1, we need to shadow | 
|  | 870 | // all the state going into the layers. This is probably better done in | 
|  | 871 | // Layer itself, but it's going to take a bit of work to get there. | 
|  | 872 | result.append(mHwcDevice->dump().c_str()); | 
| Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 873 | } | 
|  | 874 |  | 
| Steven Thomas | 6e8f706 | 2017-11-22 14:15:29 -0800 | [diff] [blame] | 875 | std::optional<hwc2_display_t> | 
|  | 876 | HWComposer::getHwcDisplayId(int32_t displayId) const { | 
|  | 877 | if (!isValidDisplay(displayId)) { | 
|  | 878 | return {}; | 
|  | 879 | } | 
|  | 880 | return mDisplayData[displayId].hwcDisplay->getId(); | 
|  | 881 | } | 
|  | 882 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 883 | // --------------------------------------------------------------------------- | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 884 |  | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 885 | HWComposer::DisplayData::DisplayData() | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 886 | : hasClientComposition(false), | 
|  | 887 | hasDeviceComposition(false), | 
| Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 888 | hwcDisplay(nullptr), | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 889 | lastPresentFence(Fence::NO_FENCE), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 890 | outbufHandle(nullptr), | 
|  | 891 | outbufAcquireFence(Fence::NO_FENCE), | 
|  | 892 | vsyncEnabled(HWC2::Vsync::Disable) { | 
|  | 893 | ALOGV("Created new DisplayData"); | 
|  | 894 | } | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 895 |  | 
|  | 896 | HWComposer::DisplayData::~DisplayData() { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 897 | } | 
|  | 898 |  | 
|  | 899 | void HWComposer::DisplayData::reset() { | 
|  | 900 | ALOGV("DisplayData reset"); | 
|  | 901 | *this = DisplayData(); | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 902 | } | 
|  | 903 |  | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 904 | // --------------------------------------------------------------------------- | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 905 | }; // namespace android |