blob: 7845cab3972715d6a8376221138ec8a6eb1867bf [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
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
David Sodman0c69cad2017-08-21 12:12:51 -070021//#define LOG_NDEBUG 0
22#undef LOG_TAG
23#define LOG_TAG "BufferLayer"
24#define ATRACE_TAG ATRACE_TAG_GRAPHICS
25
Alec Mourie60041e2019-06-14 18:59:51 -070026#include "BufferLayer.h"
Lloyd Piquefeb73d72018-12-04 17:23:44 -080027
28#include <compositionengine/CompositionEngine.h>
29#include <compositionengine/Layer.h>
30#include <compositionengine/LayerCreationArgs.h>
Lloyd Piquef5275482019-01-29 18:42:42 -080031#include <compositionengine/LayerFECompositionState.h>
Lloyd Pique37c2c9b2018-12-04 17:25:10 -080032#include <compositionengine/OutputLayer.h>
33#include <compositionengine/impl/OutputLayerCompositionState.h>
Lloyd Piquefeb73d72018-12-04 17:23:44 -080034#include <cutils/compiler.h>
35#include <cutils/native_handle.h>
36#include <cutils/properties.h>
37#include <gui/BufferItem.h>
38#include <gui/BufferQueue.h>
chaviwf83ce182019-09-12 14:43:08 -070039#include <gui/GLConsumer.h>
Lloyd Piquefeb73d72018-12-04 17:23:44 -080040#include <gui/LayerDebugInfo.h>
41#include <gui/Surface.h>
42#include <renderengine/RenderEngine.h>
43#include <ui/DebugUtils.h>
44#include <utils/Errors.h>
45#include <utils/Log.h>
46#include <utils/NativeHandle.h>
47#include <utils/StopWatch.h>
48#include <utils/Trace.h>
49
Alec Mourie60041e2019-06-14 18:59:51 -070050#include <cmath>
51#include <cstdlib>
52#include <mutex>
53#include <sstream>
54
David Sodman0c69cad2017-08-21 12:12:51 -070055#include "Colorizer.h"
56#include "DisplayDevice.h"
Mikael Pessa90092f42019-08-26 17:22:04 -070057#include "FrameTracer/FrameTracer.h"
David Sodman0c69cad2017-08-21 12:12:51 -070058#include "LayerRejecter.h"
Yiwei Zhang7e666a52018-11-15 13:33:42 -080059#include "TimeStats/TimeStats.h"
60
David Sodman0c69cad2017-08-21 12:12:51 -070061namespace android {
62
Peiyong Lin1a70eca2019-11-15 09:33:33 -080063static constexpr float defaultMaxMasteringLuminance = 1000.0;
64static constexpr float defaultMaxContentLuminance = 1000.0;
65
Lloyd Pique42ab75e2018-09-12 20:46:03 -070066BufferLayer::BufferLayer(const LayerCreationArgs& args)
Lloyd Piquefeb73d72018-12-04 17:23:44 -080067 : Layer(args),
chaviwb4c6e582019-08-16 14:35:07 -070068 mTextureName(args.textureName),
Lloyd Piquefeb73d72018-12-04 17:23:44 -080069 mCompositionLayer{mFlinger->getCompositionEngine().createLayer(
70 compositionengine::LayerCreationArgs{this})} {
Dominik Laskowski87a07e42019-10-10 20:38:02 -070071 ALOGV("Creating Layer %s", getDebugName());
David Sodman0c69cad2017-08-21 12:12:51 -070072
Lloyd Pique42ab75e2018-09-12 20:46:03 -070073 mPremultipliedAlpha = !(args.flags & ISurfaceComposerClient::eNonPremultiplied);
David Sodman0c69cad2017-08-21 12:12:51 -070074
Lloyd Pique42ab75e2018-09-12 20:46:03 -070075 mPotentialCursor = args.flags & ISurfaceComposerClient::eCursorWindow;
76 mProtectedByApp = args.flags & ISurfaceComposerClient::eProtectedByApp;
David Sodman0c69cad2017-08-21 12:12:51 -070077}
78
79BufferLayer::~BufferLayer() {
chaviwb4c6e582019-08-16 14:35:07 -070080 if (!isClone()) {
81 // The original layer and the clone layer share the same texture. Therefore, only one of
82 // the layers, in this case the original layer, needs to handle the deletion. The original
83 // layer and the clone should be removed at the same time so there shouldn't be any issue
84 // with the clone layer trying to use the deleted texture.
85 mFlinger->deleteTextureAsync(mTextureName);
86 }
Yiwei Zhang1a88c402019-11-18 10:43:58 -080087 const int32_t layerId = getSequence();
88 mFlinger->mTimeStats->onDestroy(layerId);
89 mFlinger->mFrameTracer->onDestroy(layerId);
David Sodman0c69cad2017-08-21 12:12:51 -070090}
91
David Sodmaneb085e02017-10-05 18:49:04 -070092void BufferLayer::useSurfaceDamage() {
93 if (mFlinger->mForceFullDamage) {
94 surfaceDamageRegion = Region::INVALID_REGION;
95 } else {
chaviw4244e032019-09-04 11:27:49 -070096 surfaceDamageRegion = mBufferInfo.mSurfaceDamage;
David Sodmaneb085e02017-10-05 18:49:04 -070097 }
98}
99
100void BufferLayer::useEmptyDamage() {
101 surfaceDamageRegion.clear();
102}
103
Marissa Wallfd668622018-05-10 10:21:13 -0700104bool BufferLayer::isOpaque(const Layer::State& s) const {
105 // if we don't have a buffer or sidebandStream yet, we're translucent regardless of the
106 // layer's opaque flag.
chaviwd62d3062019-09-04 14:48:02 -0700107 if ((mSidebandStream == nullptr) && (mBufferInfo.mBuffer == nullptr)) {
Marissa Wallfd668622018-05-10 10:21:13 -0700108 return false;
109 }
110
111 // if the layer has the opaque flag, then we're always opaque,
112 // otherwise we use the current buffer's format.
113 return ((s.flags & layer_state_t::eLayerOpaque) != 0) || getOpacityForFormat(getPixelFormat());
David Sodman0c69cad2017-08-21 12:12:51 -0700114}
115
116bool BufferLayer::isVisible() const {
Dominik Laskowskif7a09ed2019-10-07 13:54:18 -0700117 return !isHiddenByPolicy() && getAlpha() > 0.0f &&
chaviwd62d3062019-09-04 14:48:02 -0700118 (mBufferInfo.mBuffer != nullptr || mSidebandStream != nullptr);
David Sodman0c69cad2017-08-21 12:12:51 -0700119}
120
121bool BufferLayer::isFixedSize() const {
122 return getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE;
123}
124
Lloyd Piquea83776c2019-01-29 18:42:32 -0800125bool BufferLayer::usesSourceCrop() const {
126 return true;
127}
128
David Sodman0c69cad2017-08-21 12:12:51 -0700129static constexpr mat4 inverseOrientation(uint32_t transform) {
David Sodman41fdfc92017-11-06 16:09:56 -0800130 const mat4 flipH(-1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1);
131 const mat4 flipV(1, 0, 0, 0, 0, -1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 1);
132 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 -0700133 mat4 tr;
134
135 if (transform & NATIVE_WINDOW_TRANSFORM_ROT_90) {
136 tr = tr * rot90;
137 }
138 if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_H) {
139 tr = tr * flipH;
140 }
141 if (transform & NATIVE_WINDOW_TRANSFORM_FLIP_V) {
142 tr = tr * flipV;
143 }
144 return inverse(tr);
145}
146
Lloyd Piquef16688f2019-02-19 17:47:57 -0800147std::optional<renderengine::LayerSettings> BufferLayer::prepareClientComposition(
148 compositionengine::LayerFE::ClientCompositionTargetSettings& targetSettings) {
David Sodman0c69cad2017-08-21 12:12:51 -0700149 ATRACE_CALL();
Lloyd Piquef16688f2019-02-19 17:47:57 -0800150
151 auto result = Layer::prepareClientComposition(targetSettings);
152 if (!result) {
153 return result;
154 }
155
chaviwd62d3062019-09-04 14:48:02 -0700156 if (CC_UNLIKELY(mBufferInfo.mBuffer == 0)) {
David Sodman0c69cad2017-08-21 12:12:51 -0700157 // the texture has not been created yet, this Layer has
158 // in fact never been drawn into. This happens frequently with
159 // SurfaceView because the WindowManager can't know when the client
160 // has drawn the first time.
161
162 // If there is nothing under us, we paint the screen in black, otherwise
163 // we just skip this update.
164
165 // figure out if there is something below us
166 Region under;
167 bool finished = false;
168 mFlinger->mDrawingState.traverseInZOrder([&](Layer* layer) {
169 if (finished || layer == static_cast<BufferLayer const*>(this)) {
170 finished = true;
171 return;
172 }
Lloyd Piquea2468662019-03-07 21:31:06 -0800173
174 under.orSelf(layer->getScreenBounds());
David Sodman0c69cad2017-08-21 12:12:51 -0700175 });
176 // if not everything below us is covered, we plug the holes!
Lloyd Piquef16688f2019-02-19 17:47:57 -0800177 Region holes(targetSettings.clip.subtract(under));
David Sodman0c69cad2017-08-21 12:12:51 -0700178 if (!holes.isEmpty()) {
Lloyd Piquef16688f2019-02-19 17:47:57 -0800179 targetSettings.clearRegion.orSelf(holes);
David Sodman0c69cad2017-08-21 12:12:51 -0700180 }
Lloyd Piquef16688f2019-02-19 17:47:57 -0800181 return std::nullopt;
David Sodman0c69cad2017-08-21 12:12:51 -0700182 }
Lloyd Pique688abd42019-02-15 15:42:24 -0800183 bool blackOutLayer = (isProtected() && !targetSettings.supportsProtectedContent) ||
Lloyd Piquef16688f2019-02-19 17:47:57 -0800184 (isSecure() && !targetSettings.isSecure);
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000185 const State& s(getDrawingState());
Lloyd Piquef16688f2019-02-19 17:47:57 -0800186 auto& layer = *result;
David Sodman0c69cad2017-08-21 12:12:51 -0700187 if (!blackOutLayer) {
chaviwd62d3062019-09-04 14:48:02 -0700188 layer.source.buffer.buffer = mBufferInfo.mBuffer;
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000189 layer.source.buffer.isOpaque = isOpaque(s);
chaviwd62d3062019-09-04 14:48:02 -0700190 layer.source.buffer.fence = mBufferInfo.mFence;
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000191 layer.source.buffer.textureName = mTextureName;
192 layer.source.buffer.usePremultipliedAlpha = getPremultipledAlpha();
193 layer.source.buffer.isY410BT2020 = isHdrY410();
Peiyong Lin1a70eca2019-11-15 09:33:33 -0800194 bool hasSmpte2086 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::SMPTE2086;
195 bool hasCta861_3 = mBufferInfo.mHdrMetadata.validTypes & HdrMetadata::CTA861_3;
196 layer.source.buffer.maxMasteringLuminance = hasSmpte2086
197 ? mBufferInfo.mHdrMetadata.smpte2086.maxLuminance
198 : defaultMaxMasteringLuminance;
199 layer.source.buffer.maxContentLuminance = hasCta861_3
200 ? mBufferInfo.mHdrMetadata.cta8613.maxContentLightLevel
201 : defaultMaxContentLuminance;
David Sodman0c69cad2017-08-21 12:12:51 -0700202 // TODO: we could be more subtle with isFixedSize()
Lloyd Piquef16688f2019-02-19 17:47:57 -0800203 const bool useFiltering = targetSettings.needsFiltering || mNeedsFiltering || isFixedSize();
David Sodman0c69cad2017-08-21 12:12:51 -0700204
205 // Query the texture matrix given our current filtering mode.
206 float textureMatrix[16];
chaviwf83ce182019-09-12 14:43:08 -0700207 getDrawingTransformMatrix(useFiltering, textureMatrix);
David Sodman0c69cad2017-08-21 12:12:51 -0700208
209 if (getTransformToDisplayInverse()) {
210 /*
211 * the code below applies the primary display's inverse transform to
212 * the texture transform
213 */
Dominik Laskowski718f9602019-11-09 20:01:35 -0800214 uint32_t transform = DisplayDevice::getPrimaryDisplayRotationFlags();
David Sodman0c69cad2017-08-21 12:12:51 -0700215 mat4 tr = inverseOrientation(transform);
216
217 /**
218 * TODO(b/36727915): This is basically a hack.
219 *
220 * Ensure that regardless of the parent transformation,
221 * this buffer is always transformed from native display
222 * orientation to display orientation. For example, in the case
223 * of a camera where the buffer remains in native orientation,
224 * we want the pixels to always be upright.
225 */
226 sp<Layer> p = mDrawingParent.promote();
227 if (p != nullptr) {
228 const auto parentTransform = p->getTransform();
229 tr = tr * inverseOrientation(parentTransform.getOrientation());
230 }
231
232 // and finally apply it to the original texture matrix
233 const mat4 texTransform(mat4(static_cast<const float*>(textureMatrix)) * tr);
234 memcpy(textureMatrix, texTransform.asArray(), sizeof(textureMatrix));
235 }
236
Vishnu Nair4351ad52019-02-11 14:13:02 -0800237 const Rect win{getBounds()};
Marissa Wall290ad082019-03-06 13:23:47 -0800238 float bufferWidth = getBufferSize(s).getWidth();
239 float bufferHeight = getBufferSize(s).getHeight();
240
241 // BufferStateLayers can have a "buffer size" of [0, 0, -1, -1] when no display frame has
242 // been set and there is no parent layer bounds. In that case, the scale is meaningless so
243 // ignore them.
244 if (!getBufferSize(s).isValid()) {
245 bufferWidth = float(win.right) - float(win.left);
246 bufferHeight = float(win.bottom) - float(win.top);
247 }
David Sodman0c69cad2017-08-21 12:12:51 -0700248
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000249 const float scaleHeight = (float(win.bottom) - float(win.top)) / bufferHeight;
250 const float scaleWidth = (float(win.right) - float(win.left)) / bufferWidth;
251 const float translateY = float(win.top) / bufferHeight;
252 const float translateX = float(win.left) / bufferWidth;
253
254 // Flip y-coordinates because GLConsumer expects OpenGL convention.
255 mat4 tr = mat4::translate(vec4(.5, .5, 0, 1)) * mat4::scale(vec4(1, -1, 1, 1)) *
256 mat4::translate(vec4(-.5, -.5, 0, 1)) *
257 mat4::translate(vec4(translateX, translateY, 0, 1)) *
258 mat4::scale(vec4(scaleWidth, scaleHeight, 1.0, 1.0));
259
260 layer.source.buffer.useTextureFiltering = useFiltering;
261 layer.source.buffer.textureTransform = mat4(static_cast<const float*>(textureMatrix)) * tr;
David Sodman0c69cad2017-08-21 12:12:51 -0700262 } else {
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000263 // If layer is blacked out, force alpha to 1 so that we draw a black color
264 // layer.
265 layer.source.buffer.buffer = nullptr;
266 layer.alpha = 1.0;
David Sodman0c69cad2017-08-21 12:12:51 -0700267 }
Alec Mourie7d1d4a2019-02-05 01:13:46 +0000268
Lloyd Piquef16688f2019-02-19 17:47:57 -0800269 return result;
David Sodman0c69cad2017-08-21 12:12:51 -0700270}
271
Marissa Wallfd668622018-05-10 10:21:13 -0700272bool BufferLayer::isHdrY410() const {
273 // pixel format is HDR Y410 masquerading as RGBA_1010102
chaviw4244e032019-09-04 11:27:49 -0700274 return (mBufferInfo.mDataspace == ui::Dataspace::BT2020_ITU_PQ &&
275 mBufferInfo.mApi == NATIVE_WINDOW_API_MEDIA &&
chaviwd62d3062019-09-04 14:48:02 -0700276 mBufferInfo.mBuffer->getPixelFormat() == HAL_PIXEL_FORMAT_RGBA_1010102);
David Sodmaneb085e02017-10-05 18:49:04 -0700277}
278
Lloyd Piquef5275482019-01-29 18:42:42 -0800279void BufferLayer::latchPerFrameState(
280 compositionengine::LayerFECompositionState& compositionState) const {
281 Layer::latchPerFrameState(compositionState);
David Sodman0c69cad2017-08-21 12:12:51 -0700282
283 // Sideband layers
Lloyd Piquef5275482019-01-29 18:42:42 -0800284 if (compositionState.sidebandStream.get()) {
285 compositionState.compositionType = Hwc2::IComposerClient::Composition::SIDEBAND;
David Sodman15094112018-10-11 09:39:37 -0700286 } else {
Lloyd Piquef5275482019-01-29 18:42:42 -0800287 // Normal buffer layers
chaviw4244e032019-09-04 11:27:49 -0700288 compositionState.hdrMetadata = mBufferInfo.mHdrMetadata;
Lloyd Piquef5275482019-01-29 18:42:42 -0800289 compositionState.compositionType = mPotentialCursor
290 ? Hwc2::IComposerClient::Composition::CURSOR
291 : Hwc2::IComposerClient::Composition::DEVICE;
David Sodman0c69cad2017-08-21 12:12:51 -0700292 }
David Sodman0c69cad2017-08-21 12:12:51 -0700293}
294
Marissa Wallfd668622018-05-10 10:21:13 -0700295bool BufferLayer::onPreComposition(nsecs_t refreshStartTime) {
chaviwd62d3062019-09-04 14:48:02 -0700296 if (mBufferInfo.mBuffer != nullptr) {
Marissa Wallfd668622018-05-10 10:21:13 -0700297 Mutex::Autolock lock(mFrameEventHistoryMutex);
298 mFrameEventHistory.addPreComposition(mCurrentFrameNumber, refreshStartTime);
David Sodman0c69cad2017-08-21 12:12:51 -0700299 }
Marissa Wallfd668622018-05-10 10:21:13 -0700300 mRefreshPending = false;
301 return hasReadyFrame();
David Sodman0c69cad2017-08-21 12:12:51 -0700302}
303
Adithya Srinivasanb69e0762019-11-11 18:39:53 -0800304bool BufferLayer::onPostComposition(sp<const DisplayDevice> displayDevice,
Dominik Laskowski075d3172018-05-24 15:50:06 -0700305 const std::shared_ptr<FenceTime>& glDoneFence,
Marissa Wallfd668622018-05-10 10:21:13 -0700306 const std::shared_ptr<FenceTime>& presentFence,
307 const CompositorTiming& compositorTiming) {
308 // mFrameLatencyNeeded is true when a new frame was latched for the
309 // composition.
chaviw74b03172019-08-19 11:09:03 -0700310 if (!mBufferInfo.mFrameLatencyNeeded) return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700311
312 // Update mFrameEventHistory.
Dan Stoza436ccf32018-06-21 12:10:12 -0700313 {
Marissa Wallfd668622018-05-10 10:21:13 -0700314 Mutex::Autolock lock(mFrameEventHistoryMutex);
315 mFrameEventHistory.addPostComposition(mCurrentFrameNumber, glDoneFence, presentFence,
316 compositorTiming);
David Sodman0c69cad2017-08-21 12:12:51 -0700317 }
318
Marissa Wallfd668622018-05-10 10:21:13 -0700319 // Update mFrameTracker.
chaviw4244e032019-09-04 11:27:49 -0700320 nsecs_t desiredPresentTime = mBufferInfo.mDesiredPresentTime;
Marissa Wallfd668622018-05-10 10:21:13 -0700321 mFrameTracker.setDesiredPresentTime(desiredPresentTime);
322
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800323 const int32_t layerId = getSequence();
324 mFlinger->mTimeStats->setDesiredTime(layerId, mCurrentFrameNumber, desiredPresentTime);
Marissa Wallfd668622018-05-10 10:21:13 -0700325
Adithya Srinivasanb69e0762019-11-11 18:39:53 -0800326 const auto outputLayer = findOutputLayerForDisplay(displayDevice);
327 if (outputLayer && outputLayer->requiresClientComposition()) {
328 nsecs_t clientCompositionTimestamp = outputLayer->getState().clientCompositionTimestamp;
329 mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber,
330 clientCompositionTimestamp,
331 FrameTracer::FrameEvent::FALLBACK_COMPOSITION);
332 }
333
chaviw4244e032019-09-04 11:27:49 -0700334 std::shared_ptr<FenceTime> frameReadyFence = mBufferInfo.mFenceTime;
Marissa Wallfd668622018-05-10 10:21:13 -0700335 if (frameReadyFence->isValid()) {
336 mFrameTracker.setFrameReadyFence(std::move(frameReadyFence));
337 } else {
338 // There was no fence for this frame, so assume that it was ready
339 // to be presented at the desired present time.
340 mFrameTracker.setFrameReadyTime(desiredPresentTime);
Dominik Laskowski45de9bd2018-06-11 17:44:10 -0700341 }
Marissa Wallfd668622018-05-10 10:21:13 -0700342
Adithya Srinivasanb69e0762019-11-11 18:39:53 -0800343 const auto displayId = displayDevice->getId();
Marissa Wallfd668622018-05-10 10:21:13 -0700344 if (presentFence->isValid()) {
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800345 mFlinger->mTimeStats->setPresentFence(layerId, mCurrentFrameNumber, presentFence);
346 mFlinger->mFrameTracer->traceFence(layerId, getCurrentBufferId(), mCurrentFrameNumber,
Mikael Pessa90092f42019-08-26 17:22:04 -0700347 presentFence, FrameTracer::FrameEvent::PRESENT_FENCE);
Marissa Wallfd668622018-05-10 10:21:13 -0700348 mFrameTracker.setActualPresentFence(std::shared_ptr<FenceTime>(presentFence));
Dominik Laskowski075d3172018-05-24 15:50:06 -0700349 } else if (displayId && mFlinger->getHwComposer().isConnected(*displayId)) {
Marissa Wallfd668622018-05-10 10:21:13 -0700350 // The HWC doesn't support present fences, so use the refresh
351 // timestamp instead.
Dominik Laskowski075d3172018-05-24 15:50:06 -0700352 const nsecs_t actualPresentTime = mFlinger->getHwComposer().getRefreshTimestamp(*displayId);
Yiwei Zhang1a88c402019-11-18 10:43:58 -0800353 mFlinger->mTimeStats->setPresentTime(layerId, mCurrentFrameNumber, actualPresentTime);
354 mFlinger->mFrameTracer->traceTimestamp(layerId, getCurrentBufferId(), mCurrentFrameNumber,
Mikael Pessa90092f42019-08-26 17:22:04 -0700355 actualPresentTime,
356 FrameTracer::FrameEvent::PRESENT_FENCE);
Marissa Wallfd668622018-05-10 10:21:13 -0700357 mFrameTracker.setActualPresentTime(actualPresentTime);
358 }
359
360 mFrameTracker.advanceFrame();
chaviw74b03172019-08-19 11:09:03 -0700361 mBufferInfo.mFrameLatencyNeeded = false;
Marissa Wallfd668622018-05-10 10:21:13 -0700362 return true;
David Sodman0c69cad2017-08-21 12:12:51 -0700363}
364
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700365bool BufferLayer::latchBuffer(bool& recomputeVisibleRegions, nsecs_t latchTime,
366 nsecs_t expectedPresentTime) {
Marissa Wallfd668622018-05-10 10:21:13 -0700367 ATRACE_CALL();
David Sodman0c69cad2017-08-21 12:12:51 -0700368
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800369 bool refreshRequired = latchSidebandStream(recomputeVisibleRegions);
David Sodman0c69cad2017-08-21 12:12:51 -0700370
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800371 if (refreshRequired) {
372 return refreshRequired;
David Sodman0c69cad2017-08-21 12:12:51 -0700373 }
374
Marissa Wallfd668622018-05-10 10:21:13 -0700375 if (!hasReadyFrame()) {
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800376 return false;
David Sodman0c69cad2017-08-21 12:12:51 -0700377 }
David Sodman0c69cad2017-08-21 12:12:51 -0700378
Marissa Wallfd668622018-05-10 10:21:13 -0700379 // if we've already called updateTexImage() without going through
380 // a composition step, we have to skip this layer at this point
381 // because we cannot call updateTeximage() without a corresponding
382 // compositionComplete() call.
383 // we'll trigger an update in onPreComposition().
384 if (mRefreshPending) {
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800385 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700386 }
387
388 // If the head buffer's acquire fence hasn't signaled yet, return and
389 // try again later
390 if (!fenceHasSignaled()) {
Ady Abraham09bd3922019-04-08 10:44:56 -0700391 ATRACE_NAME("!fenceHasSignaled()");
David Sodman0c69cad2017-08-21 12:12:51 -0700392 mFlinger->signalLayerUpdate();
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800393 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700394 }
395
396 // Capture the old state of the layer for comparisons later
397 const State& s(getDrawingState());
398 const bool oldOpacity = isOpaque(s);
chaviwd62d3062019-09-04 14:48:02 -0700399
400 BufferInfo oldBufferInfo = mBufferInfo;
Marissa Wallfd668622018-05-10 10:21:13 -0700401
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700402 if (!allTransactionsSignaled(expectedPresentTime)) {
Marissa Wallebb486e2019-05-15 14:08:08 -0700403 mFlinger->setTransactionFlags(eTraversalNeeded);
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800404 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700405 }
406
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700407 status_t err = updateTexImage(recomputeVisibleRegions, latchTime, expectedPresentTime);
Marissa Wallfd668622018-05-10 10:21:13 -0700408 if (err != NO_ERROR) {
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800409 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700410 }
411
412 err = updateActiveBuffer();
413 if (err != NO_ERROR) {
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800414 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700415 }
416
Marissa Wallfd668622018-05-10 10:21:13 -0700417 err = updateFrameNumber(latchTime);
418 if (err != NO_ERROR) {
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800419 return false;
Marissa Wallfd668622018-05-10 10:21:13 -0700420 }
421
chaviw4244e032019-09-04 11:27:49 -0700422 gatherBufferInfo();
423
Marissa Wallfd668622018-05-10 10:21:13 -0700424 mRefreshPending = true;
chaviw74b03172019-08-19 11:09:03 -0700425 mBufferInfo.mFrameLatencyNeeded = true;
chaviwd62d3062019-09-04 14:48:02 -0700426 if (oldBufferInfo.mBuffer == nullptr) {
Marissa Wallfd668622018-05-10 10:21:13 -0700427 // the first time we receive a buffer, we need to trigger a
428 // geometry invalidation.
429 recomputeVisibleRegions = true;
430 }
431
chaviw4244e032019-09-04 11:27:49 -0700432 if ((mBufferInfo.mCrop != oldBufferInfo.mCrop) ||
433 (mBufferInfo.mTransform != oldBufferInfo.mTransform) ||
434 (mBufferInfo.mScaleMode != oldBufferInfo.mScaleMode) ||
435 (mBufferInfo.mTransformToDisplayInverse != oldBufferInfo.mTransformToDisplayInverse)) {
Marissa Wallfd668622018-05-10 10:21:13 -0700436 recomputeVisibleRegions = true;
437 }
438
chaviwd62d3062019-09-04 14:48:02 -0700439 if (oldBufferInfo.mBuffer != nullptr) {
440 uint32_t bufWidth = mBufferInfo.mBuffer->getWidth();
441 uint32_t bufHeight = mBufferInfo.mBuffer->getHeight();
442 if (bufWidth != uint32_t(oldBufferInfo.mBuffer->width) ||
443 bufHeight != uint32_t(oldBufferInfo.mBuffer->height)) {
Marissa Wallfd668622018-05-10 10:21:13 -0700444 recomputeVisibleRegions = true;
445 }
446 }
447
448 if (oldOpacity != isOpaque(s)) {
449 recomputeVisibleRegions = true;
450 }
451
452 // Remove any sync points corresponding to the buffer which was just
453 // latched
454 {
455 Mutex::Autolock lock(mLocalSyncPointMutex);
456 auto point = mLocalSyncPoints.begin();
457 while (point != mLocalSyncPoints.end()) {
458 if (!(*point)->frameIsAvailable() || !(*point)->transactionIsApplied()) {
459 // This sync point must have been added since we started
460 // latching. Don't drop it yet.
461 ++point;
462 continue;
463 }
464
465 if ((*point)->getFrameNumber() <= mCurrentFrameNumber) {
Alec Mourie60041e2019-06-14 18:59:51 -0700466 std::stringstream ss;
467 ss << "Dropping sync point " << (*point)->getFrameNumber();
468 ATRACE_NAME(ss.str().c_str());
Marissa Wallfd668622018-05-10 10:21:13 -0700469 point = mLocalSyncPoints.erase(point);
470 } else {
471 ++point;
472 }
473 }
474 }
475
Vishnu Nair6194e2e2019-02-06 12:58:39 -0800476 return true;
Marissa Wallfd668622018-05-10 10:21:13 -0700477}
478
479// transaction
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700480void BufferLayer::notifyAvailableFrames(nsecs_t expectedPresentTime) {
481 const auto headFrameNumber = getHeadFrameNumber(expectedPresentTime);
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700482 const bool headFenceSignaled = fenceHasSignaled();
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700483 const bool presentTimeIsCurrent = framePresentTimeIsCurrent(expectedPresentTime);
Marissa Wallfd668622018-05-10 10:21:13 -0700484 Mutex::Autolock lock(mLocalSyncPointMutex);
485 for (auto& point : mLocalSyncPoints) {
Ady Abrahamcd1580c2019-04-29 15:40:03 -0700486 if (headFrameNumber >= point->getFrameNumber() && headFenceSignaled &&
487 presentTimeIsCurrent) {
Marissa Wallfd668622018-05-10 10:21:13 -0700488 point->setFrameAvailable();
chaviw43cb3cb2019-05-31 15:23:41 -0700489 sp<Layer> requestedSyncLayer = point->getRequestedSyncLayer();
490 if (requestedSyncLayer) {
491 // Need to update the transaction flag to ensure the layer's pending transaction
492 // gets applied.
493 requestedSyncLayer->setTransactionFlags(eTransactionNeeded);
494 }
Marissa Wallfd668622018-05-10 10:21:13 -0700495 }
David Sodman0c69cad2017-08-21 12:12:51 -0700496 }
497}
498
Marissa Wallfd668622018-05-10 10:21:13 -0700499bool BufferLayer::hasReadyFrame() const {
Marissa Wall024a1912018-08-13 13:55:35 -0700500 return hasFrameUpdate() || getSidebandStreamChanged() || getAutoRefresh();
Marissa Wallfd668622018-05-10 10:21:13 -0700501}
502
503uint32_t BufferLayer::getEffectiveScalingMode() const {
504 if (mOverrideScalingMode >= 0) {
505 return mOverrideScalingMode;
506 }
507
chaviw4244e032019-09-04 11:27:49 -0700508 return mBufferInfo.mScaleMode;
Marissa Wallfd668622018-05-10 10:21:13 -0700509}
510
511bool BufferLayer::isProtected() const {
chaviwd62d3062019-09-04 14:48:02 -0700512 const sp<GraphicBuffer>& buffer(mBufferInfo.mBuffer);
Marissa Wallfd668622018-05-10 10:21:13 -0700513 return (buffer != 0) && (buffer->getUsage() & GRALLOC_USAGE_PROTECTED);
514}
515
516bool BufferLayer::latchUnsignaledBuffers() {
517 static bool propertyLoaded = false;
518 static bool latch = false;
519 static std::mutex mutex;
520 std::lock_guard<std::mutex> lock(mutex);
521 if (!propertyLoaded) {
522 char value[PROPERTY_VALUE_MAX] = {};
523 property_get("debug.sf.latch_unsignaled", value, "0");
524 latch = atoi(value);
525 propertyLoaded = true;
526 }
527 return latch;
528}
529
530// h/w composer set-up
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700531bool BufferLayer::allTransactionsSignaled(nsecs_t expectedPresentTime) {
532 const auto headFrameNumber = getHeadFrameNumber(expectedPresentTime);
Marissa Wallfd668622018-05-10 10:21:13 -0700533 bool matchingFramesFound = false;
534 bool allTransactionsApplied = true;
535 Mutex::Autolock lock(mLocalSyncPointMutex);
536
537 for (auto& point : mLocalSyncPoints) {
538 if (point->getFrameNumber() > headFrameNumber) {
539 break;
540 }
541 matchingFramesFound = true;
542
543 if (!point->frameIsAvailable()) {
544 // We haven't notified the remote layer that the frame for
545 // this point is available yet. Notify it now, and then
546 // abort this attempt to latch.
547 point->setFrameAvailable();
548 allTransactionsApplied = false;
549 break;
550 }
551
552 allTransactionsApplied = allTransactionsApplied && point->transactionIsApplied();
553 }
554 return !matchingFramesFound || allTransactionsApplied;
David Sodman0c69cad2017-08-21 12:12:51 -0700555}
556
557// As documented in libhardware header, formats in the range
558// 0x100 - 0x1FF are specific to the HAL implementation, and
559// are known to have no alpha channel
560// TODO: move definition for device-specific range into
561// hardware.h, instead of using hard-coded values here.
562#define HARDWARE_IS_DEVICE_FORMAT(f) ((f) >= 0x100 && (f) <= 0x1FF)
563
564bool BufferLayer::getOpacityForFormat(uint32_t format) {
565 if (HARDWARE_IS_DEVICE_FORMAT(format)) {
566 return true;
567 }
568 switch (format) {
569 case HAL_PIXEL_FORMAT_RGBA_8888:
570 case HAL_PIXEL_FORMAT_BGRA_8888:
571 case HAL_PIXEL_FORMAT_RGBA_FP16:
572 case HAL_PIXEL_FORMAT_RGBA_1010102:
573 return false;
574 }
575 // in all other case, we have no blending (also for unknown formats)
576 return true;
577}
578
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800579bool BufferLayer::needsFiltering(const sp<const DisplayDevice>& displayDevice) const {
Lloyd Piquef16688f2019-02-19 17:47:57 -0800580 // If we are not capturing based on the state of a known display device,
581 // just return false.
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800582 if (displayDevice == nullptr) {
Lloyd Piquef16688f2019-02-19 17:47:57 -0800583 return false;
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800584 }
585
586 const auto outputLayer = findOutputLayerForDisplay(displayDevice);
587 if (outputLayer == nullptr) {
Lloyd Piquef16688f2019-02-19 17:47:57 -0800588 return false;
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800589 }
590
Lloyd Piquef16688f2019-02-19 17:47:57 -0800591 // We need filtering if the sourceCrop rectangle size does not match the
592 // displayframe rectangle size (not a 1:1 render)
Lloyd Pique37c2c9b2018-12-04 17:25:10 -0800593 const auto& compositionState = outputLayer->getState();
594 const auto displayFrame = compositionState.displayFrame;
595 const auto sourceCrop = compositionState.sourceCrop;
Lloyd Piquef16688f2019-02-19 17:47:57 -0800596 return sourceCrop.getHeight() != displayFrame.getHeight() ||
Peiyong Linc2020ca2019-01-10 11:36:12 -0800597 sourceCrop.getWidth() != displayFrame.getWidth();
Chia-I Wu692e0832018-06-05 15:46:58 -0700598}
599
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700600uint64_t BufferLayer::getHeadFrameNumber(nsecs_t expectedPresentTime) const {
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800601 if (hasFrameUpdate()) {
Dominik Laskowskia8955dd2019-07-10 10:19:09 -0700602 return getFrameNumber(expectedPresentTime);
David Sodman0c69cad2017-08-21 12:12:51 -0700603 } else {
604 return mCurrentFrameNumber;
605 }
606}
607
Vishnu Nair60356342018-11-13 13:00:45 -0800608Rect BufferLayer::getBufferSize(const State& s) const {
609 // If we have a sideband stream, or we are scaling the buffer then return the layer size since
610 // we cannot determine the buffer size.
611 if ((s.sidebandStream != nullptr) ||
612 (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) {
613 return Rect(getActiveWidth(s), getActiveHeight(s));
614 }
615
chaviwd62d3062019-09-04 14:48:02 -0700616 if (mBufferInfo.mBuffer == nullptr) {
Vishnu Nair60356342018-11-13 13:00:45 -0800617 return Rect::INVALID_RECT;
618 }
619
chaviwd62d3062019-09-04 14:48:02 -0700620 uint32_t bufWidth = mBufferInfo.mBuffer->getWidth();
621 uint32_t bufHeight = mBufferInfo.mBuffer->getHeight();
Vishnu Nair60356342018-11-13 13:00:45 -0800622
623 // Undo any transformations on the buffer and return the result.
chaviw4244e032019-09-04 11:27:49 -0700624 if (mBufferInfo.mTransform & ui::Transform::ROT_90) {
Vishnu Nair60356342018-11-13 13:00:45 -0800625 std::swap(bufWidth, bufHeight);
626 }
627
Lloyd Pique0449b0f2018-12-20 16:23:45 -0800628 if (getTransformToDisplayInverse()) {
Dominik Laskowski718f9602019-11-09 20:01:35 -0800629 uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
Vishnu Nair60356342018-11-13 13:00:45 -0800630 if (invTransform & ui::Transform::ROT_90) {
631 std::swap(bufWidth, bufHeight);
632 }
633 }
634
635 return Rect(bufWidth, bufHeight);
636}
637
Lloyd Piquefeb73d72018-12-04 17:23:44 -0800638std::shared_ptr<compositionengine::Layer> BufferLayer::getCompositionLayer() const {
639 return mCompositionLayer;
640}
641
Vishnu Nair4351ad52019-02-11 14:13:02 -0800642FloatRect BufferLayer::computeSourceBounds(const FloatRect& parentBounds) const {
643 const State& s(getDrawingState());
644
645 // If we have a sideband stream, or we are scaling the buffer then return the layer size since
646 // we cannot determine the buffer size.
647 if ((s.sidebandStream != nullptr) ||
648 (getEffectiveScalingMode() != NATIVE_WINDOW_SCALING_MODE_FREEZE)) {
649 return FloatRect(0, 0, getActiveWidth(s), getActiveHeight(s));
650 }
651
chaviwd62d3062019-09-04 14:48:02 -0700652 if (mBufferInfo.mBuffer == nullptr) {
Vishnu Nair4351ad52019-02-11 14:13:02 -0800653 return parentBounds;
654 }
655
chaviwd62d3062019-09-04 14:48:02 -0700656 uint32_t bufWidth = mBufferInfo.mBuffer->getWidth();
657 uint32_t bufHeight = mBufferInfo.mBuffer->getHeight();
Vishnu Nair4351ad52019-02-11 14:13:02 -0800658
659 // Undo any transformations on the buffer and return the result.
chaviw4244e032019-09-04 11:27:49 -0700660 if (mBufferInfo.mTransform & ui::Transform::ROT_90) {
Vishnu Nair4351ad52019-02-11 14:13:02 -0800661 std::swap(bufWidth, bufHeight);
662 }
663
664 if (getTransformToDisplayInverse()) {
Dominik Laskowski718f9602019-11-09 20:01:35 -0800665 uint32_t invTransform = DisplayDevice::getPrimaryDisplayRotationFlags();
Vishnu Nair4351ad52019-02-11 14:13:02 -0800666 if (invTransform & ui::Transform::ROT_90) {
667 std::swap(bufWidth, bufHeight);
668 }
669 }
670
671 return FloatRect(0, 0, bufWidth, bufHeight);
672}
673
chaviw49a108c2019-08-12 11:23:06 -0700674void BufferLayer::latchAndReleaseBuffer() {
675 mRefreshPending = false;
676 if (hasReadyFrame()) {
677 bool ignored = false;
678 latchBuffer(ignored, systemTime(), 0 /* expectedPresentTime */);
679 }
680 releasePendingBuffer(systemTime());
681}
682
chaviw4244e032019-09-04 11:27:49 -0700683PixelFormat BufferLayer::getPixelFormat() const {
684 return mBufferInfo.mPixelFormat;
685}
686
687bool BufferLayer::getTransformToDisplayInverse() const {
688 return mBufferInfo.mTransformToDisplayInverse;
689}
690
691Rect BufferLayer::getBufferCrop() const {
692 // this is the crop rectangle that applies to the buffer
693 // itself (as opposed to the window)
694 if (!mBufferInfo.mCrop.isEmpty()) {
695 // if the buffer crop is defined, we use that
696 return mBufferInfo.mCrop;
chaviwd62d3062019-09-04 14:48:02 -0700697 } else if (mBufferInfo.mBuffer != nullptr) {
chaviw4244e032019-09-04 11:27:49 -0700698 // otherwise we use the whole buffer
chaviwd62d3062019-09-04 14:48:02 -0700699 return mBufferInfo.mBuffer->getBounds();
chaviw4244e032019-09-04 11:27:49 -0700700 } else {
701 // if we don't have a buffer yet, we use an empty/invalid crop
702 return Rect();
703 }
704}
705
706uint32_t BufferLayer::getBufferTransform() const {
707 return mBufferInfo.mTransform;
708}
709
710ui::Dataspace BufferLayer::getDataSpace() const {
711 return mBufferInfo.mDataspace;
712}
713
714ui::Dataspace BufferLayer::translateDataspace(ui::Dataspace dataspace) {
715 ui::Dataspace updatedDataspace = dataspace;
716 // translate legacy dataspaces to modern dataspaces
717 switch (dataspace) {
718 case ui::Dataspace::SRGB:
719 updatedDataspace = ui::Dataspace::V0_SRGB;
720 break;
721 case ui::Dataspace::SRGB_LINEAR:
722 updatedDataspace = ui::Dataspace::V0_SRGB_LINEAR;
723 break;
724 case ui::Dataspace::JFIF:
725 updatedDataspace = ui::Dataspace::V0_JFIF;
726 break;
727 case ui::Dataspace::BT601_625:
728 updatedDataspace = ui::Dataspace::V0_BT601_625;
729 break;
730 case ui::Dataspace::BT601_525:
731 updatedDataspace = ui::Dataspace::V0_BT601_525;
732 break;
733 case ui::Dataspace::BT709:
734 updatedDataspace = ui::Dataspace::V0_BT709;
735 break;
736 default:
737 break;
738 }
739
740 return updatedDataspace;
741}
742
chaviwd62d3062019-09-04 14:48:02 -0700743sp<GraphicBuffer> BufferLayer::getBuffer() const {
744 return mBufferInfo.mBuffer;
745}
746
chaviwf83ce182019-09-12 14:43:08 -0700747void BufferLayer::getDrawingTransformMatrix(bool filteringEnabled, float outMatrix[16]) {
748 GLConsumer::computeTransformMatrix(outMatrix, mBufferInfo.mBuffer, mBufferInfo.mCrop,
749 mBufferInfo.mTransform, filteringEnabled);
750}
751
chaviwb4c6e582019-08-16 14:35:07 -0700752void BufferLayer::setInitialValuesForClone(const sp<Layer>& clonedFrom) {
753 Layer::setInitialValuesForClone(clonedFrom);
754
755 sp<BufferLayer> bufferClonedFrom = static_cast<BufferLayer*>(clonedFrom.get());
756 mPremultipliedAlpha = bufferClonedFrom->mPremultipliedAlpha;
757 mPotentialCursor = bufferClonedFrom->mPotentialCursor;
758 mProtectedByApp = bufferClonedFrom->mProtectedByApp;
chaviw74b03172019-08-19 11:09:03 -0700759
760 updateCloneBufferInfo();
761}
762
763void BufferLayer::updateCloneBufferInfo() {
764 if (!isClone() || !isClonedFromAlive()) {
765 return;
766 }
767
768 sp<BufferLayer> clonedFrom = static_cast<BufferLayer*>(getClonedFrom().get());
769 mBufferInfo = clonedFrom->mBufferInfo;
770 mSidebandStream = clonedFrom->mSidebandStream;
771 surfaceDamageRegion = clonedFrom->surfaceDamageRegion;
772 mCurrentFrameNumber = clonedFrom->mCurrentFrameNumber.load();
773 mPreviousFrameNumber = clonedFrom->mPreviousFrameNumber;
774
775 // After buffer info is updated, the drawingState from the real layer needs to be copied into
776 // the cloned. This is because some properties of drawingState can change when latchBuffer is
chaviwaf87b3e2019-10-01 16:59:28 -0700777 // called. However, copying the drawingState would also overwrite the cloned layer's relatives
778 // and touchableRegionCrop. Therefore, temporarily store the relatives so they can be set in
779 // the cloned drawingState again.
chaviw74b03172019-08-19 11:09:03 -0700780 wp<Layer> tmpZOrderRelativeOf = mDrawingState.zOrderRelativeOf;
781 SortedVector<wp<Layer>> tmpZOrderRelatives = mDrawingState.zOrderRelatives;
chaviwaf87b3e2019-10-01 16:59:28 -0700782 wp<Layer> tmpTouchableRegionCrop = mDrawingState.touchableRegionCrop;
783 InputWindowInfo tmpInputInfo = mDrawingState.inputInfo;
784
chaviw74b03172019-08-19 11:09:03 -0700785 mDrawingState = clonedFrom->mDrawingState;
chaviwaf87b3e2019-10-01 16:59:28 -0700786
787 mDrawingState.touchableRegionCrop = tmpTouchableRegionCrop;
chaviw74b03172019-08-19 11:09:03 -0700788 mDrawingState.zOrderRelativeOf = tmpZOrderRelativeOf;
789 mDrawingState.zOrderRelatives = tmpZOrderRelatives;
chaviwaf87b3e2019-10-01 16:59:28 -0700790 mDrawingState.inputInfo = tmpInputInfo;
chaviwb4c6e582019-08-16 14:35:07 -0700791}
792
David Sodman0c69cad2017-08-21 12:12:51 -0700793} // namespace android
794
795#if defined(__gl_h_)
796#error "don't include gl/gl.h in this file"
797#endif
798
799#if defined(__gl2_h_)
800#error "don't include gl2/gl2.h in this file"
801#endif
Ady Abrahamb0dbdaa2020-01-06 16:19:42 -0800802
803// TODO(b/129481165): remove the #pragma below and fix conversion issues
804#pragma clang diagnostic pop // ignored "-Wconversion"