From ce4a7dfc516ee61301e9af91fad17ca1320efaab Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Thu, 28 Mar 2013 11:32:33 -0700 Subject: Don't crash when making a layer larger than supported dimensions Bug #8437401 A misplaced ref count decrement was causing a crash when attempting to resize a layer to dimensions larger than the max texture size supported by the GPU. This change fixes the crash and clarifies the warnings to make it more obvious what's happening. Change-Id: I632dc1b90aaa2605969e10523491a81c4922d3dc --- libs/hwui/Layer.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libs/hwui/Layer.cpp') diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 2998535c9916..7f4977adbb80 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -75,6 +75,13 @@ bool Layer::resize(const uint32_t width, const uint32_t height) { return true; } + const uint32_t maxTextureSize = Caches::getInstance().maxTextureSize; + if (desiredWidth > maxTextureSize || desiredHeight > maxTextureSize) { + ALOGW("Layer exceeds max. dimensions supported by the GPU (%dx%d, max=%dx%d)", + desiredWidth, desiredHeight, maxTextureSize, maxTextureSize); + return false; + } + uint32_t oldWidth = getWidth(); uint32_t oldHeight = getHeight(); -- cgit v1.2.3-59-g8ed1b