Title: [134255] trunk/Source/WebCore
Revision
134255
Author
[email protected]
Date
2012-11-12 10:36:56 -0800 (Mon, 12 Nov 2012)

Log Message

GraphicsSurfaceGLX does not handle transparency correctly.
https://bugs.webkit.org/show_bug.cgi?id=101943

GraphicsSurfacGLX must consistently use RGBA texture format.
glXCreateWindow must be called after creating the XWindow
that serves as a temporary offscreen texture storage, in order
to allow for transparency.
When creating the offscreen XWindow we must make sure,
that we use a framebuffer configuration that supports
an alpha mask.

Reviewed by Noam Rosenthal.

* platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
(WebCore):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::createSurface):
(GraphicsSurfacePrivate):
(WebCore::GraphicsSurface::platformPaintToTextureMapper):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (134254 => 134255)


--- trunk/Source/WebCore/ChangeLog	2012-11-12 18:19:51 UTC (rev 134254)
+++ trunk/Source/WebCore/ChangeLog	2012-11-12 18:36:56 UTC (rev 134255)
@@ -1,3 +1,26 @@
+2012-11-12  Zeno Albisser  <[email protected]>
+
+        GraphicsSurfaceGLX does not handle transparency correctly.
+        https://bugs.webkit.org/show_bug.cgi?id=101943
+
+        GraphicsSurfacGLX must consistently use RGBA texture format.
+        glXCreateWindow must be called after creating the XWindow
+        that serves as a temporary offscreen texture storage, in order
+        to allow for transparency.
+        When creating the offscreen XWindow we must make sure,
+        that we use a framebuffer configuration that supports
+        an alpha mask.
+
+        Reviewed by Noam Rosenthal.
+
+        * platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
+        (WebCore):
+        (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurfacePrivate::createSurface):
+        (GraphicsSurfacePrivate):
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+
 2012-11-12  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r134225.

Modified: trunk/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp (134254 => 134255)


--- trunk/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp	2012-11-12 18:19:51 UTC (rev 134254)
+++ trunk/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp	2012-11-12 18:36:56 UTC (rev 134255)
@@ -51,6 +51,20 @@
 static PFNGLDELETEFRAMEBUFFERSPROC pGlDeleteFramebuffers = 0;
 static PFNGLFRAMEBUFFERTEXTURE2DPROC pGlFramebufferTexture2D = 0;
 
+static int attributes[] = {
+    GLX_LEVEL, 0,
+    GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
+    GLX_RENDER_TYPE,   GLX_RGBA_BIT,
+    GLX_RED_SIZE,      1,
+    GLX_GREEN_SIZE,    1,
+    GLX_BLUE_SIZE,     1,
+    GLX_ALPHA_SIZE,    1,
+    GLX_DEPTH_SIZE,    1,
+    GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
+    GLX_DOUBLEBUFFER,  True,
+    None
+};
+
 class OffScreenRootWindow {
 public:
     OffScreenRootWindow()
@@ -110,13 +124,13 @@
     GLX_LEVEL,                          0,
     GLX_DRAWABLE_TYPE,                  GLX_PIXMAP_BIT | GLX_WINDOW_BIT,
     GLX_BIND_TO_TEXTURE_TARGETS_EXT,    GLX_TEXTURE_2D_BIT_EXT,
-    GLX_BIND_TO_TEXTURE_RGB_EXT,        TRUE,
+    GLX_BIND_TO_TEXTURE_RGBA_EXT,       TRUE,
     0
 };
 
 static const int glxAttributes[] = {
     GLX_TEXTURE_FORMAT_EXT,
-    GLX_TEXTURE_FORMAT_RGB_EXT,
+    GLX_TEXTURE_FORMAT_RGBA_EXT,
     GLX_TEXTURE_TARGET_EXT,
     GLX_TEXTURE_2D_EXT,
     0
@@ -127,9 +141,12 @@
         : m_display(0)
         , m_xPixmap(0)
         , m_glxPixmap(0)
+        , m_surface(0)
+        , m_glxSurface(0)
         , m_glContext(0)
         , m_detachedContext(0)
         , m_detachedSurface(0)
+        , m_fbConfig(0)
         , m_textureIsYInverted(false)
         , m_hasAlpha(false)
     {
@@ -160,21 +177,26 @@
         UNUSED_PARAM(shareContext);
 #endif
 
-        int attributes[] = {
-            GLX_LEVEL, 0,
-            GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
-            GLX_RENDER_TYPE,   GLX_RGBA_BIT,
-            GLX_RED_SIZE,      1,
-            GLX_GREEN_SIZE,    1,
-            GLX_BLUE_SIZE,     1,
-            GLX_DOUBLEBUFFER,  True,
-            None
-        };
+        int numReturned;
+        GLXFBConfig* fbConfigs = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &numReturned);
 
-        int numReturned;
-        m_fbConfigs = glXChooseFBConfig(m_display, DefaultScreen(m_display), attributes, &numReturned);
+        // Make sure that we choose a configuration that supports an alpha mask.
+        for (int i = 0; i < numReturned; ++i) {
+            XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, fbConfigs[i]);
+            if (!visualInfo)
+                continue;
+
+            XRenderPictFormat* format = XRenderFindVisualFormat(m_display, visualInfo->visual);
+            if (format && format->direct.alphaMask > 0) {
+                m_fbConfig = fbConfigs[i];
+                break;
+            }
+        }
+
+        XFree(fbConfigs);
+
         // Create a GLX context for OpenGL rendering
-        m_glContext = glXCreateNewContext(m_display, m_fbConfigs[0], GLX_RGBA_TYPE, shareContextObject, true);
+        m_glContext = glXCreateNewContext(m_display, m_fbConfig, GLX_RGBA_TYPE, shareContextObject, true);
     }
 
     ~GraphicsSurfacePrivate()
@@ -187,20 +209,18 @@
             XFreePixmap(m_display, m_xPixmap);
         m_xPixmap = 0;
 
-        if (m_fbConfigs)
-            XFree(m_fbConfigs);
-
         if (m_glContext)
             glXDestroyContext(m_display, m_glContext);
     }
 
     uint32_t createSurface(const IntSize& size)
     {
-        XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfigs[0]);
+        XVisualInfo* visualInfo = glXGetVisualFromFBConfig(m_display, m_fbConfig);
         if (!visualInfo)
             return 0;
 
         Colormap cmap = XCreateColormap(m_display, m_offScreenWindow.getXWindow(), visualInfo->visual, AllocNone);
+
         XSetWindowAttributes a;
         a.background_pixel = WhitePixel(m_display, 0);
         a.border_pixel = BlackPixel(m_display, 0);
@@ -210,6 +230,7 @@
             CWBackPixel | CWBorderPixel | CWColormap, &a);
         XSetWindowBackgroundPixmap(m_display, m_surface, 0);
         XCompositeRedirectWindow(m_display, m_surface, CompositeRedirectManual);
+        m_glxSurface = glXCreateWindow(m_display, m_fbConfig, m_surface, 0);
         XFree(visualInfo);
 
         // Make sure the XRender Extension is available.
@@ -325,10 +346,11 @@
     Pixmap m_xPixmap;
     GLXPixmap m_glxPixmap;
     Window m_surface;
+    Window m_glxSurface;
     GLXContext m_glContext;
     GLXContext m_detachedContext;
     GLXDrawable m_detachedSurface;
-    GLXFBConfig* m_fbConfigs;
+    GLXFBConfig m_fbConfig;
     bool m_textureIsYInverted;
     bool m_hasAlpha;
 };
@@ -388,6 +410,7 @@
     TransformationMatrix adjustedTransform = transform;
     adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_size), targetRect));
     TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
+    flags |= TextureMapperGL::SupportsBlending;
     texMapGL->drawTexture(platformGetTextureID(), flags, m_size, targetRect, adjustedTransform, opacity, mask);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to