Bug 735602 - Add possibility to choose EGL backend on Non-Maemo Linux/Qt/Gtk builds instead ofo GLX. r=jgilbert
authorOleg Romashin <romaxa@gmail.com>
Fri, 23 Mar 2012 14:43:52 -0400
changeset 92052 6bbe864b5162039196e06141f5df542574045313
parent 92051 9c463a882b6f3c3782d1fc3e72c2d87809a27612
child 92053 164c27136716da933ab0f7cd5d16adeccc492d16
push idunknown
push userunknown
push dateunknown
reviewersjgilbert
bugs735602
milestone14.0a1
Bug 735602 - Add possibility to choose EGL backend on Non-Maemo Linux/Qt/Gtk builds instead ofo GLX. r=jgilbert
config/autoconf.mk.in
configure.in
gfx/gl/GLContextProvider.h
gfx/gl/Makefile.in
widget/xpwidgets/nsBaseWidget.cpp
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -198,16 +198,17 @@ MOZ_WEBGL = @MOZ_WEBGL@
 MOZ_ANGLE = @MOZ_ANGLE@
 MOZ_DIRECTX_SDK_PATH = @MOZ_DIRECTX_SDK_PATH@
 MOZ_DIRECTX_SDK_CPU_SUFFIX = @MOZ_DIRECTX_SDK_CPU_SUFFIX@
 MOZ_D3DX9_VERSION = @MOZ_D3DX9_VERSION@
 MOZ_D3DX9_CAB = @MOZ_D3DX9_CAB@
 MOZ_D3DCOMPILER_CAB = @MOZ_D3DCOMPILER_CAB@
 MOZ_D3DX9_DLL = @MOZ_D3DX9_DLL@
 MOZ_D3DCOMPILER_DLL = @MOZ_D3DCOMPILER_DLL@
+MOZ_GL_PROVIDER = @MOZ_GL_PROVIDER@
 
 
 JAVA="@JAVA@"
 JAVAC="@JAVAC@"
 JAR="@JAR@"
 
 TAR=@TAR@
 
--- a/configure.in
+++ b/configure.in
@@ -4777,17 +4777,17 @@ cairo-windows)
     MOZ_INSTRUMENT_EVENT_LOOP=1
     ;;
 
 cairo-gtk2|cairo-gtk2-x11)
     MOZ_WIDGET_TOOLKIT=gtk2
     MOZ_ENABLE_GTK2=1
     MOZ_ENABLE_XREMOTE=1
     MOZ_WEBGL=1
-    MOZ_WEBGL_GLX=1
+    MOZ_GL_DEFAULT_PROVIDER=GLX
 
     AC_DEFINE(MOZ_X11)
     MOZ_X11=1
     USE_FC_FREETYPE=1
 
     TK_CFLAGS='$(MOZ_GTK2_CFLAGS)'
     TK_LIBS='$(MOZ_GTK2_LIBS)'
     AC_DEFINE(MOZ_WIDGET_GTK2)
@@ -4795,17 +4795,17 @@ cairo-gtk2|cairo-gtk2-x11)
     MOZ_INSTRUMENT_EVENT_LOOP=1
     ;;
 
 cairo-qt)
     MOZ_WIDGET_TOOLKIT=qt
     MOZ_ENABLE_QT=1
     if test -z "$WITHOUT_X11"; then
       MOZ_ENABLE_XREMOTE=1
-      MOZ_WEBGL_GLX=1
+      MOZ_GL_DEFAULT_PROVIDER=GLX
       MOZ_X11=1
       AC_DEFINE(MOZ_X11)
       XT_LIBS=
     fi
 
     MOZ_WEBGL=1
     USE_ELF_DYNSTR_GC=
     USE_FC_FREETYPE=1
@@ -6732,17 +6732,17 @@ esac
 if test $MOZ_PLATFORM_MAEMO; then
    AC_DEFINE_UNQUOTED([MOZ_PLATFORM_MAEMO], $MOZ_PLATFORM_MAEMO)
 
    if test -z "$MOZ_ENABLE_DBUS"; then
        AC_MSG_ERROR([DBus is required when building for Maemo])
    fi
 
    MOZ_GFX_OPTIMIZE_MOBILE=1
-   MOZ_WEBGL_GLX=
+   MOZ_GL_DEFAULT_PROVIDER=EGL
    MOZ_MAEMO_LIBLOCATION=
 
    if test $MOZ_PLATFORM_MAEMO = 5; then
       dnl if we have Xcomposite we should also have Xdamage and Xfixes
       MOZ_CHECK_HEADERS([X11/extensions/Xdamage.h], [],
           [AC_MSG_ERROR([Couldn't find X11/extensions/Xdamage.h which is required for composited plugins.])])
       AC_CHECK_LIB(Xcomposite, XCompositeRedirectWindow, [XCOMPOSITE_LIBS="-lXcomposite -lXdamage -lXfixes"],
                    [MISSING_X="$MISSING_X -lXcomposite"], $XLIBS)
@@ -6860,16 +6860,32 @@ MOZ_ARG_ENABLE_BOOL(egl-xrender-composit
 
 if test -n "$MOZ_EGL_XRENDER_COMPOSITE"; then
     AC_DEFINE(MOZ_EGL_XRENDER_COMPOSITE)
 fi
 
 AC_SUBST(MOZ_EGL_XRENDER_COMPOSITE)
 
 dnl ========================================================
+dnl GL provider
+dnl ========================================================
+MOZ_GL_PROVIDER=
+MOZ_ARG_WITH_STRING(gl-provider,
+[  --with-gl-provider=ID
+                          Set GL provider backend type],
+[ val=`echo $withval`
+    MOZ_GL_PROVIDER="$val"])
+
+if test -n "$MOZ_GL_PROVIDER"; then
+MOZ_GL_DEFAULT_PROVIDER=$MOZ_GL_PROVIDER
+AC_SUBST(MOZ_GL_PROVIDER)
+AC_DEFINE_UNQUOTED(MOZ_GL_PROVIDER, GLContextProvider$MOZ_GL_PROVIDER)
+fi
+
+dnl ========================================================
 dnl = faststripe theme
 dnl ========================================================
 MOZ_ARG_ENABLE_BOOL(faststripe,
 [  --enable-faststripe     Use faststripe theme],
     MOZ_THEME_FASTSTRIPE=1,
     MOZ_THEME_FASTSTRIPE= )
 AC_SUBST(MOZ_THEME_FASTSTRIPE)
 
@@ -8713,22 +8729,22 @@ if test "$MOZ_X11"; then
 
     if test -n "$MISSING_X"; then
         AC_MSG_ERROR([ Could not find the following X libraries: $MISSING_X ]);
     fi
 
 fi # MOZ_X11
 
 dnl Check for headers, etc. needed by WebGL.
-if test -n "$MOZ_WEBGL_GLX"; then
+if test "$MOZ_GL_DEFAULT_PROVIDER" = "GLX"; then
     MOZ_CHECK_HEADER(GL/glx.h)
     if test "$ac_cv_header_GL_glx_h" != "yes"; then
         AC_MSG_ERROR([Can't find header GL/glx.h for WebGL (install mesa-common-dev (Ubuntu), mesa-libGL-devel (Fedora), or Mesa-devel (openSUSE))])
     fi
-fi # MOZ_WEBGL_GLX
+fi # MOZ_GL_DEFAULT_PROVIDER=GLX
 fi # COMPILE_ENVIRONMENT
 
 if test "$USE_FC_FREETYPE"; then
     if test "$COMPILE_ENVIRONMENT"; then
     	_SAVE_CPPFLAGS="$CPPFLAGS"
     	CPPFLAGS="$CPPFLAGS $FT2_CFLAGS $XCFLAGS"
         MOZ_CHECK_HEADERS([fontconfig/fcfreetype.h], ,
             [AC_MSG_ERROR(Can't find header fontconfig/fcfreetype.h.)], [#include <fontconfig/fontconfig.h>])
--- a/gfx/gl/GLContextProvider.h
+++ b/gfx/gl/GLContextProvider.h
@@ -95,16 +95,23 @@ namespace gl {
 // X11, but only if we didn't use EGL above
 #if defined(MOZ_X11) && !defined(GL_CONTEXT_PROVIDER_DEFAULT)
 #define GL_CONTEXT_PROVIDER_NAME GLContextProviderGLX
 #include "GLContextProviderImpl.h"
 #undef GL_CONTEXT_PROVIDER_NAME
 #define GL_CONTEXT_PROVIDER_DEFAULT GLContextProviderGLX
 #endif
 
+#ifdef MOZ_GL_PROVIDER
+#define GL_CONTEXT_PROVIDER_NAME MOZ_GL_PROVIDER
+#include "GLContextProviderImpl.h"
+#undef GL_CONTEXT_PROVIDER_NAME
+#define GL_CONTEXT_PROVIDER_DEFAULT MOZ_GL_PROVIDER
+#endif
+
 #ifdef GL_CONTEXT_PROVIDER_DEFAULT
 typedef GL_CONTEXT_PROVIDER_DEFAULT GLContextProvider;
 #else
 typedef GLContextProviderNull GLContextProvider;
 #endif
 
 #undef IN_GL_CONTEXT_PROVIDER_H
 
--- a/gfx/gl/Makefile.in
+++ b/gfx/gl/Makefile.in
@@ -108,16 +108,20 @@ endif
 ifeq ($(MOZ_WIDGET_TOOLKIT),android)
 GL_PROVIDER = EGL
 endif
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
 GL_PROVIDER = EGL
 endif
 
+ifdef MOZ_GL_PROVIDER
+GL_PROVIDER = $(MOZ_GL_PROVIDER)
+endif
+
 # Mac is a special snowflake
 ifeq ($(GL_PROVIDER),CGL)
 CMMSRCS += GLContextProvider$(GL_PROVIDER).mm
 else
 CPPSRCS += GLContextProvider$(GL_PROVIDER).cpp
 endif
 
 ifeq ($(GL_PROVIDER),EGL)
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -755,17 +755,17 @@ nsBaseWidget::AutoUseBasicLayerManager::
 nsBaseWidget::AutoUseBasicLayerManager::~AutoUseBasicLayerManager()
 {
   mWidget->mTemporarilyUseBasicLayerManager = false;
 }
 
 bool
 nsBaseWidget::GetShouldAccelerate()
 {
-#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5)
+#if defined(XP_WIN) || defined(ANDROID) || (MOZ_PLATFORM_MAEMO > 5) || defined(MOZ_GL_PROVIDER)
   bool accelerateByDefault = true;
 #elif defined(XP_MACOSX)
 /* quickdraw plugins don't work with OpenGL so we need to avoid OpenGL when we want to support
  * them. e.g. 10.5 */
 # if defined(NP_NO_QUICKDRAW)
   bool accelerateByDefault = true;
 
   // 10.6.2 and lower have a bug involving textures and pixel buffer objects