Title: [139030] trunk/Source/WebCore
Revision
139030
Author
[email protected]
Date
2013-01-07 20:58:03 -0800 (Mon, 07 Jan 2013)

Log Message

[EFL][WebGL] Crash of WebKitTestRunner when running webgl layout tests
https://bugs.webkit.org/show_bug.cgi?id=105936

Patch by Viatcheslav Ostapenko <[email protected]> on 2013-01-07
Reviewed by Laszlo Gombos.

If canvas window becomes invalid don't create pixmap from it and don't
use it for painting.

Improves stability of existing webgl layout tests.

* platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
(WebCore::GraphicsSurfacePrivate::createPixmap):
(WebCore::GraphicsSurfacePrivate::size):
(WebCore::GraphicsSurface::platformGetTextureID):
(WebCore::GraphicsSurface::platformPaintToTextureMapper):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (139029 => 139030)


--- trunk/Source/WebCore/ChangeLog	2013-01-08 04:39:39 UTC (rev 139029)
+++ trunk/Source/WebCore/ChangeLog	2013-01-08 04:58:03 UTC (rev 139030)
@@ -1,3 +1,21 @@
+2013-01-07  Viatcheslav Ostapenko  <[email protected]>
+
+        [EFL][WebGL] Crash of WebKitTestRunner when running webgl layout tests
+        https://bugs.webkit.org/show_bug.cgi?id=105936
+
+        Reviewed by Laszlo Gombos.
+
+        If canvas window becomes invalid don't create pixmap from it and don't 
+        use it for painting.
+
+        Improves stability of existing webgl layout tests.
+
+        * platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp:
+        (WebCore::GraphicsSurfacePrivate::createPixmap):
+        (WebCore::GraphicsSurfacePrivate::size):
+        (WebCore::GraphicsSurface::platformGetTextureID):
+        (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+
 2013-01-07  Hajime Morrita  <[email protected]>
 
         Document::m_activeNode should be always an Element.

Modified: trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp (139029 => 139030)


--- trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2013-01-08 04:39:39 UTC (rev 139029)
+++ trunk/Source/WebCore/platform/graphics/surfaces/glx/GraphicsSurfaceGLX.cpp	2013-01-08 04:58:03 UTC (rev 139030)
@@ -237,7 +237,9 @@
     void createPixmap(uint32_t winId)
     {
         XWindowAttributes attr;
-        XGetWindowAttributes(m_display, winId, &attr);
+        if (!XGetWindowAttributes(m_display, winId, &attr))
+            return;
+        m_size = IntSize(attr.width, attr.height);
 
         XRenderPictFormat* format = XRenderFindVisualFormat(m_display, attr.visual);
         m_hasAlpha = (format->type == PictTypeDirect && format->direct.alphaMask);
@@ -341,8 +343,8 @@
     {
         if (m_size.isEmpty()) {
             XWindowAttributes attr;
-            XGetWindowAttributes(m_display, m_surface, &attr);
-            const_cast<GraphicsSurfacePrivate*>(this)->m_size = IntSize(attr.width, attr.height);
+            if (XGetWindowAttributes(m_display, m_surface, &attr))
+                const_cast<GraphicsSurfacePrivate*>(this)->m_size = IntSize(attr.width, attr.height);
         }
         return m_size;
     }
@@ -410,13 +412,17 @@
 uint32_t GraphicsSurface::platformGetTextureID()
 {
     if (!m_texture) {
+        GLXPixmap pixmap = m_private->glxPixmap();
+        if (!pixmap)
+            return 0;
+
         glGenTextures(1, &m_texture);
         glBindTexture(GL_TEXTURE_2D, m_texture);
         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-        pGlXBindTexImageEXT(m_private->display(), m_private->glxPixmap(), GLX_FRONT_EXT, 0);
+        pGlXBindTexImageEXT(m_private->display(), pixmap, GLX_FRONT_EXT, 0);
     }
 
     return m_texture;
@@ -436,11 +442,17 @@
 void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
 {
     TextureMapperGL* texMapGL = static_cast<TextureMapperGL*>(textureMapper);
+    IntSize size = m_private->size();
+    if (size.isEmpty())
+        return;
+    uint32_t texture = platformGetTextureID();
+    if (!texture)
+        return;
     TransformationMatrix adjustedTransform = transform;
-    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_private->size()), targetRect));
+    adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), size), targetRect));
     TextureMapperGL::Flags flags = m_private->textureIsYInverted() ? TextureMapperGL::ShouldFlipTexture : 0;
     flags |= TextureMapperGL::ShouldBlend;
-    texMapGL->drawTexture(platformGetTextureID(), flags, m_private->size(), targetRect, adjustedTransform, opacity, mask);
+    texMapGL->drawTexture(texture, flags, size, targetRect, adjustedTransform, opacity, mask);
 }
 
 uint32_t GraphicsSurface::platformFrontBuffer() const
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to