Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2013 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 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 21 | // #define LOG_NDEBUG 0 |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 22 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 23 | #include <cinttypes> |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 24 | |
Jim Shargo | 6ccc5e8 | 2024-07-27 03:42:08 +0000 | [diff] [blame] | 25 | #include <com_android_graphics_libgui_flags.h> |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 26 | #include <ftl/enum.h> |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 27 | #include <ftl/flags.h> |
Dan Stoza | 11611f9 | 2015-03-12 15:12:44 -0700 | [diff] [blame] | 28 | #include <gui/BufferItem.h> |
Mathias Agopian | a934764 | 2017-02-13 16:42:28 -0800 | [diff] [blame] | 29 | #include <gui/BufferQueue.h> |
Pablo Ceballos | f133d00 | 2015-10-23 12:10:13 -0700 | [diff] [blame] | 30 | #include <gui/IProducerListener.h> |
Mathias Agopian | 6a3c05b | 2017-04-27 20:06:55 -0700 | [diff] [blame] | 31 | #include <system/window.h> |
Dan Stoza | 11611f9 | 2015-03-12 15:12:44 -0700 | [diff] [blame] | 32 | |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 33 | #include "HWComposer.h" |
| 34 | #include "SurfaceFlinger.h" |
| 35 | #include "VirtualDisplaySurface.h" |
| 36 | |
Jesse Hall | 24cd98e | 2014-07-13 14:37:16 -0700 | [diff] [blame] | 37 | #define VDS_LOGE(msg, ...) ALOGE("[%s] " msg, \ |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 38 | mDisplayName.c_str(), ##__VA_ARGS__) |
Jesse Hall | 24cd98e | 2014-07-13 14:37:16 -0700 | [diff] [blame] | 39 | #define VDS_LOGW_IF(cond, msg, ...) ALOGW_IF(cond, "[%s] " msg, \ |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 40 | mDisplayName.c_str(), ##__VA_ARGS__) |
Jesse Hall | 24cd98e | 2014-07-13 14:37:16 -0700 | [diff] [blame] | 41 | #define VDS_LOGV(msg, ...) ALOGV("[%s] " msg, \ |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 42 | mDisplayName.c_str(), ##__VA_ARGS__) |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 43 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 44 | #define UNSUPPORTED() \ |
| 45 | VDS_LOGE("%s: Invalid operation on virtual display", __func__); \ |
| 46 | return INVALID_OPERATION |
| 47 | |
| 48 | namespace android { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 49 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 50 | VirtualDisplaySurface::VirtualDisplaySurface(HWComposer& hwc, VirtualDisplayId displayId, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 51 | const sp<IGraphicBufferProducer>& sink, |
| 52 | const sp<IGraphicBufferProducer>& bqProducer, |
| 53 | const sp<IGraphicBufferConsumer>& bqConsumer, |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 54 | const std::string& name, bool secure) |
Jim Shargo | 6ccc5e8 | 2024-07-27 03:42:08 +0000 | [diff] [blame] | 55 | #if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) |
| 56 | : ConsumerBase(bqProducer, bqConsumer), |
| 57 | #else |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 58 | : ConsumerBase(bqConsumer), |
Jim Shargo | 6ccc5e8 | 2024-07-27 03:42:08 +0000 | [diff] [blame] | 59 | #endif // COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(WB_CONSUMER_BASE_OWNS_BQ) |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 60 | mHwc(hwc), |
| 61 | mDisplayId(displayId), |
| 62 | mDisplayName(name), |
| 63 | mSource{}, |
| 64 | mDefaultOutputFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), |
| 65 | mOutputFormat(HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED), |
| 66 | mOutputUsage(GRALLOC_USAGE_HW_COMPOSER), |
| 67 | mProducerSlotSource(0), |
| 68 | mProducerBuffers(), |
KaiChieh Chuang | c522213 | 2019-12-20 07:38:19 +0800 | [diff] [blame] | 69 | mProducerSlotNeedReallocation(0), |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 70 | mQueueBufferOutput(), |
| 71 | mSinkBufferWidth(0), |
| 72 | mSinkBufferHeight(0), |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 73 | mFbFence(Fence::NO_FENCE), |
| 74 | mOutputFence(Fence::NO_FENCE), |
| 75 | mFbProducerSlot(BufferQueue::INVALID_BUFFER_SLOT), |
| 76 | mOutputProducerSlot(BufferQueue::INVALID_BUFFER_SLOT), |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 77 | mForceHwcCopy(SurfaceFlinger::useHwcForRgbToYuv), |
| 78 | mSecure(secure), |
| 79 | mSinkUsage(0) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 80 | mSource[SOURCE_SINK] = sink; |
Dan Stoza | b9b0883 | 2014-03-13 11:55:57 -0700 | [diff] [blame] | 81 | mSource[SOURCE_SCRATCH] = bqProducer; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 82 | |
| 83 | resetPerFrameState(); |
| 84 | |
| 85 | int sinkWidth, sinkHeight; |
Jesse Hall | 497ba0e | 2013-11-04 16:43:03 -0800 | [diff] [blame] | 86 | sink->query(NATIVE_WINDOW_WIDTH, &sinkWidth); |
| 87 | sink->query(NATIVE_WINDOW_HEIGHT, &sinkHeight); |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 88 | mSinkBufferWidth = sinkWidth; |
| 89 | mSinkBufferHeight = sinkHeight; |
Jesse Hall | 497ba0e | 2013-11-04 16:43:03 -0800 | [diff] [blame] | 90 | |
| 91 | // Pick the buffer format to request from the sink when not rendering to it |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 92 | // with GPU. If the consumer needs CPU access, use the default format |
Jesse Hall | 497ba0e | 2013-11-04 16:43:03 -0800 | [diff] [blame] | 93 | // set by the consumer. Otherwise allow gralloc to decide the format based |
| 94 | // on usage bits. |
| 95 | int sinkUsage; |
| 96 | sink->query(NATIVE_WINDOW_CONSUMER_USAGE_BITS, &sinkUsage); |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 97 | mSinkUsage |= (GRALLOC_USAGE_HW_COMPOSER | sinkUsage); |
| 98 | setOutputUsage(mSinkUsage); |
Jesse Hall | 497ba0e | 2013-11-04 16:43:03 -0800 | [diff] [blame] | 99 | if (sinkUsage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) { |
| 100 | int sinkFormat; |
| 101 | sink->query(NATIVE_WINDOW_FORMAT, &sinkFormat); |
| 102 | mDefaultOutputFormat = sinkFormat; |
| 103 | } else { |
| 104 | mDefaultOutputFormat = HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED; |
| 105 | } |
| 106 | mOutputFormat = mDefaultOutputFormat; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 107 | |
Dominik Laskowski | bf170d9 | 2018-04-19 15:08:05 -0700 | [diff] [blame] | 108 | ConsumerBase::mName = String8::format("VDS: %s", mDisplayName.c_str()); |
Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 109 | mConsumer->setConsumerName(ConsumerBase::mName); |
| 110 | mConsumer->setConsumerUsageBits(GRALLOC_USAGE_HW_COMPOSER); |
| 111 | mConsumer->setDefaultBufferSize(sinkWidth, sinkHeight); |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 112 | sink->setAsyncMode(true); |
Alec Mouri | 8d4f90a | 2018-11-14 22:33:24 +0000 | [diff] [blame] | 113 | IGraphicBufferProducer::QueueBufferOutput output; |
| 114 | mSource[SOURCE_SCRATCH]->connect(nullptr, NATIVE_WINDOW_API_EGL, false, &output); |
Brian Lindahl | 439afad | 2022-11-14 11:16:55 -0700 | [diff] [blame] | 115 | |
| 116 | for (size_t i = 0; i < sizeof(mHwcBufferIds) / sizeof(mHwcBufferIds[0]); ++i) { |
| 117 | mHwcBufferIds[i] = UINT64_MAX; |
| 118 | } |
Jesse Hall | ffe1f19 | 2013-03-22 15:13:48 -0700 | [diff] [blame] | 119 | } |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 120 | |
| 121 | VirtualDisplaySurface::~VirtualDisplaySurface() { |
Pablo Ceballos | f133d00 | 2015-10-23 12:10:13 -0700 | [diff] [blame] | 122 | mSource[SOURCE_SCRATCH]->disconnect(NATIVE_WINDOW_API_EGL); |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 123 | } |
| 124 | |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 125 | status_t VirtualDisplaySurface::beginFrame(bool mustRecompose) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 126 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 127 | return NO_ERROR; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 128 | } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 129 | |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 130 | mMustRecompose = mustRecompose; |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 131 | //For WFD use cases we must always set the recompose flag in order |
| 132 | //to support pause/resume functionality |
| 133 | if (mOutputUsage & GRALLOC_USAGE_HW_VIDEO_ENCODER) { |
| 134 | mMustRecompose = true; |
| 135 | } |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 136 | VDS_LOGW_IF(mDebugState != DebugState::Idle, "Unexpected %s in %s state", __func__, |
| 137 | ftl::enum_string(mDebugState).c_str()); |
| 138 | mDebugState = DebugState::Begun; |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 139 | |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 140 | return refreshOutputBuffer(); |
| 141 | } |
| 142 | |
| 143 | status_t VirtualDisplaySurface::prepareFrame(CompositionType compositionType) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 144 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 145 | return NO_ERROR; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 146 | } |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 147 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 148 | VDS_LOGW_IF(mDebugState != DebugState::Begun, "Unexpected %s in %s state", __func__, |
| 149 | ftl::enum_string(mDebugState).c_str()); |
| 150 | mDebugState = DebugState::Prepared; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 151 | |
| 152 | mCompositionType = compositionType; |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 153 | if (mForceHwcCopy && mCompositionType == CompositionType::Gpu) { |
Naseer Ahmed | 6a96846 | 2013-10-04 16:15:22 -0400 | [diff] [blame] | 154 | // Some hardware can do RGB->YUV conversion more efficiently in hardware |
| 155 | // controlled by HWC than in hardware controlled by the video encoder. |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 156 | // Forcing GPU-composed frames to go through an extra copy by the HWC |
Naseer Ahmed | 6a96846 | 2013-10-04 16:15:22 -0400 | [diff] [blame] | 157 | // allows the format conversion to happen there, rather than passing RGB |
| 158 | // directly to the consumer. |
| 159 | // |
| 160 | // On the other hand, when the consumer prefers RGB or can consume RGB |
| 161 | // inexpensively, this forces an unnecessary copy. |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 162 | mCompositionType = CompositionType::Mixed; |
Naseer Ahmed | 6a96846 | 2013-10-04 16:15:22 -0400 | [diff] [blame] | 163 | } |
| 164 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 165 | if (mCompositionType != mDebugLastCompositionType) { |
| 166 | VDS_LOGV("%s: composition type changed to %s", __func__, |
| 167 | toString(mCompositionType).c_str()); |
| 168 | mDebugLastCompositionType = mCompositionType; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 171 | if (mCompositionType != CompositionType::Gpu && |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 172 | (mOutputFormat != mDefaultOutputFormat || !(mOutputUsage & GRALLOC_USAGE_HW_COMPOSER))) { |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 173 | // We must have just switched from GPU-only to MIXED or HWC |
| 174 | // composition. Stop using the format and usage requested by the GPU |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 175 | // driver; they may be suboptimal when HWC is writing to the output |
| 176 | // buffer. For example, if the output is going to a video encoder, and |
| 177 | // HWC can write directly to YUV, some hardware can skip a |
| 178 | // memory-to-memory RGB-to-YUV conversion step. |
| 179 | // |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 180 | // If we just switched *to* GPU-only mode, we'll change the |
| 181 | // format/usage and get a new buffer when the GPU driver calls |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 182 | // dequeueBuffer(). |
Jesse Hall | 497ba0e | 2013-11-04 16:43:03 -0800 | [diff] [blame] | 183 | mOutputFormat = mDefaultOutputFormat; |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 184 | setOutputUsage(GRALLOC_USAGE_HW_COMPOSER); |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 185 | refreshOutputBuffer(); |
| 186 | } |
| 187 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 188 | return NO_ERROR; |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Alec Mouri | f97df4d | 2023-09-06 02:10:05 +0000 | [diff] [blame] | 191 | status_t VirtualDisplaySurface::advanceFrame(float hdrSdrRatio) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 192 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 193 | return NO_ERROR; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 194 | } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 195 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 196 | if (mCompositionType == CompositionType::Hwc) { |
| 197 | VDS_LOGW_IF(mDebugState != DebugState::Prepared, "Unexpected %s in %s state on HWC frame", |
| 198 | __func__, ftl::enum_string(mDebugState).c_str()); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 199 | } else { |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 200 | VDS_LOGW_IF(mDebugState != DebugState::GpuDone, |
| 201 | "Unexpected %s in %s state on GPU/MIXED frame", __func__, |
| 202 | ftl::enum_string(mDebugState).c_str()); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 203 | } |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 204 | mDebugState = DebugState::Hwc; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 205 | |
Jesse Hall | 14e8b01 | 2013-11-07 12:28:26 -0800 | [diff] [blame] | 206 | if (mOutputProducerSlot < 0 || |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 207 | (mCompositionType != CompositionType::Hwc && mFbProducerSlot < 0)) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 208 | // Last chance bailout if something bad happened earlier. For example, |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 209 | // in a graphics API configuration, if the sink disappears then dequeueBuffer |
| 210 | // will fail, the GPU driver won't queue a buffer, but SurfaceFlinger |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 211 | // will soldier on. So we end up here without a buffer. There should |
| 212 | // be lots of scary messages in the log just before this. |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 213 | VDS_LOGE("%s: no buffer, bailing out", __func__); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 214 | return NO_MEMORY; |
| 215 | } |
| 216 | |
Brian Lindahl | 439afad | 2022-11-14 11:16:55 -0700 | [diff] [blame] | 217 | sp<GraphicBuffer> const& fbBuffer = |
| 218 | mFbProducerSlot >= 0 ? mProducerBuffers[mFbProducerSlot] : sp<GraphicBuffer>(nullptr); |
| 219 | sp<GraphicBuffer> const& outBuffer = mProducerBuffers[mOutputProducerSlot]; |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 220 | VDS_LOGV("%s: fb=%d(%p) out=%d(%p)", __func__, mFbProducerSlot, fbBuffer.get(), |
| 221 | mOutputProducerSlot, outBuffer.get()); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 222 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 223 | const auto halDisplayId = HalVirtualDisplayId::tryCast(mDisplayId); |
| 224 | LOG_FATAL_IF(!halDisplayId); |
Jesse Hall | b716e57 | 2013-10-01 17:25:20 -0700 | [diff] [blame] | 225 | // At this point we know the output buffer acquire fence, |
| 226 | // so update HWC state with it. |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 227 | mHwc.setOutputBuffer(*halDisplayId, mOutputFence, outBuffer); |
Jesse Hall | b716e57 | 2013-10-01 17:25:20 -0700 | [diff] [blame] | 228 | |
Jesse Hall | 14e8b01 | 2013-11-07 12:28:26 -0800 | [diff] [blame] | 229 | status_t result = NO_ERROR; |
Peiyong Lin | 566a3b4 | 2018-01-09 18:22:43 -0800 | [diff] [blame] | 230 | if (fbBuffer != nullptr) { |
Brian Lindahl | 439afad | 2022-11-14 11:16:55 -0700 | [diff] [blame] | 231 | // assume that HWC has previously seen the buffer in this slot |
| 232 | sp<GraphicBuffer> hwcBuffer = sp<GraphicBuffer>(nullptr); |
| 233 | if (fbBuffer->getId() != mHwcBufferIds[mFbProducerSlot]) { |
| 234 | mHwcBufferIds[mFbProducerSlot] = fbBuffer->getId(); |
| 235 | hwcBuffer = fbBuffer; // HWC hasn't previously seen this buffer in this slot |
| 236 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 237 | // TODO: Correctly propagate the dataspace from GL composition |
Brian Lindahl | 439afad | 2022-11-14 11:16:55 -0700 | [diff] [blame] | 238 | result = mHwc.setClientTarget(*halDisplayId, mFbProducerSlot, mFbFence, hwcBuffer, |
Alec Mouri | f97df4d | 2023-09-06 02:10:05 +0000 | [diff] [blame] | 239 | ui::Dataspace::UNKNOWN, hdrSdrRatio); |
Jesse Hall | 14e8b01 | 2013-11-07 12:28:26 -0800 | [diff] [blame] | 240 | } |
| 241 | |
| 242 | return result; |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 243 | } |
| 244 | |
Jesse Hall | 851cfe8 | 2013-03-20 13:44:00 -0700 | [diff] [blame] | 245 | void VirtualDisplaySurface::onFrameCommitted() { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 246 | const auto halDisplayId = HalVirtualDisplayId::tryCast(mDisplayId); |
| 247 | if (!halDisplayId) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 248 | return; |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 249 | } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 250 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 251 | VDS_LOGW_IF(mDebugState != DebugState::Hwc, "Unexpected %s in %s state", __func__, |
| 252 | ftl::enum_string(mDebugState).c_str()); |
| 253 | mDebugState = DebugState::Idle; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 254 | |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 255 | sp<Fence> retireFence = mHwc.getPresentFence(*halDisplayId); |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 256 | if (mCompositionType == CompositionType::Mixed && mFbProducerSlot >= 0) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 257 | // release the scratch buffer back to the pool |
| 258 | Mutex::Autolock lock(mMutex); |
| 259 | int sslot = mapProducer2SourceSlot(SOURCE_SCRATCH, mFbProducerSlot); |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 260 | VDS_LOGV("%s: release scratch sslot=%d", __func__, sslot); |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 261 | addReleaseFenceLocked(sslot, mProducerBuffers[mFbProducerSlot], |
| 262 | retireFence); |
Chia-I Wu | 1e24cce | 2017-11-10 10:36:01 -0800 | [diff] [blame] | 263 | releaseBufferLocked(sslot, mProducerBuffers[mFbProducerSlot]); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 264 | } |
| 265 | |
| 266 | if (mOutputProducerSlot >= 0) { |
| 267 | int sslot = mapProducer2SourceSlot(SOURCE_SINK, mOutputProducerSlot); |
| 268 | QueueBufferOutput qbo; |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 269 | VDS_LOGV("%s: queue sink sslot=%d", __func__, sslot); |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 270 | if (retireFence->isValid() && mMustRecompose) { |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 271 | status_t result = mSource[SOURCE_SINK]->queueBuffer(sslot, |
| 272 | QueueBufferInput( |
| 273 | systemTime(), false /* isAutoTimestamp */, |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 274 | HAL_DATASPACE_UNKNOWN, |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 275 | Rect(mSinkBufferWidth, mSinkBufferHeight), |
| 276 | NATIVE_WINDOW_SCALING_MODE_FREEZE, 0 /* transform */, |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 277 | retireFence), |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 278 | &qbo); |
| 279 | if (result == NO_ERROR) { |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 280 | updateQueueBufferOutput(std::move(qbo)); |
Dan Stoza | 7143316 | 2014-02-04 16:22:36 -0800 | [diff] [blame] | 281 | } |
| 282 | } else { |
| 283 | // If the surface hadn't actually been updated, then we only went |
| 284 | // through the motions of updating the display to keep our state |
| 285 | // machine happy. We cancel the buffer to avoid triggering another |
| 286 | // re-composition and causing an infinite loop. |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 287 | mSource[SOURCE_SINK]->cancelBuffer(sslot, retireFence); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 288 | } |
| 289 | } |
| 290 | |
| 291 | resetPerFrameState(); |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 292 | } |
| 293 | |
Dan Stoza | 01049c8 | 2014-11-11 10:32:31 -0800 | [diff] [blame] | 294 | void VirtualDisplaySurface::dumpAsString(String8& /* result */) const { |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 295 | } |
| 296 | |
Marin Shalamanov | 045b700 | 2021-01-07 16:56:24 +0100 | [diff] [blame] | 297 | void VirtualDisplaySurface::resizeBuffers(const ui::Size& newSize) { |
| 298 | mQueueBufferOutput.width = newSize.width; |
| 299 | mQueueBufferOutput.height = newSize.height; |
| 300 | mSinkBufferWidth = newSize.width; |
| 301 | mSinkBufferHeight = newSize.height; |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 302 | } |
| 303 | |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 304 | const sp<Fence>& VirtualDisplaySurface::getClientTargetAcquireFence() const { |
| 305 | return mFbFence; |
| 306 | } |
Dan Stoza | 9e56aa0 | 2015-11-02 13:00:03 -0800 | [diff] [blame] | 307 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 308 | status_t VirtualDisplaySurface::requestBuffer(int pslot, |
| 309 | sp<GraphicBuffer>* outBuf) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 310 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 311 | return mSource[SOURCE_SINK]->requestBuffer(pslot, outBuf); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 312 | } |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 313 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 314 | VDS_LOGW_IF(mDebugState != DebugState::Gpu, "Unexpected %s pslot=%d in %s state", __func__, |
| 315 | pslot, ftl::enum_string(mDebugState).c_str()); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 316 | |
| 317 | *outBuf = mProducerBuffers[pslot]; |
| 318 | return NO_ERROR; |
| 319 | } |
| 320 | |
Pablo Ceballos | fa45535 | 2015-08-12 17:47:47 -0700 | [diff] [blame] | 321 | status_t VirtualDisplaySurface::setMaxDequeuedBufferCount( |
| 322 | int maxDequeuedBuffers) { |
| 323 | return mSource[SOURCE_SINK]->setMaxDequeuedBufferCount(maxDequeuedBuffers); |
| 324 | } |
| 325 | |
| 326 | status_t VirtualDisplaySurface::setAsyncMode(bool async) { |
| 327 | return mSource[SOURCE_SINK]->setAsyncMode(async); |
| 328 | } |
| 329 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 330 | status_t VirtualDisplaySurface::dequeueBuffer(Source source, |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 331 | PixelFormat format, uint64_t usage, int* sslot, sp<Fence>* fence) { |
Alan Ding | 5be0865 | 2024-05-24 01:48:07 +0000 | [diff] [blame] | 332 | LOG_ALWAYS_FATAL_IF(GpuVirtualDisplayId::tryCast(mDisplayId).has_value()); |
Jesse Hall | 8db9255 | 2013-08-29 16:03:50 -0700 | [diff] [blame] | 333 | |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 334 | // Exclude video encoder usage flag from scratch buffer usage flags. |
| 335 | if (source == SOURCE_SCRATCH) { |
| 336 | usage |= GRALLOC_USAGE_HW_FB; |
| 337 | usage &= ~(GRALLOC_USAGE_HW_VIDEO_ENCODER); |
Michael Bestas | dc203cd | 2022-02-18 17:19:02 +0200 | [diff] [blame] | 338 | VDS_LOGV("%s(%s): updated scratch buffer usage flags=%#" PRIx64, |
| 339 | __func__, ftl::enum_string(source).c_str(), usage); |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 340 | } |
| 341 | |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 342 | status_t result = |
| 343 | mSource[source]->dequeueBuffer(sslot, fence, mSinkBufferWidth, mSinkBufferHeight, |
| 344 | format, usage, nullptr, nullptr); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 345 | if (result < 0) |
| 346 | return result; |
| 347 | int pslot = mapSource2ProducerSlot(source, *sslot); |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 348 | VDS_LOGV("%s(%s): sslot=%d pslot=%d result=%d", __func__, ftl::enum_string(source).c_str(), |
| 349 | *sslot, pslot, result); |
Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 350 | uint64_t sourceBit = static_cast<uint64_t>(source) << pslot; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 351 | |
KaiChieh Chuang | c522213 | 2019-12-20 07:38:19 +0800 | [diff] [blame] | 352 | // reset producer slot reallocation flag |
| 353 | mProducerSlotNeedReallocation &= ~(1ULL << pslot); |
| 354 | |
Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 355 | if ((mProducerSlotSource & (1ULL << pslot)) != sourceBit) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 356 | // This slot was previously dequeued from the other source; must |
| 357 | // re-request the buffer. |
KaiChieh Chuang | c522213 | 2019-12-20 07:38:19 +0800 | [diff] [blame] | 358 | mProducerSlotNeedReallocation |= 1ULL << pslot; |
| 359 | |
Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 360 | mProducerSlotSource &= ~(1ULL << pslot); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 361 | mProducerSlotSource |= sourceBit; |
| 362 | } |
| 363 | |
| 364 | if (result & RELEASE_ALL_BUFFERS) { |
| 365 | for (uint32_t i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) { |
Dan Stoza | febd4f4 | 2014-04-09 16:14:51 -0700 | [diff] [blame] | 366 | if ((mProducerSlotSource & (1ULL << i)) == sourceBit) |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 367 | mProducerBuffers[i].clear(); |
| 368 | } |
| 369 | } |
| 370 | if (result & BUFFER_NEEDS_REALLOCATION) { |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 371 | auto status = mSource[source]->requestBuffer(*sslot, &mProducerBuffers[pslot]); |
| 372 | if (status < 0) { |
Jesse Hall | 0b63cd1 | 2014-04-29 16:14:14 -0700 | [diff] [blame] | 373 | mProducerBuffers[pslot].clear(); |
| 374 | mSource[source]->cancelBuffer(*sslot, *fence); |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 375 | return status; |
Jesse Hall | 0b63cd1 | 2014-04-29 16:14:14 -0700 | [diff] [blame] | 376 | } |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 377 | VDS_LOGV("%s(%s): buffers[%d]=%p fmt=%d usage=%#" PRIx64, __func__, |
| 378 | ftl::enum_string(source).c_str(), pslot, mProducerBuffers[pslot].get(), |
| 379 | mProducerBuffers[pslot]->getPixelFormat(), mProducerBuffers[pslot]->getUsage()); |
KaiChieh Chuang | c522213 | 2019-12-20 07:38:19 +0800 | [diff] [blame] | 380 | |
| 381 | // propagate reallocation to VDS consumer |
| 382 | mProducerSlotNeedReallocation |= 1ULL << pslot; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 383 | } |
| 384 | |
| 385 | return result; |
| 386 | } |
| 387 | |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 388 | status_t VirtualDisplaySurface::dequeueBuffer(int* pslot, sp<Fence>* fence, uint32_t w, uint32_t h, |
| 389 | PixelFormat format, uint64_t usage, |
| 390 | uint64_t* outBufferAge, |
| 391 | FrameEventHistoryDelta* outTimestamps) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 392 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 393 | return mSource[SOURCE_SINK]->dequeueBuffer(pslot, fence, w, h, format, usage, outBufferAge, |
| 394 | outTimestamps); |
Brian Anderson | 7c3ba8a | 2016-07-25 12:48:08 -0700 | [diff] [blame] | 395 | } |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 396 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 397 | VDS_LOGW_IF(mDebugState != DebugState::Prepared, "Unexpected %s in %s state", __func__, |
| 398 | ftl::enum_string(mDebugState).c_str()); |
| 399 | mDebugState = DebugState::Gpu; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 400 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 401 | VDS_LOGV("%s %dx%d fmt=%d usage=%#" PRIx64, __func__, w, h, format, usage); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 402 | |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 403 | status_t result = NO_ERROR; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 404 | Source source = fbSourceForCompositionType(mCompositionType); |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 405 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 406 | if (source == SOURCE_SINK) { |
Mathias Agopian | 6da15f4 | 2013-09-25 20:40:07 -0700 | [diff] [blame] | 407 | |
| 408 | if (mOutputProducerSlot < 0) { |
| 409 | // Last chance bailout if something bad happened earlier. For example, |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 410 | // in a graphics API configuration, if the sink disappears then dequeueBuffer |
| 411 | // will fail, the GPU driver won't queue a buffer, but SurfaceFlinger |
Mathias Agopian | 6da15f4 | 2013-09-25 20:40:07 -0700 | [diff] [blame] | 412 | // will soldier on. So we end up here without a buffer. There should |
| 413 | // be lots of scary messages in the log just before this. |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 414 | VDS_LOGE("%s: no buffer, bailing out", __func__); |
Mathias Agopian | 6da15f4 | 2013-09-25 20:40:07 -0700 | [diff] [blame] | 415 | return NO_MEMORY; |
| 416 | } |
| 417 | |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 418 | // We already dequeued the output buffer. If the GPU driver wants |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 419 | // something incompatible, we have to cancel and get a new one. This |
| 420 | // will mean that HWC will see a different output buffer between |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 421 | // prepare and set, but since we're in GPU-only mode already it |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 422 | // shouldn't matter. |
| 423 | |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 424 | usage |= GRALLOC_USAGE_HW_COMPOSER; |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 425 | const sp<GraphicBuffer>& buf = mProducerBuffers[mOutputProducerSlot]; |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 426 | if ((usage & ~buf->getUsage()) != 0 || |
Dan Stoza | 3be1c6b | 2014-11-18 10:24:03 -0800 | [diff] [blame] | 427 | (format != 0 && format != buf->getPixelFormat()) || |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 428 | (w != 0 && w != mSinkBufferWidth) || |
| 429 | (h != 0 && h != mSinkBufferHeight)) { |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 430 | VDS_LOGV("%s: dequeueing new output buffer: " |
| 431 | "want %dx%d fmt=%d use=%#" PRIx64 ", " |
| 432 | "have %dx%d fmt=%d use=%#" PRIx64, |
| 433 | __func__, w, h, format, usage, mSinkBufferWidth, mSinkBufferHeight, |
| 434 | buf->getPixelFormat(), buf->getUsage()); |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 435 | mOutputFormat = format; |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 436 | setOutputUsage(usage); |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 437 | result = refreshOutputBuffer(); |
| 438 | if (result < 0) |
| 439 | return result; |
| 440 | } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 441 | } |
| 442 | |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 443 | if (source == SOURCE_SINK) { |
| 444 | *pslot = mOutputProducerSlot; |
| 445 | *fence = mOutputFence; |
| 446 | } else { |
| 447 | int sslot; |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 448 | result = dequeueBuffer(source, format, usage, &sslot, fence); |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 449 | if (result >= 0) { |
| 450 | *pslot = mapSource2ProducerSlot(source, sslot); |
| 451 | } |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 452 | } |
Ian Elliott | a2eb34c | 2017-07-18 11:05:49 -0600 | [diff] [blame] | 453 | if (outBufferAge) { |
| 454 | *outBufferAge = 0; |
| 455 | } |
KaiChieh Chuang | c522213 | 2019-12-20 07:38:19 +0800 | [diff] [blame] | 456 | |
| 457 | if ((mProducerSlotNeedReallocation & (1ULL << *pslot)) != 0) { |
| 458 | result |= BUFFER_NEEDS_REALLOCATION; |
| 459 | } |
| 460 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 461 | return result; |
| 462 | } |
| 463 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 464 | status_t VirtualDisplaySurface::detachBuffer(int) { |
| 465 | UNSUPPORTED(); |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 466 | } |
| 467 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 468 | status_t VirtualDisplaySurface::detachNextBuffer(sp<GraphicBuffer>*, sp<Fence>*) { |
| 469 | UNSUPPORTED(); |
Dan Stoza | d9822a3 | 2014-03-28 15:25:31 -0700 | [diff] [blame] | 470 | } |
| 471 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 472 | status_t VirtualDisplaySurface::attachBuffer(int*, const sp<GraphicBuffer>&) { |
| 473 | UNSUPPORTED(); |
Dan Stoza | 9f3053d | 2014-03-06 15:14:33 -0800 | [diff] [blame] | 474 | } |
| 475 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 476 | status_t VirtualDisplaySurface::queueBuffer(int pslot, |
| 477 | const QueueBufferInput& input, QueueBufferOutput* output) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 478 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 479 | return mSource[SOURCE_SINK]->queueBuffer(pslot, input, output); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 480 | } |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 481 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 482 | VDS_LOGW_IF(mDebugState != DebugState::Gpu, "Unexpected %s(pslot=%d) in %s state", __func__, |
| 483 | pslot, ftl::enum_string(mDebugState).c_str()); |
| 484 | mDebugState = DebugState::GpuDone; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 485 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 486 | VDS_LOGV("%s pslot=%d", __func__, pslot); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 487 | |
| 488 | status_t result; |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 489 | if (mCompositionType == CompositionType::Mixed) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 490 | // Queue the buffer back into the scratch pool |
| 491 | QueueBufferOutput scratchQBO; |
| 492 | int sslot = mapProducer2SourceSlot(SOURCE_SCRATCH, pslot); |
Mathias Agopian | db89edc | 2013-08-02 01:40:18 -0700 | [diff] [blame] | 493 | result = mSource[SOURCE_SCRATCH]->queueBuffer(sslot, input, &scratchQBO); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 494 | if (result != NO_ERROR) |
| 495 | return result; |
| 496 | |
| 497 | // Now acquire the buffer from the scratch pool -- should be the same |
| 498 | // slot and fence as we just queued. |
| 499 | Mutex::Autolock lock(mMutex); |
Dan Stoza | 11611f9 | 2015-03-12 15:12:44 -0700 | [diff] [blame] | 500 | BufferItem item; |
Jesse Hall | bce7611 | 2013-07-16 13:46:20 -0700 | [diff] [blame] | 501 | result = acquireBufferLocked(&item, 0); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 502 | if (result != NO_ERROR) |
| 503 | return result; |
Pablo Ceballos | 47650f4 | 2015-08-04 16:38:17 -0700 | [diff] [blame] | 504 | VDS_LOGW_IF(item.mSlot != sslot, |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 505 | "%s: acquired sslot %d from SCRATCH after queueing sslot %d", __func__, |
| 506 | item.mSlot, sslot); |
Pablo Ceballos | 47650f4 | 2015-08-04 16:38:17 -0700 | [diff] [blame] | 507 | mFbProducerSlot = mapSource2ProducerSlot(SOURCE_SCRATCH, item.mSlot); |
| 508 | mFbFence = mSlots[item.mSlot].mFence; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 509 | |
| 510 | } else { |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 511 | LOG_FATAL_IF(mCompositionType != CompositionType::Gpu, |
| 512 | "Unexpected %s in state %s for composition type %s", __func__, |
| 513 | ftl::enum_string(mDebugState).c_str(), toString(mCompositionType).c_str()); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 514 | |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 515 | // Extract the GPU release fence for HWC to acquire |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 516 | int64_t timestamp; |
Andy McFadden | 3c25621 | 2013-08-16 14:55:39 -0700 | [diff] [blame] | 517 | bool isAutoTimestamp; |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 518 | android_dataspace dataSpace; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 519 | Rect crop; |
| 520 | int scalingMode; |
| 521 | uint32_t transform; |
Eino-Ville Talvala | 82c6bcc | 2015-02-19 16:10:43 -0800 | [diff] [blame] | 522 | input.deflate(×tamp, &isAutoTimestamp, &dataSpace, &crop, |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 523 | &scalingMode, &transform, &mFbFence); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 524 | |
| 525 | mFbProducerSlot = pslot; |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 526 | mOutputFence = mFbFence; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 527 | } |
| 528 | |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 529 | // This moves the frame timestamps and keeps a copy of all other fields. |
| 530 | *output = std::move(mQueueBufferOutput); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 531 | return NO_ERROR; |
| 532 | } |
| 533 | |
Pablo Ceballos | 583b1b3 | 2015-09-03 18:23:52 -0700 | [diff] [blame] | 534 | status_t VirtualDisplaySurface::cancelBuffer(int pslot, |
| 535 | const sp<Fence>& fence) { |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 536 | if (GpuVirtualDisplayId::tryCast(mDisplayId)) { |
Michael Lentine | fd9d183 | 2014-07-30 15:39:17 -0700 | [diff] [blame] | 537 | return mSource[SOURCE_SINK]->cancelBuffer(mapProducer2SourceSlot(SOURCE_SINK, pslot), fence); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 538 | } |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 539 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 540 | VDS_LOGW_IF(mDebugState != DebugState::Gpu, "Unexpected %s(pslot=%d) in %s state", __func__, |
| 541 | pslot, ftl::enum_string(mDebugState).c_str()); |
| 542 | VDS_LOGV("%s pslot=%d", __func__, pslot); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 543 | Source source = fbSourceForCompositionType(mCompositionType); |
| 544 | return mSource[source]->cancelBuffer( |
| 545 | mapProducer2SourceSlot(source, pslot), fence); |
| 546 | } |
| 547 | |
| 548 | int VirtualDisplaySurface::query(int what, int* value) { |
Michael Lentine | 47e4540 | 2014-07-18 15:34:25 -0700 | [diff] [blame] | 549 | switch (what) { |
| 550 | case NATIVE_WINDOW_WIDTH: |
| 551 | *value = mSinkBufferWidth; |
| 552 | break; |
| 553 | case NATIVE_WINDOW_HEIGHT: |
| 554 | *value = mSinkBufferHeight; |
| 555 | break; |
| 556 | default: |
| 557 | return mSource[SOURCE_SINK]->query(what, value); |
| 558 | } |
| 559 | return NO_ERROR; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 562 | status_t VirtualDisplaySurface::connect(const sp<IProducerListener>& listener, |
Mathias Agopian | 365857d | 2013-09-11 19:35:45 -0700 | [diff] [blame] | 563 | int api, bool producerControlledByApp, |
Mathias Agopian | 595264f | 2013-07-16 22:56:09 -0700 | [diff] [blame] | 564 | QueueBufferOutput* output) { |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 565 | QueueBufferOutput qbo; |
Dan Stoza | f0eaf25 | 2014-03-21 13:05:51 -0700 | [diff] [blame] | 566 | status_t result = mSource[SOURCE_SINK]->connect(listener, api, |
| 567 | producerControlledByApp, &qbo); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 568 | if (result == NO_ERROR) { |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 569 | updateQueueBufferOutput(std::move(qbo)); |
| 570 | // This moves the frame timestamps and keeps a copy of all other fields. |
| 571 | *output = std::move(mQueueBufferOutput); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 572 | } |
| 573 | return result; |
| 574 | } |
| 575 | |
Robert Carr | 97b9c86 | 2016-09-08 13:54:35 -0700 | [diff] [blame] | 576 | status_t VirtualDisplaySurface::disconnect(int api, DisconnectMode mode) { |
| 577 | return mSource[SOURCE_SINK]->disconnect(api, mode); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 578 | } |
| 579 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 580 | status_t VirtualDisplaySurface::setSidebandStream(const sp<NativeHandle>&) { |
| 581 | UNSUPPORTED(); |
Jesse Hall | 399184a | 2014-03-03 15:42:54 -0800 | [diff] [blame] | 582 | } |
| 583 | |
Pablo Ceballos | 567dbbb | 2015-08-26 18:59:08 -0700 | [diff] [blame] | 584 | void VirtualDisplaySurface::allocateBuffers(uint32_t /* width */, |
Mathias Agopian | cb496ac | 2017-05-22 14:21:00 -0700 | [diff] [blame] | 585 | uint32_t /* height */, PixelFormat /* format */, uint64_t /* usage */) { |
Dan Stoza | 29a3e90 | 2014-06-20 13:13:57 -0700 | [diff] [blame] | 586 | // TODO: Should we actually allocate buffers for a virtual display? |
| 587 | } |
| 588 | |
Dan Stoza | 9de7293 | 2015-04-16 17:28:43 -0700 | [diff] [blame] | 589 | status_t VirtualDisplaySurface::allowAllocation(bool /* allow */) { |
| 590 | return INVALID_OPERATION; |
| 591 | } |
| 592 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 593 | status_t VirtualDisplaySurface::setGenerationNumber(uint32_t) { |
| 594 | UNSUPPORTED(); |
Dan Stoza | 812ed06 | 2015-06-02 15:45:22 -0700 | [diff] [blame] | 595 | } |
| 596 | |
Dan Stoza | c6f30bd | 2015-06-08 09:32:50 -0700 | [diff] [blame] | 597 | String8 VirtualDisplaySurface::getConsumerName() const { |
| 598 | return String8("VirtualDisplaySurface"); |
| 599 | } |
| 600 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 601 | status_t VirtualDisplaySurface::setSharedBufferMode(bool) { |
| 602 | UNSUPPORTED(); |
Pablo Ceballos | ff95aab | 2016-01-13 17:09:58 -0800 | [diff] [blame] | 603 | } |
| 604 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 605 | status_t VirtualDisplaySurface::setAutoRefresh(bool) { |
| 606 | UNSUPPORTED(); |
Pablo Ceballos | ccdfd60 | 2015-10-07 15:05:45 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 609 | status_t VirtualDisplaySurface::setDequeueTimeout(nsecs_t) { |
| 610 | UNSUPPORTED(); |
Dan Stoza | 127fc63 | 2015-06-30 13:43:32 -0700 | [diff] [blame] | 611 | } |
| 612 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 613 | status_t VirtualDisplaySurface::getLastQueuedBuffer(sp<GraphicBuffer>*, sp<Fence>*, float[16]) { |
| 614 | UNSUPPORTED(); |
Dan Stoza | 50101d0 | 2016-04-07 16:53:23 -0700 | [diff] [blame] | 615 | } |
| 616 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 617 | status_t VirtualDisplaySurface::getUniqueId(uint64_t*) const { |
| 618 | UNSUPPORTED(); |
Pablo Ceballos | 8e3e92b | 2016-06-27 17:56:53 -0700 | [diff] [blame] | 619 | } |
| 620 | |
Chia-I Wu | e2786ea | 2017-08-07 10:36:08 -0700 | [diff] [blame] | 621 | status_t VirtualDisplaySurface::getConsumerUsage(uint64_t* outUsage) const { |
| 622 | return mSource[SOURCE_SINK]->getConsumerUsage(outUsage); |
| 623 | } |
| 624 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 625 | void VirtualDisplaySurface::updateQueueBufferOutput( |
Brian Anderson | 3d4039d | 2016-09-23 16:31:30 -0700 | [diff] [blame] | 626 | QueueBufferOutput&& qbo) { |
| 627 | mQueueBufferOutput = std::move(qbo); |
Brian Anderson | baaad32 | 2016-07-22 15:55:13 -0700 | [diff] [blame] | 628 | mQueueBufferOutput.transformHint = 0; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 629 | } |
| 630 | |
| 631 | void VirtualDisplaySurface::resetPerFrameState() { |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 632 | mCompositionType = CompositionType::Unknown; |
mayank parshar | b988f85 | 2014-01-10 10:27:45 +0530 | [diff] [blame] | 633 | mFbFence = Fence::NO_FENCE; |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 634 | mOutputFence = Fence::NO_FENCE; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 635 | mOutputProducerSlot = -1; |
mayank parshar | fdfde88 | 2014-01-23 15:08:31 +0530 | [diff] [blame] | 636 | mFbProducerSlot = -1; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 637 | } |
| 638 | |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 639 | status_t VirtualDisplaySurface::refreshOutputBuffer() { |
Alan Ding | 5be0865 | 2024-05-24 01:48:07 +0000 | [diff] [blame] | 640 | LOG_ALWAYS_FATAL_IF(GpuVirtualDisplayId::tryCast(mDisplayId).has_value()); |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 641 | |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 642 | if (mOutputProducerSlot >= 0) { |
| 643 | mSource[SOURCE_SINK]->cancelBuffer( |
| 644 | mapProducer2SourceSlot(SOURCE_SINK, mOutputProducerSlot), |
| 645 | mOutputFence); |
| 646 | } |
| 647 | |
| 648 | int sslot; |
Jesse Hall | 1e27ba2 | 2013-09-27 09:05:09 -0700 | [diff] [blame] | 649 | status_t result = dequeueBuffer(SOURCE_SINK, mOutputFormat, mOutputUsage, |
| 650 | &sslot, &mOutputFence); |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 651 | if (result < 0) |
| 652 | return result; |
| 653 | mOutputProducerSlot = mapSource2ProducerSlot(SOURCE_SINK, sslot); |
| 654 | |
Peiyong Lin | f3ffc4e | 2019-12-13 00:46:24 -0800 | [diff] [blame] | 655 | // On GPU-only frames, we don't have the right output buffer acquire fence |
| 656 | // until after GPU calls queueBuffer(). So here we just set the buffer |
Jesse Hall | b716e57 | 2013-10-01 17:25:20 -0700 | [diff] [blame] | 657 | // (for use in HWC prepare) but not the fence; we'll call this again with |
| 658 | // the proper fence once we have it. |
Marin Shalamanov | 0f10d0d | 2020-08-06 20:04:06 +0200 | [diff] [blame] | 659 | const auto halDisplayId = HalVirtualDisplayId::tryCast(mDisplayId); |
| 660 | LOG_FATAL_IF(!halDisplayId); |
| 661 | result = mHwc.setOutputBuffer(*halDisplayId, Fence::NO_FENCE, |
Dominik Laskowski | 075d317 | 2018-05-24 15:50:06 -0700 | [diff] [blame] | 662 | mProducerBuffers[mOutputProducerSlot]); |
Jesse Hall | 028dc8f | 2013-08-20 16:35:32 -0700 | [diff] [blame] | 663 | |
| 664 | return result; |
| 665 | } |
| 666 | |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 667 | // This slot mapping function is its own inverse, so two copies are unnecessary. |
| 668 | // Both are kept to make the intent clear where the function is called, and for |
| 669 | // the (unlikely) chance that we switch to a different mapping function. |
| 670 | int VirtualDisplaySurface::mapSource2ProducerSlot(Source source, int sslot) { |
| 671 | if (source == SOURCE_SCRATCH) { |
| 672 | return BufferQueue::NUM_BUFFER_SLOTS - sslot - 1; |
| 673 | } else { |
| 674 | return sslot; |
| 675 | } |
| 676 | } |
| 677 | int VirtualDisplaySurface::mapProducer2SourceSlot(Source source, int pslot) { |
| 678 | return mapSource2ProducerSlot(source, pslot); |
| 679 | } |
| 680 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 681 | auto VirtualDisplaySurface::fbSourceForCompositionType(CompositionType type) -> Source { |
| 682 | return type == CompositionType::Mixed ? SOURCE_SCRATCH : SOURCE_SINK; |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 683 | } |
| 684 | |
Dominik Laskowski | f5d0ea5 | 2021-09-26 17:27:01 -0700 | [diff] [blame] | 685 | std::string VirtualDisplaySurface::toString(CompositionType type) { |
| 686 | using namespace std::literals; |
Dominik Laskowski | 2f01d77 | 2022-03-23 16:01:29 -0700 | [diff] [blame] | 687 | return type == CompositionType::Unknown ? "Unknown"s : ftl::Flags(type).string(); |
Jesse Hall | 38efe86 | 2013-04-06 23:12:29 -0700 | [diff] [blame] | 688 | } |
| 689 | |
Ramakant Singh | f7e8191 | 2020-04-11 16:02:43 +0530 | [diff] [blame] | 690 | /* Helper to update the output usage when the display is secure */ |
| 691 | |
| 692 | void VirtualDisplaySurface::setOutputUsage(uint64_t /*flag*/) { |
| 693 | |
| 694 | mOutputUsage = mSinkUsage; |
| 695 | if (mSecure && (mOutputUsage & GRALLOC_USAGE_HW_VIDEO_ENCODER)) { |
| 696 | /*TODO: Currently, the framework can only say whether the display |
| 697 | * and its subsequent session are secure or not. However, there is |
| 698 | * no mechanism to distinguish the different levels of security. |
| 699 | * The current solution assumes WV L3 protection. |
| 700 | */ |
| 701 | mOutputUsage |= GRALLOC_USAGE_PROTECTED; |
| 702 | } |
| 703 | } |
| 704 | |
Jesse Hall | 99c7dbb | 2013-03-14 14:29:29 -0700 | [diff] [blame] | 705 | } // namespace android |
Ady Abraham | b0dbdaa | 2020-01-06 16:19:42 -0800 | [diff] [blame] | 706 | |
| 707 | // TODO(b/129481165): remove the #pragma below and fix conversion issues |
| 708 | #pragma clang diagnostic pop // ignored "-Wconversion" |