Title: [148264] trunk
Revision
148264
Author
zandober...@gmail.com
Date
2013-04-12 00:14:02 -0700 (Fri, 12 Apr 2013)

Log Message

Unreviewed, rolling out r148262.
http://trac.webkit.org/changeset/148262
https://bugs.webkit.org/show_bug.cgi?id=114493

Cairo dep should now build, rolling r148247 back in (Requested
by zdobersek on #webkit).

Patch by Commit Queue <rn...@webkit.org> on 2013-04-12

.: 

* Source/autotools/FindDependencies.m4:
* Source/autotools/PrintBuildConfiguration.m4:
* Source/autotools/SetupWebKitFeatures.m4:

Source/WebCore: 

* platform/graphics/GraphicsContext.cpp:
(WebCore):
* platform/graphics/ImageBuffer.cpp:
(WebCore):
* platform/graphics/cairo/GLContext.h:
(GLContext):
* platform/graphics/cairo/GraphicsContextCairo.cpp:
(WebCore::GraphicsContext::isAcceleratedContext):
(WebCore):
* platform/graphics/cairo/ImageBufferCairo.cpp:
(WebCore::ImageBufferData::ImageBufferData):
(WebCore):
(WebCore::createCairoGLSurface):
(WebCore::ImageBuffer::ImageBuffer):
(WebCore::ImageBuffer::platformTransformColorSpace):
(WebCore::mapSurfaceToImage):
(WebCore::unmapSurfaceFromImage):
(WebCore::getImageData):
(WebCore::ImageBuffer::putByteArray):
(WebCore::ImageBufferData::paintToTextureMapper):
(WebCore::ImageBuffer::platformLayer):
* platform/graphics/cairo/ImageBufferDataCairo.h:
(ImageBufferData):
* platform/graphics/egl/GLContextEGL.cpp:
(WebCore::GLContextEGL::GLContextEGL):
(WebCore::GLContextEGL::~GLContextEGL):
(WebCore::GLContextEGL::cairoDevice):
(WebCore):
* platform/graphics/egl/GLContextEGL.h:
* platform/graphics/glx/GLContextGLX.cpp:
(WebCore::GLContextGLX::GLContextGLX):
(WebCore::GLContextGLX::~GLContextGLX):
(WebCore::GLContextGLX::cairoDevice):
(WebCore):
* platform/graphics/glx/GLContextGLX.h:
(GLContextGLX):

Tools: 

* Scripts/webkitdirs.pm:
(buildAutotoolsProject):
* gtk/jhbuild.modules:

Modified Paths

Diff

Modified: trunk/ChangeLog (148263 => 148264)


--- trunk/ChangeLog	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/ChangeLog	2013-04-12 07:14:02 UTC (rev 148264)
@@ -1,3 +1,16 @@
+2013-04-12  Commit Queue  <rn...@webkit.org>
+
+        Unreviewed, rolling out r148262.
+        http://trac.webkit.org/changeset/148262
+        https://bugs.webkit.org/show_bug.cgi?id=114493
+
+        Cairo dep should now build, rolling r148247 back in (Requested
+        by zdobersek on #webkit).
+
+        * Source/autotools/FindDependencies.m4:
+        * Source/autotools/PrintBuildConfiguration.m4:
+        * Source/autotools/SetupWebKitFeatures.m4:
+
 2013-04-11  Commit Queue  <rn...@webkit.org>
 
         Unreviewed, rolling out r148247.

Modified: trunk/Source/WebCore/ChangeLog (148263 => 148264)


--- trunk/Source/WebCore/ChangeLog	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/ChangeLog	2013-04-12 07:14:02 UTC (rev 148264)
@@ -1,3 +1,49 @@
+2013-04-12  Commit Queue  <rn...@webkit.org>
+
+        Unreviewed, rolling out r148262.
+        http://trac.webkit.org/changeset/148262
+        https://bugs.webkit.org/show_bug.cgi?id=114493
+
+        Cairo dep should now build, rolling r148247 back in (Requested
+        by zdobersek on #webkit).
+
+        * platform/graphics/GraphicsContext.cpp:
+        (WebCore):
+        * platform/graphics/ImageBuffer.cpp:
+        (WebCore):
+        * platform/graphics/cairo/GLContext.h:
+        (GLContext):
+        * platform/graphics/cairo/GraphicsContextCairo.cpp:
+        (WebCore::GraphicsContext::isAcceleratedContext):
+        (WebCore):
+        * platform/graphics/cairo/ImageBufferCairo.cpp:
+        (WebCore::ImageBufferData::ImageBufferData):
+        (WebCore):
+        (WebCore::createCairoGLSurface):
+        (WebCore::ImageBuffer::ImageBuffer):
+        (WebCore::ImageBuffer::platformTransformColorSpace):
+        (WebCore::mapSurfaceToImage):
+        (WebCore::unmapSurfaceFromImage):
+        (WebCore::getImageData):
+        (WebCore::ImageBuffer::putByteArray):
+        (WebCore::ImageBufferData::paintToTextureMapper):
+        (WebCore::ImageBuffer::platformLayer):
+        * platform/graphics/cairo/ImageBufferDataCairo.h:
+        (ImageBufferData):
+        * platform/graphics/egl/GLContextEGL.cpp:
+        (WebCore::GLContextEGL::GLContextEGL):
+        (WebCore::GLContextEGL::~GLContextEGL):
+        (WebCore::GLContextEGL::cairoDevice):
+        (WebCore):
+        * platform/graphics/egl/GLContextEGL.h:
+        * platform/graphics/glx/GLContextGLX.cpp:
+        (WebCore::GLContextGLX::GLContextGLX):
+        (WebCore::GLContextGLX::~GLContextGLX):
+        (WebCore::GLContextGLX::cairoDevice):
+        (WebCore):
+        * platform/graphics/glx/GLContextGLX.h:
+        (GLContextGLX):
+
 2013-04-11  Alexey Proskuryakov  <a...@apple.com>
 
         Reduce includes of CachedSVGDocument.h

Modified: trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/GraphicsContext.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -757,7 +757,7 @@
 }
 #endif
 
-#if !USE(SKIA) && !USE(CG)
+#if !USE(SKIA) && !USE(CG) && !USE(CAIRO)
 bool GraphicsContext::isAcceleratedContext() const
 {
     return false;

Modified: trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/ImageBuffer.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -99,7 +99,7 @@
     genericConvertToLuminanceMask();
 }
 
-#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA)
+#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA) && !USE(CAIRO)
 PlatformLayer* ImageBuffer::platformLayer() const
 {
     return 0;

Modified: trunk/Source/WebCore/platform/graphics/cairo/GLContext.h (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/cairo/GLContext.h	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/cairo/GLContext.h	2013-04-12 07:14:02 UTC (rev 148264)
@@ -25,6 +25,8 @@
 #include <wtf/Noncopyable.h>
 #include <wtf/PassOwnPtr.h>
 
+typedef struct _cairo_device cairo_device_t;
+
 #if PLATFORM(X11)
 typedef struct _XDisplay Display;
 #endif
@@ -46,6 +48,7 @@
     virtual void waitNative() = 0;
     virtual bool canRenderToDefaultFramebuffer() = 0;
     virtual IntSize defaultFrameBufferSize() = 0;
+    virtual cairo_device_t* cairoDevice() = 0;
 
 #if PLATFORM(X11)
     static Display* sharedX11Display();

Modified: trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -1142,6 +1142,11 @@
     return platformContext()->imageInterpolationQuality();
 }
 
+bool GraphicsContext::isAcceleratedContext() const
+{
+    return cairo_surface_get_type(cairo_get_target(platformContext()->cr())) == CAIRO_SURFACE_TYPE_GL;
+}
+
 #if ENABLE(3D_RENDERING) && USE(TEXTURE_MAPPER)
 TransformationMatrix GraphicsContext::get3DTransform() const
 {

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -44,22 +44,68 @@
 #include <wtf/text/Base64.h>
 #include <wtf/text/WTFString.h>
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "GLContext.h"
+#include "OpenGLShims.h"
+#include "TextureMapperGL.h"
+#include <cairo-gl.h>
+#endif
+
 using namespace std;
 
 namespace WebCore {
 
-ImageBufferData::ImageBufferData(const IntSize&)
+ImageBufferData::ImageBufferData(const IntSize& size)
     : m_platformContext(0)
+    , m_size(size)
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    , m_texture(0)
+#endif
 {
 }
 
-ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode, bool& success)
+#if ENABLE(ACCELERATED_2D_CANVAS)
+PassRefPtr<cairo_surface_t> createCairoGLSurface(const IntSize& size, uint32_t& texture)
+{
+    GLContext::sharingContext()->makeContextCurrent();
+
+    // We must generate the texture ourselves, because there is no Cairo API for extracting it
+    // from a pre-existing surface.
+    glGenTextures(1, &texture);
+    glBindTexture(GL_TEXTURE_2D, texture);
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
+    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+
+    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+    glTexImage2D(GL_TEXTURE_2D, 0 /* level */, GL_RGBA8, size.width(), size.height(), 0 /* border */, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+
+    GLContext* context = GLContext::sharingContext();
+    cairo_device_t* device = context->cairoDevice();
+
+    // Thread-awareness is a huge performance hit on non-Intel drivers.
+    cairo_gl_device_set_thread_aware(device, FALSE);
+
+    return adoptRef(cairo_gl_surface_create_for_texture(device, CAIRO_CONTENT_COLOR_ALPHA, texture, size.width(), size.height()));
+}
+#endif
+
+ImageBuffer::ImageBuffer(const IntSize& size, float /* resolutionScale */, ColorSpace, RenderingMode renderingMode, bool& success)
     : m_data(size)
     , m_size(size)
     , m_logicalSize(size)
 {
     success = false;  // Make early return mean error.
-    m_data.m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height()));
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    if (renderingMode == Accelerated)
+        m_data.m_surface = createCairoGLSurface(size, m_data.m_texture);
+    else
+#endif
+        m_data.m_surface = adoptRef(cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height()));
+
     if (cairo_surface_status(m_data.m_surface.get()) != CAIRO_STATUS_SUCCESS)
         return;  // create will notice we didn't set m_initialized and fail.
 
@@ -114,7 +160,9 @@
 
 void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
 {
-    ASSERT(cairo_surface_get_type(m_data.m_surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
+    // FIXME: Enable color space conversions on accelerated canvases.
+    if (cairo_surface_get_type(m_data.m_surface.get()) != CAIRO_SURFACE_TYPE_IMAGE)
+        return;
 
     unsigned char* dataSrc = ""
     int stride = cairo_image_surface_get_stride(m_data.m_surface.get());
@@ -133,13 +181,46 @@
     cairo_surface_mark_dirty_rectangle(m_data.m_surface.get(), 0, 0, m_size.width(), m_size.height());
 }
 
+static cairo_surface_t* mapSurfaceToImage(cairo_surface_t* surface, const IntSize& size)
+{
+    if (cairo_surface_get_type(surface) == CAIRO_SURFACE_TYPE_IMAGE)
+        return surface;
+
+    cairo_surface_t* imageSurface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, size.width(), size.height());
+    RefPtr<cairo_t> cr = adoptRef(cairo_create(imageSurface));
+    cairo_set_source_surface(cr.get(), surface, 0, 0);
+    cairo_paint(cr.get());
+    return imageSurface;
+}
+
+static void unmapSurfaceFromImage(cairo_surface_t* surface, cairo_surface_t* imageSurface, const IntRect& dirtyRectangle = IntRect())
+{
+    if (surface == imageSurface && dirtyRectangle.isEmpty())
+        return;
+
+    if (dirtyRectangle.isEmpty()) {
+        cairo_surface_destroy(imageSurface);
+        return;
+    }
+
+    if (surface == imageSurface) {
+        cairo_surface_mark_dirty_rectangle(surface, dirtyRectangle.x(), dirtyRectangle.y(), dirtyRectangle.width(), dirtyRectangle.height());
+        return;
+    }
+
+    RefPtr<cairo_t> cr = adoptRef(cairo_create(surface));
+    cairo_set_source_surface(cr.get(), imageSurface, 0, 0);
+    cairo_rectangle(cr.get(), dirtyRectangle.x(), dirtyRectangle.y(), dirtyRectangle.width(), dirtyRectangle.height());
+    cairo_fill(cr.get());
+    cairo_surface_destroy(imageSurface);
+}
+
 template <Multiply multiplied>
 PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBufferData& data, const IntSize& size)
 {
-    ASSERT(cairo_surface_get_type(data.m_surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
-
     RefPtr<Uint8ClampedArray> result = Uint8ClampedArray::createUninitialized(rect.width() * rect.height() * 4);
-    unsigned char* dataSrc = ""
+    cairo_surface_t* imageSurface = mapSurfaceToImage(data.m_surface.get(), size);
+    unsigned char* dataSrc = ""
     unsigned char* dataDst = result->data();
 
     if (rect.x() < 0 || rect.y() < 0 || (rect.x() + rect.width()) > size.width() || (rect.y() + rect.height()) > size.height())
@@ -167,7 +248,7 @@
         endy = size.height();
     int numRows = endy - originy;
 
-    int stride = cairo_image_surface_get_stride(data.m_surface.get());
+    int stride = cairo_image_surface_get_stride(imageSurface);
     unsigned destBytesPerRow = 4 * rect.width();
 
     unsigned char* destRows = dataDst + desty * destBytesPerRow + destx * 4;
@@ -200,6 +281,7 @@
         destRows += destBytesPerRow;
     }
 
+    unmapSurfaceFromImage(data.m_surface.get(), imageSurface);
     return result.release();
 }
 
@@ -215,10 +297,9 @@
 
 void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, const IntSize& sourceSize, const IntRect& sourceRect, const IntPoint& destPoint, CoordinateSystem)
 {
-    ASSERT(cairo_surface_get_type(m_data.m_surface.get()) == CAIRO_SURFACE_TYPE_IMAGE);
+    cairo_surface_t* imageSurface = mapSurfaceToImage(m_data.m_surface.get(), sourceSize);
+    unsigned char* dataDst = cairo_image_surface_get_data(imageSurface);
 
-    unsigned char* dataDst = cairo_image_surface_get_data(m_data.m_surface.get());
-
     ASSERT(sourceRect.width() > 0);
     ASSERT(sourceRect.height() > 0);
 
@@ -246,7 +327,7 @@
     int numRows = endy - desty;
 
     unsigned srcBytesPerRow = 4 * sourceSize.width();
-    int stride = cairo_image_surface_get_stride(m_data.m_surface.get());
+    int stride = cairo_image_surface_get_stride(imageSurface);
 
     unsigned char* srcRows = source->data() + originy * srcBytesPerRow + originx * 4;
     for (int y = 0; y < numRows; ++y) {
@@ -274,7 +355,8 @@
         }
         srcRows += srcBytesPerRow;
     }
-    cairo_surface_mark_dirty_rectangle(m_data.m_surface.get(), destx, desty, numColumns, numRows);
+
+    unmapSurfaceFromImage(m_data.m_surface.get(), imageSurface, IntRect(destx, desty, numColumns, numRows));
 }
 
 #if !PLATFORM(GTK)
@@ -309,4 +391,32 @@
 }
 #endif
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+void ImageBufferData::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& matrix, float opacity)
+{
+    if (textureMapper->accelerationMode() != TextureMapper::OpenGLMode) {
+        notImplemented();
+        return;
+    }
+
+    ASSERT(m_texture);
+
+    // Cairo may change the active context, so we make sure to change it back after flushing.
+    GLContext* previousActiveContext = GLContext::getCurrent();
+    cairo_surface_flush(m_surface.get());
+    previousActiveContext->makeContextCurrent();
+
+    static_cast<TextureMapperGL*>(textureMapper)->drawTexture(m_texture, TextureMapperGL::ShouldBlend, m_size, targetRect, matrix, opacity);
+}
+#endif
+
+PlatformLayer* ImageBuffer::platformLayer() const
+{
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    if (m_data.m_texture)
+        return const_cast<ImageBufferData*>(&m_data);
+#endif
+    return 0;
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h	2013-04-12 07:14:02 UTC (rev 148264)
@@ -26,16 +26,31 @@
 #include "PlatformContextCairo.h"
 #include "RefPtrCairo.h"
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include "TextureMapper.h"
+#include "TextureMapperPlatformLayer.h"
+#endif
+
 namespace WebCore {
 
 class IntSize;
 
-class ImageBufferData {
+class ImageBufferData
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    : public TextureMapperPlatformLayer
+#endif
+{
 public:
     ImageBufferData(const IntSize&);
 
     RefPtr<cairo_surface_t> m_surface;
     PlatformContextCairo m_platformContext;
+    IntSize m_size;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    virtual void paintToTextureMapper(TextureMapper*, const FloatRect& target, const TransformationMatrix&, float opacity);
+    uint32_t m_texture;
+#endif
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -22,6 +22,7 @@
 #if USE(EGL)
 
 #include "GraphicsContext3D.h"
+#include <cairo.h>
 #include <wtf/OwnPtr.h>
 
 #if USE(OPENGL_ES_2)
@@ -31,6 +32,10 @@
 #include "OpenGLShims.h"
 #endif
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include <cairo-gl.h>
+#endif
+
 namespace WebCore {
 
 static EGLDisplay gSharedEGLDisplay = EGL_NO_DISPLAY;
@@ -208,11 +213,15 @@
     : m_context(context)
     , m_surface(surface)
     , m_type(type)
+    , m_cairoDevice(0)
 {
 }
 
 GLContextEGL::~GLContextEGL()
 {
+    if (m_cairoDevice)
+        cairo_device_destroy(m_cairoDevice);
+
     EGLDisplay display = sharedEGLDisplay();
     if (m_context) {
         glBindFramebuffer(GL_FRAMEBUFFER, 0);
@@ -264,6 +273,18 @@
     eglWaitNative(EGL_CORE_NATIVE_ENGINE);
 }
 
+cairo_device_t* GLContextEGL::cairoDevice()
+{
+    if (m_cairoDevice)
+        return m_cairoDevice;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    m_cairoDevice = cairo_egl_device_create(sharedEGLDisplay(), m_context);
+#endif
+
+    return m_cairoDevice;
+}
+
 #if ENABLE(WEBGL)
 PlatformGraphicsContext3D GLContextEGL::platformContext()
 {

Modified: trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/egl/GLContextEGL.h	2013-04-12 07:14:02 UTC (rev 148264)
@@ -41,8 +41,8 @@
     virtual void waitNative();
     virtual bool canRenderToDefaultFramebuffer();
     virtual IntSize defaultFrameBufferSize();
+    virtual cairo_device_t* cairoDevice();
 
-
 #if ENABLE(WEBGL)
     virtual PlatformGraphicsContext3D platformContext();
 #endif
@@ -59,6 +59,7 @@
     EGLContext m_context;
     EGLSurface m_surface;
     EGLSurfaceType m_type;
+    cairo_device_t* m_cairoDevice;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.cpp	2013-04-12 07:14:02 UTC (rev 148264)
@@ -23,8 +23,13 @@
 #include "GraphicsContext3D.h"
 #include "OpenGLShims.h"
 #include <GL/glx.h>
+#include <cairo.h>
 #include <wtf/OwnPtr.h>
 
+#if ENABLE(ACCELERATED_2D_CANVAS)
+#include <cairo-gl.h>
+#endif
+
 namespace WebCore {
 
 PassOwnPtr<GLContextGLX> GLContextGLX::createWindowContext(XID window, GLContext* sharingContext)
@@ -168,6 +173,7 @@
     , m_pbuffer(0)
     , m_pixmap(0)
     , m_glxPixmap(0)
+    , m_cairoDevice(0)
 {
 }
 
@@ -177,11 +183,15 @@
     , m_pbuffer(0)
     , m_pixmap(pixmap)
     , m_glxPixmap(glxPixmap)
+    , m_cairoDevice(0)
 {
 }
 
 GLContextGLX::~GLContextGLX()
 {
+    if (m_cairoDevice)
+        cairo_device_destroy(m_cairoDevice);
+
     if (m_context) {
         // This may be necessary to prevent crashes with NVidia's closed source drivers. Originally
         // from Mozilla's 3D canvas implementation at: http://bitbucket.org/ilmari/canvas3d/
@@ -251,6 +261,18 @@
     glXWaitX();
 }
 
+cairo_device_t* GLContextGLX::cairoDevice()
+{
+    if (m_cairoDevice)
+        return m_cairoDevice;
+
+#if ENABLE(ACCELERATED_2D_CANVAS)
+    m_cairoDevice = cairo_glx_device_create(sharedX11Display(), m_context);
+#endif
+
+    return m_cairoDevice;
+}
+
 #if USE(3D_GRAPHICS)
 PlatformGraphicsContext3D GLContextGLX::platformContext()
 {

Modified: trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h (148263 => 148264)


--- trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/WebCore/platform/graphics/glx/GLContextGLX.h	2013-04-12 07:14:02 UTC (rev 148264)
@@ -46,6 +46,7 @@
     virtual void waitNative();
     virtual bool canRenderToDefaultFramebuffer();
     virtual IntSize defaultFrameBufferSize();
+    virtual cairo_device_t* cairoDevice();
 
 #if USE(3D_GRAPHICS)
     virtual PlatformGraphicsContext3D platformContext();
@@ -63,6 +64,7 @@
     GLXPbuffer m_pbuffer;
     Pixmap m_pixmap;
     GLXPixmap m_glxPixmap;
+    cairo_device_t* m_cairoDevice;
 };
 
 } // namespace WebCore

Modified: trunk/Source/autotools/FindDependencies.m4 (148263 => 148264)


--- trunk/Source/autotools/FindDependencies.m4	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/autotools/FindDependencies.m4	2013-04-12 07:14:02 UTC (rev 148264)
@@ -298,6 +298,7 @@
         enable_accelerated_compositing="no";
     fi
 fi
+
 if test "$enable_gamepad" = "yes" && test "$os_linux" = no; then
     AC_MSG_WARN([Gamepad support is only available on Linux. Disabling Gamepad support.])
     enable_gamepad=no;
@@ -465,6 +466,21 @@
 fi
 AC_SUBST([OPENGL_LIBS])
 
+enable_accelerated_canvas=no
+if test "$enable_accelerated_compositing" = "yes" && test "$with_acceleration_backend" = "opengl"; then
+    CAIRO_GL_LIBS="cairo-gl"
+    if test "$enable_glx" = "yes"; then
+        CAIRO_GL_LIBS+=" cairo-glx"
+    fi
+    if test "$enable_egl" = "yes"; then
+        CAIRO_GL_LIBS+=" cairo-egl"
+    fi
+
+    # At the moment CairoGL does not add any extra cflags and libraries, so we can
+    # safely ignore CAIRO_GL_LIBS and CAIRO_GL_CFLAGS for the moment.
+    PKG_CHECK_MODULES(CAIRO_GL, $CAIRO_GL_LIBS, [enable_accelerated_canvas=yes], [enable_accelerated_canvas=no])
+fi
+
 if test "$enable_gamepad" = "yes"; then
     PKG_CHECK_MODULES([GAMEPAD], [gio-unix-2.0 gudev-1.0])
 

Modified: trunk/Source/autotools/PrintBuildConfiguration.m4 (148263 => 148264)


--- trunk/Source/autotools/PrintBuildConfiguration.m4	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/autotools/PrintBuildConfiguration.m4	2013-04-12 07:14:02 UTC (rev 148264)
@@ -16,6 +16,7 @@
  WebKit1 support                                          : $enable_webkit1
  WebKit2 support                                          : $enable_webkit2
  Accelerated Compositing                                  : $enable_accelerated_compositing
+ Accelerated 2D canvas                                    : $enable_accelerated_canvas
  Gamepad support                                          : $enable_gamepad
  Geolocation support                                      : $enable_geolocation
  HTML5 video element support                              : $enable_video

Modified: trunk/Source/autotools/SetupWebKitFeatures.m4 (148263 => 148264)


--- trunk/Source/autotools/SetupWebKitFeatures.m4	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Source/autotools/SetupWebKitFeatures.m4	2013-04-12 07:14:02 UTC (rev 148264)
@@ -71,6 +71,12 @@
     CONFIGURABLE_FEATURE_DEFINES="$CONFIGURABLE_FEATURE_DEFINES ENABLE_3D_RENDERING=0"
 fi
 
+if test "$enable_accelerated_canvas" = "yes"; then
+    CONFIGURABLE_FEATURE_DEFINES="$CONFIGURABLE_FEATURE_DEFINES ENABLE_ACCELERATED_2D_CANVAS=1"
+else
+    CONFIGURABLE_FEATURE_DEFINES="$CONFIGURABLE_FEATURE_DEFINES ENABLE_ACCELERATED_2D_CANVAS=0"
+fi
+
 if test "$enable_web_audio" = "yes"; then
     CONFIGURABLE_FEATURE_DEFINES="$CONFIGURABLE_FEATURE_DEFINES ENABLE_WEB_AUDIO=1"
 else
@@ -82,7 +88,6 @@
 # this command now rather than use AC_CONFIG_COMMANDS because automake rules depend
 # on the output file (WebKitFeatures.txt).
 $srcdir/Tools/gtk/generate-feature-defines-files $CONFIGURABLE_FEATURE_DEFINES \
-    ENABLE_ACCELERATED_2D_CANVAS=0 \
     ENABLE_BATTERY_STATUS=0 \
     ENABLE_BLOB=1 \
     ENABLE_CANVAS_PATH=0 \

Modified: trunk/Tools/ChangeLog (148263 => 148264)


--- trunk/Tools/ChangeLog	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Tools/ChangeLog	2013-04-12 07:14:02 UTC (rev 148264)
@@ -1,3 +1,16 @@
+2013-04-12  Commit Queue  <rn...@webkit.org>
+
+        Unreviewed, rolling out r148262.
+        http://trac.webkit.org/changeset/148262
+        https://bugs.webkit.org/show_bug.cgi?id=114493
+
+        Cairo dep should now build, rolling r148247 back in (Requested
+        by zdobersek on #webkit).
+
+        * Scripts/webkitdirs.pm:
+        (buildAutotoolsProject):
+        * gtk/jhbuild.modules:
+
 2013-04-11  Commit Queue  <rn...@webkit.org>
 
         Unreviewed, rolling out r148247.

Modified: trunk/Tools/Scripts/webkitdirs.pm (148263 => 148264)


--- trunk/Tools/Scripts/webkitdirs.pm	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Tools/Scripts/webkitdirs.pm	2013-04-12 07:14:02 UTC (rev 148264)
@@ -2119,11 +2119,18 @@
         "web-audio" => 1,
         "xslt" => 1,
     );
+
+    # These features are ones which build-webkit cannot control, typically because
+    # they can only be active when we have the proper dependencies.
+    my %unsetFeatures = (
+        "accelerated-2d-canvas" => 1,
+    );
+
     my @overridableFeatures = ();
     foreach (@features) {
         if ($configurableFeatures{$_->{option}}) {
             push @buildArgs, autotoolsFlag(${$_->{value}}, $_->{option});;
-        } else {
+        } elsif (!$unsetFeatures{$_->{option}}) {
             push @overridableFeatures, $_->{define} . "=" . (${$_->{value}} ? "1" : "0");
         }
     }

Modified: trunk/Tools/gtk/jhbuild.modules (148263 => 148264)


--- trunk/Tools/gtk/jhbuild.modules	2013-04-12 06:11:46 UTC (rev 148263)
+++ trunk/Tools/gtk/jhbuild.modules	2013-04-12 07:14:02 UTC (rev 148264)
@@ -61,7 +61,8 @@
     </branch>
   </autotools>
 
-  <autotools id="cairo" autogen-sh="configure">
+  <autotools id="cairo" autogen-sh="configure"
+             autogenargs="--enable-gl=yes --enable-egl=yes --enable-glx=yes">
     <dependencies>
       <dep package="fontconfig"/>
       <dep package="pixman"/>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to