From 9549c067d93bd87aa28d1d6d44fdb8d75b2fd276 Mon Sep 17 00:00:00 2001 From: Wim Vander Schelden Date: Thu, 7 Feb 2013 15:51:51 +0000 Subject: [PATCH] Check and fail early if requested wallpaper size exceeds maximum texture size. This fixes an issue where OpenGL initialization succeeds but buffer allocation fails because the requested wallpaper size is too large (or otherwise unsupported) by the graphics hardware. This fixes an issue where SystemUI crashes constantly on the PandaBoard when connected to a full HD display. Tested only on PandaBoard, no access to alternative hardware. Signed-off-by: Wim Vander Schelden Change-Id: I8d2e1ae9fd9772977c4e365f23f2f58bbca3787c --- .../com/android/systemui/ImageWallpaper.java | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java index 9da883a7f4c76..8d0fe75543c64 100644 --- a/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java +++ b/packages/SystemUI/src/com/android/systemui/ImageWallpaper.java @@ -378,6 +378,7 @@ public class ImageWallpaper extends WallpaperService { if (DEBUG) { Log.d(TAG, "Redrawing wallpaper"); } + if (mIsHwAccelerated) { if (!drawWallpaperWithOpenGL(sh, availw, availh, xPixels, yPixels)) { drawWallpaperWithCanvas(sh, availw, availh, xPixels, yPixels); @@ -640,13 +641,26 @@ public class ImageWallpaper extends WallpaperService { } mEglContext = createContext(mEgl, mEglDisplay, mEglConfig); + + int[] maxSize = new int[1]; + Rect frame = surfaceHolder.getSurfaceFrame(); + glGetIntegerv(GL_MAX_TEXTURE_SIZE, maxSize, 0); + if(frame.width() > maxSize[0] || frame.height() > maxSize[0]) { + mEgl.eglDestroyContext(mEglDisplay, mEglContext); + mEgl.eglTerminate(mEglDisplay); + Log.e(GL_LOG_TAG, "requested texture size " + + frame.width() + "x" + frame.height() + " exceeds the support maximum of " + + maxSize[0] + "x" + maxSize[0]); + return false; + } mEglSurface = mEgl.eglCreateWindowSurface(mEglDisplay, mEglConfig, surfaceHolder, null); if (mEglSurface == null || mEglSurface == EGL_NO_SURFACE) { int error = mEgl.eglGetError(); - if (error == EGL_BAD_NATIVE_WINDOW) { - Log.e(GL_LOG_TAG, "createWindowSurface returned EGL_BAD_NATIVE_WINDOW."); + if (error == EGL_BAD_NATIVE_WINDOW || error == EGL_BAD_ALLOC) { + Log.e(GL_LOG_TAG, "createWindowSurface returned " + + GLUtils.getEGLErrorString(error) + "."); return false; } throw new RuntimeException("createWindowSurface failed " +