blob: 9200207f4a2b06cc594ca20fb277a0dc0b6c2c30 [file] [log] [blame]
David Sodman0c69cad2017-08-21 12:12:51 -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
17//#define LOG_NDEBUG 0
18#undef LOG_TAG
19#define LOG_TAG "BufferLayer"
20#define ATRACE_TAG ATRACE_TAG_GRAPHICS
21
22#include "BufferLayer.h"
23#include "Colorizer.h"
24#include "DisplayDevice.h"
25#include "LayerRejecter.h"
26#include "clz.h"
27
28#include "RenderEngine/RenderEngine.h"
29
30#include <gui/BufferItem.h>
31#include <gui/BufferQueue.h>
32#include <gui/LayerDebugInfo.h>
33#include <gui/Surface.h>
34
35#include <ui/DebugUtils.h>
36
37#include <utils/Errors.h>
38#include <utils/Log.h>
39#include <utils/NativeHandle.h>
40#include <utils/StopWatch.h>
41#include <utils/Trace.h>
42
43#include <cutils/compiler.h>
44#include <cutils/native_handle.h>
45#include <cutils/properties.h>
46
47#include <math.h>
48#include <stdlib.h>
49#include <mutex>
50
51namespace android {
52
53BufferLayer::BufferLayer(SurfaceFlinger* flinger, const sp<Client>& client, const String8& name,
54 uint32_t w, uint32_t h, uint32_t flags)
55 : Layer(flinger, client, name, w, h, flags),
Chia-I Wub28c6742017-12-27 10:59:54 -080056 mConsumer(nullptr),
Ivan Lozanoeb13f9e2017-11-09 12:39:31 -080057 mTextureName(UINT32_MAX),
David Sodman0c69cad2017-08-21 12:12:51 -070058 mFormat(PIXEL_FORMAT_NONE),
59 mCurrentScalingMode(NATIVE_WINDOW_SCALING_MODE_FREEZE),
60 mBufferLatched(false),
61 mPreviousFrameNumber(0),
62 mUpdateTexImageFailed(false),
63 mRefreshPending(false) {
David Sodman0c69cad2017-08-21 12:12:51 -070064 ALOGV("Creating Layer %s", name.string());
David Sodman0c69cad2017-08-21 12:12:51 -070065
66 mFlinger->getRenderEngine().genTextures(1, &mTextureName);
67 mTexture.init(Texture::TEXTURE_EXTERNAL, mTextureName);
68
69 if (flags & ISurfaceComposerClient::eNonPremultiplied) mPremultipliedAlpha = false;
70
71 mCurrentState.requested = mCurrentState.active;
72
73 // drawing state & current state are identical
74 mDrawingState = mCurrentState;
75}
76
77BufferLayer::~BufferLayer() {
David Sodman0c69cad2017-08-21 12:12:51 -070078 mFlinger->deleteTextureAsync(mTextureName);
79
David Sodman6f65f3e2017-11-03 14:28:09 -070080 if (!getBE().mHwcLayers.empty()) {
David Sodman0c69cad2017-08-21 12:12:51 -070081 ALOGE("Found stale hardware composer layers when destroying "
82 "surface flinger layer %s",
83 mName.string());
84 destroyAllHwcLayers();
85 }
David Sodman0c69cad2017-08-21 12:12:51 -070086}
87
David Sodmaneb085e02017-10-05 18:49:04 -070088void BufferLayer::useSurfaceDamage() {
89 if (mFlinger->mForceFullDamage) {
90 surfaceDamageRegion = Region::INVALID_REGION;
91 } else {
Chia-I Wub28c6742017-12-27 10:59:54 -080092 surfaceDamageRegion = mConsumer->getSurfaceDamage();
David Sodmaneb085e02017-10-05 18:49:04 -070093 }
94}
95
96void BufferLayer::useEmptyDamage() {
97 surfaceDamageRegion.clear();
98}
99
David Sodman41fdfc92017-11-06 16:09:56 -0800100bool BufferLayer::isProtected() const {
David Sodman0cc69182017-11-17 12:12:07 -0800101 const sp<GraphicBuffer>& buffer(getBE().compositionInfo.mBuffer);
David Sodman5b4cffc2017-11-23 13:20:29 -0800102 return (buffer != 0) &&
103 (buffer->getUsage() & GRALLOC_USAGE_PROTECTED);
David Sodman0c69cad2017-08-21 12:12:51 -0700104}
105
106bool BufferLayer::isVisible() const {
107 return !(isHiddenByPolicy()) && getAlpha() > 0.0f &&
Peiyong Lin566a3b42018-01-09 18:22:43 -0800108 (getBE().compositionInfo.mBuffer != nullptr ||
109 getBE().compositionInfo.hwc.sidebandStream != nullptr);
David Sodman0c69cad2017-08-21 12:12:51 -0700110}
111
112bool BufferLayer::isFixedSize() const {
113 return getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE;
114}
115
116status_t BufferLayer::setBuffers(uint32_t w, uint32_t h, PixelFormat format, uint32_t flags) {
117 uint32_t const maxSurfaceDims =
118 min(mFlinger->getMaxTextureSize(), mFlinger->getMaxViewportDims());
119
120 // never allow a surface larger than what our underlying GL implementation
121 // can handle.
122 if ((uint32_t(w) > maxSurfaceDims) || (uint32_t(h) > maxSurfaceDims)) {
123 ALOGE("dimensions too large %u x %u", uint32_t(w), uint32_t(h));
124 return BAD_VALUE;
125 }
126
127 mFormat = format;
128
129 mPotentialCursor = (flags & ISurfaceComposerClient::eCursorWindow) ? true : false;
130 mProtectedByApp = (flags & ISurfaceComposerClient::eProtectedByApp) ? true : false;
131 mCurrentOpacity = getOpacityForFormat(format);
132
Chia-I Wub28c6742017-12-27 10:59:54 -0800133 mConsumer->setDefaultBufferSize(w, h);
134 mConsumer->setDefaultBufferFormat(format);
135 mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
David Sodman0c69cad2017-08-21 12:12:51 -0700136
137 return NO_ERROR;
138}
139
140static constexpr mat4 inverseOrientation(uint32_t transform) {
David Sodman41fdfc92017-11-06 16:09:56 -0800141 const mat4 flipH(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1);
142 const mat4 flipV(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1);
143 const mat4 rot90(0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1);
David Sodman0c69cad2017-08-21 12:12:51 -0700144 mat4 tr;
145
146 if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
147 tr = tr * rot90;
148 }
149 if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H) {
150 tr = tr * flipH;
151 }
152 if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V) {
153 tr = tr * flipV;
154 }
155 return inverse(tr);
156}
157
158/*
159 * onDraw will draw the current layer onto the presentable buffer
160 */
161void BufferLayer::onDraw(const RenderArea& renderArea, const Region& clip,
162 bool useIdentityTransform) const {
163 ATRACE_CALL();
164
David Sodman0cc69182017-11-17 12:12:07 -0800165 if (CC_UNLIKELY(getBE().compositionInfo.mBuffer == 0)) {
David Sodman0c69cad2017-08-21 12:12:51 -0700166 // the texture has not been created yet, this Layer has
167 // in fact never been drawn into. This happens frequently with
168 // SurfaceView because the WindowManager can't know when the client
169 // has drawn the first time.
170
171 // If there is nothing under us, we paint the screen in black, otherwise
172 // we just skip this update.
173
174 // figure out if there is something below us
175 Region under;
176 bool finished = false;
177 mFlinger->mDrawingState.traverseInZOrder([&](Layer* layer) {
178 if (finished || layer == static_cast<BufferLayer const*>(this)) {
179 finished = true;
180 return;
181 }
182 under.orSelf(renderArea.getTransform().transform(layer->visibleRegion));
183 });
184 // if not everything below us is covered, we plug the holes!
185 Region holes(clip.subtract(under));
186 if (!holes.isEmpty()) {
187 clearWithOpenGL(renderArea, 0, 0, 0, 1);
188 }
189 return;
190 }
191
192 // Bind the current buffer to the GL texture, and wait for it to be
193 // ready for us to draw into.
Chia-I Wub28c6742017-12-27 10:59:54 -0800194 status_t err = mConsumer->bindTextureImage();
David Sodman0c69cad2017-08-21 12:12:51 -0700195 if (err != NO_ERROR) {
196 ALOGW("onDraw: bindTextureImage failed (err=%d)", err);
197 // Go ahead and draw the buffer anyway; no matter what we do the screen
198 // is probably going to have something visibly wrong.
199 }
200
201 bool blackOutLayer = isProtected() || (isSecure() && !renderArea.isSecure());
202
Lloyd Pique144e1162017-12-20 16:44:52 -0800203 auto& engine(mFlinger->getRenderEngine());
David Sodman0c69cad2017-08-21 12:12:51 -0700204
205 if (!blackOutLayer) {
206 // TODO: we could be more subtle with isFixedSize()
207 const bool useFiltering = getFiltering() || needsFiltering(renderArea) || isFixedSize();
208
209 // Query the texture matrix given our current filtering mode.
210 float textureMatrix[16];
Chia-I Wub28c6742017-12-27 10:59:54 -0800211 mConsumer->setFilteringEnabled(useFiltering);
212 mConsumer->getTransformMatrix(textureMatrix);
David Sodman0c69cad2017-08-21 12:12:51 -0700213
214 if (getTransformToDisplayInverse()) {
215 /*
216 * the code below applies the primary display's inverse transform to
217 * the texture transform
218 */
219 uint32_t transform = DisplayDevice::getPrimaryDisplayOrientationTransform();
220 mat4 tr = inverseOrientation(transform);
221
222 /**
223 * TODO(b/36727915): This is basically a hack.
224 *
225 * Ensure that regardless of the parent transformation,
226 * this buffer is always transformed from native display
227 * orientation to display orientation. For example, in the case
228 * of a camera where the buffer remains in native orientation,
229 * we want the pixels to always be upright.
230 */
231 sp<Layer> p = mDrawingParent.promote();
232 if (p != nullptr) {
233 const auto parentTransform = p->getTransform();
234 tr = tr * inverseOrientation(parentTransform.getOrientation());
235 }
236
237 // and finally apply it to the original texture matrix
238 const mat4 texTransform(mat4(static_cast<const float*>(textureMatrix)) * tr);
239 memcpy(textureMatrix, texTransform.asArray(), sizeof(textureMatrix));
240 }
241
242 // Set things up for texturing.
David Sodman0cc69182017-11-17 12:12:07 -0800243 mTexture.setDimensions(getBE().compositionInfo.mBuffer->getWidth(),
244 getBE().compositionInfo.mBuffer->getHeight());
David Sodman0c69cad2017-08-21 12:12:51 -0700245 mTexture.setFiltering(useFiltering);
246 mTexture.setMatrix(textureMatrix);
247
248 engine.setupLayerTexturing(mTexture);
249 } else {
250 engine.setupLayerBlackedOut();
251 }
252 drawWithOpenGL(renderArea, useIdentityTransform);
253 engine.disableTexturing();
254}
255
David Sodmaneb085e02017-10-05 18:49:04 -0700256void BufferLayer::onLayerDisplayed(const sp<Fence>& releaseFence) {
Chia-I Wub28c6742017-12-27 10:59:54 -0800257 mConsumer->setReleaseFence(releaseFence);
David Sodmaneb085e02017-10-05 18:49:04 -0700258}
David Sodmaneb085e02017-10-05 18:49:04 -0700259
260void BufferLayer::abandon() {
Chia-I Wub28c6742017-12-27 10:59:54 -0800261 mConsumer->abandon();
David Sodmaneb085e02017-10-05 18:49:04 -0700262}
263
264bool BufferLayer::shouldPresentNow(const DispSync& dispSync) const {
265 if (mSidebandStreamChanged || mAutoRefresh) {
266 return true;
267 }
268
269 Mutex::Autolock lock(mQueueItemLock);
270 if (mQueueItems.empty()) {
271 return false;
272 }
273 auto timestamp = mQueueItems[0].mTimestamp;
Chia-I Wub28c6742017-12-27 10:59:54 -0800274 nsecs_t expectedPresent = mConsumer->computeExpectedPresent(dispSync);
David Sodmaneb085e02017-10-05 18:49:04 -0700275
276 // Ignore timestamps more than a second in the future
277 bool isPlausible = timestamp < (expectedPresent + s2ns(1));
278 ALOGW_IF(!isPlausible,
279 "[%s] Timestamp %" PRId64 " seems implausible "
280 "relative to expectedPresent %" PRId64,
281 mName.string(), timestamp, expectedPresent);
282
283 bool isDue = timestamp < expectedPresent;
284 return isDue || !isPlausible;
285}
286
287void BufferLayer::setTransformHint(uint32_t orientation) const {
Chia-I Wub28c6742017-12-27 10:59:54 -0800288 mConsumer->setTransformHint(orientation);
David Sodmaneb085e02017-10-05 18:49:04 -0700289}
290
David Sodman0c69cad2017-08-21 12:12:51 -0700291bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) {
292 if (mBufferLatched) {
293 Mutex::Autolock lock(mFrameEventHistoryMutex);
David Sodman9eeae692017-11-02 10:53:32 -0700294 mFrameEventHistory.addPreComposition(mCurrentFrameNumber,
295 refreshStartTime);
David Sodman0c69cad2017-08-21 12:12:51 -0700296 }
297 mRefreshPending = false;
David Sodman9eeae692017-11-02 10:53:32 -0700298 return mQueuedFrames > 0 || mSidebandStreamChanged ||
299 mAutoRefresh;
David Sodman0c69cad2017-08-21 12:12:51 -0700300}
David Sodmaneb085e02017-10-05 18:49:04 -0700301bool BufferLayer::onPostComposition(const std::shared_ptr<FenceTime>& glDoneFence,
302 const std::shared_ptr<FenceTime>& presentFence,
303 const CompositorTiming& compositorTiming) {
304 // mFrameLatencyNeeded is true when a new frame was latched for the
305 // composition.
306 if (!mFrameLatencyNeeded) return false;
307
308 // Update mFrameEventHistory.
309 {
310 Mutex::Autolock lock(mFrameEventHistoryMutex);
David Sodman9eeae692017-11-02 10:53:32 -0700311 mFrameEventHistory.addPostComposition(mCurrentFrameNumber, glDoneFence,
312 presentFence, compositorTiming);
David Sodmaneb085e02017-10-05 18:49:04 -0700313 }
314
315 // Update mFrameTracker.
Chia-I Wub28c6742017-12-27 10:59:54 -0800316 nsecs_t desiredPresentTime = mConsumer->getTimestamp();
David Sodmaneb085e02017-10-05 18:49:04 -0700317 mFrameTracker.setDesiredPresentTime(desiredPresentTime);
318
Chia-I Wub28c6742017-12-27 10:59:54 -0800319 std::shared_ptr<FenceTime> frameReadyFence = mConsumer->getCurrentFenceTime();
David Sodmaneb085e02017-10-05 18:49:04 -0700320 if (frameReadyFence->isValid()) {
321 mFrameTracker.setFrameReadyFence(std::move(frameReadyFence));
322 } else {
323 // There was no fence for this frame, so assume that it was ready
324 // to be presented at the desired present time.
325 mFrameTracker.setFrameReadyTime(desiredPresentTime);
326 }
327
328 if (presentFence->isValid()) {
329 mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence));
330 } else {
331 // The HWC doesn't support present fences, so use the refresh
332 // timestamp instead.
333 mFrameTracker.setActualPresentTime(
334 mFlinger->getHwComposer().getRefreshTimestamp(HWC_DISPLAY_PRIMARY));
335 }
336
337 mFrameTracker.advanceFrame();
338 mFrameLatencyNeeded = false;
339 return true;
340}
341
342std::vector<OccupancyTracker::Segment> BufferLayer::getOccupancyHistory(bool forceFlush) {
343 std::vector<OccupancyTracker::Segment> history;
Chia-I Wub28c6742017-12-27 10:59:54 -0800344 status_t result = mConsumer->getOccupancyHistory(forceFlush, &history);
David Sodmaneb085e02017-10-05 18:49:04 -0700345 if (result != NO_ERROR) {
346 ALOGW("[%s] Failed to obtain occupancy history (%d)", mName.string(), result);
347 return {};
348 }
349 return history;
350}
351
352bool BufferLayer::getTransformToDisplayInverse() const {
Chia-I Wub28c6742017-12-27 10:59:54 -0800353 return mConsumer->getTransformToDisplayInverse();
David Sodmaneb085e02017-10-05 18:49:04 -0700354}
David Sodman0c69cad2017-08-21 12:12:51 -0700355
David Sodman0c69cad2017-08-21 12:12:51 -0700356void BufferLayer::releasePendingBuffer(nsecs_t dequeueReadyTime) {
Chia-I Wub28c6742017-12-27 10:59:54 -0800357 if (!mConsumer->releasePendingBuffer()) {
David Sodman0c69cad2017-08-21 12:12:51 -0700358 return;
359 }
360
361 auto releaseFenceTime =
Chia-I Wub28c6742017-12-27 10:59:54 -0800362 std::make_shared<FenceTime>(mConsumer->getPrevFinalReleaseFence());
David Sodman0c69cad2017-08-21 12:12:51 -0700363 mReleaseTimeline.updateSignalTimes();
364 mReleaseTimeline.push(releaseFenceTime);
365
366 Mutex::Autolock lock(mFrameEventHistoryMutex);
367 if (mPreviousFrameNumber != 0) {
368 mFrameEventHistory.addRelease(mPreviousFrameNumber, dequeueReadyTime,
369 std::move(releaseFenceTime));
370 }
371}
David Sodman0c69cad2017-08-21 12:12:51 -0700372
373Region BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime) {
374 ATRACE_CALL();
375
376 if (android_atomic_acquire_cas(true, false, &mSidebandStreamChanged) == 0) {
377 // mSidebandStreamChanged was true
Chia-I Wub28c6742017-12-27 10:59:54 -0800378 mSidebandStream = mConsumer->getSidebandStream();
David Sodman386c22e2017-11-09 16:34:46 -0800379 // replicated in LayerBE until FE/BE is ready to be synchronized
David Sodman0cc69182017-11-17 12:12:07 -0800380 getBE().compositionInfo.hwc.sidebandStream = mSidebandStream;
Peiyong Lin566a3b42018-01-09 18:22:43 -0800381 if (getBE().compositionInfo.hwc.sidebandStream != nullptr) {
David Sodman0c69cad2017-08-21 12:12:51 -0700382 setTransactionFlags(eTransactionNeeded);
383 mFlinger->setTransactionFlags(eTraversalNeeded);
384 }
385 recomputeVisibleRegions = true;
386
387 const State& s(getDrawingState());
388 return getTransform().transform(Region(Rect(s.active.w, s.active.h)));
389 }
390
391 Region outDirtyRegion;
392 if (mQueuedFrames <= 0 && !mAutoRefresh) {
393 return outDirtyRegion;
394 }
395
396 // if we've already called updateTexImage() without going through
397 // a composition step, we have to skip this layer at this point
398 // because we cannot call updateTeximage() without a corresponding
399 // compositionComplete() call.
400 // we'll trigger an update in onPreComposition().
401 if (mRefreshPending) {
402 return outDirtyRegion;
403 }
404
405 // If the head buffer's acquire fence hasn't signaled yet, return and
406 // try again later
407 if (!headFenceHasSignaled()) {
408 mFlinger->signalLayerUpdate();
409 return outDirtyRegion;
410 }
411
412 // Capture the old state of the layer for comparisons later
413 const State& s(getDrawingState());
414 const bool oldOpacity = isOpaque(s);
David Sodman0cc69182017-11-17 12:12:07 -0800415 sp<GraphicBuffer> oldBuffer = getBE().compositionInfo.mBuffer;
David Sodman0c69cad2017-08-21 12:12:51 -0700416
417 if (!allTransactionsSignaled()) {
418 mFlinger->signalLayerUpdate();
419 return outDirtyRegion;
420 }
421
422 // This boolean is used to make sure that SurfaceFlinger's shadow copy
423 // of the buffer queue isn't modified when the buffer queue is returning
424 // BufferItem's that weren't actually queued. This can happen in shared
425 // buffer mode.
426 bool queuedBuffer = false;
427 LayerRejecter r(mDrawingState, getCurrentState(), recomputeVisibleRegions,
David Sodman9eeae692017-11-02 10:53:32 -0700428 getProducerStickyTransform() != 0, mName.string(),
429 mOverrideScalingMode, mFreezeGeometryUpdates);
David Sodman0c69cad2017-08-21 12:12:51 -0700430 status_t updateResult =
Chia-I Wub28c6742017-12-27 10:59:54 -0800431 mConsumer->updateTexImage(&r, mFlinger->mPrimaryDispSync,
David Sodman9eeae692017-11-02 10:53:32 -0700432 &mAutoRefresh, &queuedBuffer,
433 mLastFrameNumberReceived);
David Sodman0c69cad2017-08-21 12:12:51 -0700434 if (updateResult == BufferQueue::PRESENT_LATER) {
435 // Producer doesn't want buffer to be displayed yet. Signal a
436 // layer update so we check again at the next opportunity.
437 mFlinger->signalLayerUpdate();
438 return outDirtyRegion;
Chia-I Wu0cb75ac2017-11-27 15:56:04 -0800439 } else if (updateResult == BufferLayerConsumer::BUFFER_REJECTED) {
David Sodman0c69cad2017-08-21 12:12:51 -0700440 // If the buffer has been rejected, remove it from the shadow queue
441 // and return early
442 if (queuedBuffer) {
443 Mutex::Autolock lock(mQueueItemLock);
444 mQueueItems.removeAt(0);
445 android_atomic_dec(&mQueuedFrames);
446 }
447 return outDirtyRegion;
448 } else if (updateResult != NO_ERROR || mUpdateTexImageFailed) {
449 // This can occur if something goes wrong when trying to create the
450 // EGLImage for this buffer. If this happens, the buffer has already
451 // been released, so we need to clean up the queue and bug out
452 // early.
453 if (queuedBuffer) {
454 Mutex::Autolock lock(mQueueItemLock);
455 mQueueItems.clear();
456 android_atomic_and(0, &mQueuedFrames);
457 }
458
459 // Once we have hit this state, the shadow queue may no longer
460 // correctly reflect the incoming BufferQueue's contents, so even if
461 // updateTexImage starts working, the only safe course of action is
462 // to continue to ignore updates.
463 mUpdateTexImageFailed = true;
464
465 return outDirtyRegion;
466 }
467
468 if (queuedBuffer) {
469 // Autolock scope
Chia-I Wub28c6742017-12-27 10:59:54 -0800470 auto currentFrameNumber = mConsumer->getFrameNumber();
David Sodman0c69cad2017-08-21 12:12:51 -0700471
472 Mutex::Autolock lock(mQueueItemLock);
473
474 // Remove any stale buffers that have been dropped during
475 // updateTexImage
476 while (mQueueItems[0].mFrameNumber != currentFrameNumber) {
477 mQueueItems.removeAt(0);
478 android_atomic_dec(&mQueuedFrames);
479 }
480
481 mQueueItems.removeAt(0);
482 }
483
484 // Decrement the queued-frames count. Signal another event if we
485 // have more frames pending.
David Sodman9eeae692017-11-02 10:53:32 -0700486 if ((queuedBuffer && android_atomic_dec(&mQueuedFrames) > 1) ||
487 mAutoRefresh) {
David Sodman0c69cad2017-08-21 12:12:51 -0700488 mFlinger->signalLayerUpdate();
489 }
490
491 // update the active buffer
David Sodman0cc69182017-11-17 12:12:07 -0800492 getBE().compositionInfo.mBuffer =
Chia-I Wub28c6742017-12-27 10:59:54 -0800493 mConsumer->getCurrentBuffer(&getBE().compositionInfo.mBufferSlot);
David Sodman5b4cffc2017-11-23 13:20:29 -0800494 // replicated in LayerBE until FE/BE is ready to be synchronized
David Sodman0cc69182017-11-17 12:12:07 -0800495 mActiveBuffer = getBE().compositionInfo.mBuffer;
Peiyong Lin566a3b42018-01-09 18:22:43 -0800496 if (getBE().compositionInfo.mBuffer == nullptr) {
David Sodman0c69cad2017-08-21 12:12:51 -0700497 // this can only happen if the very first buffer was rejected.
498 return outDirtyRegion;
499 }
500
501 mBufferLatched = true;
502 mPreviousFrameNumber = mCurrentFrameNumber;
Chia-I Wub28c6742017-12-27 10:59:54 -0800503 mCurrentFrameNumber = mConsumer->getFrameNumber();
David Sodman0c69cad2017-08-21 12:12:51 -0700504
505 {
506 Mutex::Autolock lock(mFrameEventHistoryMutex);
507 mFrameEventHistory.addLatch(mCurrentFrameNumber, latchTime);
David Sodman0c69cad2017-08-21 12:12:51 -0700508 }
509
510 mRefreshPending = true;
511 mFrameLatencyNeeded = true;
Peiyong Lin566a3b42018-01-09 18:22:43 -0800512 if (oldBuffer == nullptr) {
David Sodman0c69cad2017-08-21 12:12:51 -0700513 // the first time we receive a buffer, we need to trigger a
514 // geometry invalidation.
515 recomputeVisibleRegions = true;
516 }
517
Chia-I Wub28c6742017-12-27 10:59:54 -0800518 setDataSpace(mConsumer->getCurrentDataSpace());
David Sodman0c69cad2017-08-21 12:12:51 -0700519
Chia-I Wub28c6742017-12-27 10:59:54 -0800520 Rect crop(mConsumer->getCurrentCrop());
521 const uint32_t transform(mConsumer->getCurrentTransform());
522 const uint32_t scalingMode(mConsumer->getCurrentScalingMode());
David Sodman9eeae692017-11-02 10:53:32 -0700523 if ((crop != mCurrentCrop) ||
524 (transform != mCurrentTransform) ||
David Sodman0c69cad2017-08-21 12:12:51 -0700525 (scalingMode != mCurrentScalingMode)) {
526 mCurrentCrop = crop;
527 mCurrentTransform = transform;
528 mCurrentScalingMode = scalingMode;
529 recomputeVisibleRegions = true;
530 }
531
Peiyong Lin566a3b42018-01-09 18:22:43 -0800532 if (oldBuffer != nullptr) {
David Sodman0cc69182017-11-17 12:12:07 -0800533 uint32_t bufWidth = getBE().compositionInfo.mBuffer->getWidth();
534 uint32_t bufHeight = getBE().compositionInfo.mBuffer->getHeight();
David Sodman5b4cffc2017-11-23 13:20:29 -0800535 if (bufWidth != uint32_t(oldBuffer->width) ||
536 bufHeight != uint32_t(oldBuffer->height)) {
David Sodman0c69cad2017-08-21 12:12:51 -0700537 recomputeVisibleRegions = true;
538 }
539 }
540
David Sodman0cc69182017-11-17 12:12:07 -0800541 mCurrentOpacity = getOpacityForFormat(getBE().compositionInfo.mBuffer->format);
David Sodman0c69cad2017-08-21 12:12:51 -0700542 if (oldOpacity != isOpaque(s)) {
543 recomputeVisibleRegions = true;
544 }
545
546 // Remove any sync points corresponding to the buffer which was just
547 // latched
548 {
549 Mutex::Autolock lock(mLocalSyncPointMutex);
550 auto point = mLocalSyncPoints.begin();
551 while (point != mLocalSyncPoints.end()) {
552 if (!(*point)->frameIsAvailable() || !(*point)->transactionIsApplied()) {
553 // This sync point must have been added since we started
554 // latching. Don't drop it yet.
555 ++point;
556 continue;
557 }
558
559 if ((*point)->getFrameNumber() <= mCurrentFrameNumber) {
560 point = mLocalSyncPoints.erase(point);
561 } else {
562 ++point;
563 }
564 }
565 }
566
567 // FIXME: postedRegion should be dirty & bounds
568 Region dirtyRegion(Rect(s.active.w, s.active.h));
569
570 // transform the dirty region to window-manager space
571 outDirtyRegion = (getTransform().transform(dirtyRegion));
572
573 return outDirtyRegion;
574}
575
David Sodmaneb085e02017-10-05 18:49:04 -0700576void BufferLayer::setDefaultBufferSize(uint32_t w, uint32_t h) {
Chia-I Wub28c6742017-12-27 10:59:54 -0800577 mConsumer->setDefaultBufferSize(w, h);
David Sodmaneb085e02017-10-05 18:49:04 -0700578}
579
David Sodman0c69cad2017-08-21 12:12:51 -0700580void BufferLayer::setPerFrameData(const sp<const DisplayDevice>& displayDevice) {
581 // Apply this display's projection's viewport to the visible region
582 // before giving it to the HWC HAL.
583 const Transform& tr = displayDevice->getTransform();
584 const auto& viewport = displayDevice->getViewport();
585 Region visible = tr.transform(visibleRegion.intersect(viewport));
586 auto hwcId = displayDevice->getHwcDisplayId();
David Sodman6f65f3e2017-11-03 14:28:09 -0700587 auto& hwcInfo = getBE().mHwcLayers[hwcId];
David Sodman0c69cad2017-08-21 12:12:51 -0700588 auto& hwcLayer = hwcInfo.layer;
589 auto error = hwcLayer->setVisibleRegion(visible);
590 if (error != HWC2::Error::None) {
591 ALOGE("[%s] Failed to set visible region: %s (%d)", mName.string(),
592 to_string(error).c_str(), static_cast<int32_t>(error));
593 visible.dump(LOG_TAG);
594 }
595
596 error = hwcLayer->setSurfaceDamage(surfaceDamageRegion);
597 if (error != HWC2::Error::None) {
598 ALOGE("[%s] Failed to set surface damage: %s (%d)", mName.string(),
599 to_string(error).c_str(), static_cast<int32_t>(error));
600 surfaceDamageRegion.dump(LOG_TAG);
601 }
602
603 // Sideband layers
David Sodman0cc69182017-11-17 12:12:07 -0800604 if (getBE().compositionInfo.hwc.sidebandStream.get()) {
David Sodman0c69cad2017-08-21 12:12:51 -0700605 setCompositionType(hwcId, HWC2::Composition::Sideband);
606 ALOGV("[%s] Requesting Sideband composition", mName.string());
David Sodman0cc69182017-11-17 12:12:07 -0800607 error = hwcLayer->setSidebandStream(getBE().compositionInfo.hwc.sidebandStream->handle());
David Sodman0c69cad2017-08-21 12:12:51 -0700608 if (error != HWC2::Error::None) {
609 ALOGE("[%s] Failed to set sideband stream %p: %s (%d)", mName.string(),
David Sodman0cc69182017-11-17 12:12:07 -0800610 getBE().compositionInfo.hwc.sidebandStream->handle(), to_string(error).c_str(),
David Sodman9eeae692017-11-02 10:53:32 -0700611 static_cast<int32_t>(error));
David Sodman0c69cad2017-08-21 12:12:51 -0700612 }
613 return;
614 }
615
David Sodman0c69cad2017-08-21 12:12:51 -0700616 // Device or Cursor layers
617 if (mPotentialCursor) {
618 ALOGV("[%s] Requesting Cursor composition", mName.string());
619 setCompositionType(hwcId, HWC2::Composition::Cursor);
620 } else {
621 ALOGV("[%s] Requesting Device composition", mName.string());
622 setCompositionType(hwcId, HWC2::Composition::Device);
623 }
624
Peiyong Lin13170c82018-01-22 18:55:51 -0800625 ALOGV("setPerFrameData: dataspace = %d", mDrawingState.dataSpace);
626 error = hwcLayer->setDataspace(mDrawingState.dataSpace);
David Sodman0c69cad2017-08-21 12:12:51 -0700627 if (error != HWC2::Error::None) {
Peiyong Lin13170c82018-01-22 18:55:51 -0800628 ALOGE("[%s] Failed to set dataspace %d: %s (%d)", mName.string(), mDrawingState.dataSpace,
David Sodman0c69cad2017-08-21 12:12:51 -0700629 to_string(error).c_str(), static_cast<int32_t>(error));
630 }
631
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -0700632 const HdrMetadata& metadata = mConsumer->getCurrentHdrMetadata();
633 error = hwcLayer->setHdrMetadata(metadata);
Courtney Goeltzenleuchter301bb302018-03-12 11:12:42 -0600634 if (error != HWC2::Error::None && error != HWC2::Error::Unsupported) {
Courtney Goeltzenleuchterf9c98e52018-02-12 07:23:17 -0700635 ALOGE("[%s] Failed to set hdrMetadata: %s (%d)", mName.string(),
636 to_string(error).c_str(), static_cast<int32_t>(error));
637 }
638
David Sodman0c69cad2017-08-21 12:12:51 -0700639 uint32_t hwcSlot = 0;
640 sp<GraphicBuffer> hwcBuffer;
David Sodman0cc69182017-11-17 12:12:07 -0800641 hwcInfo.bufferCache.getHwcBuffer(getBE().compositionInfo.mBufferSlot,
642 getBE().compositionInfo.mBuffer, &hwcSlot, &hwcBuffer);
David Sodman0c69cad2017-08-21 12:12:51 -0700643
Chia-I Wub28c6742017-12-27 10:59:54 -0800644 auto acquireFence = mConsumer->getCurrentFence();
David Sodman0c69cad2017-08-21 12:12:51 -0700645 error = hwcLayer->setBuffer(hwcSlot, hwcBuffer, acquireFence);
646 if (error != HWC2::Error::None) {
David Sodman9eeae692017-11-02 10:53:32 -0700647 ALOGE("[%s] Failed to set buffer %p: %s (%d)", mName.string(),
David Sodman0cc69182017-11-17 12:12:07 -0800648 getBE().compositionInfo.mBuffer->handle, to_string(error).c_str(),
David Sodman9eeae692017-11-02 10:53:32 -0700649 static_cast<int32_t>(error));
David Sodman0c69cad2017-08-21 12:12:51 -0700650 }
651}
652
David Sodman41fdfc92017-11-06 16:09:56 -0800653bool BufferLayer::isOpaque(const Layer::State& s) const {
David Sodman0c69cad2017-08-21 12:12:51 -0700654 // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the
655 // layer's opaque flag.
David Sodman0cc69182017-11-17 12:12:07 -0800656 if ((getBE().compositionInfo.hwc.sidebandStream == nullptr) && (getBE().compositionInfo.mBuffer == nullptr)) {
David Sodman0c69cad2017-08-21 12:12:51 -0700657 return false;
658 }
659
660 // if the layer has the opaque flag, then we're always opaque,
661 // otherwise we use the current buffer's format.
662 return ((s.flags & layer_state_t::eLayerOpaque) != 0) || mCurrentOpacity;
663}
664
665void BufferLayer::onFirstRef() {
666 // Creates a custom BufferQueue for SurfaceFlingerConsumer to use
667 sp<IGraphicBufferProducer> producer;
668 sp<IGraphicBufferConsumer> consumer;
669 BufferQueue::createBufferQueue(&producer, &consumer, true);
670 mProducer = new MonitoredProducer(producer, mFlinger, this);
Chia-I Wub28c6742017-12-27 10:59:54 -0800671 mConsumer = new BufferLayerConsumer(consumer,
Chia-I Wu9f2db772017-11-30 21:06:50 -0800672 mFlinger->getRenderEngine(), mTextureName, this);
Chia-I Wub28c6742017-12-27 10:59:54 -0800673 mConsumer->setConsumerUsageBits(getEffectiveUsage(0));
674 mConsumer->setContentsChangedListener(this);
675 mConsumer->setName(mName);
David Sodman0c69cad2017-08-21 12:12:51 -0700676
677 if (mFlinger->isLayerTripleBufferingDisabled()) {
678 mProducer->setMaxDequeuedBufferCount(2);
679 }
680
681 const sp<const DisplayDevice> hw(mFlinger->getDefaultDisplayDevice());
682 updateTransformHint(hw);
683}
684
685// ---------------------------------------------------------------------------
686// Interface implementation for SurfaceFlingerConsumer::ContentsChangedListener
687// ---------------------------------------------------------------------------
688
689void BufferLayer::onFrameAvailable(const BufferItem& item) {
690 // Add this buffer from our internal queue tracker
691 { // Autolock scope
692 Mutex::Autolock lock(mQueueItemLock);
Lloyd Pique4d234852018-01-22 17:21:36 -0800693 mFlinger->mInterceptor->saveBufferUpdate(this, item.mGraphicBuffer->getWidth(),
694 item.mGraphicBuffer->getHeight(),
695 item.mFrameNumber);
David Sodman0c69cad2017-08-21 12:12:51 -0700696 // Reset the frame number tracker when we receive the first buffer after
697 // a frame number reset
698 if (item.mFrameNumber == 1) {
699 mLastFrameNumberReceived = 0;
700 }
701
702 // Ensure that callbacks are handled in order
703 while (item.mFrameNumber != mLastFrameNumberReceived + 1) {
David Sodman9eeae692017-11-02 10:53:32 -0700704 status_t result = mQueueItemCondition.waitRelative(mQueueItemLock,
705 ms2ns(500));
David Sodman0c69cad2017-08-21 12:12:51 -0700706 if (result != NO_ERROR) {
707 ALOGE("[%s] Timed out waiting on callback", mName.string());
708 }
709 }
710
711 mQueueItems.push_back(item);
712 android_atomic_inc(&mQueuedFrames);
713
714 // Wake up any pending callbacks
715 mLastFrameNumberReceived = item.mFrameNumber;
716 mQueueItemCondition.broadcast();
717 }
718
719 mFlinger->signalLayerUpdate();
720}
721
722void BufferLayer::onFrameReplaced(const BufferItem& item) {
723 { // Autolock scope
724 Mutex::Autolock lock(mQueueItemLock);
725
726 // Ensure that callbacks are handled in order
727 while (item.mFrameNumber != mLastFrameNumberReceived + 1) {
David Sodman9eeae692017-11-02 10:53:32 -0700728 status_t result = mQueueItemCondition.waitRelative(mQueueItemLock,
729 ms2ns(500));
David Sodman0c69cad2017-08-21 12:12:51 -0700730 if (result != NO_ERROR) {
731 ALOGE("[%s] Timed out waiting on callback", mName.string());
732 }
733 }
734
735 if (mQueueItems.empty()) {
736 ALOGE("Can't replace a frame on an empty queue");
737 return;
738 }
739 mQueueItems.editItemAt(mQueueItems.size() - 1) = item;
740
741 // Wake up any pending callbacks
742 mLastFrameNumberReceived = item.mFrameNumber;
743 mQueueItemCondition.broadcast();
744 }
745}
746
747void BufferLayer::onSidebandStreamChanged() {
748 if (android_atomic_release_cas(false, true, &mSidebandStreamChanged) == 0) {
749 // mSidebandStreamChanged was false
750 mFlinger->signalLayerUpdate();
751 }
752}
753
754bool BufferLayer::needsFiltering(const RenderArea& renderArea) const {
755 return mNeedsFiltering || renderArea.needsFiltering();
756}
757
758// As documented in libhardware header, formats in the range
759// 0x100 - 0x1FF are specific to the HAL implementation, and
760// are known to have no alpha channel
761// TODO: move definition for device-specific range into
762// hardware.h, instead of using hard-coded values here.
763#define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF)
764
765bool BufferLayer::getOpacityForFormat(uint32_t format) {
766 if (HARDWARE_IS_DEVICE_FORMAT(format)) {
767 return true;
768 }
769 switch (format) {
770 case HAL_PIXEL_FORMAT_RGBA_8888:
771 case HAL_PIXEL_FORMAT_BGRA_8888:
772 case HAL_PIXEL_FORMAT_RGBA_FP16:
773 case HAL_PIXEL_FORMAT_RGBA_1010102:
774 return false;
775 }
776 // in all other case, we have no blending (also for unknown formats)
777 return true;
778}
779
David Sodman41fdfc92017-11-06 16:09:56 -0800780void BufferLayer::drawWithOpenGL(const RenderArea& renderArea, bool useIdentityTransform) const {
David Sodman0c69cad2017-08-21 12:12:51 -0700781 const State& s(getDrawingState());
782
David Sodman9eeae692017-11-02 10:53:32 -0700783 computeGeometry(renderArea, getBE().mMesh, useIdentityTransform);
David Sodman0c69cad2017-08-21 12:12:51 -0700784
785 /*
786 * NOTE: the way we compute the texture coordinates here produces
787 * different results than when we take the HWC path -- in the later case
788 * the "source crop" is rounded to texel boundaries.
789 * This can produce significantly different results when the texture
790 * is scaled by a large amount.
791 *
792 * The GL code below is more logical (imho), and the difference with
793 * HWC is due to a limitation of the HWC API to integers -- a question
794 * is suspend is whether we should ignore this problem or revert to
795 * GL composition when a buffer scaling is applied (maybe with some
796 * minimal value)? Or, we could make GL behave like HWC -- but this feel
797 * like more of a hack.
798 */
Dan Stoza80d61162017-12-20 15:57:52 -0800799 const Rect bounds{computeBounds()}; // Rounds from FloatRect
David Sodman0c69cad2017-08-21 12:12:51 -0700800
801 Transform t = getTransform();
Dan Stoza80d61162017-12-20 15:57:52 -0800802 Rect win = bounds;
David Sodman0c69cad2017-08-21 12:12:51 -0700803 if (!s.finalCrop.isEmpty()) {
804 win = t.transform(win);
805 if (!win.intersect(s.finalCrop, &win)) {
806 win.clear();
807 }
808 win = t.inverse().transform(win);
Dan Stoza80d61162017-12-20 15:57:52 -0800809 if (!win.intersect(bounds, &win)) {
David Sodman0c69cad2017-08-21 12:12:51 -0700810 win.clear();
811 }
812 }
813
814 float left = float(win.left) / float(s.active.w);
815 float top = float(win.top) / float(s.active.h);
816 float right = float(win.right) / float(s.active.w);
817 float bottom = float(win.bottom) / float(s.active.h);
818
819 // TODO: we probably want to generate the texture coords with the mesh
820 // here we assume that we only have 4 vertices
David Sodman9eeae692017-11-02 10:53:32 -0700821 Mesh::VertexArray<vec2> texCoords(getBE().mMesh.getTexCoordArray<vec2>());
David Sodman0c69cad2017-08-21 12:12:51 -0700822 texCoords[0] = vec2(left, 1.0f - top);
823 texCoords[1] = vec2(left, 1.0f - bottom);
824 texCoords[2] = vec2(right, 1.0f - bottom);
825 texCoords[3] = vec2(right, 1.0f - top);
826
Lloyd Pique144e1162017-12-20 16:44:52 -0800827 auto& engine(mFlinger->getRenderEngine());
David Sodman0c69cad2017-08-21 12:12:51 -0700828 engine.setupLayerBlending(mPremultipliedAlpha, isOpaque(s), false /* disableTexture */,
829 getColor());
David Sodman0c69cad2017-08-21 12:12:51 -0700830 engine.setSourceDataSpace(mCurrentState.dataSpace);
Chia-I Wu5c6e4632018-01-11 08:54:38 -0800831
Chia-I Wu8d2651e2018-01-24 12:18:49 -0800832 if (mCurrentState.dataSpace == HAL_DATASPACE_BT2020_ITU_PQ &&
Chia-I Wu5c6e4632018-01-11 08:54:38 -0800833 mConsumer->getCurrentApi() == NATIVE_WINDOW_API_MEDIA &&
834 getBE().compositionInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102) {
835 engine.setSourceY410BT2020(true);
836 }
837
David Sodman9eeae692017-11-02 10:53:32 -0700838 engine.drawMesh(getBE().mMesh);
David Sodman0c69cad2017-08-21 12:12:51 -0700839 engine.disableBlending();
Chia-I Wu5c6e4632018-01-11 08:54:38 -0800840
841 engine.setSourceY410BT2020(false);
David Sodman0c69cad2017-08-21 12:12:51 -0700842}
843
844uint32_t BufferLayer::getProducerStickyTransform() const {
845 int producerStickyTransform = 0;
846 int ret = mProducer->query(NATIVE_WINDOW_STICKY_TRANSFORM, &producerStickyTransform);
847 if (ret != OK) {
848 ALOGW("%s: Error %s (%d) while querying window sticky transform.", __FUNCTION__,
849 strerror(-ret), ret);
850 return 0;
851 }
852 return static_cast<uint32_t>(producerStickyTransform);
853}
854
855bool BufferLayer::latchUnsignaledBuffers() {
856 static bool propertyLoaded = false;
857 static bool latch = false;
858 static std::mutex mutex;
859 std::lock_guard<std::mutex> lock(mutex);
860 if (!propertyLoaded) {
861 char value[PROPERTY_VALUE_MAX] = {};
862 property_get("debug.sf.latch_unsignaled", value, "0");
863 latch = atoi(value);
864 propertyLoaded = true;
865 }
866 return latch;
867}
868
869uint64_t BufferLayer::getHeadFrameNumber() const {
870 Mutex::Autolock lock(mQueueItemLock);
871 if (!mQueueItems.empty()) {
872 return mQueueItems[0].mFrameNumber;
873 } else {
874 return mCurrentFrameNumber;
875 }
876}
877
878bool BufferLayer::headFenceHasSignaled() const {
David Sodman0c69cad2017-08-21 12:12:51 -0700879 if (latchUnsignaledBuffers()) {
880 return true;
881 }
882
883 Mutex::Autolock lock(mQueueItemLock);
884 if (mQueueItems.empty()) {
885 return true;
886 }
887 if (mQueueItems[0].mIsDroppable) {
888 // Even though this buffer's fence may not have signaled yet, it could
889 // be replaced by another buffer before it has a chance to, which means
890 // that it's possible to get into a situation where a buffer is never
891 // able to be latched. To avoid this, grab this buffer anyway.
892 return true;
893 }
David Sodman9eeae692017-11-02 10:53:32 -0700894 return mQueueItems[0].mFenceTime->getSignalTime() !=
895 Fence::SIGNAL_TIME_PENDING;
David Sodman0c69cad2017-08-21 12:12:51 -0700896}
897
898uint32_t BufferLayer::getEffectiveScalingMode() const {
899 if (mOverrideScalingMode >= 0) {
900 return mOverrideScalingMode;
901 }
902 return mCurrentScalingMode;
903}
904
905// ----------------------------------------------------------------------------
906// transaction
907// ----------------------------------------------------------------------------
908
909void BufferLayer::notifyAvailableFrames() {
910 auto headFrameNumber = getHeadFrameNumber();
911 bool headFenceSignaled = headFenceHasSignaled();
912 Mutex::Autolock lock(mLocalSyncPointMutex);
913 for (auto& point : mLocalSyncPoints) {
914 if (headFrameNumber >= point->getFrameNumber() && headFenceSignaled) {
915 point->setFrameAvailable();
916 }
917 }
918}
919
920sp<IGraphicBufferProducer> BufferLayer::getProducer() const {
921 return mProducer;
922}
923
924// ---------------------------------------------------------------------------
925// h/w composer set-up
926// ---------------------------------------------------------------------------
927
928bool BufferLayer::allTransactionsSignaled() {
929 auto headFrameNumber = getHeadFrameNumber();
930 bool matchingFramesFound = false;
931 bool allTransactionsApplied = true;
932 Mutex::Autolock lock(mLocalSyncPointMutex);
933
934 for (auto& point : mLocalSyncPoints) {
935 if (point->getFrameNumber() > headFrameNumber) {
936 break;
937 }
938 matchingFramesFound = true;
939
940 if (!point->frameIsAvailable()) {
941 // We haven't notified the remote layer that the frame for
942 // this point is available yet. Notify it now, and then
943 // abort this attempt to latch.
944 point->setFrameAvailable();
945 allTransactionsApplied = false;
946 break;
947 }
948
949 allTransactionsApplied = allTransactionsApplied && point->transactionIsApplied();
950 }
951 return !matchingFramesFound || allTransactionsApplied;
952}
953
954} // namespace android
955
956#if defined(__gl_h_)
957#error "don't include gl/gl.h in this file"
958#endif
959
960#if defined(__gl2_h_)
961#error "don't include gl2/gl2.h in this file"
962#endif