Bug 844698 Make Qt EGL port working on X11 Maemo/Meego after bug 716859 landed. r=jgilbert
authorOleg Romashin <romaxa@gmail.com>
Wed, 27 Feb 2013 20:56:29 -0800
changeset 123383 249ff1a50e4011bc78bd18abea02f10d0d24d413
parent 123382 5c028f93d3c9877f93c7101192da1533ffd657f3
child 123384 a8a1e08cc3ac10c17f4ded9229a51a2593a815c6
push id23808
push userromaxa@gmail.com
push dateThu, 28 Feb 2013 19:52:46 +0000
treeherdermozilla-inbound@249ff1a50e40 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs844698, 716859
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 844698 Make Qt EGL port working on X11 Maemo/Meego after bug 716859 landed. r=jgilbert
gfx/gl/GLContextProviderEGL.cpp
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -222,20 +222,20 @@ class GLContextEGL : public GLContext
                                                         eglShareContext,
                                                         attribs);
         if (!context && shareContext) {
             shareContext = nullptr;
             context = sEGLLibrary.fCreateContext(EGL_DISPLAY(),
                                                  config,
                                                  EGL_NO_CONTEXT,
                                                  attribs);
-            if (!context) {
-                NS_WARNING("Failed to create EGLContext!");
-                return nullptr;
-            }
+        }
+        if (!context) {
+            NS_WARNING("Failed to create EGLContext!");
+            return nullptr;
         }
 
         nsRefPtr<GLContextEGL> glContext = new GLContextEGL(caps,
                                                             shareContext,
                                                             isOffscreen,
                                                             config,
                                                             surface,
                                                             context);
@@ -2029,30 +2029,35 @@ already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
         return nullptr;
     }
 
     bool doubleBuffered = true;
 
+    bool hasNativeContext = aWidget->HasGLContext();
     EGLContext eglContext = sEGLLibrary.fGetCurrentContext();
-    if (aWidget->HasGLContext() && eglContext) {
-        //int colorDepth = gfxPlatform::GetPlatform()->GetScreenDepth();
+    if (hasNativeContext && eglContext) {
         void* platformContext = eglContext;
+        SurfaceCaps caps = SurfaceCaps::Any();
 #ifdef MOZ_WIDGET_QT
+        int depth = gfxPlatform::GetPlatform()->GetScreenDepth();
         QGLContext* context = const_cast<QGLContext*>(QGLContext::currentContext());
         if (context && context->device()) {
             depth = context->device()->depth();
         }
-        doubleBuffered = context->format().doubleBuffer();
+        const QGLFormat& format = context->format();
+        doubleBuffered = format.doubleBuffer();
         platformContext = context;
+        caps.bpp16 = depth == 16 ? true : false;
+        caps.alpha = format.rgba();
+        caps.depth = format.depth();
+        caps.stencil = format.stencil();
 #endif
-
-        SurfaceCaps caps = SurfaceCaps::Any();
         EGLConfig config = EGL_NO_CONFIG;
         EGLSurface surface = sEGLLibrary.fGetCurrentSurface(LOCAL_EGL_DRAW);
         nsRefPtr<GLContextEGL> glContext =
             new GLContextEGL(caps,
                              gGlobalContext, false,
                              config, surface, eglContext);
 
         if (!glContext->Init())
@@ -2211,21 +2216,22 @@ CreateEGLSurfaceForXSurface(gfxASurface*
         LOCAL_EGL_DEPTH_SIZE,           0,
         LOCAL_EGL_BIND_TO_TEXTURE_RGB,  LOCAL_EGL_TRUE,
         LOCAL_EGL_NONE
     };
 
     if (!sEGLLibrary.fChooseConfig(EGL_DISPLAY(),
                                    sEGLLibrary.HasKHRLockSurface() ?
                                        pixmap_lock_config : pixmap_config,
-                                   configs, numConfigs, &numConfigs))
+                                   configs, numConfigs, &numConfigs)
+        || numConfigs == 0)
+    {
+        NS_WARNING("No EGL Config for pixmap!");
         return nullptr;
-
-    if (numConfigs == 0)
-        return nullptr;
+    }
 
     int i = 0;
     for (i = 0; i < numConfigs; ++i) {
         if (opaque)
             surface = sEGLLibrary.fCreatePixmapSurface(EGL_DISPLAY(), configs[i],
                                                        (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgb);
         else
@@ -2233,16 +2239,17 @@ CreateEGLSurfaceForXSurface(gfxASurface*
                                                        (EGLNativePixmapType)xsurface->XDrawable(),
                                                        pixmap_config_rgba);
 
         if (surface != EGL_NO_SURFACE)
             break;
     }
 
     if (!surface) {
+        NS_WARNING("Failed to CreatePixmapSurface!");
         return nullptr;
     }
 
     if (aConfig)
         *aConfig = configs[i];
 
     return surface;
 }
@@ -2283,19 +2290,19 @@ GLContextEGL::CreateEGLPixmapOffscreenCo
     if (!config) {
         return nullptr;
     }
     MOZ_ASSERT(surface);
 
     GLContextEGL* shareContext = GetGlobalContextEGL();
     SurfaceCaps dummyCaps = SurfaceCaps::Any();
     nsRefPtr<GLContextEGL> glContext =
-    GLContextEGL::CreateGLContext(dummyCaps,
-                                  shareContext, true,
-                                  surface, config);
+        GLContextEGL::CreateGLContext(dummyCaps,
+                                      shareContext, true,
+                                      config, surface);
     if (!glContext) {
         NS_WARNING("Failed to create GLContext from XSurface");
         sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
         return nullptr;
     }
 
     if (!glContext->Init()) {
         NS_WARNING("Failed to initialize GLContext!");