[kde-workspace] kwin: Fix GL error when do texture from pixmap

My dashboard
Submitter Jammy Zhou
Subject [kde-workspace] kwin: Fix GL error when do texture from pixmap
Date March 11, 2011, 1:05 a.m.
List thread <20110311010543.C20ADA609B@git.kde.org>
Project kde-commits
State New
Headers show

Comments

Jammy Zhou - March 11, 2011, 1:05 a.m.
Git commit 87f8d76d179088a9563748257bbd1c16747b2210 by Jammy Zhou.
Committed on 10/03/2011 at 10:50.
Pushed by jammyzhou into branch 'master'.

Fix GL error when do texture from pixmap

This problem happens on Freescale imx51 ARM platform

CCMAIL: patches@linaro.org

M  +2    -0    kwin/scene_opengl.cpp     
M  +10   -0    kwin/scene_opengl_egl.cpp     

http://commits.kde.org/kde-workspace/87f8d76d179088a9563748257bbd1c16747b2210

Patch

diff --git a/kwin/scene_opengl.cpp b/kwin/scene_opengl.cpp
index 1070081..58ea7d7 100644
--- a/kwin/scene_opengl.cpp
+++ b/kwin/scene_opengl.cpp
@@ -329,6 +329,8 @@  QRegion SceneOpenGL::Texture::optimizeBindDamage(const QRegion& reg, int limit)
 bool SceneOpenGL::Texture::load(const Pixmap& pix, const QSize& size,
                                 int depth)
 {
+    if (pix == None)
+        return false;
     return load(pix, size, depth,
                 QRegion(0, 0, size.width(), size.height()));
 }
diff --git a/kwin/scene_opengl_egl.cpp b/kwin/scene_opengl_egl.cpp
index 4f456cb..ede88de 100644
--- a/kwin/scene_opengl_egl.cpp
+++ b/kwin/scene_opengl_egl.cpp
@@ -232,6 +232,10 @@  bool SceneOpenGL::Texture::load(const Pixmap& pix, const QSize& size,
     Q_UNUSED(size)
     Q_UNUSED(depth)
     Q_UNUSED(region)
+
+    if (pix == None)
+        return false;
+
     if (mTexture == None) {
         createTexture();
         bind();
@@ -245,6 +249,12 @@  bool SceneOpenGL::Texture::load(const Pixmap& pix, const QSize& size,
         };
         EGLImageKHR image = eglCreateImageKHR(dpy, EGL_NO_CONTEXT, EGL_NATIVE_PIXMAP_KHR,
                                               (EGLClientBuffer)pix, attribs);
+
+        if (EGL_NO_IMAGE_KHR == image) {
+            kDebug(1212) << "failed to create egl image";
+            unbind();
+            return false;
+        }
         glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, (GLeglImageOES)image);
         eglDestroyImageKHR(dpy, image);
         unbind();