summaryrefslogtreecommitdiffstats
path: root/libs/surfaceflinger/Layer.cpp
diff options
context:
space:
mode:
authorMathias Agopian <mathias@google.com>2010-04-14 16:43:44 -0700
committerMathias Agopian <mathias@google.com>2010-04-14 16:43:44 -0700
commitca99fb8f65f3ea249c56fb6dccefffb54e87696e (patch)
tree6071c87bf800c60d8c2f8dbd85a2f0c2b6e669f7 /libs/surfaceflinger/Layer.cpp
parentdaeec8c5b335ba84aa932a80e6319be5d71f1956 (diff)
downloadframeworks_native-ca99fb8f65f3ea249c56fb6dccefffb54e87696e.zip
frameworks_native-ca99fb8f65f3ea249c56fb6dccefffb54e87696e.tar.gz
frameworks_native-ca99fb8f65f3ea249c56fb6dccefffb54e87696e.tar.bz2
fix [2594950] Flash: Zooming in on some content crashes the Nexus One and causes it to reboot (runtime restart)
We now limit the size of the surface to the maximum size supported by the GPU. On Nexus One this will 2048 -- it could be different on other devices. Surface creation fails if the limit is exceeded. Change-Id: I9ecfc2e9c58c9e283782b61ebfc6b590f71df785
Diffstat (limited to 'libs/surfaceflinger/Layer.cpp')
-rw-r--r--libs/surfaceflinger/Layer.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 4dc4a15..0a3254d 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -41,6 +41,10 @@
namespace android {
+template <typename T> inline T min(T a, T b) {
+ return a<b ? a : b;
+}
+
// ---------------------------------------------------------------------------
const uint32_t Layer::typeInfo = LayerBaseClient::typeInfo | 4;
@@ -109,17 +113,26 @@ status_t Layer::setBuffers( uint32_t w, uint32_t h,
// the display's pixel format
const DisplayHardware& hw(graphicPlane(0).displayHardware());
+ uint32_t const maxSurfaceDims = min(
+ hw.getMaxTextureSize(), hw.getMaxViewportDims());
+
+ // never allow a surface larger than what our underlying GL implementation
+ // can handle.
+ if ((uint32_t(w)>maxSurfaceDims) || (uint32_t(h)>maxSurfaceDims)) {
+ return BAD_VALUE;
+ }
+
PixelFormatInfo displayInfo;
getPixelFormatInfo(hw.getFormat(), &displayInfo);
const uint32_t hwFlags = hw.getFlags();
mFormat = format;
- mWidth = w;
+ mWidth = w;
mHeight = h;
mSecure = (flags & ISurfaceComposer::eSecure) ? true : false;
mNeedsBlending = (info.h_alpha - info.l_alpha) > 0;
mNoEGLImageForSwBuffers = !(hwFlags & DisplayHardware::CACHED_BUFFERS);
-
+
// we use the red index
int displayRedSize = displayInfo.getSize(PixelFormatInfo::INDEX_RED);
int layerRedsize = info.getSize(PixelFormatInfo::INDEX_RED);