From 9c9c19134593655c36fe70aaa45a91ad4f75e36f Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Mon, 19 Jul 2021 12:02:16 -0700 Subject: Skip creating external textures that exceeds size limit Skia always accept an Android buffer and wraps it around with a texture even if its size exceeds the limit GL exposes. Therefore let's skip creating the texture in SurfaceFlinger and outputs an error log to logcat. I chose to do it in SurfaceFlinger rather than RenderEngine is because the external texture mapping is designed to be asynchronous, so it'd be better to keep that way. The limit is also exposed out of RenderEngine so SurfaceFlinger can check it before creating external textures as well. Bug: 190399306 Test: The test mentioned in the bug fails instead of crashing SurfaceFlinger. Test: atest SurfaceFlinger_test Test: atest libsurfaceflinger_unittest Change-Id: I52d253ed5a10f0e4ade372048721913405ed668a --- services/surfaceflinger/BufferQueueLayer.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'services/surfaceflinger/BufferQueueLayer.cpp') diff --git a/services/surfaceflinger/BufferQueueLayer.cpp b/services/surfaceflinger/BufferQueueLayer.cpp index 6b6d43425d..99e470dfe6 100644 --- a/services/surfaceflinger/BufferQueueLayer.cpp +++ b/services/surfaceflinger/BufferQueueLayer.cpp @@ -515,13 +515,10 @@ void BufferQueueLayer::onFirstRef() { } status_t BufferQueueLayer::setDefaultBufferProperties(uint32_t w, uint32_t h, PixelFormat format) { - uint32_t const maxSurfaceDims = - std::min(mFlinger->getMaxTextureSize(), mFlinger->getMaxViewportDims()); - // never allow a surface larger than what our underlying GL implementation // can handle. - if ((uint32_t(w) > maxSurfaceDims) || (uint32_t(h) > maxSurfaceDims)) { - ALOGE("dimensions too large %u x %u", uint32_t(w), uint32_t(h)); + if (mFlinger->exceedsMaxRenderTargetSize(w, h)) { + ALOGE("dimensions too large %" PRIu32 " x %" PRIu32, w, h); return BAD_VALUE; } -- cgit v1.2.3-59-g8ed1b