Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d9731a57 authored by Romain Guy's avatar Romain Guy Committed by Android Git Automerger
Browse files

am bf53be46: am 09353f74: Merge "Check and fail early if requested wallpaper...

am bf53be46: am 09353f74: Merge "Check and fail early if requested wallpaper size exceeds maximum texture size."

* commit 'bf53be46':
  Check and fail early if requested wallpaper size exceeds maximum texture size.
parents a60fdfac bf53be46
Loading
Loading
Loading
Loading
+16 −2
Original line number Diff line number Diff line
@@ -365,6 +365,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);
@@ -627,12 +628,25 @@ 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 " +