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, |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 182 | ui::PixelFormat* 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 | |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 314 | std::vector<ui::ColorMode> HWComposer::getColorModes(int32_t displayId) const { |
| 315 | std::vector<ui::ColorMode> 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)); |
Peiyong Lin | fd997e0 | 2018-03-28 15:29:00 -0700 | [diff] [blame] | 327 | return std::vector<ui::ColorMode>(); |
Courtney Goeltzenleuchter | fad9d8c | 2016-06-23 11:49:50 -0600 | [diff] [blame] | 328 | } |
| 329 | |
| 330 | return modes; |
| 331 | } |
| 332 | |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 333 | status_t HWComposer::setActiveColorMode(int32_t displayId, ui::ColorMode mode, |
| 334 | ui::RenderIntent renderIntent) { |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 335 | if (!isValidDisplay(displayId)) { |
| 336 | ALOGE("setActiveColorMode: Display %d is not valid", displayId); |
| 337 | return BAD_INDEX; |
| 338 | } |
| 339 | |
| 340 | auto& displayData = mDisplayData[displayId]; |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 341 | auto error = displayData.hwcDisplay->setColorMode(mode, renderIntent); |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 342 | if (error != HWC2::Error::None) { |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 343 | ALOGE("setActiveConfig: Failed to set color mode %d" |
| 344 | "with render intent %d on display %d: " |
| 345 | "%s (%d)", mode, renderIntent, displayId, |
| 346 | to_string(error).c_str(), |
Michael Wright | 28f24d0 | 2016-07-12 13:30:53 -0700 | [diff] [blame] | 347 | static_cast<int32_t>(error)); |
| 348 | return UNKNOWN_ERROR; |
| 349 | } |
| 350 | |
| 351 | return NO_ERROR; |
| 352 | } |
| 353 | |
| 354 | |
Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 355 | void HWComposer::setVsyncEnabled(int32_t displayId, HWC2::Vsync enabled) { |
| 356 | if (displayId < 0 || displayId >= HWC_DISPLAY_VIRTUAL) { |
| 357 | ALOGD("setVsyncEnabled: Ignoring for virtual display %d", displayId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 358 | return; |
| 359 | } |
| 360 | |
Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 361 | if (!isValidDisplay(displayId)) { |
| 362 | ALOGE("setVsyncEnabled: Attempted to access invalid display %d", |
| 363 | displayId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 364 | return; |
| 365 | } |
| 366 | |
| 367 | // NOTE: we use our own internal lock here because we have to call |
| 368 | // into the HWC with the lock held, and we want to make sure |
| 369 | // that even if HWC blocks (which it shouldn't), it won't |
| 370 | // affect other threads. |
| 371 | Mutex::Autolock _l(mVsyncLock); |
Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 372 | auto& displayData = mDisplayData[displayId]; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 373 | if (enabled != displayData.vsyncEnabled) { |
| 374 | ATRACE_CALL(); |
| 375 | auto error = displayData.hwcDisplay->setVsyncEnabled(enabled); |
| 376 | if (error == HWC2::Error::None) { |
| 377 | displayData.vsyncEnabled = enabled; |
| 378 | |
| 379 | char tag[16]; |
Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 380 | snprintf(tag, sizeof(tag), "HW_VSYNC_ON_%1u", displayId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 381 | ATRACE_INT(tag, enabled == HWC2::Vsync::Enable ? 1 : 0); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 382 | } else { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 383 | ALOGE("setVsyncEnabled: Failed to set vsync to %s on %d/%" PRIu64 |
Fabien Sanglard | df0b705 | 2016-11-30 15:51:53 -0800 | [diff] [blame] | 384 | ": %s (%d)", to_string(enabled).c_str(), displayId, |
| 385 | mDisplayData[displayId].hwcDisplay->getId(), |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 386 | to_string(error).c_str(), static_cast<int32_t>(error)); |
Prashant Malani | 2c9b11f | 2014-05-25 01:36:31 -0700 | [diff] [blame] | 387 | } |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 388 | } |
Colin Cross | 10fbdb6 | 2012-07-12 17:56:34 -0700 | [diff] [blame] | 389 | } |
| 390 | |
Chia-I Wu | 06d63de | 2017-01-04 14:58:51 +0800 | [diff] [blame] | 391 | status_t HWComposer::setClientTarget(int32_t displayId, uint32_t slot, |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 392 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& target, |
Peiyong Lin | 34beb7a | 2018-03-28 11:57:12 -0700 | [diff] [blame] | 393 | ui::Dataspace dataspace) { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 394 | if (!isValidDisplay(displayId)) { |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 395 | return BAD_INDEX; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 396 | } |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 397 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 398 | ALOGV("setClientTarget for display %d", displayId); |
| 399 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
Daniel Nicoara | 1f42e3a | 2017-04-10 13:27:32 -0400 | [diff] [blame] | 400 | auto error = hwcDisplay->setClientTarget(slot, target, acquireFence, dataspace); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 401 | if (error != HWC2::Error::None) { |
| 402 | ALOGE("Failed to set client target for display %d: %s (%d)", displayId, |
| 403 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 404 | return BAD_VALUE; |
| 405 | } |
| 406 | |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 407 | return NO_ERROR; |
| 408 | } |
| 409 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 410 | status_t HWComposer::prepare(DisplayDevice& displayDevice) { |
| 411 | ATRACE_CALL(); |
| 412 | |
| 413 | Mutex::Autolock _l(mDisplayLock); |
| 414 | auto displayId = displayDevice.getHwcDisplayId(); |
Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 415 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { |
| 416 | ALOGV("Skipping HWComposer prepare for non-HWC display"); |
| 417 | return NO_ERROR; |
| 418 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 419 | if (!isValidDisplay(displayId)) { |
| 420 | return BAD_INDEX; |
| 421 | } |
| 422 | |
| 423 | auto& displayData = mDisplayData[displayId]; |
| 424 | auto& hwcDisplay = displayData.hwcDisplay; |
| 425 | if (!hwcDisplay->isConnected()) { |
| 426 | return NO_ERROR; |
| 427 | } |
| 428 | |
| 429 | uint32_t numTypes = 0; |
| 430 | uint32_t numRequests = 0; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 431 | |
| 432 | HWC2::Error error = HWC2::Error::None; |
| 433 | |
Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 434 | // First try to skip validate altogether when there is no client |
| 435 | // composition. When there is client composition, since we haven't |
| 436 | // rendered to the client target yet, we should not attempt to skip |
| 437 | // validate. |
| 438 | // |
| 439 | // displayData.hasClientComposition hasn't been updated for this frame. |
| 440 | // The check below is incorrect. We actually rely on HWC here to fall |
| 441 | // back to validate when there is any client layer. |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 442 | displayData.validateWasSkipped = false; |
Chia-I Wu | 41b98d4 | 2017-12-11 11:04:36 -0800 | [diff] [blame] | 443 | if (!displayData.hasClientComposition) { |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 444 | sp<android::Fence> outPresentFence; |
| 445 | uint32_t state = UINT32_MAX; |
| 446 | error = hwcDisplay->presentOrValidate(&numTypes, &numRequests, &outPresentFence , &state); |
| 447 | if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) { |
| 448 | ALOGV("skipValidate: Failed to Present or Validate"); |
| 449 | return UNKNOWN_ERROR; |
| 450 | } |
| 451 | if (state == 1) { //Present Succeeded. |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 452 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 453 | error = hwcDisplay->getReleaseFences(&releaseFences); |
| 454 | displayData.releaseFences = std::move(releaseFences); |
| 455 | displayData.lastPresentFence = outPresentFence; |
| 456 | displayData.validateWasSkipped = true; |
| 457 | displayData.presentError = error; |
| 458 | return NO_ERROR; |
| 459 | } |
| 460 | // Present failed but Validate ran. |
| 461 | } else { |
| 462 | error = hwcDisplay->validate(&numTypes, &numRequests); |
| 463 | } |
| 464 | ALOGV("SkipValidate failed, Falling back to SLOW validate/present"); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 465 | if (error != HWC2::Error::None && error != HWC2::Error::HasChanges) { |
| 466 | ALOGE("prepare: validate failed for display %d: %s (%d)", displayId, |
| 467 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 468 | return BAD_INDEX; |
| 469 | } |
| 470 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 471 | std::unordered_map<HWC2::Layer*, HWC2::Composition> changedTypes; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 472 | changedTypes.reserve(numTypes); |
| 473 | error = hwcDisplay->getChangedCompositionTypes(&changedTypes); |
| 474 | if (error != HWC2::Error::None) { |
| 475 | ALOGE("prepare: getChangedCompositionTypes failed on display %d: " |
| 476 | "%s (%d)", displayId, to_string(error).c_str(), |
| 477 | static_cast<int32_t>(error)); |
| 478 | return BAD_INDEX; |
| 479 | } |
| 480 | |
| 481 | |
| 482 | displayData.displayRequests = static_cast<HWC2::DisplayRequest>(0); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 483 | std::unordered_map<HWC2::Layer*, HWC2::LayerRequest> layerRequests; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 484 | layerRequests.reserve(numRequests); |
| 485 | error = hwcDisplay->getRequests(&displayData.displayRequests, |
| 486 | &layerRequests); |
| 487 | if (error != HWC2::Error::None) { |
| 488 | ALOGE("prepare: getRequests failed on display %d: %s (%d)", displayId, |
| 489 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 490 | return BAD_INDEX; |
| 491 | } |
| 492 | |
| 493 | displayData.hasClientComposition = false; |
| 494 | displayData.hasDeviceComposition = false; |
| 495 | for (auto& layer : displayDevice.getVisibleLayersSortedByZ()) { |
| 496 | auto hwcLayer = layer->getHwcLayer(displayId); |
| 497 | |
| 498 | if (changedTypes.count(hwcLayer) != 0) { |
| 499 | // We pass false so we only update our state and don't call back |
| 500 | // into the HWC device |
| 501 | validateChange(layer->getCompositionType(displayId), |
| 502 | changedTypes[hwcLayer]); |
| 503 | layer->setCompositionType(displayId, changedTypes[hwcLayer], false); |
| 504 | } |
| 505 | |
| 506 | switch (layer->getCompositionType(displayId)) { |
| 507 | case HWC2::Composition::Client: |
| 508 | displayData.hasClientComposition = true; |
| 509 | break; |
| 510 | case HWC2::Composition::Device: |
| 511 | case HWC2::Composition::SolidColor: |
| 512 | case HWC2::Composition::Cursor: |
| 513 | case HWC2::Composition::Sideband: |
| 514 | displayData.hasDeviceComposition = true; |
| 515 | break; |
| 516 | default: |
| 517 | break; |
| 518 | } |
| 519 | |
| 520 | if (layerRequests.count(hwcLayer) != 0 && |
| 521 | layerRequests[hwcLayer] == |
| 522 | HWC2::LayerRequest::ClearClientTarget) { |
| 523 | layer->setClearClientTarget(displayId, true); |
| 524 | } else { |
| 525 | if (layerRequests.count(hwcLayer) != 0) { |
| 526 | ALOGE("prepare: Unknown layer request: %s", |
| 527 | to_string(layerRequests[hwcLayer]).c_str()); |
| 528 | } |
| 529 | layer->setClearClientTarget(displayId, false); |
| 530 | } |
| 531 | } |
| 532 | |
| 533 | error = hwcDisplay->acceptChanges(); |
| 534 | if (error != HWC2::Error::None) { |
| 535 | ALOGE("prepare: acceptChanges failed: %s", to_string(error).c_str()); |
| 536 | return BAD_INDEX; |
| 537 | } |
| 538 | |
| 539 | return NO_ERROR; |
| 540 | } |
| 541 | |
| 542 | bool HWComposer::hasDeviceComposition(int32_t displayId) const { |
Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 543 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { |
| 544 | // Displays without a corresponding HWC display are never composed by |
| 545 | // the device |
| 546 | return false; |
| 547 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 548 | if (!isValidDisplay(displayId)) { |
| 549 | ALOGE("hasDeviceComposition: Invalid display %d", displayId); |
| 550 | return false; |
| 551 | } |
| 552 | return mDisplayData[displayId].hasDeviceComposition; |
| 553 | } |
| 554 | |
Madhuri Athota | 88a905b | 2017-05-04 16:58:15 +0530 | [diff] [blame] | 555 | bool HWComposer::hasFlipClientTargetRequest(int32_t displayId) const { |
| 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 | } |
| 561 | if (!isValidDisplay(displayId)) { |
| 562 | ALOGE("hasFlipClientTargetRequest: Invalid display %d", displayId); |
| 563 | return false; |
| 564 | } |
| 565 | return ((static_cast<uint32_t>(mDisplayData[displayId].displayRequests) & |
| 566 | static_cast<uint32_t>(HWC2::DisplayRequest::FlipClientTarget)) != 0); |
| 567 | } |
| 568 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 569 | bool HWComposer::hasClientComposition(int32_t displayId) const { |
Dan Stoza | ec0f717 | 2016-07-21 11:09:40 -0700 | [diff] [blame] | 570 | if (displayId == DisplayDevice::DISPLAY_ID_INVALID) { |
| 571 | // Displays without a corresponding HWC display are always composed by |
| 572 | // the client |
| 573 | return true; |
| 574 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 575 | if (!isValidDisplay(displayId)) { |
| 576 | ALOGE("hasClientComposition: Invalid display %d", displayId); |
| 577 | return true; |
| 578 | } |
| 579 | return mDisplayData[displayId].hasClientComposition; |
| 580 | } |
| 581 | |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 582 | sp<Fence> HWComposer::getPresentFence(int32_t displayId) const { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 583 | if (!isValidDisplay(displayId)) { |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 584 | ALOGE("getPresentFence failed for invalid display %d", displayId); |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 585 | return Fence::NO_FENCE; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 586 | } |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 587 | return mDisplayData[displayId].lastPresentFence; |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 588 | } |
| 589 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 590 | sp<Fence> HWComposer::getLayerReleaseFence(int32_t displayId, |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 591 | HWC2::Layer* layer) const { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 592 | if (!isValidDisplay(displayId)) { |
| 593 | ALOGE("getLayerReleaseFence: Invalid display"); |
| 594 | return Fence::NO_FENCE; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 595 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 596 | auto displayFences = mDisplayData[displayId].releaseFences; |
| 597 | if (displayFences.count(layer) == 0) { |
| 598 | ALOGV("getLayerReleaseFence: Release fence not found"); |
| 599 | return Fence::NO_FENCE; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 600 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 601 | return displayFences[layer]; |
Riley Andrews | 03414a1 | 2014-07-01 14:22:59 -0700 | [diff] [blame] | 602 | } |
| 603 | |
Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 604 | status_t HWComposer::presentAndGetReleaseFences(int32_t displayId) { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 605 | ATRACE_CALL(); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 606 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 607 | if (!isValidDisplay(displayId)) { |
| 608 | return BAD_INDEX; |
Mathias Agopian | c397360 | 2012-08-31 17:51:25 -0700 | [diff] [blame] | 609 | } |
Pablo Ceballos | d814cf2 | 2015-09-11 14:37:39 -0700 | [diff] [blame] | 610 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 611 | auto& displayData = mDisplayData[displayId]; |
| 612 | auto& hwcDisplay = displayData.hwcDisplay; |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 613 | |
| 614 | if (displayData.validateWasSkipped) { |
Chia-I Wu | ae5a6b8 | 2017-10-10 09:09:22 -0700 | [diff] [blame] | 615 | // explicitly flush all pending commands |
| 616 | auto error = mHwcDevice->flushCommands(); |
| 617 | if (displayData.presentError != HWC2::Error::None) { |
| 618 | error = displayData.presentError; |
| 619 | } |
Fabien Sanglard | 249c0ae | 2017-06-19 19:22:36 -0700 | [diff] [blame] | 620 | if (error != HWC2::Error::None) { |
| 621 | ALOGE("skipValidate: failed for display %d: %s (%d)", |
| 622 | displayId, to_string(error).c_str(), static_cast<int32_t>(error)); |
| 623 | return UNKNOWN_ERROR; |
| 624 | } |
| 625 | return NO_ERROR; |
| 626 | } |
| 627 | |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 628 | auto error = hwcDisplay->present(&displayData.lastPresentFence); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 629 | if (error != HWC2::Error::None) { |
Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 630 | ALOGE("presentAndGetReleaseFences: failed for display %d: %s (%d)", |
| 631 | displayId, to_string(error).c_str(), static_cast<int32_t>(error)); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 632 | return UNKNOWN_ERROR; |
| 633 | } |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 634 | |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 635 | std::unordered_map<HWC2::Layer*, sp<Fence>> releaseFences; |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 636 | error = hwcDisplay->getReleaseFences(&releaseFences); |
| 637 | if (error != HWC2::Error::None) { |
Fabien Sanglard | a87aa7b | 2016-11-30 16:27:22 -0800 | [diff] [blame] | 638 | ALOGE("presentAndGetReleaseFences: Failed to get release fences " |
| 639 | "for display %d: %s (%d)", |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 640 | displayId, to_string(error).c_str(), |
| 641 | static_cast<int32_t>(error)); |
| 642 | return UNKNOWN_ERROR; |
Mathias Agopian | f435863 | 2012-08-22 17:16:19 -0700 | [diff] [blame] | 643 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 644 | |
| 645 | displayData.releaseFences = std::move(releaseFences); |
| 646 | |
| 647 | return NO_ERROR; |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 648 | } |
| 649 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 650 | status_t HWComposer::setPowerMode(int32_t displayId, int32_t intMode) { |
| 651 | ALOGV("setPowerMode(%d, %d)", displayId, intMode); |
| 652 | if (!isValidDisplay(displayId)) { |
| 653 | ALOGE("setPowerMode: Bad display"); |
| 654 | return BAD_INDEX; |
| 655 | } |
| 656 | if (displayId >= VIRTUAL_DISPLAY_ID_BASE) { |
| 657 | ALOGE("setPowerMode: Virtual display %d passed in, returning", |
| 658 | displayId); |
| 659 | return BAD_INDEX; |
| 660 | } |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 661 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 662 | auto mode = static_cast<HWC2::PowerMode>(intMode); |
| 663 | if (mode == HWC2::PowerMode::Off) { |
| 664 | setVsyncEnabled(displayId, HWC2::Vsync::Disable); |
| 665 | } |
| 666 | |
| 667 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
| 668 | switch (mode) { |
| 669 | case HWC2::PowerMode::Off: |
| 670 | case HWC2::PowerMode::On: |
| 671 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); |
| 672 | { |
| 673 | auto error = hwcDisplay->setPowerMode(mode); |
| 674 | if (error != HWC2::Error::None) { |
| 675 | ALOGE("setPowerMode: Unable to set power mode %s for " |
| 676 | "display %d: %s (%d)", to_string(mode).c_str(), |
| 677 | displayId, to_string(error).c_str(), |
| 678 | static_cast<int32_t>(error)); |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 679 | } |
| 680 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 681 | break; |
| 682 | case HWC2::PowerMode::Doze: |
| 683 | case HWC2::PowerMode::DozeSuspend: |
| 684 | ALOGV("setPowerMode: Calling HWC %s", to_string(mode).c_str()); |
| 685 | { |
| 686 | bool supportsDoze = false; |
| 687 | auto error = hwcDisplay->supportsDoze(&supportsDoze); |
| 688 | if (error != HWC2::Error::None) { |
| 689 | ALOGE("setPowerMode: Unable to query doze support for " |
| 690 | "display %d: %s (%d)", displayId, |
| 691 | to_string(error).c_str(), |
| 692 | static_cast<int32_t>(error)); |
| 693 | } |
| 694 | if (!supportsDoze) { |
| 695 | mode = HWC2::PowerMode::On; |
| 696 | } |
| 697 | |
| 698 | error = hwcDisplay->setPowerMode(mode); |
| 699 | if (error != HWC2::Error::None) { |
| 700 | ALOGE("setPowerMode: Unable to set power mode %s for " |
| 701 | "display %d: %s (%d)", to_string(mode).c_str(), |
| 702 | displayId, to_string(error).c_str(), |
| 703 | static_cast<int32_t>(error)); |
| 704 | } |
| 705 | } |
| 706 | break; |
| 707 | default: |
| 708 | ALOGV("setPowerMode: Not calling HWC"); |
| 709 | break; |
Mathias Agopian | da27af9 | 2012-09-13 18:17:13 -0700 | [diff] [blame] | 710 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 711 | |
| 712 | return NO_ERROR; |
| 713 | } |
| 714 | |
| 715 | status_t HWComposer::setActiveConfig(int32_t displayId, size_t configId) { |
| 716 | if (!isValidDisplay(displayId)) { |
| 717 | ALOGE("setActiveConfig: Display %d is not valid", displayId); |
| 718 | return BAD_INDEX; |
| 719 | } |
| 720 | |
| 721 | auto& displayData = mDisplayData[displayId]; |
| 722 | if (displayData.configMap.count(configId) == 0) { |
| 723 | ALOGE("setActiveConfig: Invalid config %zd", configId); |
| 724 | return BAD_INDEX; |
| 725 | } |
| 726 | |
| 727 | auto error = displayData.hwcDisplay->setActiveConfig( |
| 728 | displayData.configMap[configId]); |
| 729 | if (error != HWC2::Error::None) { |
| 730 | ALOGE("setActiveConfig: Failed to set config %zu on display %d: " |
| 731 | "%s (%d)", configId, displayId, to_string(error).c_str(), |
| 732 | static_cast<int32_t>(error)); |
| 733 | return UNKNOWN_ERROR; |
| 734 | } |
| 735 | |
| 736 | return NO_ERROR; |
| 737 | } |
| 738 | |
Dan Stoza | 9f26a9c | 2016-06-22 14:51:09 -0700 | [diff] [blame] | 739 | status_t HWComposer::setColorTransform(int32_t displayId, |
| 740 | const mat4& transform) { |
| 741 | if (!isValidDisplay(displayId)) { |
| 742 | ALOGE("setColorTransform: Display %d is not valid", displayId); |
| 743 | return BAD_INDEX; |
| 744 | } |
| 745 | |
| 746 | auto& displayData = mDisplayData[displayId]; |
| 747 | bool isIdentity = transform == mat4(); |
| 748 | auto error = displayData.hwcDisplay->setColorTransform(transform, |
| 749 | isIdentity ? HAL_COLOR_TRANSFORM_IDENTITY : |
| 750 | HAL_COLOR_TRANSFORM_ARBITRARY_MATRIX); |
| 751 | if (error != HWC2::Error::None) { |
| 752 | ALOGE("setColorTransform: Failed to set transform on display %d: " |
| 753 | "%s (%d)", displayId, to_string(error).c_str(), |
| 754 | static_cast<int32_t>(error)); |
| 755 | return UNKNOWN_ERROR; |
| 756 | } |
| 757 | |
| 758 | return NO_ERROR; |
| 759 | } |
| 760 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 761 | void HWComposer::disconnectDisplay(int displayId) { |
| 762 | LOG_ALWAYS_FATAL_IF(displayId < 0); |
| 763 | auto& displayData = mDisplayData[displayId]; |
| 764 | |
| 765 | auto displayType = HWC2::DisplayType::Invalid; |
| 766 | auto error = displayData.hwcDisplay->getType(&displayType); |
| 767 | if (error != HWC2::Error::None) { |
| 768 | ALOGE("disconnectDisplay: Failed to determine type of display %d", |
| 769 | displayId); |
| 770 | return; |
| 771 | } |
| 772 | |
| 773 | // If this was a virtual display, add its slot back for reuse by future |
| 774 | // virtual displays |
| 775 | if (displayType == HWC2::DisplayType::Virtual) { |
| 776 | mFreeDisplaySlots.insert(displayId); |
| 777 | ++mRemainingHwcVirtualDisplays; |
| 778 | } |
| 779 | |
| 780 | auto hwcId = displayData.hwcDisplay->getId(); |
| 781 | mHwcDisplaySlots.erase(hwcId); |
| 782 | displayData.reset(); |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 783 | |
| 784 | mHwcDevice->destroyDisplay(hwcId); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 785 | } |
| 786 | |
| 787 | status_t HWComposer::setOutputBuffer(int32_t displayId, |
| 788 | const sp<Fence>& acquireFence, const sp<GraphicBuffer>& buffer) { |
| 789 | if (!isValidDisplay(displayId)) { |
| 790 | ALOGE("setOutputBuffer: Display %d is not valid", displayId); |
| 791 | return BAD_INDEX; |
| 792 | } |
| 793 | |
| 794 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
| 795 | auto displayType = HWC2::DisplayType::Invalid; |
| 796 | auto error = hwcDisplay->getType(&displayType); |
| 797 | if (error != HWC2::Error::None) { |
| 798 | ALOGE("setOutputBuffer: Failed to determine type of display %d", |
| 799 | displayId); |
| 800 | return NAME_NOT_FOUND; |
| 801 | } |
| 802 | |
| 803 | if (displayType != HWC2::DisplayType::Virtual) { |
| 804 | ALOGE("setOutputBuffer: Display %d is not virtual", displayId); |
| 805 | return INVALID_OPERATION; |
| 806 | } |
| 807 | |
| 808 | error = hwcDisplay->setOutputBuffer(buffer, acquireFence); |
| 809 | if (error != HWC2::Error::None) { |
| 810 | ALOGE("setOutputBuffer: Failed to set buffer on display %d: %s (%d)", |
| 811 | displayId, to_string(error).c_str(), |
| 812 | static_cast<int32_t>(error)); |
| 813 | return UNKNOWN_ERROR; |
| 814 | } |
| 815 | |
| 816 | return NO_ERROR; |
| 817 | } |
| 818 | |
| 819 | void HWComposer::clearReleaseFences(int32_t displayId) { |
| 820 | if (!isValidDisplay(displayId)) { |
| 821 | ALOGE("clearReleaseFences: Display %d is not valid", displayId); |
| 822 | return; |
| 823 | } |
| 824 | mDisplayData[displayId].releaseFences.clear(); |
Mathias Agopian | 3e8b853 | 2012-05-13 20:42:01 -0700 | [diff] [blame] | 825 | } |
| 826 | |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 827 | status_t HWComposer::getHdrCapabilities( |
| 828 | int32_t displayId, HdrCapabilities* outCapabilities) { |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 829 | if (!isValidDisplay(displayId)) { |
| 830 | ALOGE("getHdrCapabilities: Display %d is not valid", displayId); |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 831 | return BAD_INDEX; |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 832 | } |
| 833 | |
| 834 | auto& hwcDisplay = mDisplayData[displayId].hwcDisplay; |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 835 | auto error = hwcDisplay->getHdrCapabilities(outCapabilities); |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 836 | if (error != HWC2::Error::None) { |
| 837 | ALOGE("getOutputCapabilities: Failed to get capabilities on display %d:" |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 838 | " %s (%d)", displayId, to_string(error).c_str(), |
| 839 | static_cast<int32_t>(error)); |
| 840 | return UNKNOWN_ERROR; |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 841 | } |
Peiyong Lin | 6266589 | 2018-04-16 11:07:44 -0700 | [diff] [blame] | 842 | return NO_ERROR; |
Dan Stoza | c4f471e | 2016-03-24 09:31:08 -0700 | [diff] [blame] | 843 | } |
| 844 | |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame^] | 845 | int32_t HWComposer::getSupportedPerFrameMetadata(int32_t displayId) const { |
| 846 | if (!isValidDisplay(displayId)) { |
| 847 | ALOGE("getPerFrameMetadataKeys: Attempted to access invalid display %d", |
| 848 | displayId); |
| 849 | return 0; |
| 850 | } |
| 851 | |
| 852 | int32_t supportedMetadata; |
| 853 | auto error = mDisplayData[displayId].hwcDisplay->getSupportedPerFrameMetadata( |
| 854 | &supportedMetadata); |
| 855 | if (error != HWC2::Error::None) { |
| 856 | ALOGE("getPerFrameMetadataKeys failed for display %d: %s (%d)", displayId, |
| 857 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 858 | return 0; |
| 859 | } |
| 860 | |
| 861 | return supportedMetadata; |
| 862 | } |
| 863 | |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 864 | std::vector<ui::RenderIntent> HWComposer::getRenderIntents(int32_t displayId, |
| 865 | ui::ColorMode colorMode) const { |
| 866 | if (!isValidDisplay(displayId)) { |
| 867 | ALOGE("getRenderIntents: Attempted to access invalid display %d", |
| 868 | displayId); |
| 869 | return {}; |
| 870 | } |
| 871 | |
| 872 | std::vector<ui::RenderIntent> renderIntents; |
| 873 | auto error = mDisplayData[displayId].hwcDisplay->getRenderIntents(colorMode, &renderIntents); |
| 874 | if (error != HWC2::Error::None) { |
Peiyong Lin | 0ac5f4e | 2018-04-19 22:06:34 -0700 | [diff] [blame^] | 875 | ALOGE("getRenderIntents failed for display %d: %s (%d)", displayId, |
Peiyong Lin | 0e7a791 | 2018-04-05 14:36:36 -0700 | [diff] [blame] | 876 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 877 | return std::vector<ui::RenderIntent>(); |
| 878 | } |
| 879 | |
| 880 | return renderIntents; |
| 881 | } |
| 882 | |
| 883 | mat4 HWComposer::getDataspaceSaturationMatrix(int32_t displayId, ui::Dataspace dataspace) { |
| 884 | if (!isValidDisplay(displayId)) { |
| 885 | ALOGE("getDataSpaceSaturationMatrix: Attempted to access invalid display %d", |
| 886 | displayId); |
| 887 | return {}; |
| 888 | } |
| 889 | |
| 890 | mat4 matrix; |
| 891 | auto error = mDisplayData[displayId].hwcDisplay->getDataspaceSaturationMatrix(dataspace, |
| 892 | &matrix); |
| 893 | if (error != HWC2::Error::None) { |
| 894 | ALOGE("getDataSpaceSaturationMatrix failed for display %d: %s (%d)", displayId, |
| 895 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 896 | return mat4(); |
| 897 | } |
| 898 | |
| 899 | return matrix; |
| 900 | } |
| 901 | |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 902 | // Converts a PixelFormat to a human-readable string. Max 11 chars. |
| 903 | // (Could use a table of prefab String8 objects.) |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 904 | /* |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 905 | static String8 getFormatStr(PixelFormat format) { |
| 906 | switch (format) { |
| 907 | case PIXEL_FORMAT_RGBA_8888: return String8("RGBA_8888"); |
| 908 | case PIXEL_FORMAT_RGBX_8888: return String8("RGBx_8888"); |
| 909 | case PIXEL_FORMAT_RGB_888: return String8("RGB_888"); |
| 910 | case PIXEL_FORMAT_RGB_565: return String8("RGB_565"); |
| 911 | case PIXEL_FORMAT_BGRA_8888: return String8("BGRA_8888"); |
Andy McFadden | f0058ca | 2014-05-20 13:28:50 -0700 | [diff] [blame] | 912 | case HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED: |
| 913 | return String8("ImplDef"); |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 914 | default: |
| 915 | String8 result; |
| 916 | result.appendFormat("? %08x", format); |
| 917 | return result; |
| 918 | } |
| 919 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 920 | */ |
Andy McFadden | 4df87bd | 2014-04-21 18:08:54 -0700 | [diff] [blame] | 921 | |
Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 922 | bool HWComposer::isUsingVrComposer() const { |
Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 923 | return getComposer()->isUsingVrComposer(); |
Hendrik Wagenaar | 87670ff | 2017-02-01 12:10:46 -0800 | [diff] [blame] | 924 | } |
| 925 | |
Mathias Agopian | 74d211a | 2013-04-22 16:55:35 +0200 | [diff] [blame] | 926 | void HWComposer::dump(String8& result) const { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 927 | // TODO: In order to provide a dump equivalent to HWC1, we need to shadow |
| 928 | // all the state going into the layers. This is probably better done in |
| 929 | // Layer itself, but it's going to take a bit of work to get there. |
| 930 | result.append(mHwcDevice->dump().c_str()); |
Mathias Agopian | 8372785 | 2010-09-23 18:13:21 -0700 | [diff] [blame] | 931 | } |
| 932 | |
Steven Thomas | 6e8f706 | 2017-11-22 14:15:29 -0800 | [diff] [blame] | 933 | std::optional<hwc2_display_t> |
| 934 | HWComposer::getHwcDisplayId(int32_t displayId) const { |
| 935 | if (!isValidDisplay(displayId)) { |
| 936 | return {}; |
| 937 | } |
| 938 | return mDisplayData[displayId].hwcDisplay->getId(); |
| 939 | } |
| 940 | |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 941 | // --------------------------------------------------------------------------- |
Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 942 | |
Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 943 | HWComposer::DisplayData::DisplayData() |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 944 | : hasClientComposition(false), |
| 945 | hasDeviceComposition(false), |
Steven Thomas | 94e35b9 | 2017-07-26 18:48:28 -0700 | [diff] [blame] | 946 | hwcDisplay(nullptr), |
Fabien Sanglard | 11d0fc3 | 2016-12-01 15:43:01 -0800 | [diff] [blame] | 947 | lastPresentFence(Fence::NO_FENCE), |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 948 | outbufHandle(nullptr), |
| 949 | outbufAcquireFence(Fence::NO_FENCE), |
| 950 | vsyncEnabled(HWC2::Vsync::Disable) { |
| 951 | ALOGV("Created new DisplayData"); |
| 952 | } |
Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 953 | |
| 954 | HWComposer::DisplayData::~DisplayData() { |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 955 | } |
| 956 | |
| 957 | void HWComposer::DisplayData::reset() { |
| 958 | ALOGV("DisplayData reset"); |
| 959 | *this = DisplayData(); |
Jesse Hall | a9a1b00 | 2013-02-27 16:39:25 -0800 | [diff] [blame] | 960 | } |
| 961 | |
Mathias Agopian | 2965b26 | 2012-04-08 15:13:32 -0700 | [diff] [blame] | 962 | // --------------------------------------------------------------------------- |
Mathias Agopian | a350ff9 | 2010-08-10 17:14:02 -0700 | [diff] [blame] | 963 | }; // namespace android |