| 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 |  | 
| Kalle Raita | a099a24 | 2017-01-11 11:17:29 -0800 | [diff] [blame] | 62 | HWComposer::HWComposer(const std::string& serviceName) | 
| Logan Chien | 2342977 | 2017-05-16 10:18:17 +0800 | [diff] [blame] | 63 | : mHwcDevice(), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 64 | mDisplayData(2), | 
|  | 65 | mFreeDisplaySlots(), | 
|  | 66 | mHwcDisplaySlots(), | 
|  | 67 | mCBContext(), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 68 | mVSyncCounts(), | 
| Chia-I Wu | 15b27e0 | 2017-05-11 16:06:07 -0700 | [diff] [blame] | 69 | mRemainingHwcVirtualDisplays(0) | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 70 | { | 
| Mathias Agopian | bef42c5 | 2013-08-21 17:45:46 -0700 | [diff] [blame] | 71 | for (size_t i=0 ; i<HWC_NUM_PHYSICAL_DISPLAY_TYPES ; i++) { | 
|  | 72 | mLastHwVSync[i] = 0; | 
|  | 73 | mVSyncCounts[i] = 0; | 
|  | 74 | } | 
|  | 75 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 76 | mHwcDevice = std::make_unique<HWC2::Device>(serviceName); | 
|  | 77 | mRemainingHwcVirtualDisplays = mHwcDevice->getMaxVirtualDisplayCount(); | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 78 | } | 
|  | 79 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 80 | HWComposer::~HWComposer() {} | 
|  | 81 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 82 | void HWComposer::registerCallback(HWC2::ComposerCallback* callback, | 
|  | 83 | int32_t sequenceId) { | 
|  | 84 | mHwcDevice->registerCallback(callback, sequenceId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 85 | } | 
|  | 86 |  | 
| Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 87 | bool HWComposer::hasCapability(HWC2::Capability capability) const | 
|  | 88 | { | 
|  | 89 | return mHwcDevice->getCapabilities().count(capability) > 0; | 
|  | 90 | } | 
|  | 91 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 92 | bool HWComposer::isValidDisplay(int32_t displayId) const { | 
|  | 93 | return static_cast<size_t>(displayId) < mDisplayData.size() && | 
|  | 94 | mDisplayData[displayId].hwcDisplay; | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | void 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 McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 119 | } | 
|  | 120 | } | 
|  | 121 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 122 | void 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 127 | if (!mDisplayData[0].hwcDisplay) { | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 128 | ALOGE_IF(connection != HWC2::Connection::Connected, "Assumed primary" | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 129 | " display would be connected"); | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 130 | mDisplayData[0].hwcDisplay = mHwcDevice->getDisplayById(displayId); | 
|  | 131 | mHwcDisplaySlots[displayId] = 0; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 132 | } else { | 
|  | 133 | // Disconnect is handled through HWComposer::disconnectDisplay via | 
|  | 134 | // SurfaceFlinger's onHotplugReceived callback handling | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 135 | if (connection == HWC2::Connection::Connected) { | 
|  | 136 | mDisplayData[1].hwcDisplay = mHwcDevice->getDisplayById(displayId); | 
|  | 137 | mHwcDisplaySlots[displayId] = 1; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 138 | } | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 139 | } | 
| Andy McFadden | b0d1dd3 | 2012-09-10 14:08:09 -0700 | [diff] [blame] | 140 | } | 
|  | 141 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 142 | bool 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 149 | auto displayType = HWC2::DisplayType::Invalid; | 
|  | 150 | auto error = display->getType(&displayType); | 
|  | 151 | if (error != HWC2::Error::None) { | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 152 | ALOGE("onVsync: Failed to determine type of display %" PRIu64, | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 153 | display->getId()); | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 154 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 155 | } | 
| 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 | if (displayType == HWC2::DisplayType::Virtual) { | 
|  | 158 | ALOGE("Virtual display %" PRIu64 " passed to vsync callback", | 
|  | 159 | display->getId()); | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 160 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 161 | } | 
|  | 162 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 163 | if (mHwcDisplaySlots.count(display->getId()) == 0) { | 
|  | 164 | ALOGE("Unknown physical display %" PRIu64 " passed to vsync callback", | 
|  | 165 | display->getId()); | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 166 | return false; | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 167 | } | 
|  | 168 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 169 | int32_t disp = mHwcDisplaySlots[display->getId()]; | 
|  | 170 | { | 
|  | 171 | Mutex::Autolock _l(mLock); | 
| Jesse Hall | 1bd20e0 | 2012-08-29 10:47:52 -0700 | [diff] [blame] | 172 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 173 | // 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 180 | return false; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 181 | } | 
|  | 182 |  | 
|  | 183 | mLastHwVSync[disp] = timestamp; | 
| Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 184 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 185 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 186 | if (outDisplay) { | 
|  | 187 | *outDisplay = disp; | 
|  | 188 | } | 
|  | 189 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 190 | char tag[16]; | 
|  | 191 | snprintf(tag, sizeof(tag), "HW_VSYNC_%1u", disp); | 
|  | 192 | ATRACE_INT(tag, ++mVSyncCounts[disp] & 1); | 
|  | 193 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 194 | return true; | 
| Jesse Hall | 1c569c4 | 2013-04-05 13:44:52 -0700 | [diff] [blame] | 195 | } | 
|  | 196 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 197 | status_t HWComposer::allocateVirtualDisplay(uint32_t width, uint32_t height, | 
| Dan Stoza | 5cf424b | 2016-05-20 14:02:39 -0700 | [diff] [blame] | 198 | android_pixel_format_t* format, int32_t *outId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 199 | if (mRemainingHwcVirtualDisplays == 0) { | 
|  | 200 | ALOGE("allocateVirtualDisplay: No remaining virtual displays"); | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 201 | return NO_MEMORY; | 
|  | 202 | } | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 203 |  | 
| Fabien Sanglard | c8e387e | 2017-03-10 10:30:28 -0800 | [diff] [blame] | 204 | if (SurfaceFlinger::maxVirtualDisplaySize != 0 && | 
|  | 205 | (width > SurfaceFlinger::maxVirtualDisplaySize || | 
|  | 206 | height > SurfaceFlinger::maxVirtualDisplaySize)) { | 
| Fabien Sanglard | e29055f | 2017-03-08 11:36:46 -0800 | [diff] [blame] | 207 | ALOGE("createVirtualDisplay: Can't create a virtual display with" | 
| Fabien Sanglard | c8e387e | 2017-03-10 10:30:28 -0800 | [diff] [blame] | 208 | " a dimension > %" PRIu64 " (tried %u x %u)", | 
|  | 209 | SurfaceFlinger::maxVirtualDisplaySize, width, height); | 
| Fabien Sanglard | e29055f | 2017-03-08 11:36:46 -0800 | [diff] [blame] | 210 | return INVALID_OPERATION; | 
|  | 211 | } | 
|  | 212 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 213 | HWC2::Display* display; | 
| Dan Stoza | 5cf424b | 2016-05-20 14:02:39 -0700 | [diff] [blame] | 214 | auto error = mHwcDevice->createVirtualDisplay(width, height, format, | 
|  | 215 | &display); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 216 | if (error != HWC2::Error::None) { | 
|  | 217 | ALOGE("allocateVirtualDisplay: Failed to create HWC virtual display"); | 
|  | 218 | return NO_MEMORY; | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 219 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 220 |  | 
|  | 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 Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 232 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 233 |  | 
|  | 234 | mDisplayData[displaySlot].hwcDisplay = display; | 
|  | 235 |  | 
|  | 236 | --mRemainingHwcVirtualDisplays; | 
|  | 237 | *outId = static_cast<int32_t>(displaySlot); | 
|  | 238 |  | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 239 | return NO_ERROR; | 
|  | 240 | } | 
|  | 241 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 242 | HWC2::Layer* HWComposer::createLayer(int32_t displayId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 243 | 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 248 | HWC2::Layer* layer; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 249 | 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 258 | void 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 Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 271 | nsecs_t HWComposer::getRefreshTimestamp(int32_t displayId) const { | 
| Mathias Agopian | d3ee231 | 2012-08-02 14:01:42 -0700 | [diff] [blame] | 272 | // 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 Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 277 | auto vsyncPeriod = getActiveConfig(displayId)->getVsyncPeriod(); | 
|  | 278 | return now - ((now - mLastHwVSync[displayId]) % vsyncPeriod); | 
| Mathias Agopian | 3eb38cb | 2012-04-03 22:09:52 -0700 | [diff] [blame] | 279 | } | 
|  | 280 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 281 | bool HWComposer::isConnected(int32_t displayId) const { | 
|  | 282 | if (!isValidDisplay(displayId)) { | 
|  | 283 | ALOGE("isConnected: Attempted to access invalid display %d", displayId); | 
| Mathias Agopian | e60b068 | 2012-08-21 23:34:09 -0700 | [diff] [blame] | 284 | return false; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 285 | } | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 286 | return mDisplayData[displayId].hwcDisplay->isConnected(); | 
| Mathias Agopian | 9c6e297 | 2011-09-20 17:21:56 -0700 | [diff] [blame] | 287 | } | 
|  | 288 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 289 | std::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 Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 300 | } | 
|  | 301 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 302 | return configs; | 
| Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 303 | } | 
|  | 304 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 305 | std::shared_ptr<const HWC2::Display::Config> | 
|  | 306 | HWComposer::getActiveConfig(int32_t displayId) const { | 
|  | 307 | if (!isValidDisplay(displayId)) { | 
| Fabien Sanglard | b7432cc | 2016-11-11 09:40:27 -0800 | [diff] [blame] | 308 | ALOGV("getActiveConfigs: Attempted to access invalid display %d", | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 309 | displayId); | 
|  | 310 | return nullptr; | 
| Mathias Agopian | 5895934 | 2010-10-07 14:57:04 -0700 | [diff] [blame] | 311 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 312 | std::shared_ptr<const HWC2::Display::Config> config; | 
|  | 313 | auto error = mDisplayData[displayId].hwcDisplay->getActiveConfig(&config); | 
|  | 314 | if (error == HWC2::Error::BadConfig) { | 
| Fabien Sanglard | b7432cc | 2016-11-11 09:40:27 -0800 | [diff] [blame] | 315 | ALOGE("getActiveConfig: No config active, returning null"); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 316 | 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 Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 328 | } | 
|  | 329 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 330 | std::vector<android_color_mode_t> HWComposer::getColorModes(int32_t displayId) const { | 
|  | 331 | std::vector<android_color_mode_t> modes; | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 332 |  | 
|  | 333 | if (!isValidDisplay(displayId)) { | 
|  | 334 | ALOGE("getColorModes: Attempted to access invalid display %d", | 
|  | 335 | displayId); | 
|  | 336 | return modes; | 
|  | 337 | } | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 338 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 339 | auto error = mDisplayData[displayId].hwcDisplay->getColorModes(&modes); | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 340 | 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 Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 343 | return std::vector<android_color_mode_t>(); | 
| Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 344 | } | 
|  | 345 |  | 
|  | 346 | return modes; | 
|  | 347 | } | 
|  | 348 |  | 
| Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 349 | status_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 Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 368 | void 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 371 | return; | 
|  | 372 | } | 
|  | 373 |  | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 374 | if (!isValidDisplay(displayId)) { | 
|  | 375 | ALOGE("setVsyncEnabled: Attempted to access invalid display %d", | 
|  | 376 | displayId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 377 | 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 Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 385 | auto& displayData = mDisplayData[displayId]; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 386 | 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 Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 393 | snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 394 | ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0); | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 395 | } else { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 396 | ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64 | 
| Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 397 | ": %s (%d)", to_string(enabled).c_str(), displayId, | 
|  | 398 | mDisplayData[displayId].hwcDisplay->getId(), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 399 | to_string(error).c_str(), static_cast<int32_t>(error)); | 
| Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 400 | } | 
| Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 401 | } | 
| Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 402 | } | 
|  | 403 |  | 
| Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 404 | status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot, | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 405 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target, | 
|  | 406 | android_dataspace_t dataspace) { | 
|  | 407 | if (!isValidDisplay(displayId)) { | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 408 | return BAD_INDEX; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 409 | } | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 410 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 411 | ALOGV("setClientTarget for display %d", displayId); | 
|  | 412 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; | 
| Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 413 | auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 414 | 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 Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 420 | return NO_ERROR; | 
|  | 421 | } | 
|  | 422 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 423 | status_t HWComposer::prepare(DisplayDevice& displayDevice) { | 
|  | 424 | ATRACE_CALL(); | 
|  | 425 |  | 
|  | 426 | Mutex::Autolock _l(mDisplayLock); | 
|  | 427 | auto displayId = displayDevice.getHwcDisplayId(); | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 428 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { | 
|  | 429 | ALOGV("Skipping HWComposer prepare for non-HWC display"); | 
|  | 430 | return NO_ERROR; | 
|  | 431 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 432 | 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 Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 444 |  | 
|  | 445 | HWC2::Error error = HWC2::Error::None; | 
|  | 446 |  | 
| Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 447 | // 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 Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 455 | displayData.validateWasSkipped = false; | 
| Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 456 | if (!displayData.hasClientComposition) { | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 457 | 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 465 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 466 | 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 478 | 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 484 | std::unordered_map<HWC2::Layer*, HWC2::Composition> changedTypes; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 485 | 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 496 | std::unordered_map<HWC2::Layer*, HWC2::LayerRequest> layerRequests; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 497 | 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 |  | 
|  | 555 | bool HWComposer::hasDeviceComposition(int32_t displayId) const { | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 556 | 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 561 | if (!isValidDisplay(displayId)) { | 
|  | 562 | ALOGE("hasDeviceComposition: Invalid display %d", displayId); | 
|  | 563 | return false; | 
|  | 564 | } | 
|  | 565 | return mDisplayData[displayId].hasDeviceComposition; | 
|  | 566 | } | 
|  | 567 |  | 
|  | 568 | bool HWComposer::hasClientComposition(int32_t displayId) const { | 
| Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 569 | 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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 574 | if (!isValidDisplay(displayId)) { | 
|  | 575 | ALOGE("hasClientComposition: Invalid display %d", displayId); | 
|  | 576 | return true; | 
|  | 577 | } | 
|  | 578 | return mDisplayData[displayId].hasClientComposition; | 
|  | 579 | } | 
|  | 580 |  | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 581 | sp<Fence> HWComposer::getPresentFence(int32_t displayId) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 582 | if (!isValidDisplay(displayId)) { | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 583 | ALOGE("getPresentFence failed for invalid display %d", displayId); | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 584 | return Fence::NO_FENCE; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 585 | } | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 586 | return mDisplayData[displayId].lastPresentFence; | 
| Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 587 | } | 
|  | 588 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 589 | sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId, | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 590 | HWC2::Layer* layer) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 591 | if (!isValidDisplay(displayId)) { | 
|  | 592 | ALOGE("getLayerReleaseFence: Invalid display"); | 
|  | 593 | return Fence::NO_FENCE; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 594 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 595 | auto displayFences = mDisplayData[displayId].releaseFences; | 
|  | 596 | if (displayFences.count(layer) == 0) { | 
|  | 597 | ALOGV("getLayerReleaseFence: Release fence not found"); | 
|  | 598 | return Fence::NO_FENCE; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 599 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 600 | return displayFences[layer]; | 
| Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 601 | } | 
|  | 602 |  | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 603 | status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 604 | ATRACE_CALL(); | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 605 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 606 | if (!isValidDisplay(displayId)) { | 
|  | 607 | return BAD_INDEX; | 
| Mathias Agopian | c397360 | 2012-08-31 17:51:25 -0700 | [diff] [blame] | 608 | } | 
| Pablo Ceballos | d814cf2 | 2015-09-11 14:37:39 -0700 | [diff] [blame] | 609 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 610 | auto& displayData = mDisplayData[displayId]; | 
|  | 611 | auto& hwcDisplay = displayData.hwcDisplay; | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 612 |  | 
|  | 613 | if (displayData.validateWasSkipped) { | 
| Chia-I Wu | 0c6ce46 | 2017-06-22 10:48:28 -0700 | [diff] [blame] | 614 | hwcDisplay->discardCommands(); | 
| Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 615 | 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 Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 624 | auto error = hwcDisplay->present(&displayData.lastPresentFence); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 625 | if (error != HWC2::Error::None) { | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 626 | ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)", | 
|  | 627 | displayId, to_string(error).c_str(), static_cast<int32_t>(error)); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 628 | return UNKNOWN_ERROR; | 
|  | 629 | } | 
| Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 630 |  | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 631 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 632 | error = hwcDisplay->getReleaseFences(&releaseFences); | 
|  | 633 | if (error != HWC2::Error::None) { | 
| Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 634 | ALOGE("presentAndGetReleaseFences: Failed to get release fences " | 
|  | 635 | "for display %d: %s (%d)", | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 636 | displayId, to_string(error).c_str(), | 
|  | 637 | static_cast<int32_t>(error)); | 
|  | 638 | return UNKNOWN_ERROR; | 
| Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 639 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 640 |  | 
|  | 641 | displayData.releaseFences = std::move(releaseFences); | 
|  | 642 |  | 
|  | 643 | return NO_ERROR; | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 644 | } | 
|  | 645 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 646 | status_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 Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 657 |  | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 658 | 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 Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 675 | } | 
|  | 676 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 677 | 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 Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 706 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 707 |  | 
|  | 708 | return NO_ERROR; | 
|  | 709 | } | 
|  | 710 |  | 
|  | 711 | status_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 Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 735 | status_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 Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 757 | void 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 Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 779 |  | 
|  | 780 | mHwcDevice->destroyDisplay(hwcId); | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 781 | } | 
|  | 782 |  | 
|  | 783 | status_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 |  | 
|  | 815 | void 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 Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 821 | } | 
|  | 822 |  | 
| Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 823 | std::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 McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 843 | // Converts a PixelFormat to a human-readable string.  Max 11 chars. | 
|  | 844 | // (Could use a table of prefab String8 objects.) | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 845 | /* | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 846 | static 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 McFadden | f0058ca | 2014-05-20 13:28:50 -0700 | [diff] [blame] | 853 | case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: | 
|  | 854 | return String8("ImplDef"); | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 855 | default: | 
|  | 856 | String8 result; | 
|  | 857 | result.appendFormat("? %08x", format); | 
|  | 858 | return result; | 
|  | 859 | } | 
|  | 860 | } | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 861 | */ | 
| Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 862 |  | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 863 | bool HWComposer::isUsingVrComposer() const { | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 864 | return getComposer()->isUsingVrComposer(); | 
| Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 865 | } | 
|  | 866 |  | 
| Mathias Agopian | 74d211a | 2013-04-22 16:55:35 +0200 | [diff] [blame] | 867 | void HWComposer::dump(String8& result) const { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 868 | // 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 Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 872 | } | 
|  | 873 |  | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 874 | // --------------------------------------------------------------------------- | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 875 |  | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 876 | HWComposer::DisplayData::DisplayData() | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 877 | : hasClientComposition(false), | 
|  | 878 | hasDeviceComposition(false), | 
| Steven Thomas | b02664d | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 879 | hwcDisplay(nullptr), | 
| Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 880 | lastPresentFence(Fence::NO_FENCE), | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 881 | outbufHandle(nullptr), | 
|  | 882 | outbufAcquireFence(Fence::NO_FENCE), | 
|  | 883 | vsyncEnabled(HWC2::Vsync::Disable) { | 
|  | 884 | ALOGV("Created new DisplayData"); | 
|  | 885 | } | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 886 |  | 
|  | 887 | HWComposer::DisplayData::~DisplayData() { | 
| Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 888 | } | 
|  | 889 |  | 
|  | 890 | void HWComposer::DisplayData::reset() { | 
|  | 891 | ALOGV("DisplayData reset"); | 
|  | 892 | *this = DisplayData(); | 
| Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 893 | } | 
|  | 894 |  | 
| Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 895 | // --------------------------------------------------------------------------- | 
| Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 896 | }; // namespace android |