blob: ec73b9d49e63da78e21266ca11488f3757970f30 [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"
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080036#include "TimeStats/TimeStats.h"
Valerie Hau0bc09152018-12-20 07:42:47 -080037
Marissa Wall61c58622018-07-18 10:12:20 -070038namespace android {
39
Lloyd Pique42ab75e2018-09-12 20:46:03 -070040// clang-format off
41const std::array<float, 16> BufferStateLayer::IDENTITY_MATRIX{
42 1, 0, 0, 0,
43 0, 1, 0, 0,
44 0, 0, 1, 0,
45 0, 0, 0, 1
46};
47// clang-format on
Marissa Wall61c58622018-07-18 10:12:20 -070048
Marissa Wall947d34e2019-03-29 14:03:53 -070049BufferStateLayer::BufferStateLayer(const LayerCreationArgs& args)
50 : BufferLayer(args), mHwcSlotGenerator(new HwcSlotGenerator()) {
Vishnu Nair60356342018-11-13 13:00:45 -080051 mOverrideScalingMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
Marissa Wall3ff826c2019-02-07 11:58:25 -080052 mCurrentState.dataspace = ui::Dataspace::V0_SRGB;
Vishnu Nair60356342018-11-13 13:00:45 -080053}
Marissa Wall61c58622018-07-18 10:12:20 -070054
Alec Mouri4545a8a2019-08-08 20:05:32 -070055BufferStateLayer::~BufferStateLayer() {
chaviwb4c6e582019-08-16 14:35:07 -070056 // The original layer and the clone layer share the same texture and buffer. Therefore, only
57 // one of the layers, in this case the original layer, needs to handle the deletion. The
58 // original layer and the clone should be removed at the same time so there shouldn't be any
59 // issue with the clone layer trying to use the texture.
60 if (mBufferInfo.mBuffer != nullptr && !isClone()) {
chaviwd62d3062019-09-04 14:48:02 -070061 // Ensure that mBuffer is uncached from RenderEngine here, as
Alec Mouri4545a8a2019-08-08 20:05:32 -070062 // RenderEngine may have been using the buffer as an external texture
63 // after the client uncached the buffer.
64 auto& engine(mFlinger->getRenderEngine());
chaviwd62d3062019-09-04 14:48:02 -070065 engine.unbindExternalTextureBuffer(mBufferInfo.mBuffer->getId());
Alec Mouri4545a8a2019-08-08 20:05:32 -070066 }
67}
68
Robert Carr92c29762021-01-05 14:01:20 -080069status_t BufferStateLayer::addReleaseFence(const sp<CallbackHandle>& ch,
70 const sp<Fence>& fence) {
71 if (ch == nullptr) {
72 return OK;
73 }
74 if (!ch->previousReleaseFence.get()) {
75 ch->previousReleaseFence = fence;
76 return OK;
77 }
78
79 // Below logic is lifted from ConsumerBase.cpp:
80 // Check status of fences first because merging is expensive.
81 // Merging an invalid fence with any other fence results in an
82 // invalid fence.
83 auto currentStatus = ch->previousReleaseFence->getStatus();
84 if (currentStatus == Fence::Status::Invalid) {
85 ALOGE("Existing fence has invalid state, layer: %s", mName.c_str());
86 return BAD_VALUE;
87 }
88
89 auto incomingStatus = fence->getStatus();
90 if (incomingStatus == Fence::Status::Invalid) {
91 ALOGE("New fence has invalid state, layer: %s", mName.c_str());
92 ch->previousReleaseFence = fence;
93 return BAD_VALUE;
94 }
95
96 // If both fences are signaled or both are unsignaled, we need to merge
97 // them to get an accurate timestamp.
98 if (currentStatus == incomingStatus) {
99 char fenceName[32] = {};
100 snprintf(fenceName, 32, "%.28s", mName.c_str());
101 sp<Fence> mergedFence = Fence::merge(
102 fenceName, ch->previousReleaseFence, fence);
103 if (!mergedFence.get()) {
104 ALOGE("failed to merge release fences, layer: %s", mName.c_str());
105 // synchronization is broken, the best we can do is hope fences
106 // signal in order so the new fence will act like a union
107 ch->previousReleaseFence = fence;
108 return BAD_VALUE;
109 }
110 ch->previousReleaseFence = mergedFence;
111 } else if (incomingStatus == Fence::Status::Unsignaled) {
112 // If one fence has signaled and the other hasn't, the unsignaled
113 // fence will approximately correspond with the correct timestamp.
114 // There's a small race if both fences signal at about the same time
115 // and their statuses are retrieved with unfortunate timing. However,
116 // by this point, they will have both signaled and only the timestamp
117 // will be slightly off; any dependencies after this point will
118 // already have been met.
119 ch->previousReleaseFence = fence;
120 }
121 // else if (currentStatus == Fence::Status::Unsignaled) is a no-op.
122
123 return OK;
124}
125
Marissa Wall61c58622018-07-18 10:12:20 -0700126// -----------------------------------------------------------------------
127// Interface implementation for Layer
128// -----------------------------------------------------------------------
Marissa Wallfda30bb2018-10-12 11:34:28 -0700129void BufferStateLayer::onLayerDisplayed(const sp<Fence>& releaseFence) {
Robert Carr92c29762021-01-05 14:01:20 -0800130 if (!releaseFence->isValid()) {
131 return;
132 }
Marissa Wall5a68a772018-12-22 17:43:42 -0800133 // The previous release fence notifies the client that SurfaceFlinger is done with the previous
134 // buffer that was presented on this layer. The first transaction that came in this frame that
135 // replaced the previous buffer on this layer needs this release fence, because the fence will
136 // let the client know when that previous buffer is removed from the screen.
137 //
138 // Every other transaction on this layer does not need a release fence because no other
139 // Transactions that were set on this layer this frame are going to have their preceeding buffer
140 // removed from the display this frame.
141 //
142 // For example, if we have 3 transactions this frame. The first transaction doesn't contain a
143 // buffer so it doesn't need a previous release fence because the layer still needs the previous
144 // buffer. The second transaction contains a buffer so it needs a previous release fence because
145 // the previous buffer will be released this frame. The third transaction also contains a
146 // buffer. It replaces the buffer in the second transaction. The buffer in the second
147 // transaction will now no longer be presented so it is released immediately and the third
148 // transaction doesn't need a previous release fence.
Robert Carr92c29762021-01-05 14:01:20 -0800149 sp<CallbackHandle> ch;
Marissa Wall5a68a772018-12-22 17:43:42 -0800150 for (auto& handle : mDrawingState.callbackHandles) {
151 if (handle->releasePreviousBuffer) {
Robert Carr92c29762021-01-05 14:01:20 -0800152 ch = handle;
Marissa Wall5a68a772018-12-22 17:43:42 -0800153 break;
154 }
155 }
Robert Carr92c29762021-01-05 14:01:20 -0800156 auto status = addReleaseFence(ch, releaseFence);
157 if (status != OK) {
158 ALOGE("Failed to add release fence for layer %s", getName().c_str());
159 }
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700160
Valerie Haubf784642020-01-29 07:25:23 -0800161 mPreviousReleaseFence = releaseFence;
162
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700163 // Prevent tracing the same release multiple times.
164 if (mPreviousFrameNumber != mPreviousReleasedFrameNumber) {
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700165 mPreviousReleasedFrameNumber = mPreviousFrameNumber;
166 }
Marissa Wall61c58622018-07-18 10:12:20 -0700167}
168
Valerie Haubf784642020-01-29 07:25:23 -0800169void BufferStateLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
Valerie Hau32cdc1f2019-10-21 14:45:54 -0700170 for (const auto& handle : mDrawingState.callbackHandles) {
171 handle->transformHint = mTransformHint;
Valerie Hau871d6352020-01-29 08:44:02 -0800172 handle->dequeueReadyTime = dequeueReadyTime;
Valerie Hau32cdc1f2019-10-21 14:45:54 -0700173 }
174
Marissa Wallefb71af2019-06-27 14:45:53 -0700175 mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles(
Marissa Wall5a68a772018-12-22 17:43:42 -0800176 mDrawingState.callbackHandles);
177
178 mDrawingState.callbackHandles = {};
Valerie Haubf784642020-01-29 07:25:23 -0800179
180 const sp<Fence>& releaseFence(mPreviousReleaseFence);
181 std::shared_ptr<FenceTime> releaseFenceTime = std::make_shared<FenceTime>(releaseFence);
182 {
183 Mutex::Autolock lock(mFrameEventHistoryMutex);
184 if (mPreviousFrameNumber != 0) {
185 mFrameEventHistory.addRelease(mPreviousFrameNumber, dequeueReadyTime,
186 std::move(releaseFenceTime));
187 }
188 }
Marissa Wall61c58622018-07-18 10:12:20 -0700189}
190
Valerie Hau871d6352020-01-29 08:44:02 -0800191void BufferStateLayer::finalizeFrameEventHistory(const std::shared_ptr<FenceTime>& glDoneFence,
192 const CompositorTiming& compositorTiming) {
193 for (const auto& handle : mDrawingState.callbackHandles) {
194 handle->gpuCompositionDoneFence = glDoneFence;
195 handle->compositorTiming = compositorTiming;
196 }
197}
198
Ana Krulec010d2192018-10-08 06:29:54 -0700199bool BufferStateLayer::shouldPresentNow(nsecs_t /*expectedPresentTime*/) const {
Marissa Wall61c58622018-07-18 10:12:20 -0700200 if (getSidebandStreamChanged() || getAutoRefresh()) {
201 return true;
202 }
203
Marissa Wall024a1912018-08-13 13:55:35 -0700204 return hasFrameUpdate();
Marissa Wall61c58622018-07-18 10:12:20 -0700205}
206
Marissa Walle2ffb422018-10-12 11:33:52 -0700207bool BufferStateLayer::willPresentCurrentTransaction() const {
208 // Returns true if the most recent Transaction applied to CurrentState will be presented.
Robert Carr321e83c2019-08-19 15:49:30 -0700209 return (getSidebandStreamChanged() || getAutoRefresh() ||
Valerie Hauaa194562019-02-05 16:21:38 -0800210 (mCurrentState.modified &&
Robert Carr321e83c2019-08-19 15:49:30 -0700211 (mCurrentState.buffer != nullptr || mCurrentState.bgColorLayer != nullptr))) &&
212 !mLayerDetached;
Marissa Wall61c58622018-07-18 10:12:20 -0700213}
214
Valerie Hau3282b3c2020-02-03 15:37:27 -0800215/* TODO: vhau uncomment once deferred transaction migration complete in
216 * WindowManager
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800217void BufferStateLayer::pushPendingState() {
218 if (!mCurrentState.modified) {
Marissa Wall61c58622018-07-18 10:12:20 -0700219 return;
220 }
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800221 mPendingStates.push_back(mCurrentState);
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700222 ATRACE_INT(mTransactionName.c_str(), mPendingStates.size());
Marissa Wall61c58622018-07-18 10:12:20 -0700223}
Valerie Hau3282b3c2020-02-03 15:37:27 -0800224*/
Marissa Wall61c58622018-07-18 10:12:20 -0700225
226bool BufferStateLayer::applyPendingStates(Layer::State* stateToCommit) {
Valerie Hau3282b3c2020-02-03 15:37:27 -0800227 mCurrentStateModified = mCurrentState.modified;
228 bool stateUpdateAvailable = Layer::applyPendingStates(stateToCommit);
229 mCurrentStateModified = stateUpdateAvailable && mCurrentStateModified;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800230 mCurrentState.modified = false;
Marissa Wall61c58622018-07-18 10:12:20 -0700231 return stateUpdateAvailable;
232}
233
Marissa Wall861616d2018-10-22 12:52:23 -0700234// Crop that applies to the window
235Rect BufferStateLayer::getCrop(const Layer::State& /*s*/) const {
236 return Rect::INVALID_RECT;
Marissa Wall61c58622018-07-18 10:12:20 -0700237}
238
239bool BufferStateLayer::setTransform(uint32_t transform) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800240 if (mCurrentState.transform == transform) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800241 mCurrentState.transform = transform;
242 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700243 setTransactionFlags(eTransactionNeeded);
244 return true;
245}
246
247bool BufferStateLayer::setTransformToDisplayInverse(bool transformToDisplayInverse) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800248 if (mCurrentState.transformToDisplayInverse == transformToDisplayInverse) return false;
249 mCurrentState.sequence++;
250 mCurrentState.transformToDisplayInverse = transformToDisplayInverse;
251 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700252 setTransactionFlags(eTransactionNeeded);
253 return true;
254}
255
256bool BufferStateLayer::setCrop(const Rect& crop) {
Marissa Wall290ad082019-03-06 13:23:47 -0800257 Rect c = crop;
258 if (c.left < 0) {
259 c.left = 0;
260 }
261 if (c.top < 0) {
262 c.top = 0;
263 }
264 // If the width and/or height are < 0, make it [0, 0, -1, -1] so the equality comparision below
265 // treats all invalid rectangles the same.
266 if (!c.isValid()) {
267 c.makeInvalid();
268 }
269
270 if (mCurrentState.crop == c) return false;
Marissa Wall290ad082019-03-06 13:23:47 -0800271 mCurrentState.crop = c;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800272 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700273 setTransactionFlags(eTransactionNeeded);
274 return true;
275}
276
Marissa Wall861616d2018-10-22 12:52:23 -0700277bool BufferStateLayer::setFrame(const Rect& frame) {
278 int x = frame.left;
279 int y = frame.top;
280 int w = frame.getWidth();
281 int h = frame.getHeight();
282
Marissa Wall0f3242d2018-12-20 15:10:22 -0800283 if (x < 0) {
284 x = 0;
285 w = frame.right;
286 }
287
288 if (y < 0) {
289 y = 0;
290 h = frame.bottom;
291 }
292
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800293 if (mCurrentState.active.transform.tx() == x && mCurrentState.active.transform.ty() == y &&
294 mCurrentState.active.w == w && mCurrentState.active.h == h) {
Marissa Wall861616d2018-10-22 12:52:23 -0700295 return false;
296 }
297
298 if (!frame.isValid()) {
299 x = y = w = h = 0;
300 }
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800301 mCurrentState.active.transform.set(x, y);
302 mCurrentState.active.w = w;
303 mCurrentState.active.h = h;
Marissa Wall861616d2018-10-22 12:52:23 -0700304
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800305 mCurrentState.sequence++;
306 mCurrentState.modified = true;
Marissa Wall861616d2018-10-22 12:52:23 -0700307 setTransactionFlags(eTransactionNeeded);
308 return true;
309}
310
Valerie Hau871d6352020-01-29 08:44:02 -0800311bool BufferStateLayer::addFrameEvent(const sp<Fence>& acquireFence, nsecs_t postedTime,
312 nsecs_t desiredPresentTime) {
Valerie Haubf784642020-01-29 07:25:23 -0800313 Mutex::Autolock lock(mFrameEventHistoryMutex);
314 mAcquireTimeline.updateSignalTimes();
315 std::shared_ptr<FenceTime> acquireFenceTime =
316 std::make_shared<FenceTime>((acquireFence ? acquireFence : Fence::NO_FENCE));
317 NewFrameEventsEntry newTimestamps = {mCurrentState.frameNumber, postedTime, desiredPresentTime,
318 acquireFenceTime};
Valerie Hau871d6352020-01-29 08:44:02 -0800319 mFrameEventHistory.setProducerWantsEvents();
Valerie Haubf784642020-01-29 07:25:23 -0800320 mFrameEventHistory.addQueue(newTimestamps);
321 return true;
322}
323
324bool BufferStateLayer::setBuffer(const sp<GraphicBuffer>& buffer, const sp<Fence>& acquireFence,
325 nsecs_t postTime, nsecs_t desiredPresentTime,
326 const client_cache_t& clientCacheId) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800327 if (mCurrentState.buffer) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700328 mReleasePreviousBuffer = true;
329 }
330
Valerie Hau134651a2020-01-28 16:21:22 -0800331 mCurrentState.frameNumber++;
Valerie Hau2f54d642020-01-22 09:37:03 -0800332
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800333 mCurrentState.buffer = buffer;
Marissa Wall947d34e2019-03-29 14:03:53 -0700334 mCurrentState.clientCacheId = clientCacheId;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800335 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700336 setTransactionFlags(eTransactionNeeded);
Ady Abraham09bd3922019-04-08 10:44:56 -0700337
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800338 const int32_t layerId = getSequence();
Valerie Hau134651a2020-01-28 16:21:22 -0800339 mFlinger->mTimeStats->setPostTime(layerId, mCurrentState.frameNumber, getName().c_str(),
340 postTime);
Valerie Hau871d6352020-01-29 08:44:02 -0800341 desiredPresentTime = desiredPresentTime <= 0 ? 0 : desiredPresentTime;
chaviwfa67b552019-08-12 16:51:55 -0700342 mCurrentState.desiredPresentTime = desiredPresentTime;
Ady Abraham09bd3922019-04-08 10:44:56 -0700343
Ady Abraham5def7332020-05-29 16:13:47 -0700344 mFlinger->mScheduler->recordLayerHistory(this, desiredPresentTime,
345 LayerHistory::LayerUpdateType::Buffer);
Ady Abraham09bd3922019-04-08 10:44:56 -0700346
Valerie Hau871d6352020-01-29 08:44:02 -0800347 addFrameEvent(acquireFence, postTime, desiredPresentTime);
Marissa Wall61c58622018-07-18 10:12:20 -0700348 return true;
349}
350
351bool BufferStateLayer::setAcquireFence(const sp<Fence>& fence) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700352 // The acquire fences of BufferStateLayers have already signaled before they are set
353 mCallbackHandleAcquireTime = fence->getSignalTime();
354
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800355 mCurrentState.acquireFence = fence;
356 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700357 setTransactionFlags(eTransactionNeeded);
358 return true;
359}
360
361bool BufferStateLayer::setDataspace(ui::Dataspace dataspace) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800362 if (mCurrentState.dataspace == dataspace) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800363 mCurrentState.dataspace = dataspace;
364 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700365 setTransactionFlags(eTransactionNeeded);
366 return true;
367}
368
369bool BufferStateLayer::setHdrMetadata(const HdrMetadata& hdrMetadata) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800370 if (mCurrentState.hdrMetadata == hdrMetadata) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800371 mCurrentState.hdrMetadata = hdrMetadata;
372 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700373 setTransactionFlags(eTransactionNeeded);
374 return true;
375}
376
377bool BufferStateLayer::setSurfaceDamageRegion(const Region& surfaceDamage) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800378 mCurrentState.surfaceDamageRegion = surfaceDamage;
379 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700380 setTransactionFlags(eTransactionNeeded);
381 return true;
382}
383
384bool BufferStateLayer::setApi(int32_t api) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800385 if (mCurrentState.api == api) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800386 mCurrentState.api = api;
387 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700388 setTransactionFlags(eTransactionNeeded);
389 return true;
390}
391
392bool BufferStateLayer::setSidebandStream(const sp<NativeHandle>& sidebandStream) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800393 if (mCurrentState.sidebandStream == sidebandStream) return false;
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800394 mCurrentState.sidebandStream = sidebandStream;
395 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700396 setTransactionFlags(eTransactionNeeded);
397
398 if (!mSidebandStreamChanged.exchange(true)) {
399 // mSidebandStreamChanged was false
400 mFlinger->signalLayerUpdate();
401 }
402 return true;
403}
404
Marissa Walle2ffb422018-10-12 11:33:52 -0700405bool BufferStateLayer::setTransactionCompletedListeners(
406 const std::vector<sp<CallbackHandle>>& handles) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700407 // If there is no handle, we will not send a callback so reset mReleasePreviousBuffer and return
Marissa Walle2ffb422018-10-12 11:33:52 -0700408 if (handles.empty()) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700409 mReleasePreviousBuffer = false;
Marissa Walle2ffb422018-10-12 11:33:52 -0700410 return false;
411 }
412
413 const bool willPresent = willPresentCurrentTransaction();
414
415 for (const auto& handle : handles) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700416 // If this transaction set a buffer on this layer, release its previous buffer
417 handle->releasePreviousBuffer = mReleasePreviousBuffer;
418
Marissa Walle2ffb422018-10-12 11:33:52 -0700419 // If this layer will be presented in this frame
420 if (willPresent) {
Marissa Wallfda30bb2018-10-12 11:34:28 -0700421 // If this transaction set an acquire fence on this layer, set its acquire time
422 handle->acquireTime = mCallbackHandleAcquireTime;
423
Marissa Walle2ffb422018-10-12 11:33:52 -0700424 // Notify the transaction completed thread that there is a pending latched callback
425 // handle
Marissa Wall5a68a772018-12-22 17:43:42 -0800426 mFlinger->getTransactionCompletedThread().registerPendingCallbackHandle(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700427
428 // Store so latched time and release fence can be set
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800429 mCurrentState.callbackHandles.push_back(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700430
431 } else { // If this layer will NOT need to be relatched and presented this frame
432 // Notify the transaction completed thread this handle is done
Marissa Wallefb71af2019-06-27 14:45:53 -0700433 mFlinger->getTransactionCompletedThread().registerUnpresentedCallbackHandle(handle);
Marissa Walle2ffb422018-10-12 11:33:52 -0700434 }
435 }
436
Marissa Wallfda30bb2018-10-12 11:34:28 -0700437 mReleasePreviousBuffer = false;
438 mCallbackHandleAcquireTime = -1;
439
Marissa Walle2ffb422018-10-12 11:33:52 -0700440 return willPresent;
441}
442
Valerie Hau7618b232020-01-09 16:03:08 -0800443void BufferStateLayer::forceSendCallbacks() {
444 mFlinger->getTransactionCompletedThread().finalizePendingCallbackHandles(
445 mCurrentState.callbackHandles);
446}
447
Marissa Wall61c58622018-07-18 10:12:20 -0700448bool BufferStateLayer::setTransparentRegionHint(const Region& transparent) {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800449 mCurrentState.transparentRegionHint = transparent;
450 mCurrentState.modified = true;
Marissa Wall61c58622018-07-18 10:12:20 -0700451 setTransactionFlags(eTransactionNeeded);
452 return true;
453}
454
Marissa Wall861616d2018-10-22 12:52:23 -0700455Rect BufferStateLayer::getBufferSize(const State& s) const {
456 // for buffer state layers we use the display frame size as the buffer size.
457 if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
458 return Rect(getActiveWidth(s), getActiveHeight(s));
Marissa Wall61c58622018-07-18 10:12:20 -0700459 }
460
Marissa Wall861616d2018-10-22 12:52:23 -0700461 // if the display frame is not defined, use the parent bounds as the buffer size.
462 const auto& p = mDrawingParent.promote();
463 if (p != nullptr) {
Vishnu Nair4351ad52019-02-11 14:13:02 -0800464 Rect parentBounds = Rect(p->getBounds(Region()));
Marissa Wall861616d2018-10-22 12:52:23 -0700465 if (!parentBounds.isEmpty()) {
466 return parentBounds;
467 }
468 }
469
Marissa Wall861616d2018-10-22 12:52:23 -0700470 return Rect::INVALID_RECT;
Marissa Wall61c58622018-07-18 10:12:20 -0700471}
Vishnu Nair4351ad52019-02-11 14:13:02 -0800472
473FloatRect BufferStateLayer::computeSourceBounds(const FloatRect& parentBounds) const {
474 const State& s(getDrawingState());
475 // for buffer state layers we use the display frame size as the buffer size.
476 if (getActiveWidth(s) < UINT32_MAX && getActiveHeight(s) < UINT32_MAX) {
477 return FloatRect(0, 0, getActiveWidth(s), getActiveHeight(s));
478 }
479
480 // if the display frame is not defined, use the parent bounds as the buffer size.
481 return parentBounds;
482}
483
Marissa Wall61c58622018-07-18 10:12:20 -0700484// -----------------------------------------------------------------------
485
486// -----------------------------------------------------------------------
487// Interface implementation for BufferLayer
488// -----------------------------------------------------------------------
489bool BufferStateLayer::fenceHasSignaled() const {
490 if (latchUnsignaledBuffers()) {
491 return true;
492 }
493
Alec Mouri91f6df32020-01-30 08:48:58 -0800494 const bool fenceSignaled =
495 getDrawingState().acquireFence->getStatus() == Fence::Status::Signaled;
496 if (!fenceSignaled) {
497 mFlinger->mTimeStats->incrementLatchSkipped(getSequence(),
498 TimeStats::LatchSkipReason::LateAcquire);
499 }
500
501 return fenceSignaled;
Marissa Wall61c58622018-07-18 10:12:20 -0700502}
503
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700504bool BufferStateLayer::framePresentTimeIsCurrent(nsecs_t expectedPresentTime) const {
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700505 if (!hasFrameUpdate() || isRemovedFromCurrentState()) {
506 return true;
507 }
508
chaviwfa67b552019-08-12 16:51:55 -0700509 return mCurrentState.desiredPresentTime <= expectedPresentTime;
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700510}
511
Valerie Hau871d6352020-01-29 08:44:02 -0800512bool BufferStateLayer::onPreComposition(nsecs_t refreshStartTime) {
513 for (const auto& handle : mDrawingState.callbackHandles) {
514 handle->refreshStartTime = refreshStartTime;
515 }
516 return BufferLayer::onPreComposition(refreshStartTime);
517}
518
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700519uint64_t BufferStateLayer::getFrameNumber(nsecs_t /*expectedPresentTime*/) const {
Valerie Hau134651a2020-01-28 16:21:22 -0800520 return mDrawingState.frameNumber;
Marissa Wall61c58622018-07-18 10:12:20 -0700521}
522
Robert Carrfe1209c2020-02-11 12:25:35 -0800523/**
524 * This is the frameNumber used for deferred transaction signalling. We need to use this because
525 * of cases where we defer a transaction for a surface to itself. In the BLAST world this
526 * may not make a huge amount of sense (Why not just merge the Buffer transaction with the
527 * deferred transaction?) but this is an important legacy use case, for example moving
528 * a window at the same time it draws makes use of this kind of technique. So anyway
529 * imagine we have something like this:
530 *
531 * Transaction { // containing
532 * Buffer -> frameNumber = 2
533 * DeferTransactionUntil -> frameNumber = 2
534 * Random other stuff
535 * }
536 * Now imagine getHeadFrameNumber returned mDrawingState.mFrameNumber (or mCurrentFrameNumber).
537 * Prior to doTransaction SurfaceFlinger will call notifyAvailableFrames, but because we
538 * haven't swapped mCurrentState to mDrawingState yet we will think the sync point
539 * is not ready. So we will return false from applyPendingState and not swap
540 * current state to drawing state. But because we don't swap current state
541 * to drawing state the number will never update and we will be stuck. This way
542 * we can see we need to return the frame number for the buffer we are about
543 * to apply.
544 */
545uint64_t BufferStateLayer::getHeadFrameNumber(nsecs_t /* expectedPresentTime */) const {
546 return mCurrentState.frameNumber;
547}
548
Marissa Wall61c58622018-07-18 10:12:20 -0700549bool BufferStateLayer::getAutoRefresh() const {
550 // TODO(marissaw): support shared buffer mode
551 return false;
552}
553
554bool BufferStateLayer::getSidebandStreamChanged() const {
555 return mSidebandStreamChanged.load();
556}
557
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800558bool BufferStateLayer::latchSidebandStream(bool& recomputeVisibleRegions) {
Marissa Wall61c58622018-07-18 10:12:20 -0700559 if (mSidebandStreamChanged.exchange(false)) {
560 const State& s(getDrawingState());
561 // mSidebandStreamChanged was true
Lloyd Pique0b785d82018-12-04 17:25:27 -0800562 mSidebandStream = s.sidebandStream;
Lloyd Piquede196652020-01-22 17:29:58 -0800563 editCompositionState()->sidebandStream = mSidebandStream;
Lloyd Pique0b785d82018-12-04 17:25:27 -0800564 if (mSidebandStream != nullptr) {
Marissa Wall61c58622018-07-18 10:12:20 -0700565 setTransactionFlags(eTransactionNeeded);
566 mFlinger->setTransactionFlags(eTraversalNeeded);
567 }
568 recomputeVisibleRegions = true;
569
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800570 return true;
Marissa Wall61c58622018-07-18 10:12:20 -0700571 }
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800572 return false;
Marissa Wall61c58622018-07-18 10:12:20 -0700573}
574
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800575bool BufferStateLayer::hasFrameUpdate() const {
Valerie Hauaa194562019-02-05 16:21:38 -0800576 const State& c(getCurrentState());
577 return mCurrentStateModified && (c.buffer != nullptr || c.bgColorLayer != nullptr);
Marissa Wall61c58622018-07-18 10:12:20 -0700578}
579
Alec Mouri39801c02018-10-10 10:44:47 -0700580status_t BufferStateLayer::bindTextureImage() {
Marissa Wall61c58622018-07-18 10:12:20 -0700581 const State& s(getDrawingState());
582 auto& engine(mFlinger->getRenderEngine());
583
Alec Mourib5c4f352019-02-19 19:46:38 -0800584 return engine.bindExternalTextureBuffer(mTextureName, s.buffer, s.acquireFence);
Marissa Wall61c58622018-07-18 10:12:20 -0700585}
586
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700587status_t BufferStateLayer::updateTexImage(bool& /*recomputeVisibleRegions*/, nsecs_t latchTime,
588 nsecs_t /*expectedPresentTime*/) {
Marissa Wall61c58622018-07-18 10:12:20 -0700589 const State& s(getDrawingState());
590
591 if (!s.buffer) {
Valerie Hauaa194562019-02-05 16:21:38 -0800592 if (s.bgColorLayer) {
593 for (auto& handle : mDrawingState.callbackHandles) {
594 handle->latchTime = latchTime;
595 }
596 }
Marissa Wall61c58622018-07-18 10:12:20 -0700597 return NO_ERROR;
598 }
599
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800600 const int32_t layerId = getSequence();
Yiwei Zhang9689e2f2018-05-11 12:33:23 -0700601
Marissa Wall61c58622018-07-18 10:12:20 -0700602 // Reject if the layer is invalid
603 uint32_t bufferWidth = s.buffer->width;
604 uint32_t bufferHeight = s.buffer->height;
605
Peiyong Linefefaac2018-08-17 12:27:51 -0700606 if (s.transform & ui::Transform::ROT_90) {
Peiyong Lin3db42342018-08-16 09:15:59 -0700607 std::swap(bufferWidth, bufferHeight);
Marissa Wall61c58622018-07-18 10:12:20 -0700608 }
609
610 if (s.transformToDisplayInverse) {
Dominik Laskowski718f9602019-11-09 20:01:35 -0800611 uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
Peiyong Linefefaac2018-08-17 12:27:51 -0700612 if (invTransform & ui::Transform::ROT_90) {
Peiyong Lin3db42342018-08-16 09:15:59 -0700613 std::swap(bufferWidth, bufferHeight);
Marissa Wall61c58622018-07-18 10:12:20 -0700614 }
615 }
616
Vishnu Nair60356342018-11-13 13:00:45 -0800617 if (getEffectiveScalingMode() == NATIVE_WINDOW_SCALING_MODE_FREEZE &&
Marissa Wall61c58622018-07-18 10:12:20 -0700618 (s.active.w != bufferWidth || s.active.h != bufferHeight)) {
619 ALOGE("[%s] rejecting buffer: "
620 "bufferWidth=%d, bufferHeight=%d, front.active.{w=%d, h=%d}",
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700621 getDebugName(), bufferWidth, bufferHeight, s.active.w, s.active.h);
Valerie Hau134651a2020-01-28 16:21:22 -0800622 mFlinger->mTimeStats->removeTimeRecord(layerId, mDrawingState.frameNumber);
Marissa Wall61c58622018-07-18 10:12:20 -0700623 return BAD_VALUE;
624 }
625
Marissa Wall5a68a772018-12-22 17:43:42 -0800626 for (auto& handle : mDrawingState.callbackHandles) {
627 handle->latchTime = latchTime;
Valerie Hau871d6352020-01-29 08:44:02 -0800628 handle->frameNumber = mDrawingState.frameNumber;
Marissa Wall5a68a772018-12-22 17:43:42 -0800629 }
Marissa Walle2ffb422018-10-12 11:33:52 -0700630
Alec Mouri56e538f2019-01-14 15:22:01 -0800631 if (!SyncFeatures::getInstance().useNativeFenceSync()) {
Marissa Wall61c58622018-07-18 10:12:20 -0700632 // Bind the new buffer to the GL texture.
633 //
634 // Older devices require the "implicit" synchronization provided
635 // by glEGLImageTargetTexture2DOES, which this method calls. Newer
636 // devices will either call this in Layer::onDraw, or (if it's not
637 // a GL-composited layer) not at all.
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800638 status_t err = bindTextureImage();
Marissa Wall61c58622018-07-18 10:12:20 -0700639 if (err != NO_ERROR) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800640 mFlinger->mTimeStats->onDestroy(layerId);
Marissa Wall61c58622018-07-18 10:12:20 -0700641 return BAD_VALUE;
642 }
643 }
644
Valerie Hau134651a2020-01-28 16:21:22 -0800645 mFlinger->mTimeStats->setAcquireFence(layerId, mDrawingState.frameNumber,
chaviw95631e32020-06-09 13:43:32 -0700646 std::make_shared<FenceTime>(mDrawingState.acquireFence));
Valerie Hau134651a2020-01-28 16:21:22 -0800647 mFlinger->mTimeStats->setLatchTime(layerId, mDrawingState.frameNumber, latchTime);
Marissa Wall61c58622018-07-18 10:12:20 -0700648
Marissa Wall16c112d2019-03-20 13:21:13 -0700649 mCurrentStateModified = false;
650
Marissa Wall61c58622018-07-18 10:12:20 -0700651 return NO_ERROR;
652}
653
654status_t BufferStateLayer::updateActiveBuffer() {
655 const State& s(getDrawingState());
656
657 if (s.buffer == nullptr) {
658 return BAD_VALUE;
659 }
660
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700661 mPreviousBufferId = getCurrentBufferId();
chaviwd62d3062019-09-04 14:48:02 -0700662 mBufferInfo.mBuffer = s.buffer;
663 mBufferInfo.mFence = s.acquireFence;
Marissa Wall61c58622018-07-18 10:12:20 -0700664
665 return NO_ERROR;
666}
667
Valerie Haubf784642020-01-29 07:25:23 -0800668status_t BufferStateLayer::updateFrameNumber(nsecs_t latchTime) {
Marissa Wall61c58622018-07-18 10:12:20 -0700669 // TODO(marissaw): support frame history events
Mikael Pessa2e1608f2019-07-19 11:25:35 -0700670 mPreviousFrameNumber = mCurrentFrameNumber;
Valerie Hau134651a2020-01-28 16:21:22 -0800671 mCurrentFrameNumber = mDrawingState.frameNumber;
Valerie Haubf784642020-01-29 07:25:23 -0800672 {
673 Mutex::Autolock lock(mFrameEventHistoryMutex);
674 mFrameEventHistory.addLatch(mCurrentFrameNumber, latchTime);
675 }
Marissa Wall61c58622018-07-18 10:12:20 -0700676 return NO_ERROR;
677}
678
Marissa Wall947d34e2019-03-29 14:03:53 -0700679void BufferStateLayer::HwcSlotGenerator::bufferErased(const client_cache_t& clientCacheId) {
680 std::lock_guard lock(mMutex);
681 if (!clientCacheId.isValid()) {
682 ALOGE("invalid process, failed to erase buffer");
683 return;
684 }
685 eraseBufferLocked(clientCacheId);
686}
687
688uint32_t BufferStateLayer::HwcSlotGenerator::getHwcCacheSlot(const client_cache_t& clientCacheId) {
689 std::lock_guard<std::mutex> lock(mMutex);
690 auto itr = mCachedBuffers.find(clientCacheId);
691 if (itr == mCachedBuffers.end()) {
692 return addCachedBuffer(clientCacheId);
693 }
694 auto& [hwcCacheSlot, counter] = itr->second;
695 counter = mCounter++;
696 return hwcCacheSlot;
697}
698
699uint32_t BufferStateLayer::HwcSlotGenerator::addCachedBuffer(const client_cache_t& clientCacheId)
700 REQUIRES(mMutex) {
701 if (!clientCacheId.isValid()) {
702 ALOGE("invalid process, returning invalid slot");
703 return BufferQueue::INVALID_BUFFER_SLOT;
704 }
705
706 ClientCache::getInstance().registerErasedRecipient(clientCacheId, wp<ErasedRecipient>(this));
707
708 uint32_t hwcCacheSlot = getFreeHwcCacheSlot();
709 mCachedBuffers[clientCacheId] = {hwcCacheSlot, mCounter++};
710 return hwcCacheSlot;
711}
712
713uint32_t BufferStateLayer::HwcSlotGenerator::getFreeHwcCacheSlot() REQUIRES(mMutex) {
714 if (mFreeHwcCacheSlots.empty()) {
715 evictLeastRecentlyUsed();
716 }
717
718 uint32_t hwcCacheSlot = mFreeHwcCacheSlots.top();
719 mFreeHwcCacheSlots.pop();
720 return hwcCacheSlot;
721}
722
723void BufferStateLayer::HwcSlotGenerator::evictLeastRecentlyUsed() REQUIRES(mMutex) {
724 uint64_t minCounter = UINT_MAX;
725 client_cache_t minClientCacheId = {};
726 for (const auto& [clientCacheId, slotCounter] : mCachedBuffers) {
727 const auto& [hwcCacheSlot, counter] = slotCounter;
728 if (counter < minCounter) {
729 minCounter = counter;
730 minClientCacheId = clientCacheId;
731 }
732 }
733 eraseBufferLocked(minClientCacheId);
734
735 ClientCache::getInstance().unregisterErasedRecipient(minClientCacheId, this);
736}
737
738void BufferStateLayer::HwcSlotGenerator::eraseBufferLocked(const client_cache_t& clientCacheId)
739 REQUIRES(mMutex) {
740 auto itr = mCachedBuffers.find(clientCacheId);
741 if (itr == mCachedBuffers.end()) {
742 return;
743 }
744 auto& [hwcCacheSlot, counter] = itr->second;
745
746 // TODO send to hwc cache and resources
747
748 mFreeHwcCacheSlots.push(hwcCacheSlot);
749 mCachedBuffers.erase(clientCacheId);
750}
chaviw4244e032019-09-04 11:27:49 -0700751
752void BufferStateLayer::gatherBufferInfo() {
chaviwdebadb82020-03-26 14:57:24 -0700753 BufferLayer::gatherBufferInfo();
chaviw4244e032019-09-04 11:27:49 -0700754
chaviwdebadb82020-03-26 14:57:24 -0700755 const State& s(getDrawingState());
chaviw4244e032019-09-04 11:27:49 -0700756 mBufferInfo.mDesiredPresentTime = s.desiredPresentTime;
757 mBufferInfo.mFenceTime = std::make_shared<FenceTime>(s.acquireFence);
758 mBufferInfo.mFence = s.acquireFence;
chaviw4244e032019-09-04 11:27:49 -0700759 mBufferInfo.mTransform = s.transform;
760 mBufferInfo.mDataspace = translateDataspace(s.dataspace);
761 mBufferInfo.mCrop = computeCrop(s);
762 mBufferInfo.mScaleMode = NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW;
763 mBufferInfo.mSurfaceDamage = s.surfaceDamageRegion;
764 mBufferInfo.mHdrMetadata = s.hdrMetadata;
765 mBufferInfo.mApi = s.api;
chaviw4244e032019-09-04 11:27:49 -0700766 mBufferInfo.mTransformToDisplayInverse = s.transformToDisplayInverse;
chaviwf83ce182019-09-12 14:43:08 -0700767 mBufferInfo.mBufferSlot = mHwcSlotGenerator->getHwcCacheSlot(s.clientCacheId);
chaviw4244e032019-09-04 11:27:49 -0700768}
769
770Rect BufferStateLayer::computeCrop(const State& s) {
771 if (s.crop.isEmpty() && s.buffer) {
772 return s.buffer->getBounds();
773 } else if (s.buffer) {
774 Rect crop = s.crop;
775 crop.left = std::max(crop.left, 0);
776 crop.top = std::max(crop.top, 0);
777 uint32_t bufferWidth = s.buffer->getWidth();
778 uint32_t bufferHeight = s.buffer->getHeight();
779 if (bufferHeight <= std::numeric_limits<int32_t>::max() &&
780 bufferWidth <= std::numeric_limits<int32_t>::max()) {
781 crop.right = std::min(crop.right, static_cast<int32_t>(bufferWidth));
782 crop.bottom = std::min(crop.bottom, static_cast<int32_t>(bufferHeight));
783 }
784 if (!crop.isValid()) {
785 // Crop rect is out of bounds, return whole buffer
786 return s.buffer->getBounds();
787 }
788 return crop;
789 }
790 return s.crop;
791}
792
chaviwb4c6e582019-08-16 14:35:07 -0700793sp<Layer> BufferStateLayer::createClone() {
Dominik Laskowski87a07e42019-10-10 20:38:02 -0700794 LayerCreationArgs args(mFlinger.get(), nullptr, mName + " (Mirror)", 0, 0, 0, LayerMetadata());
chaviwb4c6e582019-08-16 14:35:07 -0700795 args.textureName = mTextureName;
Lloyd Pique1c3a5eb2019-10-03 13:07:08 -0700796 sp<BufferStateLayer> layer = mFlinger->getFactory().createBufferStateLayer(args);
chaviwb4c6e582019-08-16 14:35:07 -0700797 layer->mHwcSlotGenerator = mHwcSlotGenerator;
798 layer->setInitialValuesForClone(this);
799 return layer;
800}
Valerie Hau92bf5482020-02-10 09:49:08 -0800801
802Layer::RoundedCornerState BufferStateLayer::getRoundedCornerState() const {
803 const auto& p = mDrawingParent.promote();
804 if (p != nullptr) {
805 RoundedCornerState parentState = p->getRoundedCornerState();
806 if (parentState.radius > 0) {
807 ui::Transform t = getActiveTransform(getDrawingState());
808 t = t.inverse();
809 parentState.cropRect = t.transform(parentState.cropRect);
810 // The rounded corners shader only accepts 1 corner radius for performance reasons,
811 // but a transform matrix can define horizontal and vertical scales.
812 // Let's take the average between both of them and pass into the shader, practically we
813 // never do this type of transformation on windows anyway.
814 parentState.radius *= (t[0][0] + t[1][1]) / 2.0f;
815 return parentState;
816 }
817 }
818 const float radius = getDrawingState().cornerRadius;
819 const State& s(getDrawingState());
820 if (radius <= 0 || (getActiveWidth(s) == UINT32_MAX && getActiveHeight(s) == UINT32_MAX))
821 return RoundedCornerState();
822 return RoundedCornerState(FloatRect(static_cast<float>(s.active.transform.tx()),
823 static_cast<float>(s.active.transform.ty()),
824 static_cast<float>(s.active.transform.tx() + s.active.w),
825 static_cast<float>(s.active.transform.ty() + s.active.h)),
826 radius);
827}
Marissa Wall61c58622018-07-18 10:12:20 -0700828} // namespace android
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800829
830// TODO(b/129481165): remove the #pragma below and fix conversion issues
831#pragma clang diagnostic pop // ignored "-Wconversion"