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