Unreviewed, rolling out r148262.
authorzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2013 07:14:02 +0000 (07:14 +0000)
committerzandobersek@gmail.com <zandobersek@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 12 Apr 2013 07:14:02 +0000 (07:14 +0000)
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 <rniwa@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:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@148264 268f45cc-cd09-0410-ab3c-d52691b4dbfc

18 files changed:
ChangeLog
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/GraphicsContext.cpp
Source/WebCore/platform/graphics/ImageBuffer.cpp
Source/WebCore/platform/graphics/cairo/GLContext.h
Source/WebCore/platform/graphics/cairo/GraphicsContextCairo.cpp
Source/WebCore/platform/graphics/cairo/ImageBufferCairo.cpp
Source/WebCore/platform/graphics/cairo/ImageBufferDataCairo.h
Source/WebCore/platform/graphics/egl/GLContextEGL.cpp
Source/WebCore/platform/graphics/egl/GLContextEGL.h
Source/WebCore/platform/graphics/glx/GLContextGLX.cpp
Source/WebCore/platform/graphics/glx/GLContextGLX.h
Source/autotools/FindDependencies.m4
Source/autotools/PrintBuildConfiguration.m4
Source/autotools/SetupWebKitFeatures.m4
Tools/ChangeLog
Tools/Scripts/webkitdirs.pm
Tools/gtk/jhbuild.modules

index cec54a7..6bf202d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2013-04-12  Commit Queue  <rniwa@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  <rniwa@webkit.org>
 
         Unreviewed, rolling out r148247.
index 7d73102..34a245f 100644 (file)
@@ -1,3 +1,49 @@
+2013-04-12  Commit Queue  <rniwa@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  <ap@apple.com>
 
         Reduce includes of CachedSVGDocument.h
index 762c60b..cf95661 100644 (file)
@@ -757,7 +757,7 @@ void GraphicsContext::setPlatformShouldSmoothFonts(bool)
 }
 #endif
 
-#if !USE(SKIA) && !USE(CG)
+#if !USE(SKIA) && !USE(CG) && !USE(CAIRO)
 bool GraphicsContext::isAcceleratedContext() const
 {
     return false;
index bfd547a..25e7365 100644 (file)
@@ -99,7 +99,7 @@ void ImageBuffer::convertToLuminanceMask()
     genericConvertToLuminanceMask();
 }
 
-#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA)
+#if USE(ACCELERATED_COMPOSITING) && !USE(SKIA) && !USE(CAIRO)
 PlatformLayer* ImageBuffer::platformLayer() const
 {
     return 0;
index 1a88072..38df7a6 100644 (file)
@@ -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 @@ public:
     virtual void waitNative() = 0;
     virtual bool canRenderToDefaultFramebuffer() = 0;
     virtual IntSize defaultFrameBufferSize() = 0;
+    virtual cairo_device_t* cairoDevice() = 0;
 
 #if PLATFORM(X11)
     static Display* sharedX11Display();
index 09998c9..bf53bde 100644 (file)
@@ -1142,6 +1142,11 @@ InterpolationQuality GraphicsContext::imageInterpolationQuality() const
     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
 {
index 9b469d0..51fbf0f 100644 (file)
 #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::drawPattern(GraphicsContext* context, const FloatRect& srcRect
 
 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 = cairo_image_surface_get_data(m_data.m_surface.get());
     int stride = cairo_image_surface_get_stride(m_data.m_surface.get());
@@ -133,13 +181,46 @@ void ImageBuffer::platformTransformColorSpace(const Vector<int>& lookUpTable)
     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_image_surface_get_data(data.m_surface.get());
+    cairo_surface_t* imageSurface = mapSurfaceToImage(data.m_surface.get(), size);
+    unsigned char* dataSrc = cairo_image_surface_get_data(imageSurface);
     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 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
         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 @@ PassRefPtr<Uint8ClampedArray> getImageData(const IntRect& rect, const ImageBuffe
         destRows += destBytesPerRow;
     }
 
+    unmapSurfaceFromImage(data.m_surface.get(), imageSurface);
     return result.release();
 }
 
@@ -215,9 +297,8 @@ PassRefPtr<Uint8ClampedArray> ImageBuffer::getPremultipliedImageData(const IntRe
 
 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);
-
-    unsigned char* dataDst = cairo_image_surface_get_data(m_data.m_surface.get());
+    cairo_surface_t* imageSurface = mapSurfaceToImage(m_data.m_surface.get(), sourceSize);
+    unsigned char* dataDst = cairo_image_surface_get_data(imageSurface);
 
     ASSERT(sourceRect.width() > 0);
     ASSERT(sourceRect.height() > 0);
@@ -246,7 +327,7 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
     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 @@ void ImageBuffer::putByteArray(Multiply multiplied, Uint8ClampedArray* source, c
         }
         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 @@ String ImageBuffer::toDataURL(const String& mimeType, const double*, CoordinateS
 }
 #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
index c9faf8d..72ea4c3 100644 (file)
 #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
index b9389b4..8a9b59d 100644 (file)
@@ -22,6 +22,7 @@
 #if USE(EGL)
 
 #include "GraphicsContext3D.h"
+#include <cairo.h>
 #include <wtf/OwnPtr.h>
 
 #if USE(OPENGL_ES_2)
 #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 @@ GLContextEGL::GLContextEGL(EGLContext context, EGLSurface surface, EGLSurfaceTyp
     : 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 @@ void GLContextEGL::waitNative()
     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()
 {
index c5d4bf7..7516c69 100644 (file)
@@ -41,7 +41,7 @@ public:
     virtual void waitNative();
     virtual bool canRenderToDefaultFramebuffer();
     virtual IntSize defaultFrameBufferSize();
-
+    virtual cairo_device_t* cairoDevice();
 
 #if ENABLE(WEBGL)
     virtual PlatformGraphicsContext3D platformContext();
@@ -59,6 +59,7 @@ private:
     EGLContext m_context;
     EGLSurface m_surface;
     EGLSurfaceType m_type;
+    cairo_device_t* m_cairoDevice;
 };
 
 } // namespace WebCore
index 31f32cf..176f772 100644 (file)
 #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 @@ GLContextGLX::GLContextGLX(GLXContext context)
     , m_pbuffer(0)
     , m_pixmap(0)
     , m_glxPixmap(0)
+    , m_cairoDevice(0)
 {
 }
 
@@ -177,11 +183,15 @@ GLContextGLX::GLContextGLX(GLXContext context, Pixmap pixmap, GLXPixmap glxPixma
     , 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 @@ void GLContextGLX::waitNative()
     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()
 {
index 888146b..edefc04 100644 (file)
@@ -46,6 +46,7 @@ public:
     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 @@ private:
     GLXPbuffer m_pbuffer;
     Pixmap m_pixmap;
     GLXPixmap m_glxPixmap;
+    cairo_device_t* m_cairoDevice;
 };
 
 } // namespace WebCore
index 7660983..e15ea4c 100644 (file)
@@ -298,6 +298,7 @@ if test "$enable_accelerated_compositing" = "auto"; then
         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 @@ if test "$with_acceleration_backend" = "opengl"; then
 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])
 
index be9c520..6a60a65 100644 (file)
@@ -16,6 +16,7 @@ Features:
  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
index b068b31..b5fa922 100644 (file)
@@ -71,6 +71,12 @@ else
     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 @@ fi
 # 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 \
index aa3c57c..d0e3504 100644 (file)
@@ -1,3 +1,16 @@
+2013-04-12  Commit Queue  <rniwa@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  <rniwa@webkit.org>
 
         Unreviewed, rolling out r148247.
index dba6ddd..af8eed6 100755 (executable)
@@ -2119,11 +2119,18 @@ sub buildAutotoolsProject($@)
         "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");
         }
     }
index 496e088..48c87a3 100644 (file)
@@ -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"/>