blob: 3e651713e4df18ce9568e66f224f4df670e3fd18 [file] [log] [blame]
Marissa Wall61c58622018-07-18 10:12:20 -07001/*
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 Abrahamb0dbdaa2020-01-06 16:19:42 -080017// TODO(b/129481165): remove the #pragma below and fix conversion issues
18#pragma clang diagnostic push
19#pragma clang diagnostic ignored "-Wconversion"
20
Marissa Wall61c58622018-07-18 10:12:20 -070021//#define LOG_NDEBUG 0
22#undef LOG_TAG
23#define LOG_TAG "BufferStateLayer"
24#define ATRACE_TAG ATRACE_TAG_GRAPHICS
25
Lloyd Pique9755fb72019-03-26 14:44:40 -070026#include "BufferStateLayer.h"
27
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080028#include <limits>
Marissa Wall61c58622018-07-18 10:12:20 -070029
Lloyd Pique9755fb72019-03-26 14:44:40 -070030#include <compositionengine/LayerFECompositionState.h>
Marissa Wall947d34e2019-03-29 14:03:53 -070031#include <gui/BufferQueue.h>
Marissa Wall61c58622018-07-18 10:12:20 -070032#include <private/gui/SyncFeatures.h>
Peiyong Lincbc184f2018-08-22 13:24:10 -070033#include <renderengine/Image.h>
Marissa Wall61c58622018-07-18 10:12:20 -070034
Vishnu Nairfa247b12020-02-11 08:58:26 -080035#include "EffectLayer.h"
Mikael Pessa90092f42019-08-26 17:22:04 -070036#include "FrameTracer/FrameTracer.h"
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080037#include "TimeStats/TimeStats.h"
Valerie Hau0bc09152018-12-20 07:42:47 -080038
Marissa Wall61c58622018-07-18 10:12:20 -070039namespace android {
40
Lloyd Pique42ab75e2018-09-12 20:46:03 -070041// clang-format off
42const std::array<float, 16> BufferStateLayer::IDENTITY_MATRIX{
43 1, 0, 0, 0,
44 0, 1, 0, 0,
45 0, 0, 1, 0,
46 0, 0, 0, 1
47};
48// clang-format on
Marissa Wall61c58622018-07-18 10:12:20 -070049
Marissa Wall947d34e2019-03-29 14:03:53 -070050BufferStateLayer::BufferStateLayer(const LayerCreationArgs& args)
51 : BufferLayer(args), mHwcSlotGenerator(new HwcSlotGenerator()) {
Vishnu Nair60356342018-11-13 13:00:45 -080052 mOverrideScalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
Marissa Wall3ff826c2019-02-07 11:58:25 -080053 mCurrentState.dataspace = ui::Dataspace::V0_SRGB;
chaviwb4c6e582019-08-16 14:35:07 -070054 if (const auto display = args.displayDevice) {
55 updateTransformHint(display);
56 }
Vishnu Nair60356342018-11-13 13:00:45 -080057}
Marissa Wall61c58622018-07-18 10:12:20 -070058
Alec Mouri4545a8a2019-08-08 20:05:32 -070059BufferStateLayer::~BufferStateLayer() {
chaviwb4c6e582019-08-16 14:35:07 -070060 // The original layer and the clone layer share the same texture and buffer. Therefore, only
61 // one of the layers, in this case the original layer, needs to handle the deletion. The
62 // original layer and the clone should be removed at the same time so there shouldn't be any
63 // issue with the clone layer trying to use the texture.
64 if (mBufferInfo.mBuffer != nullptr && !isClone()) {
chaviwd62d3062019-09-04 14:48:02 -070065 // Ensure that mBuffer is uncached from RenderEngine here, as
Alec Mouri4545a8a2019-08-08 20:05:32 -070066 // RenderEngine may have been using the buffer as an external texture
67 // after the client uncached the buffer.
68 auto& engine(mFlinger->getRenderEngine());
chaviwd62d3062019-09-04 14:48:02 -070069 engine.unbindExternalTextureBuffer(mBufferInfo.mBuffer->getId());
Alec Mouri4545a8a2019-08-08 20:05:32 -070070 }
71}
72
Marissa Wall61c58622018-07-18 10:12:20 -070073// -----------------------------------------------------------------------
74// Interface implementation for Layer
75// -----------------------------------------------------------------------
Marissa Wallfda30bb2018-10-12 11:34:28 -070076void BufferStateLayer::onLayerDisplayed(const sp<Fence>& releaseFence) {
Marissa Wall5a68a772018-12-22 17:43:42 -080077 // The previous release fence notifies the client that SurfaceFlinger is done with the previous
78 // buffer that was presented on this layer. The first transaction that came in this frame that
79 // replaced the previous buffer on this layer needs this release fence, because the fence will
80 // let the client know when that previous buffer is removed from the screen.
81 //
82 // Every other transaction on this layer does not need a release fence because no other
83 // Transactions that were set on this layer this frame are going to have their preceeding buffer
84 // removed from the display this frame.
85 //
86 // For example, if we have 3 transactions this frame. The first transaction doesn't contain a
87 // buffer so it doesn't need a previous release fence because the layer still needs the previous
88 // buffer. The second transaction contains a buffer so it needs a previous release fence because
89 // the previous buffer will be released this frame. The third transaction also contains a
90 // buffer. It replaces the buffer in the second transaction. The buffer in the second
91 // transaction will now no longer be presented so it is released immediately and the third
92 // transaction doesn't need a previous release fence.
93 for (auto& handle : mDrawingState.callbackHandles) {
94 if (handle->releasePreviousBuffer) {
95 handle->previousReleaseFence = releaseFence;
96 break;
97 }
98 }
Mikael Pessa2e1608f2019-07-19 11:25:35 -070099
Valerie Haubf784642020-01-29 07:25:23 -0800100 mPreviousReleaseFence = releaseFence;
101
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700102 // Prevent tracing the same release multiple times.
103 if (mPreviousFrameNumber != mPreviousReleasedFrameNumber) {
Mikael Pessa90092f42019-08-26 17:22:04 -0700104 mFlinger->mFrameTracer->traceFence(getSequence(), mPreviousBufferId, mPreviousFrameNumber,
105 std::make_shared<FenceTime>(releaseFence),
106 FrameTracer::FrameEvent::RELEASE_FENCE);
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700107 mPreviousReleasedFrameNumber = mPreviousFrameNumber;
108 }
Marissa Wall61c58622018-07-18 10:12:20 -0700109}
110
Valerie Hau32cdc1f2019-10-21 14:45:54 -0700111void BufferStateLayer::setTransformHint(uint32_t orientation) const {
112 mTransformHint = orientation;
Marissa Wall61c58622018-07-18 10:12:20 -0700113}
114
Valerie Haubf784642020-01-29 07:25:23 -0800115void BufferStateLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
Valerie Hau32cdc1f2019-10-21 14:45:54 -0700116 for (const auto& handle : mDrawingState.callbackHandles) {
117 handle->transformHint = mTransformHint;
Valerie Hau871d6352020-01-29 08:44:02 -0800118 handle->dequeueReadyTime = dequeueReadyTime;
Valerie Hau32cdc1f2019-10-21 14:45:54 -0700119 }
120
Marissa Wallefb71af2019-06-27 14:45:53 -0700121 mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles(
Marissa Wall5a68a772018-12-22 17:43:42 -0800122 mDrawingState.callbackHandles);
123
124 mDrawingState.callbackHandles = {};
Valerie Haubf784642020-01-29 07:25:23 -0800125
126 const sp<Fence>& releaseFence(mPreviousReleaseFence);
127 std::shared_ptr<FenceTime> releaseFenceTime = std::make_shared<FenceTime>(releaseFence);
128 {
129 Mutex::Autolock lock(mFrameEventHistoryMutex);
130 if (mPreviousFrameNumber != 0) {
131 mFrameEventHistory.addRelease(mPreviousFrameNumber, dequeueReadyTime,
132 std::move(releaseFenceTime));
133 }
134 }
Marissa Wall61c58622018-07-18 10:12:20 -0700135}
136
Valerie Hau871d6352020-01-29 08:44:02 -0800137void BufferStateLayer::finalizeFrameEventHistory(const std::shared_ptr<FenceTime>& glDoneFence,
138 const CompositorTiming& compositorTiming) {
139 for (const auto& handle : mDrawingState.callbackHandles) {
140 handle->gpuCompositionDoneFence = glDoneFence;
141 handle->compositorTiming = compositorTiming;
142 }
143}
144
Ana Krulec010d2192018-10-08 06:29:54 -0700145bool BufferStateLayer::shouldPresentNow(nsecs_t /*expectedPresentTime*/) const {
Marissa Wall61c58622018-07-18 10:12:20 -0700146 if (getSidebandStreamChanged() || getAutoRefresh()) {
147 return true;
148 }
149
Marissa Wall024a1912018-08-13 13:55:35 -0700150 return hasFrameUpdate();
Marissa Wall61c58622018-07-18 10:12:20 -0700151}
152
Marissa Walle2ffb422018-10-12 11:33:52 -0700153bool BufferStateLayer::willPresentCurrentTransaction() const {
154 // Returns true if the most recent Transaction applied to CurrentState will be presented.
Robert Carr321e83c2019-08-19 15:49:30 -0700155 return (getSidebandStreamChanged() || getAutoRefresh() ||
Valerie Hauaa194562019-02-05 16:21:38 -0800156 (mCurrentState.modified &&
Robert Carr321e83c2019-08-19 15:49:30 -0700157 (mCurrentState.buffer != nullptr || mCurrentState.bgColorLayer != nullptr))) &&
158 !mLayerDetached;
Marissa Wall61c58622018-07-18 10:12:20 -0700159}
160
Valerie Hau3282b3c2020-02-03 15:37:27 -0800161/* TODO: vhau uncomment once deferred transaction migration complete in
162 * WindowManager
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800163void BufferStateLayer::pushPendingState() {
164 if (!mCurrentState.modified) {
Marissa Wall61c58622018-07-18 10:12:20 -0700165 return;
166 }
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800167 mPendingStates.push_back(mCurrentState);
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700168 ATRACE_INT(mTransactionName.c_str(), mPendingStates.size());
Marissa Wall61c58622018-07-18 10:12:20 -0700169}
Valerie Hau3282b3c2020-02-03 15:37:27 -0800170*/
Marissa Wall61c58622018-07-18 10:12:20 -0700171
172bool BufferStateLayer::applyPendingStates(Layer::State* stateToCommit) {
Valerie Hau3282b3c2020-02-03 15:37:27 -0800173 mCurrentStateModified = mCurrentState.modified;
174 bool stateUpdateAvailable = Layer::applyPendingStates(stateToCommit);
175 mCurrentStateModified = stateUpdateAvailable && mCurrentStateModified;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800176 mCurrentState.modified = false;
Marissa Wall61c58622018-07-18 10:12:20 -0700177 return stateUpdateAvailable;
178}
179
Marissa Wall861616d2018-10-22 12:52:23 -0700180// Crop that applies to the window
181Rect BufferStateLayer::getCrop(const Layer::State& /*s*/) const {
182 return Rect::INVALID_RECT;
Marissa Wall61c58622018-07-18 10:12:20 -0700183}
184
185bool BufferStateLayer::setTransform(uint32_t transform) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800186 if (mCurrentState.transform == transform) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800187 mCurrentState.transform = transform;
188 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700189 setTransactionFlags(eTransactionNeeded);
190 return true;
191}
192
193bool BufferStateLayer::setTransformToDisplayInverse(bool transformToDisplayInverse) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800194 if (mCurrentState.transformToDisplayInverse == transformToDisplayInverse) return false;
195 mCurrentState.sequence++;
196 mCurrentState.transformToDisplayInverse = transformToDisplayInverse;
197 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700198 setTransactionFlags(eTransactionNeeded);
199 return true;
200}
201
202bool BufferStateLayer::setCrop(const Rect& crop) {
Marissa Wall290ad082019-03-06 13:23:47 -0800203 Rect c = crop;
204 if (c.left < 0) {
205 c.left = 0;
206 }
207 if (c.top < 0) {
208 c.top = 0;
209 }
210 // If the width and/or height are < 0, make it [0, 0, -1, -1] so the equality comparision below
211 // treats all invalid rectangles the same.
212 if (!c.isValid()) {
213 c.makeInvalid();
214 }
215
216 if (mCurrentState.crop == c) return false;
Marissa Wall290ad082019-03-06 13:23:47 -0800217 mCurrentState.crop = c;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800218 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700219 setTransactionFlags(eTransactionNeeded);
220 return true;
221}
222
Marissa Wall861616d2018-10-22 12:52:23 -0700223bool BufferStateLayer::setFrame(const Rect& frame) {
224 int x = frame.left;
225 int y = frame.top;
226 int w = frame.getWidth();
227 int h = frame.getHeight();
228
Marissa Wall0f3242d2018-12-20 15:10:22 -0800229 if (x < 0) {
230 x = 0;
231 w = frame.right;
232 }
233
234 if (y < 0) {
235 y = 0;
236 h = frame.bottom;
237 }
238
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800239 if (mCurrentState.active.transform.tx() == x && mCurrentState.active.transform.ty() == y &&
240 mCurrentState.active.w == w && mCurrentState.active.h == h) {
Marissa Wall861616d2018-10-22 12:52:23 -0700241 return false;
242 }
243
244 if (!frame.isValid()) {
245 x = y = w = h = 0;
246 }
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800247 mCurrentState.active.transform.set(x, y);
248 mCurrentState.active.w = w;
249 mCurrentState.active.h = h;
Marissa Wall861616d2018-10-22 12:52:23 -0700250
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800251 mCurrentState.sequence++;
252 mCurrentState.modified = true;
Marissa Wall861616d2018-10-22 12:52:23 -0700253 setTransactionFlags(eTransactionNeeded);
254 return true;
255}
256
Valerie Hau871d6352020-01-29 08:44:02 -0800257bool BufferStateLayer::addFrameEvent(const sp<Fence>& acquireFence, nsecs_t postedTime,
258 nsecs_t desiredPresentTime) {
Valerie Haubf784642020-01-29 07:25:23 -0800259 Mutex::Autolock lock(mFrameEventHistoryMutex);
260 mAcquireTimeline.updateSignalTimes();
261 std::shared_ptr<FenceTime> acquireFenceTime =
262 std::make_shared<FenceTime>((acquireFence ? acquireFence : Fence::NO_FENCE));
263 NewFrameEventsEntry newTimestamps = {mCurrentState.frameNumber, postedTime, desiredPresentTime,
264 acquireFenceTime};
Valerie Hau871d6352020-01-29 08:44:02 -0800265 mFrameEventHistory.setProducerWantsEvents();
Valerie Haubf784642020-01-29 07:25:23 -0800266 mFrameEventHistory.addQueue(newTimestamps);
267 return true;
268}
269
270bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, const sp<Fence>& acquireFence,
271 nsecs_t postTime, nsecs_t desiredPresentTime,
272 const client_cache_t& clientCacheId) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800273 if (mCurrentState.buffer) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700274 mReleasePreviousBuffer = true;
275 }
276
Valerie Hau134651a2020-01-28 16:21:22 -0800277 mCurrentState.frameNumber++;
Valerie Hau2f54d642020-01-22 09:37:03 -0800278
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800279 mCurrentState.buffer = buffer;
Marissa Wall947d34e2019-03-29 14:03:53 -0700280 mCurrentState.clientCacheId = clientCacheId;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800281 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700282 setTransactionFlags(eTransactionNeeded);
Ady Abraham09bd3922019-04-08 10:44:56 -0700283
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800284 const int32_t layerId = getSequence();
Valerie Hau134651a2020-01-28 16:21:22 -0800285 mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(),
286 postTime);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800287 mFlinger->mFrameTracer->traceNewLayer(layerId, getName().c_str());
Valerie Hau134651a2020-01-28 16:21:22 -0800288 mFlinger->mFrameTracer->traceTimestamp(layerId, buffer->getId(), mCurrentState.frameNumber,
289 postTime, FrameTracer::FrameEvent::POST);
Valerie Hau871d6352020-01-29 08:44:02 -0800290 desiredPresentTime = desiredPresentTime <= 0 ? 0 : desiredPresentTime;
chaviwfa67b552019-08-12 16:51:55 -0700291 mCurrentState.desiredPresentTime = desiredPresentTime;
Ady Abraham09bd3922019-04-08 10:44:56 -0700292
Valerie Hau871d6352020-01-29 08:44:02 -0800293 mFlinger->mScheduler->recordLayerHistory(this, desiredPresentTime);
Ady Abraham09bd3922019-04-08 10:44:56 -0700294
Valerie Hau871d6352020-01-29 08:44:02 -0800295 addFrameEvent(acquireFence, postTime, desiredPresentTime);
Marissa Wall61c58622018-07-18 10:12:20 -0700296 return true;
297}
298
299bool BufferStateLayer::setAcquireFence(const sp<Fence>& fence) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700300 // The acquire fences of BufferStateLayers have already signaled before they are set
301 mCallbackHandleAcquireTime = fence->getSignalTime();
302
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800303 mCurrentState.acquireFence = fence;
304 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700305 setTransactionFlags(eTransactionNeeded);
306 return true;
307}
308
309bool BufferStateLayer::setDataspace(ui::Dataspace dataspace) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800310 if (mCurrentState.dataspace == dataspace) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800311 mCurrentState.dataspace = dataspace;
312 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700313 setTransactionFlags(eTransactionNeeded);
314 return true;
315}
316
317bool BufferStateLayer::setHdrMetadata(const HdrMetadata& hdrMetadata) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800318 if (mCurrentState.hdrMetadata == hdrMetadata) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800319 mCurrentState.hdrMetadata = hdrMetadata;
320 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700321 setTransactionFlags(eTransactionNeeded);
322 return true;
323}
324
325bool BufferStateLayer::setSurfaceDamageRegion(const Region& surfaceDamage) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800326 mCurrentState.surfaceDamageRegion = surfaceDamage;
327 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700328 setTransactionFlags(eTransactionNeeded);
329 return true;
330}
331
332bool BufferStateLayer::setApi(int32_t api) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800333 if (mCurrentState.api == api) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800334 mCurrentState.api = api;
335 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700336 setTransactionFlags(eTransactionNeeded);
337 return true;
338}
339
340bool BufferStateLayer::setSidebandStream(const sp<NativeHandle>& sidebandStream) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800341 if (mCurrentState.sidebandStream == sidebandStream) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800342 mCurrentState.sidebandStream = sidebandStream;
343 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700344 setTransactionFlags(eTransactionNeeded);
345
346 if (!mSidebandStreamChanged.exchange(true)) {
347 // mSidebandStreamChanged was false
348 mFlinger->signalLayerUpdate();
349 }
350 return true;
351}
352
Marissa Walle2ffb422018-10-12 11:33:52 -0700353bool BufferStateLayer::setTransactionCompletedListeners(
354 const std::vector<sp<CallbackHandle>>& handles) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700355 // If there is no handle, we will not send a callback so reset mReleasePreviousBuffer and return
Marissa Walle2ffb422018-10-12 11:33:52 -0700356 if (handles.empty()) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700357 mReleasePreviousBuffer = false;
Marissa Walle2ffb422018-10-12 11:33:52 -0700358 return false;
359 }
360
361 const bool willPresent = willPresentCurrentTransaction();
362
363 for (const auto& handle : handles) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700364 // If this transaction set a buffer on this layer, release its previous buffer
365 handle->releasePreviousBuffer = mReleasePreviousBuffer;
366
Marissa Walle2ffb422018-10-12 11:33:52 -0700367 // If this layer will be presented in this frame
368 if (willPresent) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700369 // If this transaction set an acquire fence on this layer, set its acquire time
370 handle->acquireTime = mCallbackHandleAcquireTime;
371
Marissa Walle2ffb422018-10-12 11:33:52 -0700372 // Notify the transaction completed thread that there is a pending latched callback
373 // handle
Marissa Wall5a68a772018-12-22 17:43:42 -0800374 mFlinger->getTransactionCompletedThread().registerPendingCallbackHandle(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700375
376 // Store so latched time and release fence can be set
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800377 mCurrentState.callbackHandles.push_back(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700378
379 } else { // If this layer will NOT need to be relatched and presented this frame
380 // Notify the transaction completed thread this handle is done
Marissa Wallefb71af2019-06-27 14:45:53 -0700381 mFlinger->getTransactionCompletedThread().registerUnpresentedCallbackHandle(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700382 }
383 }
384
Marissa Wallfda30bb2018-10-12 11:34:28 -0700385 mReleasePreviousBuffer = false;
386 mCallbackHandleAcquireTime = -1;
387
Marissa Walle2ffb422018-10-12 11:33:52 -0700388 return willPresent;
389}
390
Valerie Hau7618b232020-01-09 16:03:08 -0800391void BufferStateLayer::forceSendCallbacks() {
392 mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles(
393 mCurrentState.callbackHandles);
394}
395
Marissa Wall61c58622018-07-18 10:12:20 -0700396bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800397 mCurrentState.transparentRegionHint = transparent;
398 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700399 setTransactionFlags(eTransactionNeeded);
400 return true;
401}
402
Marissa Wall861616d2018-10-22 12:52:23 -0700403Rect BufferStateLayer::getBufferSize(const State& s) const {
404 // for buffer state layers we use the display frame size as the buffer size.
405 if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
406 return Rect(getActiveWidth(s), getActiveHeight(s));
Marissa Wall61c58622018-07-18 10:12:20 -0700407 }
408
Marissa Wall861616d2018-10-22 12:52:23 -0700409 // if the display frame is not defined, use the parent bounds as the buffer size.
410 const auto& p = mDrawingParent.promote();
411 if (p != nullptr) {
Vishnu Nair4351ad52019-02-11 14:13:02 -0800412 Rect parentBounds = Rect(p->getBounds(Region()));
Marissa Wall861616d2018-10-22 12:52:23 -0700413 if (!parentBounds.isEmpty()) {
414 return parentBounds;
415 }
416 }
417
Marissa Wall861616d2018-10-22 12:52:23 -0700418 return Rect::INVALID_RECT;
Marissa Wall61c58622018-07-18 10:12:20 -0700419}
Vishnu Nair4351ad52019-02-11 14:13:02 -0800420
421FloatRect BufferStateLayer::computeSourceBounds(const FloatRect& parentBounds) const {
422 const State& s(getDrawingState());
423 // for buffer state layers we use the display frame size as the buffer size.
424 if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
425 return FloatRect(0, 0, getActiveWidth(s), getActiveHeight(s));
426 }
427
428 // if the display frame is not defined, use the parent bounds as the buffer size.
429 return parentBounds;
430}
431
Marissa Wall61c58622018-07-18 10:12:20 -0700432// -----------------------------------------------------------------------
433
434// -----------------------------------------------------------------------
435// Interface implementation for BufferLayer
436// -----------------------------------------------------------------------
437bool BufferStateLayer::fenceHasSignaled() const {
438 if (latchUnsignaledBuffers()) {
439 return true;
440 }
441
Alec Mouri91f6df32020-01-30 08:48:58 -0800442 const bool fenceSignaled =
443 getDrawingState().acquireFence->getStatus() == Fence::Status::Signaled;
444 if (!fenceSignaled) {
445 mFlinger->mTimeStats->incrementLatchSkipped(getSequence(),
446 TimeStats::LatchSkipReason::LateAcquire);
447 }
448
449 return fenceSignaled;
Marissa Wall61c58622018-07-18 10:12:20 -0700450}
451
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700452bool BufferStateLayer::framePresentTimeIsCurrent(nsecs_t expectedPresentTime) const {
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700453 if (!hasFrameUpdate() || isRemovedFromCurrentState()) {
454 return true;
455 }
456
chaviwfa67b552019-08-12 16:51:55 -0700457 return mCurrentState.desiredPresentTime <= expectedPresentTime;
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700458}
459
Valerie Hau871d6352020-01-29 08:44:02 -0800460bool BufferStateLayer::onPreComposition(nsecs_t refreshStartTime) {
461 for (const auto& handle : mDrawingState.callbackHandles) {
462 handle->refreshStartTime = refreshStartTime;
463 }
464 return BufferLayer::onPreComposition(refreshStartTime);
465}
466
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700467uint64_t BufferStateLayer::getFrameNumber(nsecs_t /*expectedPresentTime*/) const {
Valerie Hau134651a2020-01-28 16:21:22 -0800468 return mDrawingState.frameNumber;
Marissa Wall61c58622018-07-18 10:12:20 -0700469}
470
Robert Carrfe1209c2020-02-11 12:25:35 -0800471/**
472 * This is the frameNumber used for deferred transaction signalling. We need to use this because
473 * of cases where we defer a transaction for a surface to itself. In the BLAST world this
474 * may not make a huge amount of sense (Why not just merge the Buffer transaction with the
475 * deferred transaction?) but this is an important legacy use case, for example moving
476 * a window at the same time it draws makes use of this kind of technique. So anyway
477 * imagine we have something like this:
478 *
479 * Transaction { // containing
480 * Buffer -> frameNumber = 2
481 * DeferTransactionUntil -> frameNumber = 2
482 * Random other stuff
483 * }
484 * Now imagine getHeadFrameNumber returned mDrawingState.mFrameNumber (or mCurrentFrameNumber).
485 * Prior to doTransaction SurfaceFlinger will call notifyAvailableFrames, but because we
486 * haven't swapped mCurrentState to mDrawingState yet we will think the sync point
487 * is not ready. So we will return false from applyPendingState and not swap
488 * current state to drawing state. But because we don't swap current state
489 * to drawing state the number will never update and we will be stuck. This way
490 * we can see we need to return the frame number for the buffer we are about
491 * to apply.
492 */
493uint64_t BufferStateLayer::getHeadFrameNumber(nsecs_t /* expectedPresentTime */) const {
494 return mCurrentState.frameNumber;
495}
496
Marissa Wall61c58622018-07-18 10:12:20 -0700497bool BufferStateLayer::getAutoRefresh() const {
498 // TODO(marissaw): support shared buffer mode
499 return false;
500}
501
502bool BufferStateLayer::getSidebandStreamChanged() const {
503 return mSidebandStreamChanged.load();
504}
505
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800506bool BufferStateLayer::latchSidebandStream(bool& recomputeVisibleRegions) {
Marissa Wall61c58622018-07-18 10:12:20 -0700507 if (mSidebandStreamChanged.exchange(false)) {
508 const State& s(getDrawingState());
509 // mSidebandStreamChanged was true
Lloyd Pique0b785d82018-12-04 17:25:27 -0800510 mSidebandStream = s.sidebandStream;
Lloyd Piquede196652020-01-22 17:29:58 -0800511 editCompositionState()->sidebandStream = mSidebandStream;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800512 if (mSidebandStream != nullptr) {
Marissa Wall61c58622018-07-18 10:12:20 -0700513 setTransactionFlags(eTransactionNeeded);
514 mFlinger->setTransactionFlags(eTraversalNeeded);
515 }
516 recomputeVisibleRegions = true;
517
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800518 return true;
Marissa Wall61c58622018-07-18 10:12:20 -0700519 }
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800520 return false;
Marissa Wall61c58622018-07-18 10:12:20 -0700521}
522
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800523bool BufferStateLayer::hasFrameUpdate() const {
Valerie Hauaa194562019-02-05 16:21:38 -0800524 const State& c(getCurrentState());
525 return mCurrentStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
Marissa Wall61c58622018-07-18 10:12:20 -0700526}
527
Alec Mouri39801c02018-10-10 10:44:47 -0700528status_t BufferStateLayer::bindTextureImage() {
Marissa Wall61c58622018-07-18 10:12:20 -0700529 const State& s(getDrawingState());
530 auto& engine(mFlinger->getRenderEngine());
531
Alec Mourib5c4f352019-02-19 19:46:38 -0800532 return engine.bindExternalTextureBuffer(mTextureName, s.buffer, s.acquireFence);
Marissa Wall61c58622018-07-18 10:12:20 -0700533}
534
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700535status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nsecs_t latchTime,
536 nsecs_t /*expectedPresentTime*/) {
Marissa Wall61c58622018-07-18 10:12:20 -0700537 const State& s(getDrawingState());
538
539 if (!s.buffer) {
Valerie Hauaa194562019-02-05 16:21:38 -0800540 if (s.bgColorLayer) {
541 for (auto& handle : mDrawingState.callbackHandles) {
542 handle->latchTime = latchTime;
543 }
544 }
Marissa Wall61c58622018-07-18 10:12:20 -0700545 return NO_ERROR;
546 }
547
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800548 const int32_t layerId = getSequence();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700549
Marissa Wall61c58622018-07-18 10:12:20 -0700550 // Reject if the layer is invalid
551 uint32_t bufferWidth = s.buffer->width;
552 uint32_t bufferHeight = s.buffer->height;
553
Peiyong Linefefaac2018-08-17 12:27:51 -0700554 if (s.transform & ui::Transform::ROT_90) {
Peiyong Lin3db42342018-08-16 09:15:59 -0700555 std::swap(bufferWidth, bufferHeight);
Marissa Wall61c58622018-07-18 10:12:20 -0700556 }
557
558 if (s.transformToDisplayInverse) {
Dominik Laskowski718f9602019-11-09 20:01:35 -0800559 uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
Peiyong Linefefaac2018-08-17 12:27:51 -0700560 if (invTransform & ui::Transform::ROT_90) {
Peiyong Lin3db42342018-08-16 09:15:59 -0700561 std::swap(bufferWidth, bufferHeight);
Marissa Wall61c58622018-07-18 10:12:20 -0700562 }
563 }
564
Vishnu Nair60356342018-11-13 13:00:45 -0800565 if (getEffectiveScalingMode() == NATIVE_WINDOW_SCALING_MODE_FREEZE &&
Marissa Wall61c58622018-07-18 10:12:20 -0700566 (s.active.w != bufferWidth || s.active.h != bufferHeight)) {
567 ALOGE("[%s] rejecting buffer: "
568 "bufferWidth=%d, bufferHeight=%d, front.active.{w=%d, h=%d}",
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700569 getDebugName(), bufferWidth, bufferHeight, s.active.w, s.active.h);
Valerie Hau134651a2020-01-28 16:21:22 -0800570 mFlinger->mTimeStats->removeTimeRecord(layerId, mDrawingState.frameNumber);
Marissa Wall61c58622018-07-18 10:12:20 -0700571 return BAD_VALUE;
572 }
573
Marissa Wall5a68a772018-12-22 17:43:42 -0800574 for (auto& handle : mDrawingState.callbackHandles) {
575 handle->latchTime = latchTime;
Valerie Hau871d6352020-01-29 08:44:02 -0800576 handle->frameNumber = mDrawingState.frameNumber;
Marissa Wall5a68a772018-12-22 17:43:42 -0800577 }
Marissa Walle2ffb422018-10-12 11:33:52 -0700578
Alec Mouri56e538f2019-01-14 15:22:01 -0800579 if (!SyncFeatures::getInstance().useNativeFenceSync()) {
Marissa Wall61c58622018-07-18 10:12:20 -0700580 // Bind the new buffer to the GL texture.
581 //
582 // Older devices require the "implicit" synchronization provided
583 // by glEGLImageTargetTexture2DOES, which this method calls. Newer
584 // devices will either call this in Layer::onDraw, or (if it's not
585 // a GL-composited layer) not at all.
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800586 status_t err = bindTextureImage();
Marissa Wall61c58622018-07-18 10:12:20 -0700587 if (err != NO_ERROR) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800588 mFlinger->mTimeStats->onDestroy(layerId);
589 mFlinger->mFrameTracer->onDestroy(layerId);
Marissa Wall61c58622018-07-18 10:12:20 -0700590 return BAD_VALUE;
591 }
592 }
593
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700594 const uint64_t bufferID = getCurrentBufferId();
Valerie Hau134651a2020-01-28 16:21:22 -0800595 mFlinger->mTimeStats->setAcquireFence(layerId, mDrawingState.frameNumber,
596 mBufferInfo.mFenceTime);
597 mFlinger->mFrameTracer->traceFence(layerId, bufferID, mDrawingState.frameNumber,
598 mBufferInfo.mFenceTime,
Mikael Pessa90092f42019-08-26 17:22:04 -0700599 FrameTracer::FrameEvent::ACQUIRE_FENCE);
Valerie Hau134651a2020-01-28 16:21:22 -0800600 mFlinger->mTimeStats->setLatchTime(layerId, mDrawingState.frameNumber, latchTime);
601 mFlinger->mFrameTracer->traceTimestamp(layerId, bufferID, mDrawingState.frameNumber, latchTime,
Mikael Pessa90092f42019-08-26 17:22:04 -0700602 FrameTracer::FrameEvent::LATCH);
Marissa Wall61c58622018-07-18 10:12:20 -0700603
Marissa Wall16c112d2019-03-20 13:21:13 -0700604 mCurrentStateModified = false;
605
Marissa Wall61c58622018-07-18 10:12:20 -0700606 return NO_ERROR;
607}
608
609status_t BufferStateLayer::updateActiveBuffer() {
610 const State& s(getDrawingState());
611
612 if (s.buffer == nullptr) {
613 return BAD_VALUE;
614 }
615
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700616 mPreviousBufferId = getCurrentBufferId();
chaviwd62d3062019-09-04 14:48:02 -0700617 mBufferInfo.mBuffer = s.buffer;
618 mBufferInfo.mFence = s.acquireFence;
Marissa Wall61c58622018-07-18 10:12:20 -0700619
620 return NO_ERROR;
621}
622
Valerie Haubf784642020-01-29 07:25:23 -0800623status_t BufferStateLayer::updateFrameNumber(nsecs_t latchTime) {
Marissa Wall61c58622018-07-18 10:12:20 -0700624 // TODO(marissaw): support frame history events
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700625 mPreviousFrameNumber = mCurrentFrameNumber;
Valerie Hau134651a2020-01-28 16:21:22 -0800626 mCurrentFrameNumber = mDrawingState.frameNumber;
Valerie Haubf784642020-01-29 07:25:23 -0800627 {
628 Mutex::Autolock lock(mFrameEventHistoryMutex);
629 mFrameEventHistory.addLatch(mCurrentFrameNumber, latchTime);
630 }
Marissa Wall61c58622018-07-18 10:12:20 -0700631 return NO_ERROR;
632}
633
Lloyd Piquede196652020-01-22 17:29:58 -0800634void BufferStateLayer::preparePerFrameCompositionState() {
635 BufferLayer::preparePerFrameCompositionState();
636
637 auto* compositionState = editCompositionState();
638 if (compositionState->compositionType == Hwc2::IComposerClient::Composition::SIDEBAND) {
Lloyd Piquef5275482019-01-29 18:42:42 -0800639 return;
640 }
Marissa Wall61c58622018-07-18 10:12:20 -0700641
Lloyd Piquede196652020-01-22 17:29:58 -0800642 compositionState->buffer = mBufferInfo.mBuffer;
643 compositionState->bufferSlot = mBufferInfo.mBufferSlot;
644 compositionState->acquireFence = mBufferInfo.mFence;
Marissa Wall61c58622018-07-18 10:12:20 -0700645}
646
Marissa Wall947d34e2019-03-29 14:03:53 -0700647void BufferStateLayer::HwcSlotGenerator::bufferErased(const client_cache_t& clientCacheId) {
648 std::lock_guard lock(mMutex);
649 if (!clientCacheId.isValid()) {
650 ALOGE("invalid process, failed to erase buffer");
651 return;
652 }
653 eraseBufferLocked(clientCacheId);
654}
655
656uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) {
657 std::lock_guard<std::mutex> lock(mMutex);
658 auto itr = mCachedBuffers.find(clientCacheId);
659 if (itr == mCachedBuffers.end()) {
660 return addCachedBuffer(clientCacheId);
661 }
662 auto& [hwcCacheSlot, counter] = itr->second;
663 counter = mCounter++;
664 return hwcCacheSlot;
665}
666
667uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId)
668 REQUIRES(mMutex) {
669 if (!clientCacheId.isValid()) {
670 ALOGE("invalid process, returning invalid slot");
671 return BufferQueue::INVALID_BUFFER_SLOT;
672 }
673
674 ClientCache::getInstance().registerErasedRecipient(clientCacheId, wp<ErasedRecipient>(this));
675
676 uint32_t hwcCacheSlot = getFreeHwcCacheSlot();
677 mCachedBuffers[clientCacheId] = {hwcCacheSlot, mCounter++};
678 return hwcCacheSlot;
679}
680
681uint32_t BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) {
682 if (mFreeHwcCacheSlots.empty()) {
683 evictLeastRecentlyUsed();
684 }
685
686 uint32_t hwcCacheSlot = mFreeHwcCacheSlots.top();
687 mFreeHwcCacheSlots.pop();
688 return hwcCacheSlot;
689}
690
691void BufferStateLayer::HwcSlotGenerator::evictLeastRecentlyUsed() REQUIRES(mMutex) {
692 uint64_t minCounter = UINT_MAX;
693 client_cache_t minClientCacheId = {};
694 for (const auto& [clientCacheId, slotCounter] : mCachedBuffers) {
695 const auto& [hwcCacheSlot, counter] = slotCounter;
696 if (counter < minCounter) {
697 minCounter = counter;
698 minClientCacheId = clientCacheId;
699 }
700 }
701 eraseBufferLocked(minClientCacheId);
702
703 ClientCache::getInstance().unregisterErasedRecipient(minClientCacheId, this);
704}
705
706void BufferStateLayer::HwcSlotGenerator::eraseBufferLocked(const client_cache_t& clientCacheId)
707 REQUIRES(mMutex) {
708 auto itr = mCachedBuffers.find(clientCacheId);
709 if (itr == mCachedBuffers.end()) {
710 return;
711 }
712 auto& [hwcCacheSlot, counter] = itr->second;
713
714 // TODO send to hwc cache and resources
715
716 mFreeHwcCacheSlots.push(hwcCacheSlot);
717 mCachedBuffers.erase(clientCacheId);
718}
chaviw4244e032019-09-04 11:27:49 -0700719
720void BufferStateLayer::gatherBufferInfo() {
chaviwdebadb82020-03-26 14:57:24 -0700721 BufferLayer::gatherBufferInfo();
chaviw4244e032019-09-04 11:27:49 -0700722
chaviwdebadb82020-03-26 14:57:24 -0700723 const State& s(getDrawingState());
chaviw4244e032019-09-04 11:27:49 -0700724 mBufferInfo.mDesiredPresentTime = s.desiredPresentTime;
725 mBufferInfo.mFenceTime = std::make_shared<FenceTime>(s.acquireFence);
726 mBufferInfo.mFence = s.acquireFence;
chaviw4244e032019-09-04 11:27:49 -0700727 mBufferInfo.mTransform = s.transform;
728 mBufferInfo.mDataspace = translateDataspace(s.dataspace);
729 mBufferInfo.mCrop = computeCrop(s);
730 mBufferInfo.mScaleMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
731 mBufferInfo.mSurfaceDamage = s.surfaceDamageRegion;
732 mBufferInfo.mHdrMetadata = s.hdrMetadata;
733 mBufferInfo.mApi = s.api;
chaviw4244e032019-09-04 11:27:49 -0700734 mBufferInfo.mTransformToDisplayInverse = s.transformToDisplayInverse;
chaviwf83ce182019-09-12 14:43:08 -0700735 mBufferInfo.mBufferSlot = mHwcSlotGenerator->getHwcCacheSlot(s.clientCacheId);
chaviw4244e032019-09-04 11:27:49 -0700736}
737
738Rect BufferStateLayer::computeCrop(const State& s) {
739 if (s.crop.isEmpty() && s.buffer) {
740 return s.buffer->getBounds();
741 } else if (s.buffer) {
742 Rect crop = s.crop;
743 crop.left = std::max(crop.left, 0);
744 crop.top = std::max(crop.top, 0);
745 uint32_t bufferWidth = s.buffer->getWidth();
746 uint32_t bufferHeight = s.buffer->getHeight();
747 if (bufferHeight <= std::numeric_limits<int32_t>::max() &&
748 bufferWidth <= std::numeric_limits<int32_t>::max()) {
749 crop.right = std::min(crop.right, static_cast<int32_t>(bufferWidth));
750 crop.bottom = std::min(crop.bottom, static_cast<int32_t>(bufferHeight));
751 }
752 if (!crop.isValid()) {
753 // Crop rect is out of bounds, return whole buffer
754 return s.buffer->getBounds();
755 }
756 return crop;
757 }
758 return s.crop;
759}
760
chaviwb4c6e582019-08-16 14:35:07 -0700761sp<Layer> BufferStateLayer::createClone() {
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700762 LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, 0, 0, LayerMetadata());
chaviwb4c6e582019-08-16 14:35:07 -0700763 args.textureName = mTextureName;
Lloyd Pique1c3a5eb2019-10-03 13:07:08 -0700764 sp<BufferStateLayer> layer = mFlinger->getFactory().createBufferStateLayer(args);
chaviwb4c6e582019-08-16 14:35:07 -0700765 layer->mHwcSlotGenerator = mHwcSlotGenerator;
766 layer->setInitialValuesForClone(this);
767 return layer;
768}
Valerie Hau92bf5482020-02-10 09:49:08 -0800769
770Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const {
771 const auto& p = mDrawingParent.promote();
772 if (p != nullptr) {
773 RoundedCornerState parentState = p->getRoundedCornerState();
774 if (parentState.radius > 0) {
775 ui::Transform t = getActiveTransform(getDrawingState());
776 t = t.inverse();
777 parentState.cropRect = t.transform(parentState.cropRect);
778 // The rounded corners shader only accepts 1 corner radius for performance reasons,
779 // but a transform matrix can define horizontal and vertical scales.
780 // Let's take the average between both of them and pass into the shader, practically we
781 // never do this type of transformation on windows anyway.
782 parentState.radius *= (t[0][0] + t[1][1]) / 2.0f;
783 return parentState;
784 }
785 }
786 const float radius = getDrawingState().cornerRadius;
787 const State& s(getDrawingState());
788 if (radius <= 0 || (getActiveWidth(s) == UINT32_MAX && getActiveHeight(s) == UINT32_MAX))
789 return RoundedCornerState();
790 return RoundedCornerState(FloatRect(static_cast<float>(s.active.transform.tx()),
791 static_cast<float>(s.active.transform.ty()),
792 static_cast<float>(s.active.transform.tx() + s.active.w),
793 static_cast<float>(s.active.transform.ty() + s.active.h)),
794 radius);
795}
Marissa Wall61c58622018-07-18 10:12:20 -0700796} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800797
798// TODO(b/129481165): remove the #pragma below and fix conversion issues
799#pragma clang diagnostic pop // ignored "-Wconversion"