David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2017 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 | |
| 17 | //#define LOG_NDEBUG 0 |
| 18 | #undef LOG_TAG |
| 19 | #define LOG_TAG "BufferLayer" |
| 20 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 21 | |
| 22 | #include "BufferLayer.h" |
| 23 | #include "Colorizer.h" |
| 24 | #include "DisplayDevice.h" |
| 25 | #include "LayerRejecter.h" |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 26 | |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 27 | #include "TimeStats/TimeStats.h" |
| 28 | |
Peiyong Lin | cbc184f | 2018-08-22 13:24:10 -0700 | [diff] [blame] | 29 | #include <renderengine/RenderEngine.h> |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 30 | |
| 31 | #include <gui/BufferItem.h> |
| 32 | #include <gui/BufferQueue.h> |
| 33 | #include <gui/LayerDebugInfo.h> |
| 34 | #include <gui/Surface.h> |
| 35 | |
| 36 | #include <ui/DebugUtils.h> |
| 37 | |
| 38 | #include <utils/Errors.h> |
| 39 | #include <utils/Log.h> |
| 40 | #include <utils/NativeHandle.h> |
| 41 | #include <utils/StopWatch.h> |
| 42 | #include <utils/Trace.h> |
| 43 | |
| 44 | #include <cutils/compiler.h> |
| 45 | #include <cutils/native_handle.h> |
| 46 | #include <cutils/properties.h> |
| 47 | |
| 48 | #include <math.h> |
| 49 | #include <stdlib.h> |
| 50 | #include <mutex> |
| 51 | |
| 52 | namespace android { |
| 53 | |
Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 54 | BufferLayer::BufferLayer(const LayerCreationArgs& args) |
| 55 | : Layer(args), mTextureName(args.flinger->getNewTexture()) { |
| 56 | ALOGV("Creating Layer %s", args.name.string()); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 57 | |
Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 58 | mPremultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 59 | |
Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 60 | mPotentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow; |
| 61 | mProtectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | BufferLayer::~BufferLayer() { |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 65 | mFlinger->deleteTextureAsync(mTextureName); |
| 66 | |
David Sodman | 6f65f3e | 2017-11-03 14:28:09 -0700 | [diff] [blame] | 67 | if (!getBE().mHwcLayers.empty()) { |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 68 | ALOGE("Found stale hardware composer layers when destroying " |
| 69 | "surface flinger layer %s", |
| 70 | mName.string()); |
chaviw | 61626f2 | 2018-11-15 16:26:27 -0800 | [diff] [blame] | 71 | destroyAllHwcLayersPlusChildren(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 72 | } |
Yiwei Zhang | dc22404 | 2018-10-18 15:34:00 -0700 | [diff] [blame] | 73 | |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 74 | mFlinger->mTimeStats->onDestroy(getSequence()); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 75 | } |
| 76 | |
David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 77 | void BufferLayer::useSurfaceDamage() { |
| 78 | if (mFlinger->mForceFullDamage) { |
| 79 | surfaceDamageRegion = Region::INVALID_REGION; |
| 80 | } else { |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 81 | surfaceDamageRegion = getDrawingSurfaceDamage(); |
David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 82 | } |
| 83 | } |
| 84 | |
| 85 | void BufferLayer::useEmptyDamage() { |
| 86 | surfaceDamageRegion.clear(); |
| 87 | } |
| 88 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 89 | bool BufferLayer::isOpaque(const Layer::State& s) const { |
| 90 | // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the |
| 91 | // layer's opaque flag. |
| 92 | if ((getBE().compositionInfo.hwc.sidebandStream == nullptr) && (mActiveBuffer == nullptr)) { |
| 93 | return false; |
| 94 | } |
| 95 | |
| 96 | // if the layer has the opaque flag, then we're always opaque, |
| 97 | // otherwise we use the current buffer's format. |
| 98 | return ((s.flags & layer_state_t::eLayerOpaque) != 0) || getOpacityForFormat(getPixelFormat()); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | bool BufferLayer::isVisible() const { |
| 102 | return !(isHiddenByPolicy()) && getAlpha() > 0.0f && |
David Sodman | 0cf8f8d | 2017-12-20 18:19:45 -0800 | [diff] [blame] | 103 | (mActiveBuffer != nullptr || getBE().compositionInfo.hwc.sidebandStream != nullptr); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 104 | } |
| 105 | |
| 106 | bool BufferLayer::isFixedSize() const { |
| 107 | return getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE; |
| 108 | } |
| 109 | |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 110 | static constexpr mat4 inverseOrientation(uint32_t transform) { |
David Sodman | 41fdfc9 | 2017-11-06 16:09:56 -0800 | [diff] [blame] | 111 | const mat4 flipH(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1); |
| 112 | const mat4 flipV(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1); |
| 113 | const mat4 rot90(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 114 | mat4 tr; |
| 115 | |
| 116 | if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90) { |
| 117 | tr = tr * rot90; |
| 118 | } |
| 119 | if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H) { |
| 120 | tr = tr * flipH; |
| 121 | } |
| 122 | if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V) { |
| 123 | tr = tr * flipV; |
| 124 | } |
| 125 | return inverse(tr); |
| 126 | } |
| 127 | |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 128 | bool BufferLayer::prepareClientLayer(const RenderArea& renderArea, const Region& clip, |
| 129 | bool useIdentityTransform, Region& clearRegion, |
| 130 | renderengine::LayerSettings& layer) { |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 131 | ATRACE_CALL(); |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 132 | Layer::prepareClientLayer(renderArea, clip, useIdentityTransform, clearRegion, layer); |
David Sodman | 0cf8f8d | 2017-12-20 18:19:45 -0800 | [diff] [blame] | 133 | if (CC_UNLIKELY(mActiveBuffer == 0)) { |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 134 | // the texture has not been created yet, this Layer has |
| 135 | // in fact never been drawn into. This happens frequently with |
| 136 | // SurfaceView because the WindowManager can't know when the client |
| 137 | // has drawn the first time. |
| 138 | |
| 139 | // If there is nothing under us, we paint the screen in black, otherwise |
| 140 | // we just skip this update. |
| 141 | |
| 142 | // figure out if there is something below us |
| 143 | Region under; |
| 144 | bool finished = false; |
| 145 | mFlinger->mDrawingState.traverseInZOrder([&](Layer* layer) { |
| 146 | if (finished || layer == static_cast<BufferLayer const*>(this)) { |
| 147 | finished = true; |
| 148 | return; |
| 149 | } |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 150 | under.orSelf(layer->visibleRegion); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 151 | }); |
| 152 | // if not everything below us is covered, we plug the holes! |
| 153 | Region holes(clip.subtract(under)); |
| 154 | if (!holes.isEmpty()) { |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 155 | clearRegion.orSelf(holes); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 156 | } |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 157 | return false; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 158 | } |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 159 | bool blackOutLayer = isProtected() || (isSecure() && !renderArea.isSecure()); |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 160 | const State& s(getDrawingState()); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 161 | if (!blackOutLayer) { |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 162 | layer.source.buffer.buffer = mActiveBuffer; |
| 163 | layer.source.buffer.isOpaque = isOpaque(s); |
| 164 | layer.source.buffer.fence = mActiveBufferFence; |
| 165 | layer.source.buffer.cacheHint = useCachedBufferForClientComposition() |
| 166 | ? renderengine::Buffer::CachingHint::USE_CACHE |
| 167 | : renderengine::Buffer::CachingHint::NO_CACHE; |
| 168 | layer.source.buffer.textureName = mTextureName; |
| 169 | layer.source.buffer.usePremultipliedAlpha = getPremultipledAlpha(); |
| 170 | layer.source.buffer.isY410BT2020 = isHdrY410(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 171 | // TODO: we could be more subtle with isFixedSize() |
Peiyong Lin | c2020ca | 2019-01-10 11:36:12 -0800 | [diff] [blame] | 172 | const bool useFiltering = needsFiltering() || renderArea.needsFiltering() || isFixedSize(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 173 | |
| 174 | // Query the texture matrix given our current filtering mode. |
| 175 | float textureMatrix[16]; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 176 | setFilteringEnabled(useFiltering); |
| 177 | getDrawingTransformMatrix(textureMatrix); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 178 | |
| 179 | if (getTransformToDisplayInverse()) { |
| 180 | /* |
| 181 | * the code below applies the primary display's inverse transform to |
| 182 | * the texture transform |
| 183 | */ |
| 184 | uint32_t transform = DisplayDevice::getPrimaryDisplayOrientationTransform(); |
| 185 | mat4 tr = inverseOrientation(transform); |
| 186 | |
| 187 | /** |
| 188 | * TODO(b/36727915): This is basically a hack. |
| 189 | * |
| 190 | * Ensure that regardless of the parent transformation, |
| 191 | * this buffer is always transformed from native display |
| 192 | * orientation to display orientation. For example, in the case |
| 193 | * of a camera where the buffer remains in native orientation, |
| 194 | * we want the pixels to always be upright. |
| 195 | */ |
| 196 | sp<Layer> p = mDrawingParent.promote(); |
| 197 | if (p != nullptr) { |
| 198 | const auto parentTransform = p->getTransform(); |
| 199 | tr = tr * inverseOrientation(parentTransform.getOrientation()); |
| 200 | } |
| 201 | |
| 202 | // and finally apply it to the original texture matrix |
| 203 | const mat4 texTransform(mat4(static_cast<const float*>(textureMatrix)) * tr); |
| 204 | memcpy(textureMatrix, texTransform.asArray(), sizeof(textureMatrix)); |
| 205 | } |
| 206 | |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 207 | const Rect win{computeBounds()}; |
| 208 | const float bufferWidth = getBufferSize(s).getWidth(); |
| 209 | const float bufferHeight = getBufferSize(s).getHeight(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 210 | |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 211 | const float scaleHeight = (float(win.bottom) - float(win.top)) / bufferHeight; |
| 212 | const float scaleWidth = (float(win.right) - float(win.left)) / bufferWidth; |
| 213 | const float translateY = float(win.top) / bufferHeight; |
| 214 | const float translateX = float(win.left) / bufferWidth; |
| 215 | |
| 216 | // Flip y-coordinates because GLConsumer expects OpenGL convention. |
| 217 | mat4 tr = mat4::translate(vec4(.5, .5, 0, 1)) * mat4::scale(vec4(1, -1, 1, 1)) * |
| 218 | mat4::translate(vec4(-.5, -.5, 0, 1)) * |
| 219 | mat4::translate(vec4(translateX, translateY, 0, 1)) * |
| 220 | mat4::scale(vec4(scaleWidth, scaleHeight, 1.0, 1.0)); |
| 221 | |
| 222 | layer.source.buffer.useTextureFiltering = useFiltering; |
| 223 | layer.source.buffer.textureTransform = mat4(static_cast<const float*>(textureMatrix)) * tr; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 224 | } else { |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 225 | // If layer is blacked out, force alpha to 1 so that we draw a black color |
| 226 | // layer. |
| 227 | layer.source.buffer.buffer = nullptr; |
| 228 | layer.alpha = 1.0; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 229 | } |
Alec Mouri | 0f71483 | 2018-11-12 15:31:06 -0800 | [diff] [blame^] | 230 | |
| 231 | return true; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 232 | } |
| 233 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 234 | bool BufferLayer::isHdrY410() const { |
| 235 | // pixel format is HDR Y410 masquerading as RGBA_1010102 |
| 236 | return (mCurrentDataSpace == ui::Dataspace::BT2020_ITU_PQ && |
| 237 | getDrawingApi() == NATIVE_WINDOW_API_MEDIA && |
| 238 | getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102); |
David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 239 | } |
| 240 | |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 241 | void BufferLayer::setPerFrameData(DisplayId displayId, const ui::Transform& transform, |
| 242 | const Rect& viewport, int32_t supportedPerFrameMetadata) { |
Dominik Laskowski | 3415776 | 2018-10-31 13:07:19 -0700 | [diff] [blame] | 243 | RETURN_IF_NO_HWC_LAYER(displayId); |
| 244 | |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 245 | // Apply this display's projection's viewport to the visible region |
| 246 | // before giving it to the HWC HAL. |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 247 | Region visible = transform.transform(visibleRegion.intersect(viewport)); |
| 248 | |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 249 | auto& hwcInfo = getBE().mHwcLayers[displayId]; |
| 250 | auto& hwcLayer = hwcInfo.layer; |
| 251 | auto error = hwcLayer->setVisibleRegion(visible); |
| 252 | if (error != HWC2::Error::None) { |
| 253 | ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(), |
| 254 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 255 | visible.dump(LOG_TAG); |
| 256 | } |
David Sodman | ba34049 | 2018-08-05 21:51:33 -0700 | [diff] [blame] | 257 | getBE().compositionInfo.hwc.visibleRegion = visible; |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 258 | |
| 259 | error = hwcLayer->setSurfaceDamage(surfaceDamageRegion); |
| 260 | if (error != HWC2::Error::None) { |
| 261 | ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(), |
| 262 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 263 | surfaceDamageRegion.dump(LOG_TAG); |
| 264 | } |
David Sodman | ba34049 | 2018-08-05 21:51:33 -0700 | [diff] [blame] | 265 | getBE().compositionInfo.hwc.surfaceDamage = surfaceDamageRegion; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 266 | |
| 267 | // Sideband layers |
David Sodman | 0cc6918 | 2017-11-17 12:12:07 -0800 | [diff] [blame] | 268 | if (getBE().compositionInfo.hwc.sidebandStream.get()) { |
Dominik Laskowski | 7e04546 | 2018-05-30 13:02:02 -0700 | [diff] [blame] | 269 | setCompositionType(displayId, HWC2::Composition::Sideband); |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 270 | ALOGV("[%s] Requesting Sideband composition", mName.string()); |
| 271 | error = hwcLayer->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle()); |
| 272 | if (error != HWC2::Error::None) { |
| 273 | ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(), |
| 274 | getBE().compositionInfo.hwc.sidebandStream->handle(), to_string(error).c_str(), |
| 275 | static_cast<int32_t>(error)); |
| 276 | } |
David Sodman | ba34049 | 2018-08-05 21:51:33 -0700 | [diff] [blame] | 277 | getBE().compositionInfo.compositionType = HWC2::Composition::Sideband; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 278 | return; |
| 279 | } |
| 280 | |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 281 | // Device or Cursor layers |
| 282 | if (mPotentialCursor) { |
| 283 | ALOGV("[%s] Requesting Cursor composition", mName.string()); |
| 284 | setCompositionType(displayId, HWC2::Composition::Cursor); |
| 285 | } else { |
| 286 | ALOGV("[%s] Requesting Device composition", mName.string()); |
| 287 | setCompositionType(displayId, HWC2::Composition::Device); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 288 | } |
| 289 | |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 290 | ALOGV("setPerFrameData: dataspace = %d", mCurrentDataSpace); |
| 291 | error = hwcLayer->setDataspace(mCurrentDataSpace); |
| 292 | if (error != HWC2::Error::None) { |
| 293 | ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mCurrentDataSpace, |
| 294 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 295 | } |
| 296 | |
| 297 | const HdrMetadata& metadata = getDrawingHdrMetadata(); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 298 | error = hwcLayer->setPerFrameMetadata(supportedPerFrameMetadata, metadata); |
David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 299 | if (error != HWC2::Error::None && error != HWC2::Error::Unsupported) { |
| 300 | ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", mName.string(), |
| 301 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 302 | } |
| 303 | |
| 304 | error = hwcLayer->setColorTransform(getColorTransform()); |
| 305 | if (error != HWC2::Error::None) { |
| 306 | ALOGE("[%s] Failed to setColorTransform: %s (%d)", mName.string(), |
| 307 | to_string(error).c_str(), static_cast<int32_t>(error)); |
| 308 | } |
David Sodman | ba34049 | 2018-08-05 21:51:33 -0700 | [diff] [blame] | 309 | getBE().compositionInfo.hwc.dataspace = mCurrentDataSpace; |
| 310 | getBE().compositionInfo.hwc.hdrMetadata = getDrawingHdrMetadata(); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 311 | getBE().compositionInfo.hwc.supportedPerFrameMetadata = supportedPerFrameMetadata; |
Peiyong Lin | d378863 | 2018-09-18 16:01:31 -0700 | [diff] [blame] | 312 | getBE().compositionInfo.hwc.colorTransform = getColorTransform(); |
Lloyd Pique | 074e812 | 2018-07-26 12:57:23 -0700 | [diff] [blame] | 313 | |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 314 | setHwcLayerBuffer(displayId); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 317 | bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) { |
| 318 | if (mBufferLatched) { |
| 319 | Mutex::Autolock lock(mFrameEventHistoryMutex); |
| 320 | mFrameEventHistory.addPreComposition(mCurrentFrameNumber, refreshStartTime); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 321 | } |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 322 | mRefreshPending = false; |
| 323 | return hasReadyFrame(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 324 | } |
| 325 | |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 326 | bool BufferLayer::onPostComposition(const std::optional<DisplayId>& displayId, |
| 327 | const std::shared_ptr<FenceTime>& glDoneFence, |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 328 | const std::shared_ptr<FenceTime>& presentFence, |
| 329 | const CompositorTiming& compositorTiming) { |
| 330 | // mFrameLatencyNeeded is true when a new frame was latched for the |
| 331 | // composition. |
| 332 | if (!mFrameLatencyNeeded) return false; |
| 333 | |
| 334 | // Update mFrameEventHistory. |
Dan Stoza | 436ccf3 | 2018-06-21 12:10:12 -0700 | [diff] [blame] | 335 | { |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 336 | Mutex::Autolock lock(mFrameEventHistoryMutex); |
| 337 | mFrameEventHistory.addPostComposition(mCurrentFrameNumber, glDoneFence, presentFence, |
| 338 | compositorTiming); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 339 | } |
| 340 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 341 | // Update mFrameTracker. |
| 342 | nsecs_t desiredPresentTime = getDesiredPresentTime(); |
| 343 | mFrameTracker.setDesiredPresentTime(desiredPresentTime); |
| 344 | |
Yiwei Zhang | 9689e2f | 2018-05-11 12:33:23 -0700 | [diff] [blame] | 345 | const int32_t layerID = getSequence(); |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 346 | mFlinger->mTimeStats->setDesiredTime(layerID, mCurrentFrameNumber, desiredPresentTime); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 347 | |
| 348 | std::shared_ptr<FenceTime> frameReadyFence = getCurrentFenceTime(); |
| 349 | if (frameReadyFence->isValid()) { |
| 350 | mFrameTracker.setFrameReadyFence(std::move(frameReadyFence)); |
| 351 | } else { |
| 352 | // There was no fence for this frame, so assume that it was ready |
| 353 | // to be presented at the desired present time. |
| 354 | mFrameTracker.setFrameReadyTime(desiredPresentTime); |
Dominik Laskowski | 45de9bd | 2018-06-11 17:44:10 -0700 | [diff] [blame] | 355 | } |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 356 | |
| 357 | if (presentFence->isValid()) { |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 358 | mFlinger->mTimeStats->setPresentFence(layerID, mCurrentFrameNumber, presentFence); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 359 | mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence)); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 360 | } else if (displayId && mFlinger->getHwComposer().isConnected(*displayId)) { |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 361 | // The HWC doesn't support present fences, so use the refresh |
| 362 | // timestamp instead. |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 363 | const nsecs_t actualPresentTime = mFlinger->getHwComposer().getRefreshTimestamp(*displayId); |
Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 364 | mFlinger->mTimeStats->setPresentTime(layerID, mCurrentFrameNumber, actualPresentTime); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 365 | mFrameTracker.setActualPresentTime(actualPresentTime); |
| 366 | } |
| 367 | |
| 368 | mFrameTracker.advanceFrame(); |
| 369 | mFrameLatencyNeeded = false; |
| 370 | return true; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 371 | } |
| 372 | |
Alec Mouri | 86770e5 | 2018-09-24 22:40:58 +0000 | [diff] [blame] | 373 | Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime, |
| 374 | const sp<Fence>& releaseFence) { |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 375 | ATRACE_CALL(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 376 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 377 | std::optional<Region> sidebandStreamDirtyRegion = latchSidebandStream(recomputeVisibleRegions); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 378 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 379 | if (sidebandStreamDirtyRegion) { |
| 380 | return *sidebandStreamDirtyRegion; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 381 | } |
| 382 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 383 | Region dirtyRegion; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 384 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 385 | if (!hasReadyFrame()) { |
| 386 | return dirtyRegion; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 387 | } |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 388 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 389 | // if we've already called updateTexImage() without going through |
| 390 | // a composition step, we have to skip this layer at this point |
| 391 | // because we cannot call updateTeximage() without a corresponding |
| 392 | // compositionComplete() call. |
| 393 | // we'll trigger an update in onPreComposition(). |
| 394 | if (mRefreshPending) { |
| 395 | return dirtyRegion; |
| 396 | } |
| 397 | |
| 398 | // If the head buffer's acquire fence hasn't signaled yet, return and |
| 399 | // try again later |
| 400 | if (!fenceHasSignaled()) { |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 401 | mFlinger->signalLayerUpdate(); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 402 | return dirtyRegion; |
| 403 | } |
| 404 | |
| 405 | // Capture the old state of the layer for comparisons later |
| 406 | const State& s(getDrawingState()); |
| 407 | const bool oldOpacity = isOpaque(s); |
| 408 | sp<GraphicBuffer> oldBuffer = mActiveBuffer; |
| 409 | |
| 410 | if (!allTransactionsSignaled()) { |
| 411 | mFlinger->signalLayerUpdate(); |
| 412 | return dirtyRegion; |
| 413 | } |
| 414 | |
Alec Mouri | 86770e5 | 2018-09-24 22:40:58 +0000 | [diff] [blame] | 415 | status_t err = updateTexImage(recomputeVisibleRegions, latchTime, releaseFence); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 416 | if (err != NO_ERROR) { |
| 417 | return dirtyRegion; |
| 418 | } |
| 419 | |
| 420 | err = updateActiveBuffer(); |
| 421 | if (err != NO_ERROR) { |
| 422 | return dirtyRegion; |
| 423 | } |
| 424 | |
| 425 | mBufferLatched = true; |
| 426 | |
| 427 | err = updateFrameNumber(latchTime); |
| 428 | if (err != NO_ERROR) { |
| 429 | return dirtyRegion; |
| 430 | } |
| 431 | |
| 432 | mRefreshPending = true; |
| 433 | mFrameLatencyNeeded = true; |
| 434 | if (oldBuffer == nullptr) { |
| 435 | // the first time we receive a buffer, we need to trigger a |
| 436 | // geometry invalidation. |
| 437 | recomputeVisibleRegions = true; |
| 438 | } |
| 439 | |
| 440 | ui::Dataspace dataSpace = getDrawingDataSpace(); |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 441 | // translate legacy dataspaces to modern dataspaces |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 442 | switch (dataSpace) { |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 443 | case ui::Dataspace::SRGB: |
| 444 | dataSpace = ui::Dataspace::V0_SRGB; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 445 | break; |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 446 | case ui::Dataspace::SRGB_LINEAR: |
| 447 | dataSpace = ui::Dataspace::V0_SRGB_LINEAR; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 448 | break; |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 449 | case ui::Dataspace::JFIF: |
| 450 | dataSpace = ui::Dataspace::V0_JFIF; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 451 | break; |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 452 | case ui::Dataspace::BT601_625: |
| 453 | dataSpace = ui::Dataspace::V0_BT601_625; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 454 | break; |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 455 | case ui::Dataspace::BT601_525: |
| 456 | dataSpace = ui::Dataspace::V0_BT601_525; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 457 | break; |
Peiyong Lin | 14724e6 | 2018-12-05 07:27:30 -0800 | [diff] [blame] | 458 | case ui::Dataspace::BT709: |
| 459 | dataSpace = ui::Dataspace::V0_BT709; |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 460 | break; |
| 461 | default: |
| 462 | break; |
| 463 | } |
| 464 | mCurrentDataSpace = dataSpace; |
| 465 | |
| 466 | Rect crop(getDrawingCrop()); |
| 467 | const uint32_t transform(getDrawingTransform()); |
| 468 | const uint32_t scalingMode(getDrawingScalingMode()); |
| 469 | if ((crop != mCurrentCrop) || (transform != mCurrentTransform) || |
| 470 | (scalingMode != mCurrentScalingMode)) { |
| 471 | mCurrentCrop = crop; |
| 472 | mCurrentTransform = transform; |
| 473 | mCurrentScalingMode = scalingMode; |
| 474 | recomputeVisibleRegions = true; |
| 475 | } |
| 476 | |
| 477 | if (oldBuffer != nullptr) { |
| 478 | uint32_t bufWidth = mActiveBuffer->getWidth(); |
| 479 | uint32_t bufHeight = mActiveBuffer->getHeight(); |
| 480 | if (bufWidth != uint32_t(oldBuffer->width) || bufHeight != uint32_t(oldBuffer->height)) { |
| 481 | recomputeVisibleRegions = true; |
| 482 | } |
| 483 | } |
| 484 | |
| 485 | if (oldOpacity != isOpaque(s)) { |
| 486 | recomputeVisibleRegions = true; |
| 487 | } |
| 488 | |
| 489 | // Remove any sync points corresponding to the buffer which was just |
| 490 | // latched |
| 491 | { |
| 492 | Mutex::Autolock lock(mLocalSyncPointMutex); |
| 493 | auto point = mLocalSyncPoints.begin(); |
| 494 | while (point != mLocalSyncPoints.end()) { |
| 495 | if (!(*point)->frameIsAvailable() || !(*point)->transactionIsApplied()) { |
| 496 | // This sync point must have been added since we started |
| 497 | // latching. Don't drop it yet. |
| 498 | ++point; |
| 499 | continue; |
| 500 | } |
| 501 | |
| 502 | if ((*point)->getFrameNumber() <= mCurrentFrameNumber) { |
| 503 | point = mLocalSyncPoints.erase(point); |
| 504 | } else { |
| 505 | ++point; |
| 506 | } |
| 507 | } |
| 508 | } |
| 509 | |
| 510 | // FIXME: postedRegion should be dirty & bounds |
| 511 | // transform the dirty region to window-manager space |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 512 | return getTransform().transform(Region(getBufferSize(s))); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 513 | } |
| 514 | |
| 515 | // transaction |
| 516 | void BufferLayer::notifyAvailableFrames() { |
| 517 | auto headFrameNumber = getHeadFrameNumber(); |
| 518 | bool headFenceSignaled = fenceHasSignaled(); |
| 519 | Mutex::Autolock lock(mLocalSyncPointMutex); |
| 520 | for (auto& point : mLocalSyncPoints) { |
| 521 | if (headFrameNumber >= point->getFrameNumber() && headFenceSignaled) { |
| 522 | point->setFrameAvailable(); |
| 523 | } |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 524 | } |
| 525 | } |
| 526 | |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 527 | bool BufferLayer::hasReadyFrame() const { |
Marissa Wall | 024a191 | 2018-08-13 13:55:35 -0700 | [diff] [blame] | 528 | return hasFrameUpdate() || getSidebandStreamChanged() || getAutoRefresh(); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 529 | } |
| 530 | |
| 531 | uint32_t BufferLayer::getEffectiveScalingMode() const { |
| 532 | if (mOverrideScalingMode >= 0) { |
| 533 | return mOverrideScalingMode; |
| 534 | } |
| 535 | |
| 536 | return mCurrentScalingMode; |
| 537 | } |
| 538 | |
| 539 | bool BufferLayer::isProtected() const { |
| 540 | const sp<GraphicBuffer>& buffer(mActiveBuffer); |
| 541 | return (buffer != 0) && (buffer->getUsage() & GRALLOC_USAGE_PROTECTED); |
| 542 | } |
| 543 | |
| 544 | bool BufferLayer::latchUnsignaledBuffers() { |
| 545 | static bool propertyLoaded = false; |
| 546 | static bool latch = false; |
| 547 | static std::mutex mutex; |
| 548 | std::lock_guard<std::mutex> lock(mutex); |
| 549 | if (!propertyLoaded) { |
| 550 | char value[PROPERTY_VALUE_MAX] = {}; |
| 551 | property_get("debug.sf.latch_unsignaled", value, "0"); |
| 552 | latch = atoi(value); |
| 553 | propertyLoaded = true; |
| 554 | } |
| 555 | return latch; |
| 556 | } |
| 557 | |
| 558 | // h/w composer set-up |
| 559 | bool BufferLayer::allTransactionsSignaled() { |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 560 | auto headFrameNumber = getHeadFrameNumber(); |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 561 | bool matchingFramesFound = false; |
| 562 | bool allTransactionsApplied = true; |
| 563 | Mutex::Autolock lock(mLocalSyncPointMutex); |
| 564 | |
| 565 | for (auto& point : mLocalSyncPoints) { |
| 566 | if (point->getFrameNumber() > headFrameNumber) { |
| 567 | break; |
| 568 | } |
| 569 | matchingFramesFound = true; |
| 570 | |
| 571 | if (!point->frameIsAvailable()) { |
| 572 | // We haven't notified the remote layer that the frame for |
| 573 | // this point is available yet. Notify it now, and then |
| 574 | // abort this attempt to latch. |
| 575 | point->setFrameAvailable(); |
| 576 | allTransactionsApplied = false; |
| 577 | break; |
| 578 | } |
| 579 | |
| 580 | allTransactionsApplied = allTransactionsApplied && point->transactionIsApplied(); |
| 581 | } |
| 582 | return !matchingFramesFound || allTransactionsApplied; |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 583 | } |
| 584 | |
| 585 | // As documented in libhardware header, formats in the range |
| 586 | // 0x100 - 0x1FF are specific to the HAL implementation, and |
| 587 | // are known to have no alpha channel |
| 588 | // TODO: move definition for device-specific range into |
| 589 | // hardware.h, instead of using hard-coded values here. |
| 590 | #define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF) |
| 591 | |
| 592 | bool BufferLayer::getOpacityForFormat(uint32_t format) { |
| 593 | if (HARDWARE_IS_DEVICE_FORMAT(format)) { |
| 594 | return true; |
| 595 | } |
| 596 | switch (format) { |
| 597 | case HAL_PIXEL_FORMAT_RGBA_8888: |
| 598 | case HAL_PIXEL_FORMAT_BGRA_8888: |
| 599 | case HAL_PIXEL_FORMAT_RGBA_FP16: |
| 600 | case HAL_PIXEL_FORMAT_RGBA_1010102: |
| 601 | return false; |
| 602 | } |
| 603 | // in all other case, we have no blending (also for unknown formats) |
| 604 | return true; |
| 605 | } |
| 606 | |
Peiyong Lin | c2020ca | 2019-01-10 11:36:12 -0800 | [diff] [blame] | 607 | bool BufferLayer::needsFiltering() const { |
| 608 | const auto displayFrame = getBE().compositionInfo.hwc.displayFrame; |
| 609 | const auto sourceCrop = getBE().compositionInfo.hwc.sourceCrop; |
| 610 | return mNeedsFiltering || sourceCrop.getHeight() != displayFrame.getHeight() || |
| 611 | sourceCrop.getWidth() != displayFrame.getWidth(); |
Chia-I Wu | 692e083 | 2018-06-05 15:46:58 -0700 | [diff] [blame] | 612 | } |
| 613 | |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 614 | uint64_t BufferLayer::getHeadFrameNumber() const { |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 615 | if (hasFrameUpdate()) { |
Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 616 | return getFrameNumber(); |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 617 | } else { |
| 618 | return mCurrentFrameNumber; |
| 619 | } |
| 620 | } |
| 621 | |
Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 622 | Rect BufferLayer::getBufferSize(const State& s) const { |
| 623 | // If we have a sideband stream, or we are scaling the buffer then return the layer size since |
| 624 | // we cannot determine the buffer size. |
| 625 | if ((s.sidebandStream != nullptr) || |
| 626 | (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) { |
| 627 | return Rect(getActiveWidth(s), getActiveHeight(s)); |
| 628 | } |
| 629 | |
| 630 | if (mActiveBuffer == nullptr) { |
| 631 | return Rect::INVALID_RECT; |
| 632 | } |
| 633 | |
| 634 | uint32_t bufWidth = mActiveBuffer->getWidth(); |
| 635 | uint32_t bufHeight = mActiveBuffer->getHeight(); |
| 636 | |
| 637 | // Undo any transformations on the buffer and return the result. |
| 638 | if (mCurrentTransform & ui::Transform::ROT_90) { |
| 639 | std::swap(bufWidth, bufHeight); |
| 640 | } |
| 641 | |
Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 642 | if (getTransformToDisplayInverse()) { |
Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 643 | uint32_t invTransform = DisplayDevice::getPrimaryDisplayOrientationTransform(); |
| 644 | if (invTransform & ui::Transform::ROT_90) { |
| 645 | std::swap(bufWidth, bufHeight); |
| 646 | } |
| 647 | } |
| 648 | |
| 649 | return Rect(bufWidth, bufHeight); |
| 650 | } |
| 651 | |
David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 652 | } // namespace android |
| 653 | |
| 654 | #if defined(__gl_h_) |
| 655 | #error "don't include gl/gl.h in this file" |
| 656 | #endif |
| 657 | |
| 658 | #if defined(__gl2_h_) |
| 659 | #error "don't include gl2/gl2.h in this file" |
| 660 | #endif |