diff options
author | Wim Vander Schelden <wim.vander.schelden@philips.com> | 2013-02-07 15:51:51 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2013-02-14 19:16:23 +0000 |
commit | 9549c067d93bd87aa28d1d6d44fdb8d75b2fd276 (patch) | |
tree | d8737c072555b24d37e7a3a5bca33080865df60e /packages/SystemUI/src | |
parent | 37edbbc62fa031c75ce5a1298fdd07d981907e89 (diff) | |
download | frameworks_base-9549c067d93bd87aa28d1d6d44fdb8d75b2fd276.zip frameworks_base-9549c067d93bd87aa28d1d6d44fdb8d75b2fd276.tar.gz frameworks_base-9549c067d93bd87aa28d1d6d44fdb8d75b2fd276.tar.bz2 |
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 <wim.vander.schelden@philips.com>
Change-Id: I8d2e1ae9fd9772977c4e365f23f2f58bbca3787c
Diffstat (limited to 'packages/SystemUI/src')
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/ImageWallpaper.java | 18 |
1 files 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 9da883a..8d0fe75 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 " + |