| 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 |  | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 17 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 18 | #pragma clang diagnostic push | 
|  | 19 | #pragma clang diagnostic ignored "-Wconversion" | 
|  | 20 |  | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 21 | //#define LOG_NDEBUG 0 | 
|  | 22 | #undef LOG_TAG | 
|  | 23 | #define LOG_TAG "BufferLayer" | 
|  | 24 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS | 
|  | 25 |  | 
| Alec Mouri | e60041e | 2019-06-14 18:59:51 -0700 | [diff] [blame] | 26 | #include "BufferLayer.h" | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 27 |  | 
|  | 28 | #include <compositionengine/CompositionEngine.h> | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 29 | #include <compositionengine/LayerFECompositionState.h> | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 30 | #include <compositionengine/OutputLayer.h> | 
|  | 31 | #include <compositionengine/impl/OutputLayerCompositionState.h> | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 32 | #include <cutils/compiler.h> | 
|  | 33 | #include <cutils/native_handle.h> | 
|  | 34 | #include <cutils/properties.h> | 
|  | 35 | #include <gui/BufferItem.h> | 
|  | 36 | #include <gui/BufferQueue.h> | 
| chaviw | f83ce18 | 2019-09-12 14:43:08 -0700 | [diff] [blame] | 37 | #include <gui/GLConsumer.h> | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 38 | #include <gui/LayerDebugInfo.h> | 
|  | 39 | #include <gui/Surface.h> | 
|  | 40 | #include <renderengine/RenderEngine.h> | 
|  | 41 | #include <ui/DebugUtils.h> | 
|  | 42 | #include <utils/Errors.h> | 
|  | 43 | #include <utils/Log.h> | 
|  | 44 | #include <utils/NativeHandle.h> | 
|  | 45 | #include <utils/StopWatch.h> | 
|  | 46 | #include <utils/Trace.h> | 
|  | 47 |  | 
| Alec Mouri | e60041e | 2019-06-14 18:59:51 -0700 | [diff] [blame] | 48 | #include <cmath> | 
|  | 49 | #include <cstdlib> | 
|  | 50 | #include <mutex> | 
|  | 51 | #include <sstream> | 
|  | 52 |  | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 53 | #include "Colorizer.h" | 
|  | 54 | #include "DisplayDevice.h" | 
| Mikael Pessa | 90092f4 | 2019-08-26 17:22:04 -0700 | [diff] [blame] | 55 | #include "FrameTracer/FrameTracer.h" | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 56 | #include "LayerRejecter.h" | 
| Yiwei Zhang | 7e666a5 | 2018-11-15 13:33:42 -0800 | [diff] [blame] | 57 | #include "TimeStats/TimeStats.h" | 
|  | 58 |  | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 59 | namespace android { | 
|  | 60 |  | 
| Peiyong Lin | 1a70eca | 2019-11-15 09:33:33 -0800 | [diff] [blame] | 61 | static constexpr float defaultMaxMasteringLuminance = 1000.0; | 
|  | 62 | static constexpr float defaultMaxContentLuminance = 1000.0; | 
|  | 63 |  | 
| Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 64 | BufferLayer::BufferLayer(const LayerCreationArgs& args) | 
| Lloyd Pique | feb73d7 | 2018-12-04 17:23:44 -0800 | [diff] [blame] | 65 | : Layer(args), | 
| chaviw | b4c6e58 | 2019-08-16 14:35:07 -0700 | [diff] [blame] | 66 | mTextureName(args.textureName), | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 67 | mCompositionState{mFlinger->getCompositionEngine().createLayerFECompositionState()} { | 
| Dominik Laskowski | 87a07e4 | 2019-10-10 20:38:02 -0700 | [diff] [blame] | 68 | ALOGV("Creating Layer %s", getDebugName()); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 69 |  | 
| Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 70 | mPremultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 71 |  | 
| Lloyd Pique | 42ab75e | 2018-09-12 20:46:03 -0700 | [diff] [blame] | 72 | mPotentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow; | 
|  | 73 | mProtectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 74 | } | 
|  | 75 |  | 
|  | 76 | BufferLayer::~BufferLayer() { | 
| chaviw | b4c6e58 | 2019-08-16 14:35:07 -0700 | [diff] [blame] | 77 | if (!isClone()) { | 
|  | 78 | // The original layer and the clone layer share the same texture. Therefore, only one of | 
|  | 79 | // the layers, in this case the original layer, needs to handle the deletion. The original | 
|  | 80 | // layer and the clone should be removed at the same time so there shouldn't be any issue | 
|  | 81 | // with the clone layer trying to use the deleted texture. | 
|  | 82 | mFlinger->deleteTextureAsync(mTextureName); | 
|  | 83 | } | 
| Yiwei Zhang | 1a88c40 | 2019-11-18 10:43:58 -0800 | [diff] [blame] | 84 | const int32_t layerId = getSequence(); | 
|  | 85 | mFlinger->mTimeStats->onDestroy(layerId); | 
|  | 86 | mFlinger->mFrameTracer->onDestroy(layerId); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 87 | } | 
|  | 88 |  | 
| David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 89 | void BufferLayer::useSurfaceDamage() { | 
|  | 90 | if (mFlinger->mForceFullDamage) { | 
|  | 91 | surfaceDamageRegion = Region::INVALID_REGION; | 
|  | 92 | } else { | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 93 | surfaceDamageRegion = mBufferInfo.mSurfaceDamage; | 
| David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 94 | } | 
|  | 95 | } | 
|  | 96 |  | 
|  | 97 | void BufferLayer::useEmptyDamage() { | 
|  | 98 | surfaceDamageRegion.clear(); | 
|  | 99 | } | 
|  | 100 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 101 | bool BufferLayer::isOpaque(const Layer::State& s) const { | 
|  | 102 | // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the | 
|  | 103 | // layer's opaque flag. | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 104 | if ((mSidebandStream == nullptr) && (mBufferInfo.mBuffer == nullptr)) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 105 | return false; | 
|  | 106 | } | 
|  | 107 |  | 
|  | 108 | // if the layer has the opaque flag, then we're always opaque, | 
|  | 109 | // otherwise we use the current buffer's format. | 
|  | 110 | return ((s.flags & layer_state_t::eLayerOpaque) != 0) || getOpacityForFormat(getPixelFormat()); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 111 | } | 
|  | 112 |  | 
|  | 113 | bool BufferLayer::isVisible() const { | 
| Dominik Laskowski | f7a09ed | 2019-10-07 13:54:18 -0700 | [diff] [blame] | 114 | return !isHiddenByPolicy() && getAlpha() > 0.0f && | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 115 | (mBufferInfo.mBuffer != nullptr || mSidebandStream != nullptr); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 116 | } | 
|  | 117 |  | 
|  | 118 | bool BufferLayer::isFixedSize() const { | 
|  | 119 | return getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE; | 
|  | 120 | } | 
|  | 121 |  | 
| Lloyd Pique | a83776c | 2019-01-29 18:42:32 -0800 | [diff] [blame] | 122 | bool BufferLayer::usesSourceCrop() const { | 
|  | 123 | return true; | 
|  | 124 | } | 
|  | 125 |  | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 126 | static constexpr mat4 inverseOrientation(uint32_t transform) { | 
| David Sodman | 41fdfc9 | 2017-11-06 16:09:56 -0800 | [diff] [blame] | 127 | const mat4 flipH(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1); | 
|  | 128 | const mat4 flipV(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1); | 
|  | 129 | 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] | 130 | mat4 tr; | 
|  | 131 |  | 
|  | 132 | if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90) { | 
|  | 133 | tr = tr * rot90; | 
|  | 134 | } | 
|  | 135 | if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H) { | 
|  | 136 | tr = tr * flipH; | 
|  | 137 | } | 
|  | 138 | if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V) { | 
|  | 139 | tr = tr * flipV; | 
|  | 140 | } | 
|  | 141 | return inverse(tr); | 
|  | 142 | } | 
|  | 143 |  | 
| Vishnu Nair | 9b079a2 | 2020-01-21 14:36:08 -0800 | [diff] [blame] | 144 | std::optional<compositionengine::LayerFE::LayerSettings> BufferLayer::prepareClientComposition( | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 145 | compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) { | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 146 | ATRACE_CALL(); | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 147 |  | 
| Vishnu Nair | 9b079a2 | 2020-01-21 14:36:08 -0800 | [diff] [blame] | 148 | std::optional<compositionengine::LayerFE::LayerSettings> result = | 
|  | 149 | Layer::prepareClientComposition(targetSettings); | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 150 | if (!result) { | 
|  | 151 | return result; | 
|  | 152 | } | 
|  | 153 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 154 | if (CC_UNLIKELY(mBufferInfo.mBuffer == 0)) { | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 155 | // the texture has not been created yet, this Layer has | 
|  | 156 | // in fact never been drawn into. This happens frequently with | 
|  | 157 | // SurfaceView because the WindowManager can't know when the client | 
|  | 158 | // has drawn the first time. | 
|  | 159 |  | 
|  | 160 | // If there is nothing under us, we paint the screen in black, otherwise | 
|  | 161 | // we just skip this update. | 
|  | 162 |  | 
|  | 163 | // figure out if there is something below us | 
|  | 164 | Region under; | 
|  | 165 | bool finished = false; | 
|  | 166 | mFlinger->mDrawingState.traverseInZOrder([&](Layer* layer) { | 
|  | 167 | if (finished || layer == static_cast<BufferLayer const*>(this)) { | 
|  | 168 | finished = true; | 
|  | 169 | return; | 
|  | 170 | } | 
| Lloyd Pique | a246866 | 2019-03-07 21:31:06 -0800 | [diff] [blame] | 171 |  | 
|  | 172 | under.orSelf(layer->getScreenBounds()); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 173 | }); | 
|  | 174 | // if not everything below us is covered, we plug the holes! | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 175 | Region holes(targetSettings.clip.subtract(under)); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 176 | if (!holes.isEmpty()) { | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 177 | targetSettings.clearRegion.orSelf(holes); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 178 | } | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 179 | return std::nullopt; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 180 | } | 
| Lloyd Pique | 688abd4 | 2019-02-15 15:42:24 -0800 | [diff] [blame] | 181 | bool blackOutLayer = (isProtected() && !targetSettings.supportsProtectedContent) || | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 182 | (isSecure() && !targetSettings.isSecure); | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 183 | compositionengine::LayerFE::LayerSettings& layer = *result; | 
| Vishnu Nair | b87d94f | 2020-02-13 09:17:36 -0800 | [diff] [blame] | 184 | if (blackOutLayer) { | 
|  | 185 | prepareClearClientComposition(layer, true /* blackout */); | 
|  | 186 | return layer; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 187 | } | 
| Alec Mouri | e7d1d4a | 2019-02-05 01:13:46 +0000 | [diff] [blame] | 188 |  | 
| Vishnu Nair | b87d94f | 2020-02-13 09:17:36 -0800 | [diff] [blame] | 189 | const State& s(getDrawingState()); | 
|  | 190 | layer.source.buffer.buffer = mBufferInfo.mBuffer; | 
|  | 191 | layer.source.buffer.isOpaque = isOpaque(s); | 
|  | 192 | layer.source.buffer.fence = mBufferInfo.mFence; | 
|  | 193 | layer.source.buffer.textureName = mTextureName; | 
|  | 194 | layer.source.buffer.usePremultipliedAlpha = getPremultipledAlpha(); | 
|  | 195 | layer.source.buffer.isY410BT2020 = isHdrY410(); | 
|  | 196 | bool hasSmpte2086 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::SMPTE2086; | 
|  | 197 | bool hasCta861_3 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::CTA861_3; | 
|  | 198 | layer.source.buffer.maxMasteringLuminance = hasSmpte2086 | 
|  | 199 | ? mBufferInfo.mHdrMetadata.smpte2086.maxLuminance | 
|  | 200 | : defaultMaxMasteringLuminance; | 
|  | 201 | layer.source.buffer.maxContentLuminance = hasCta861_3 | 
|  | 202 | ? mBufferInfo.mHdrMetadata.cta8613.maxContentLightLevel | 
|  | 203 | : defaultMaxContentLuminance; | 
|  | 204 | layer.frameNumber = mCurrentFrameNumber; | 
|  | 205 | layer.bufferId = mBufferInfo.mBuffer ? mBufferInfo.mBuffer->getId() : 0; | 
|  | 206 |  | 
|  | 207 | // TODO: we could be more subtle with isFixedSize() | 
|  | 208 | const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize(); | 
|  | 209 |  | 
|  | 210 | // Query the texture matrix given our current filtering mode. | 
|  | 211 | float textureMatrix[16]; | 
|  | 212 | getDrawingTransformMatrix(useFiltering, textureMatrix); | 
|  | 213 |  | 
|  | 214 | if (getTransformToDisplayInverse()) { | 
|  | 215 | /* | 
|  | 216 | * the code below applies the primary display's inverse transform to | 
|  | 217 | * the texture transform | 
|  | 218 | */ | 
|  | 219 | uint32_t transform = DisplayDevice::getPrimaryDisplayRotationFlags(); | 
|  | 220 | mat4 tr = inverseOrientation(transform); | 
|  | 221 |  | 
|  | 222 | /** | 
|  | 223 | * TODO(b/36727915): This is basically a hack. | 
|  | 224 | * | 
|  | 225 | * Ensure that regardless of the parent transformation, | 
|  | 226 | * this buffer is always transformed from native display | 
|  | 227 | * orientation to display orientation. For example, in the case | 
|  | 228 | * of a camera where the buffer remains in native orientation, | 
|  | 229 | * we want the pixels to always be upright. | 
|  | 230 | */ | 
|  | 231 | sp<Layer> p = mDrawingParent.promote(); | 
|  | 232 | if (p != nullptr) { | 
|  | 233 | const auto parentTransform = p->getTransform(); | 
|  | 234 | tr = tr * inverseOrientation(parentTransform.getOrientation()); | 
|  | 235 | } | 
|  | 236 |  | 
|  | 237 | // and finally apply it to the original texture matrix | 
|  | 238 | const mat4 texTransform(mat4(static_cast<const float*>(textureMatrix)) * tr); | 
|  | 239 | memcpy(textureMatrix, texTransform.asArray(), sizeof(textureMatrix)); | 
|  | 240 | } | 
|  | 241 |  | 
|  | 242 | const Rect win{getBounds()}; | 
|  | 243 | float bufferWidth = getBufferSize(s).getWidth(); | 
|  | 244 | float bufferHeight = getBufferSize(s).getHeight(); | 
|  | 245 |  | 
|  | 246 | // BufferStateLayers can have a "buffer size" of [0, 0, -1, -1] when no display frame has | 
|  | 247 | // been set and there is no parent layer bounds. In that case, the scale is meaningless so | 
|  | 248 | // ignore them. | 
|  | 249 | if (!getBufferSize(s).isValid()) { | 
|  | 250 | bufferWidth = float(win.right) - float(win.left); | 
|  | 251 | bufferHeight = float(win.bottom) - float(win.top); | 
|  | 252 | } | 
|  | 253 |  | 
|  | 254 | const float scaleHeight = (float(win.bottom) - float(win.top)) / bufferHeight; | 
|  | 255 | const float scaleWidth = (float(win.right) - float(win.left)) / bufferWidth; | 
|  | 256 | const float translateY = float(win.top) / bufferHeight; | 
|  | 257 | const float translateX = float(win.left) / bufferWidth; | 
|  | 258 |  | 
|  | 259 | // Flip y-coordinates because GLConsumer expects OpenGL convention. | 
|  | 260 | mat4 tr = mat4::translate(vec4(.5, .5, 0, 1)) * mat4::scale(vec4(1, -1, 1, 1)) * | 
|  | 261 | mat4::translate(vec4(-.5, -.5, 0, 1)) * | 
|  | 262 | mat4::translate(vec4(translateX, translateY, 0, 1)) * | 
|  | 263 | mat4::scale(vec4(scaleWidth, scaleHeight, 1.0, 1.0)); | 
|  | 264 |  | 
|  | 265 | layer.source.buffer.useTextureFiltering = useFiltering; | 
|  | 266 | layer.source.buffer.textureTransform = mat4(static_cast<const float*>(textureMatrix)) * tr; | 
|  | 267 |  | 
| Vishnu Nair | 9b079a2 | 2020-01-21 14:36:08 -0800 | [diff] [blame] | 268 | return layer; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 269 | } | 
|  | 270 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 271 | bool BufferLayer::isHdrY410() const { | 
|  | 272 | // pixel format is HDR Y410 masquerading as RGBA_1010102 | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 273 | return (mBufferInfo.mDataspace == ui::Dataspace::BT2020_ITU_PQ && | 
|  | 274 | mBufferInfo.mApi == NATIVE_WINDOW_API_MEDIA && | 
| chaviw | debadb8 | 2020-03-26 14:57:24 -0700 | [diff] [blame] | 275 | mBufferInfo.mPixelFormat == HAL_PIXEL_FORMAT_RGBA_1010102); | 
| David Sodman | eb085e0 | 2017-10-05 18:49:04 -0700 | [diff] [blame] | 276 | } | 
|  | 277 |  | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 278 | sp<compositionengine::LayerFE> BufferLayer::getCompositionEngineLayerFE() const { | 
|  | 279 | return asLayerFE(); | 
|  | 280 | } | 
|  | 281 |  | 
|  | 282 | compositionengine::LayerFECompositionState* BufferLayer::editCompositionState() { | 
|  | 283 | return mCompositionState.get(); | 
|  | 284 | } | 
|  | 285 |  | 
|  | 286 | const compositionengine::LayerFECompositionState* BufferLayer::getCompositionState() const { | 
|  | 287 | return mCompositionState.get(); | 
|  | 288 | } | 
|  | 289 |  | 
|  | 290 | void BufferLayer::preparePerFrameCompositionState() { | 
|  | 291 | Layer::preparePerFrameCompositionState(); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 292 |  | 
|  | 293 | // Sideband layers | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 294 | auto* compositionState = editCompositionState(); | 
|  | 295 | if (compositionState->sidebandStream.get()) { | 
|  | 296 | compositionState->compositionType = Hwc2::IComposerClient::Composition::SIDEBAND; | 
| Robert Carr | a6bb2bc | 2020-04-08 11:03:23 -0700 | [diff] [blame] | 297 | return; | 
| David Sodman | 1509411 | 2018-10-11 09:39:37 -0700 | [diff] [blame] | 298 | } else { | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 299 | // Normal buffer layers | 
| Lloyd Pique | de19665 | 2020-01-22 17:29:58 -0800 | [diff] [blame] | 300 | compositionState->hdrMetadata = mBufferInfo.mHdrMetadata; | 
|  | 301 | compositionState->compositionType = mPotentialCursor | 
| Lloyd Pique | f527548 | 2019-01-29 18:42:42 -0800 | [diff] [blame] | 302 | ? Hwc2::IComposerClient::Composition::CURSOR | 
|  | 303 | : Hwc2::IComposerClient::Composition::DEVICE; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 304 | } | 
| Robert Carr | a6bb2bc | 2020-04-08 11:03:23 -0700 | [diff] [blame] | 305 |  | 
|  | 306 | compositionState->buffer = mBufferInfo.mBuffer; | 
|  | 307 | compositionState->bufferSlot = (mBufferInfo.mBufferSlot == BufferQueue::INVALID_BUFFER_SLOT) | 
|  | 308 | ? 0 | 
|  | 309 | : mBufferInfo.mBufferSlot; | 
|  | 310 | compositionState->acquireFence = mBufferInfo.mFence; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 311 | } | 
|  | 312 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 313 | bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) { | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 314 | if (mBufferInfo.mBuffer != nullptr) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 315 | Mutex::Autolock lock(mFrameEventHistoryMutex); | 
|  | 316 | mFrameEventHistory.addPreComposition(mCurrentFrameNumber, refreshStartTime); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 317 | } | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 318 | mRefreshPending = false; | 
|  | 319 | return hasReadyFrame(); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 320 | } | 
|  | 321 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 322 | bool BufferLayer::onPostComposition(const DisplayDevice* display, | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 323 | const std::shared_ptr<FenceTime>& glDoneFence, | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 324 | const std::shared_ptr<FenceTime>& presentFence, | 
|  | 325 | const CompositorTiming& compositorTiming) { | 
|  | 326 | // mFrameLatencyNeeded is true when a new frame was latched for the | 
|  | 327 | // composition. | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 328 | if (!mBufferInfo.mFrameLatencyNeeded) return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 329 |  | 
|  | 330 | // Update mFrameEventHistory. | 
| Dan Stoza | 436ccf3 | 2018-06-21 12:10:12 -0700 | [diff] [blame] | 331 | { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 332 | Mutex::Autolock lock(mFrameEventHistoryMutex); | 
|  | 333 | mFrameEventHistory.addPostComposition(mCurrentFrameNumber, glDoneFence, presentFence, | 
|  | 334 | compositorTiming); | 
| Valerie Hau | 93d5a5e | 2020-02-13 14:50:01 -0800 | [diff] [blame] | 335 | finalizeFrameEventHistory(glDoneFence, compositorTiming); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 336 | } | 
|  | 337 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 338 | // Update mFrameTracker. | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 339 | nsecs_t desiredPresentTime = mBufferInfo.mDesiredPresentTime; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 340 | mFrameTracker.setDesiredPresentTime(desiredPresentTime); | 
|  | 341 |  | 
| Yiwei Zhang | 1a88c40 | 2019-11-18 10:43:58 -0800 | [diff] [blame] | 342 | const int32_t layerId = getSequence(); | 
|  | 343 | mFlinger->mTimeStats->setDesiredTime(layerId, mCurrentFrameNumber, desiredPresentTime); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 344 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 345 | const auto outputLayer = findOutputLayerForDisplay(display); | 
| Adithya Srinivasan | b69e076 | 2019-11-11 18:39:53 -0800 | [diff] [blame] | 346 | if (outputLayer && outputLayer->requiresClientComposition()) { | 
|  | 347 | nsecs_t clientCompositionTimestamp = outputLayer->getState().clientCompositionTimestamp; | 
|  | 348 | mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, | 
|  | 349 | clientCompositionTimestamp, | 
|  | 350 | FrameTracer::FrameEvent::FALLBACK_COMPOSITION); | 
|  | 351 | } | 
|  | 352 |  | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 353 | std::shared_ptr<FenceTime> frameReadyFence = mBufferInfo.mFenceTime; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 354 | if (frameReadyFence->isValid()) { | 
|  | 355 | mFrameTracker.setFrameReadyFence(std::move(frameReadyFence)); | 
|  | 356 | } else { | 
|  | 357 | // There was no fence for this frame, so assume that it was ready | 
|  | 358 | // to be presented at the desired present time. | 
|  | 359 | mFrameTracker.setFrameReadyTime(desiredPresentTime); | 
| Dominik Laskowski | 45de9bd | 2018-06-11 17:44:10 -0700 | [diff] [blame] | 360 | } | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 361 |  | 
|  | 362 | if (presentFence->isValid()) { | 
| Yiwei Zhang | 1a88c40 | 2019-11-18 10:43:58 -0800 | [diff] [blame] | 363 | mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence); | 
|  | 364 | mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber, | 
| Mikael Pessa | 90092f4 | 2019-08-26 17:22:04 -0700 | [diff] [blame] | 365 | presentFence, FrameTracer::FrameEvent::PRESENT_FENCE); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 366 | mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence)); | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 367 | } else if (!display) { | 
|  | 368 | // Do nothing. | 
|  | 369 | } else if (const auto displayId = display->getId(); | 
|  | 370 | displayId && mFlinger->getHwComposer().isConnected(*displayId)) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 371 | // The HWC doesn't support present fences, so use the refresh | 
|  | 372 | // timestamp instead. | 
| Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 373 | const nsecs_t actualPresentTime = mFlinger->getHwComposer().getRefreshTimestamp(*displayId); | 
| Yiwei Zhang | 1a88c40 | 2019-11-18 10:43:58 -0800 | [diff] [blame] | 374 | mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime); | 
|  | 375 | mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber, | 
| Mikael Pessa | 90092f4 | 2019-08-26 17:22:04 -0700 | [diff] [blame] | 376 | actualPresentTime, | 
|  | 377 | FrameTracer::FrameEvent::PRESENT_FENCE); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 378 | mFrameTracker.setActualPresentTime(actualPresentTime); | 
|  | 379 | } | 
|  | 380 |  | 
|  | 381 | mFrameTracker.advanceFrame(); | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 382 | mBufferInfo.mFrameLatencyNeeded = false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 383 | return true; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 384 | } | 
|  | 385 |  | 
| chaviw | debadb8 | 2020-03-26 14:57:24 -0700 | [diff] [blame] | 386 | void BufferLayer::gatherBufferInfo() { | 
|  | 387 | mBufferInfo.mPixelFormat = | 
|  | 388 | !mBufferInfo.mBuffer ? PIXEL_FORMAT_NONE : mBufferInfo.mBuffer->format; | 
|  | 389 | mBufferInfo.mFrameLatencyNeeded = true; | 
|  | 390 | } | 
|  | 391 |  | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 392 | bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime, | 
|  | 393 | nsecs_t expectedPresentTime) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 394 | ATRACE_CALL(); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 395 |  | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 396 | bool refreshRequired = latchSidebandStream(recomputeVisibleRegions); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 397 |  | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 398 | if (refreshRequired) { | 
|  | 399 | return refreshRequired; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 400 | } | 
|  | 401 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 402 | if (!hasReadyFrame()) { | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 403 | return false; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 404 | } | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 405 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 406 | // if we've already called updateTexImage() without going through | 
|  | 407 | // a composition step, we have to skip this layer at this point | 
|  | 408 | // because we cannot call updateTeximage() without a corresponding | 
|  | 409 | // compositionComplete() call. | 
|  | 410 | // we'll trigger an update in onPreComposition(). | 
|  | 411 | if (mRefreshPending) { | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 412 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 413 | } | 
|  | 414 |  | 
|  | 415 | // If the head buffer's acquire fence hasn't signaled yet, return and | 
|  | 416 | // try again later | 
|  | 417 | if (!fenceHasSignaled()) { | 
| Ady Abraham | 09bd392 | 2019-04-08 10:44:56 -0700 | [diff] [blame] | 418 | ATRACE_NAME("!fenceHasSignaled()"); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 419 | mFlinger->signalLayerUpdate(); | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 420 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 421 | } | 
|  | 422 |  | 
|  | 423 | // Capture the old state of the layer for comparisons later | 
|  | 424 | const State& s(getDrawingState()); | 
|  | 425 | const bool oldOpacity = isOpaque(s); | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 426 |  | 
|  | 427 | BufferInfo oldBufferInfo = mBufferInfo; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 428 |  | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 429 | if (!allTransactionsSignaled(expectedPresentTime)) { | 
| Marissa Wall | ebb486e | 2019-05-15 14:08:08 -0700 | [diff] [blame] | 430 | mFlinger->setTransactionFlags(eTraversalNeeded); | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 431 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 432 | } | 
|  | 433 |  | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 434 | status_t err = updateTexImage(recomputeVisibleRegions, latchTime, expectedPresentTime); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 435 | if (err != NO_ERROR) { | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 436 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 437 | } | 
|  | 438 |  | 
|  | 439 | err = updateActiveBuffer(); | 
|  | 440 | if (err != NO_ERROR) { | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 441 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 442 | } | 
|  | 443 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 444 | err = updateFrameNumber(latchTime); | 
|  | 445 | if (err != NO_ERROR) { | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 446 | return false; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 447 | } | 
|  | 448 |  | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 449 | gatherBufferInfo(); | 
|  | 450 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 451 | mRefreshPending = true; | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 452 | if (oldBufferInfo.mBuffer == nullptr) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 453 | // the first time we receive a buffer, we need to trigger a | 
|  | 454 | // geometry invalidation. | 
|  | 455 | recomputeVisibleRegions = true; | 
|  | 456 | } | 
|  | 457 |  | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 458 | if ((mBufferInfo.mCrop != oldBufferInfo.mCrop) || | 
|  | 459 | (mBufferInfo.mTransform != oldBufferInfo.mTransform) || | 
|  | 460 | (mBufferInfo.mScaleMode != oldBufferInfo.mScaleMode) || | 
|  | 461 | (mBufferInfo.mTransformToDisplayInverse != oldBufferInfo.mTransformToDisplayInverse)) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 462 | recomputeVisibleRegions = true; | 
|  | 463 | } | 
|  | 464 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 465 | if (oldBufferInfo.mBuffer != nullptr) { | 
|  | 466 | uint32_t bufWidth = mBufferInfo.mBuffer->getWidth(); | 
|  | 467 | uint32_t bufHeight = mBufferInfo.mBuffer->getHeight(); | 
|  | 468 | if (bufWidth != uint32_t(oldBufferInfo.mBuffer->width) || | 
|  | 469 | bufHeight != uint32_t(oldBufferInfo.mBuffer->height)) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 470 | recomputeVisibleRegions = true; | 
|  | 471 | } | 
|  | 472 | } | 
|  | 473 |  | 
|  | 474 | if (oldOpacity != isOpaque(s)) { | 
|  | 475 | recomputeVisibleRegions = true; | 
|  | 476 | } | 
|  | 477 |  | 
|  | 478 | // Remove any sync points corresponding to the buffer which was just | 
|  | 479 | // latched | 
|  | 480 | { | 
|  | 481 | Mutex::Autolock lock(mLocalSyncPointMutex); | 
|  | 482 | auto point = mLocalSyncPoints.begin(); | 
|  | 483 | while (point != mLocalSyncPoints.end()) { | 
|  | 484 | if (!(*point)->frameIsAvailable() || !(*point)->transactionIsApplied()) { | 
|  | 485 | // This sync point must have been added since we started | 
|  | 486 | // latching. Don't drop it yet. | 
|  | 487 | ++point; | 
|  | 488 | continue; | 
|  | 489 | } | 
|  | 490 |  | 
|  | 491 | if ((*point)->getFrameNumber() <= mCurrentFrameNumber) { | 
| Alec Mouri | e60041e | 2019-06-14 18:59:51 -0700 | [diff] [blame] | 492 | std::stringstream ss; | 
|  | 493 | ss << "Dropping sync point " << (*point)->getFrameNumber(); | 
|  | 494 | ATRACE_NAME(ss.str().c_str()); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 495 | point = mLocalSyncPoints.erase(point); | 
|  | 496 | } else { | 
|  | 497 | ++point; | 
|  | 498 | } | 
|  | 499 | } | 
|  | 500 | } | 
|  | 501 |  | 
| Vishnu Nair | 6194e2e | 2019-02-06 12:58:39 -0800 | [diff] [blame] | 502 | return true; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 503 | } | 
|  | 504 |  | 
|  | 505 | // transaction | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 506 | void BufferLayer::notifyAvailableFrames(nsecs_t expectedPresentTime) { | 
|  | 507 | const auto headFrameNumber = getHeadFrameNumber(expectedPresentTime); | 
| Ady Abraham | cd1580c | 2019-04-29 15:40:03 -0700 | [diff] [blame] | 508 | const bool headFenceSignaled = fenceHasSignaled(); | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 509 | const bool presentTimeIsCurrent = framePresentTimeIsCurrent(expectedPresentTime); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 510 | Mutex::Autolock lock(mLocalSyncPointMutex); | 
|  | 511 | for (auto& point : mLocalSyncPoints) { | 
| Ady Abraham | cd1580c | 2019-04-29 15:40:03 -0700 | [diff] [blame] | 512 | if (headFrameNumber >= point->getFrameNumber() && headFenceSignaled && | 
|  | 513 | presentTimeIsCurrent) { | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 514 | point->setFrameAvailable(); | 
| chaviw | 43cb3cb | 2019-05-31 15:23:41 -0700 | [diff] [blame] | 515 | sp<Layer> requestedSyncLayer = point->getRequestedSyncLayer(); | 
|  | 516 | if (requestedSyncLayer) { | 
|  | 517 | // Need to update the transaction flag to ensure the layer's pending transaction | 
|  | 518 | // gets applied. | 
|  | 519 | requestedSyncLayer->setTransactionFlags(eTransactionNeeded); | 
|  | 520 | } | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 521 | } | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 522 | } | 
|  | 523 | } | 
|  | 524 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 525 | bool BufferLayer::hasReadyFrame() const { | 
| Marissa Wall | 024a191 | 2018-08-13 13:55:35 -0700 | [diff] [blame] | 526 | return hasFrameUpdate() || getSidebandStreamChanged() || getAutoRefresh(); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 527 | } | 
|  | 528 |  | 
|  | 529 | uint32_t BufferLayer::getEffectiveScalingMode() const { | 
|  | 530 | if (mOverrideScalingMode >= 0) { | 
|  | 531 | return mOverrideScalingMode; | 
|  | 532 | } | 
|  | 533 |  | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 534 | return mBufferInfo.mScaleMode; | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 535 | } | 
|  | 536 |  | 
|  | 537 | bool BufferLayer::isProtected() const { | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 538 | const sp<GraphicBuffer>& buffer(mBufferInfo.mBuffer); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 539 | return (buffer != 0) && (buffer->getUsage() & GRALLOC_USAGE_PROTECTED); | 
|  | 540 | } | 
|  | 541 |  | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 542 | // h/w composer set-up | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 543 | bool BufferLayer::allTransactionsSignaled(nsecs_t expectedPresentTime) { | 
|  | 544 | const auto headFrameNumber = getHeadFrameNumber(expectedPresentTime); | 
| Marissa Wall | fd66862 | 2018-05-10 10:21:13 -0700 | [diff] [blame] | 545 | bool matchingFramesFound = false; | 
|  | 546 | bool allTransactionsApplied = true; | 
|  | 547 | Mutex::Autolock lock(mLocalSyncPointMutex); | 
|  | 548 |  | 
|  | 549 | for (auto& point : mLocalSyncPoints) { | 
|  | 550 | if (point->getFrameNumber() > headFrameNumber) { | 
|  | 551 | break; | 
|  | 552 | } | 
|  | 553 | matchingFramesFound = true; | 
|  | 554 |  | 
|  | 555 | if (!point->frameIsAvailable()) { | 
|  | 556 | // We haven't notified the remote layer that the frame for | 
|  | 557 | // this point is available yet. Notify it now, and then | 
|  | 558 | // abort this attempt to latch. | 
|  | 559 | point->setFrameAvailable(); | 
|  | 560 | allTransactionsApplied = false; | 
|  | 561 | break; | 
|  | 562 | } | 
|  | 563 |  | 
|  | 564 | allTransactionsApplied = allTransactionsApplied && point->transactionIsApplied(); | 
|  | 565 | } | 
|  | 566 | return !matchingFramesFound || allTransactionsApplied; | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 567 | } | 
|  | 568 |  | 
|  | 569 | // As documented in libhardware header, formats in the range | 
|  | 570 | // 0x100 - 0x1FF are specific to the HAL implementation, and | 
|  | 571 | // are known to have no alpha channel | 
|  | 572 | // TODO: move definition for device-specific range into | 
|  | 573 | // hardware.h, instead of using hard-coded values here. | 
|  | 574 | #define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF) | 
|  | 575 |  | 
|  | 576 | bool BufferLayer::getOpacityForFormat(uint32_t format) { | 
|  | 577 | if (HARDWARE_IS_DEVICE_FORMAT(format)) { | 
|  | 578 | return true; | 
|  | 579 | } | 
|  | 580 | switch (format) { | 
|  | 581 | case HAL_PIXEL_FORMAT_RGBA_8888: | 
|  | 582 | case HAL_PIXEL_FORMAT_BGRA_8888: | 
|  | 583 | case HAL_PIXEL_FORMAT_RGBA_FP16: | 
|  | 584 | case HAL_PIXEL_FORMAT_RGBA_1010102: | 
|  | 585 | return false; | 
|  | 586 | } | 
|  | 587 | // in all other case, we have no blending (also for unknown formats) | 
|  | 588 | return true; | 
|  | 589 | } | 
|  | 590 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 591 | bool BufferLayer::needsFiltering(const DisplayDevice* display) const { | 
|  | 592 | const auto outputLayer = findOutputLayerForDisplay(display); | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 593 | if (outputLayer == nullptr) { | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 594 | return false; | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 595 | } | 
|  | 596 |  | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 597 | // We need filtering if the sourceCrop rectangle size does not match the | 
|  | 598 | // displayframe rectangle size (not a 1:1 render) | 
| Lloyd Pique | 37c2c9b | 2018-12-04 17:25:10 -0800 | [diff] [blame] | 599 | const auto& compositionState = outputLayer->getState(); | 
|  | 600 | const auto displayFrame = compositionState.displayFrame; | 
|  | 601 | const auto sourceCrop = compositionState.sourceCrop; | 
| Lloyd Pique | f16688f | 2019-02-19 17:47:57 -0800 | [diff] [blame] | 602 | return sourceCrop.getHeight() != displayFrame.getHeight() || | 
| Peiyong Lin | c2020ca | 2019-01-10 11:36:12 -0800 | [diff] [blame] | 603 | sourceCrop.getWidth() != displayFrame.getWidth(); | 
| Chia-I Wu | 692e083 | 2018-06-05 15:46:58 -0700 | [diff] [blame] | 604 | } | 
|  | 605 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 606 | bool BufferLayer::needsFilteringForScreenshots(const DisplayDevice* display, | 
| Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame] | 607 | const ui::Transform& inverseParentTransform) const { | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 608 | const auto outputLayer = findOutputLayerForDisplay(display); | 
| Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame] | 609 | if (outputLayer == nullptr) { | 
|  | 610 | return false; | 
|  | 611 | } | 
|  | 612 |  | 
|  | 613 | // We need filtering if the sourceCrop rectangle size does not match the | 
|  | 614 | // viewport rectangle size (not a 1:1 render) | 
|  | 615 | const auto& compositionState = outputLayer->getState(); | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 616 | const ui::Transform& displayTransform = display->getTransform(); | 
| Alec Mouri | 5a6d857 | 2020-03-23 23:56:15 -0700 | [diff] [blame] | 617 | const ui::Transform inverseTransform = inverseParentTransform * displayTransform.inverse(); | 
|  | 618 | // Undo the transformation of the displayFrame so that we're back into | 
|  | 619 | // layer-stack space. | 
|  | 620 | const Rect frame = inverseTransform.transform(compositionState.displayFrame); | 
|  | 621 | const FloatRect sourceCrop = compositionState.sourceCrop; | 
|  | 622 |  | 
|  | 623 | int32_t frameHeight = frame.getHeight(); | 
|  | 624 | int32_t frameWidth = frame.getWidth(); | 
|  | 625 | // If the display transform had a rotational component then undo the | 
|  | 626 | // rotation so that the orientation matches the source crop. | 
|  | 627 | if (displayTransform.getOrientation() & ui::Transform::ROT_90) { | 
|  | 628 | std::swap(frameHeight, frameWidth); | 
|  | 629 | } | 
|  | 630 | return sourceCrop.getHeight() != frameHeight || sourceCrop.getWidth() != frameWidth; | 
|  | 631 | } | 
|  | 632 |  | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 633 | uint64_t BufferLayer::getHeadFrameNumber(nsecs_t expectedPresentTime) const { | 
| Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 634 | if (hasFrameUpdate()) { | 
| Dominik Laskowski | a8955dd | 2019-07-10 10:19:09 -0700 | [diff] [blame] | 635 | return getFrameNumber(expectedPresentTime); | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 636 | } else { | 
|  | 637 | return mCurrentFrameNumber; | 
|  | 638 | } | 
|  | 639 | } | 
|  | 640 |  | 
| Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 641 | Rect BufferLayer::getBufferSize(const State& s) const { | 
|  | 642 | // If we have a sideband stream, or we are scaling the buffer then return the layer size since | 
|  | 643 | // we cannot determine the buffer size. | 
|  | 644 | if ((s.sidebandStream != nullptr) || | 
|  | 645 | (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) { | 
|  | 646 | return Rect(getActiveWidth(s), getActiveHeight(s)); | 
|  | 647 | } | 
|  | 648 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 649 | if (mBufferInfo.mBuffer == nullptr) { | 
| Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 650 | return Rect::INVALID_RECT; | 
|  | 651 | } | 
|  | 652 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 653 | uint32_t bufWidth = mBufferInfo.mBuffer->getWidth(); | 
|  | 654 | uint32_t bufHeight = mBufferInfo.mBuffer->getHeight(); | 
| Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 655 |  | 
|  | 656 | // Undo any transformations on the buffer and return the result. | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 657 | if (mBufferInfo.mTransform & ui::Transform::ROT_90) { | 
| Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 658 | std::swap(bufWidth, bufHeight); | 
|  | 659 | } | 
|  | 660 |  | 
| Lloyd Pique | 0449b0f | 2018-12-20 16:23:45 -0800 | [diff] [blame] | 661 | if (getTransformToDisplayInverse()) { | 
| Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 662 | uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags(); | 
| Vishnu Nair | 6035634 | 2018-11-13 13:00:45 -0800 | [diff] [blame] | 663 | if (invTransform & ui::Transform::ROT_90) { | 
|  | 664 | std::swap(bufWidth, bufHeight); | 
|  | 665 | } | 
|  | 666 | } | 
|  | 667 |  | 
|  | 668 | return Rect(bufWidth, bufHeight); | 
|  | 669 | } | 
|  | 670 |  | 
| Vishnu Nair | 4351ad5 | 2019-02-11 14:13:02 -0800 | [diff] [blame] | 671 | FloatRect BufferLayer::computeSourceBounds(const FloatRect& parentBounds) const { | 
|  | 672 | const State& s(getDrawingState()); | 
|  | 673 |  | 
|  | 674 | // If we have a sideband stream, or we are scaling the buffer then return the layer size since | 
|  | 675 | // we cannot determine the buffer size. | 
|  | 676 | if ((s.sidebandStream != nullptr) || | 
|  | 677 | (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) { | 
|  | 678 | return FloatRect(0, 0, getActiveWidth(s), getActiveHeight(s)); | 
|  | 679 | } | 
|  | 680 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 681 | if (mBufferInfo.mBuffer == nullptr) { | 
| Vishnu Nair | 4351ad5 | 2019-02-11 14:13:02 -0800 | [diff] [blame] | 682 | return parentBounds; | 
|  | 683 | } | 
|  | 684 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 685 | uint32_t bufWidth = mBufferInfo.mBuffer->getWidth(); | 
|  | 686 | uint32_t bufHeight = mBufferInfo.mBuffer->getHeight(); | 
| Vishnu Nair | 4351ad5 | 2019-02-11 14:13:02 -0800 | [diff] [blame] | 687 |  | 
|  | 688 | // Undo any transformations on the buffer and return the result. | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 689 | if (mBufferInfo.mTransform & ui::Transform::ROT_90) { | 
| Vishnu Nair | 4351ad5 | 2019-02-11 14:13:02 -0800 | [diff] [blame] | 690 | std::swap(bufWidth, bufHeight); | 
|  | 691 | } | 
|  | 692 |  | 
|  | 693 | if (getTransformToDisplayInverse()) { | 
| Dominik Laskowski | 718f960 | 2019-11-09 20:01:35 -0800 | [diff] [blame] | 694 | uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags(); | 
| Vishnu Nair | 4351ad5 | 2019-02-11 14:13:02 -0800 | [diff] [blame] | 695 | if (invTransform & ui::Transform::ROT_90) { | 
|  | 696 | std::swap(bufWidth, bufHeight); | 
|  | 697 | } | 
|  | 698 | } | 
|  | 699 |  | 
|  | 700 | return FloatRect(0, 0, bufWidth, bufHeight); | 
|  | 701 | } | 
|  | 702 |  | 
| chaviw | 49a108c | 2019-08-12 11:23:06 -0700 | [diff] [blame] | 703 | void BufferLayer::latchAndReleaseBuffer() { | 
|  | 704 | mRefreshPending = false; | 
|  | 705 | if (hasReadyFrame()) { | 
|  | 706 | bool ignored = false; | 
|  | 707 | latchBuffer(ignored, systemTime(), 0 /* expectedPresentTime */); | 
|  | 708 | } | 
|  | 709 | releasePendingBuffer(systemTime()); | 
|  | 710 | } | 
|  | 711 |  | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 712 | PixelFormat BufferLayer::getPixelFormat() const { | 
|  | 713 | return mBufferInfo.mPixelFormat; | 
|  | 714 | } | 
|  | 715 |  | 
|  | 716 | bool BufferLayer::getTransformToDisplayInverse() const { | 
|  | 717 | return mBufferInfo.mTransformToDisplayInverse; | 
|  | 718 | } | 
|  | 719 |  | 
|  | 720 | Rect BufferLayer::getBufferCrop() const { | 
|  | 721 | // this is the crop rectangle that applies to the buffer | 
|  | 722 | // itself (as opposed to the window) | 
|  | 723 | if (!mBufferInfo.mCrop.isEmpty()) { | 
|  | 724 | // if the buffer crop is defined, we use that | 
|  | 725 | return mBufferInfo.mCrop; | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 726 | } else if (mBufferInfo.mBuffer != nullptr) { | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 727 | // otherwise we use the whole buffer | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 728 | return mBufferInfo.mBuffer->getBounds(); | 
| chaviw | 4244e03 | 2019-09-04 11:27:49 -0700 | [diff] [blame] | 729 | } else { | 
|  | 730 | // if we don't have a buffer yet, we use an empty/invalid crop | 
|  | 731 | return Rect(); | 
|  | 732 | } | 
|  | 733 | } | 
|  | 734 |  | 
|  | 735 | uint32_t BufferLayer::getBufferTransform() const { | 
|  | 736 | return mBufferInfo.mTransform; | 
|  | 737 | } | 
|  | 738 |  | 
|  | 739 | ui::Dataspace BufferLayer::getDataSpace() const { | 
|  | 740 | return mBufferInfo.mDataspace; | 
|  | 741 | } | 
|  | 742 |  | 
|  | 743 | ui::Dataspace BufferLayer::translateDataspace(ui::Dataspace dataspace) { | 
|  | 744 | ui::Dataspace updatedDataspace = dataspace; | 
|  | 745 | // translate legacy dataspaces to modern dataspaces | 
|  | 746 | switch (dataspace) { | 
|  | 747 | case ui::Dataspace::SRGB: | 
|  | 748 | updatedDataspace = ui::Dataspace::V0_SRGB; | 
|  | 749 | break; | 
|  | 750 | case ui::Dataspace::SRGB_LINEAR: | 
|  | 751 | updatedDataspace = ui::Dataspace::V0_SRGB_LINEAR; | 
|  | 752 | break; | 
|  | 753 | case ui::Dataspace::JFIF: | 
|  | 754 | updatedDataspace = ui::Dataspace::V0_JFIF; | 
|  | 755 | break; | 
|  | 756 | case ui::Dataspace::BT601_625: | 
|  | 757 | updatedDataspace = ui::Dataspace::V0_BT601_625; | 
|  | 758 | break; | 
|  | 759 | case ui::Dataspace::BT601_525: | 
|  | 760 | updatedDataspace = ui::Dataspace::V0_BT601_525; | 
|  | 761 | break; | 
|  | 762 | case ui::Dataspace::BT709: | 
|  | 763 | updatedDataspace = ui::Dataspace::V0_BT709; | 
|  | 764 | break; | 
|  | 765 | default: | 
|  | 766 | break; | 
|  | 767 | } | 
|  | 768 |  | 
|  | 769 | return updatedDataspace; | 
|  | 770 | } | 
|  | 771 |  | 
| chaviw | d62d306 | 2019-09-04 14:48:02 -0700 | [diff] [blame] | 772 | sp<GraphicBuffer> BufferLayer::getBuffer() const { | 
|  | 773 | return mBufferInfo.mBuffer; | 
|  | 774 | } | 
|  | 775 |  | 
| chaviw | f83ce18 | 2019-09-12 14:43:08 -0700 | [diff] [blame] | 776 | void BufferLayer::getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]) { | 
|  | 777 | GLConsumer::computeTransformMatrix(outMatrix, mBufferInfo.mBuffer, mBufferInfo.mCrop, | 
|  | 778 | mBufferInfo.mTransform, filteringEnabled); | 
|  | 779 | } | 
|  | 780 |  | 
| chaviw | b4c6e58 | 2019-08-16 14:35:07 -0700 | [diff] [blame] | 781 | void BufferLayer::setInitialValuesForClone(const sp<Layer>& clonedFrom) { | 
|  | 782 | Layer::setInitialValuesForClone(clonedFrom); | 
|  | 783 |  | 
|  | 784 | sp<BufferLayer> bufferClonedFrom = static_cast<BufferLayer*>(clonedFrom.get()); | 
|  | 785 | mPremultipliedAlpha = bufferClonedFrom->mPremultipliedAlpha; | 
|  | 786 | mPotentialCursor = bufferClonedFrom->mPotentialCursor; | 
|  | 787 | mProtectedByApp = bufferClonedFrom->mProtectedByApp; | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 788 |  | 
|  | 789 | updateCloneBufferInfo(); | 
|  | 790 | } | 
|  | 791 |  | 
|  | 792 | void BufferLayer::updateCloneBufferInfo() { | 
|  | 793 | if (!isClone() || !isClonedFromAlive()) { | 
|  | 794 | return; | 
|  | 795 | } | 
|  | 796 |  | 
|  | 797 | sp<BufferLayer> clonedFrom = static_cast<BufferLayer*>(getClonedFrom().get()); | 
|  | 798 | mBufferInfo = clonedFrom->mBufferInfo; | 
|  | 799 | mSidebandStream = clonedFrom->mSidebandStream; | 
|  | 800 | surfaceDamageRegion = clonedFrom->surfaceDamageRegion; | 
|  | 801 | mCurrentFrameNumber = clonedFrom->mCurrentFrameNumber.load(); | 
|  | 802 | mPreviousFrameNumber = clonedFrom->mPreviousFrameNumber; | 
|  | 803 |  | 
|  | 804 | // After buffer info is updated, the drawingState from the real layer needs to be copied into | 
|  | 805 | // the cloned. This is because some properties of drawingState can change when latchBuffer is | 
| chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 806 | // called. However, copying the drawingState would also overwrite the cloned layer's relatives | 
|  | 807 | // and touchableRegionCrop. Therefore, temporarily store the relatives so they can be set in | 
|  | 808 | // the cloned drawingState again. | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 809 | wp<Layer> tmpZOrderRelativeOf = mDrawingState.zOrderRelativeOf; | 
|  | 810 | SortedVector<wp<Layer>> tmpZOrderRelatives = mDrawingState.zOrderRelatives; | 
| chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 811 | wp<Layer> tmpTouchableRegionCrop = mDrawingState.touchableRegionCrop; | 
|  | 812 | InputWindowInfo tmpInputInfo = mDrawingState.inputInfo; | 
|  | 813 |  | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 814 | mDrawingState = clonedFrom->mDrawingState; | 
| chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 815 |  | 
|  | 816 | mDrawingState.touchableRegionCrop = tmpTouchableRegionCrop; | 
| chaviw | 74b0317 | 2019-08-19 11:09:03 -0700 | [diff] [blame] | 817 | mDrawingState.zOrderRelativeOf = tmpZOrderRelativeOf; | 
|  | 818 | mDrawingState.zOrderRelatives = tmpZOrderRelatives; | 
| chaviw | af87b3e | 2019-10-01 16:59:28 -0700 | [diff] [blame] | 819 | mDrawingState.inputInfo = tmpInputInfo; | 
| chaviw | b4c6e58 | 2019-08-16 14:35:07 -0700 | [diff] [blame] | 820 | } | 
|  | 821 |  | 
| Dominik Laskowski | b7251f4 | 2020-04-20 17:42:59 -0700 | [diff] [blame] | 822 | void BufferLayer::setTransformHint(ui::Transform::RotationFlags displayTransformHint) { | 
| Vishnu Nair | 6213bd9 | 2020-05-08 17:42:25 -0700 | [diff] [blame] | 823 | mTransformHint = getFixedTransformHint(); | 
|  | 824 | if (mTransformHint == ui::Transform::ROT_INVALID) { | 
|  | 825 | mTransformHint = displayTransformHint; | 
|  | 826 | } | 
|  | 827 | } | 
|  | 828 |  | 
| David Sodman | 0c69cad | 2017-08-21 12:12:51 -0700 | [diff] [blame] | 829 | } // namespace android | 
|  | 830 |  | 
|  | 831 | #if defined(__gl_h_) | 
|  | 832 | #error "don't include gl/gl.h in this file" | 
|  | 833 | #endif | 
|  | 834 |  | 
|  | 835 | #if defined(__gl2_h_) | 
|  | 836 | #error "don't include gl2/gl2.h in this file" | 
|  | 837 | #endif | 
| Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 838 |  | 
|  | 839 | // TODO(b/129481165): remove the #pragma below and fix conversion issues | 
|  | 840 | #pragma clang diagnostic pop // ignored "-Wconversion" |