summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/WebCore/ChangeLog120
-rw-r--r--Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp6
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp8
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h9
-rw-r--r--Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp136
-rw-r--r--Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp78
-rw-r--r--Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp69
-rw-r--r--Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h2
-rw-r--r--Source/WebKit2/CMakeLists.txt4
-rw-r--r--Source/WebKit2/ChangeLog46
-rw-r--r--Source/WebKit2/Scripts/webkit2/messages_unittest.py24
-rw-r--r--Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp20
-rw-r--r--Source/WebKit2/Shared/API/c/qt/WKImageQt.h1
-rw-r--r--Source/api.pri9
14 files changed, 405 insertions, 127 deletions
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index e954e70a4..396a7c4c5 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,123 @@
+2012-10-18 Tommy Widenflycht <tommyw@google.com>
+
+ MediaStream API: Add better RTCPeerConnectionHandler creation logic
+ https://bugs.webkit.org/show_bug.cgi?id=99308
+
+ Reviewed by Adam Barth.
+
+ This patch makes sure that if the RTCPeerConnectionHandler can't be fully initialized/created
+ the RTCPeerConnection constructor throws an exception.
+
+ Not full testable, existing tests cover the normal case though.
+
+ * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp:
+ (WebCore::RTCPeerConnectionHandler::create):
+ (WebCore::RTCPeerConnectionHandlerChromium::RTCPeerConnectionHandlerChromium):
+ (WebCore::RTCPeerConnectionHandlerChromium::createWebHandler):
+ (WebCore::RTCPeerConnectionHandlerChromium::initialize):
+ (WebCore::RTCPeerConnectionHandlerChromium::createOffer):
+ (WebCore::RTCPeerConnectionHandlerChromium::createAnswer):
+ (WebCore::RTCPeerConnectionHandlerChromium::setLocalDescription):
+ (WebCore::RTCPeerConnectionHandlerChromium::setRemoteDescription):
+ (WebCore::RTCPeerConnectionHandlerChromium::updateIce):
+ (WebCore::RTCPeerConnectionHandlerChromium::addIceCandidate):
+ (WebCore::RTCPeerConnectionHandlerChromium::localDescription):
+ (WebCore::RTCPeerConnectionHandlerChromium::remoteDescription):
+ (WebCore::RTCPeerConnectionHandlerChromium::addStream):
+ (WebCore::RTCPeerConnectionHandlerChromium::removeStream):
+ (WebCore::RTCPeerConnectionHandlerChromium::getStats):
+ (WebCore::RTCPeerConnectionHandlerChromium::openDataChannel):
+ (WebCore::RTCPeerConnectionHandlerChromium::sendStringData):
+ (WebCore::RTCPeerConnectionHandlerChromium::sendRawData):
+ (WebCore::RTCPeerConnectionHandlerChromium::closeDataChannel):
+ (WebCore::RTCPeerConnectionHandlerChromium::stop):
+ * platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h:
+ (RTCPeerConnectionHandlerChromium):
+
+2012-10-19 Zeno Albisser <zeno@webkit.org>
+
+ Temporarily disable use of QCocoaNativeInterface in GraphicsSurfaceMac.
+ https://bugs.webkit.org/show_bug.cgi?id=99320
+
+ The current version of Qt5 deployed on the buildbots does not yet have
+ an implementation for QCocoaNativeInterface::nativeResourceForContext().
+ Therefore we disable this code path until Qt5/qtbase has been updated to
+ a revision above Change-Id: Id00efc88a73d7df04a68c022f19d9d1c4f6d386b.
+
+ Once Qt5 has been updated, this patch must be reverted.
+
+ Reviewed by Noam Rosenthal.
+
+ * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
+ (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+
+2012-10-18 Zeno Albisser <zeno@webkit.org>
+
+ GraphicsSurface should not modify the current GL context.
+ https://bugs.webkit.org/show_bug.cgi?id=99320
+
+ Instead of reusing the currently bound GL context for drawing
+ the texture onto the GraphicsSurface, GraphicsSurface should
+ create a new context that shares the texture names with a context
+ provided by the caller.
+ This way the OpenGL states are clearly separated and we do not
+ risk interfeering with the currently bound GL context.
+
+ Reviewed by Noam Rosenthal.
+
+ * platform/graphics/qt/GraphicsContext3DQt.cpp:
+ (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate):
+ When creating a GraphicsSurface pass the platform GL context
+ as a parameter, so it can be used for sharing textures with.
+ (WebCore::GraphicsContext3DPrivate::copyToGraphicsSurface):
+ Pass the texture instead of the FBO. A Texture can be drawn
+ directly or bound to another FBO, where a framebuffer
+ always needs to be blit onto the surface.
+ (WebCore::GraphicsContext3DPrivate::createGraphicsSurfaces):
+ Pass the platform GL context as a parameter.
+ * platform/graphics/surfaces/GraphicsSurface.cpp:
+ (WebCore::GraphicsSurface::create):
+ (WebCore::GraphicsSurface::copyFromTexture):
+ * platform/graphics/surfaces/GraphicsSurface.h:
+ (GraphicsSurface):
+ * platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp:
+ (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+ Create a new GL context that shares the textures with the
+ context provided by the caller.
+ (WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::makeCurrent):
+ Add a convenience function to make the context that
+ belongs to the surface current.
+ (GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::doneCurrent):
+ Add a convenience function to make the previously
+ bound context current again.
+ (WebCore::GraphicsSurfacePrivate::copyFromTexture):
+ Move blitting of the texture onto the surface
+ into a separate function within GraphicsSurfacePrivate.
+ (WebCore::GraphicsSurface::platformCopyFromTexture):
+ Rename function platformCopyFromFramebuffer to
+ platformCopyFromTexture, as we are now passing the texture only.
+ (WebCore::GraphicsSurface::platformCreate):
+ * platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp:
+ (WebCore):
+ (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::makeCurrent):
+ Add a convenience function to make the context that
+ belongs to the surface current.
+ (GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::doneCurrent):
+ Add a convenience function to make the previously
+ (WebCore::GraphicsSurfacePrivate::copyFromTexture):
+ Move blitting of the texture onto the surface
+ into a separate function within GraphicsSurfacePrivate.
+ (WebCore::resolveGLMethods):
+ Resolve additional GL methods necessary for this change.
+ (WebCore::GraphicsSurface::platformCopyFromTexture):
+ Rename function platformCopyFromFramebuffer to
+ platformCopyFromTexture, as we are now passing the texture only.
+ (WebCore::GraphicsSurface::platformCreate):
+
2012-10-18 Kent Tamura <tkent@chromium.org>
Set min-width property instead of width property for date/time fields
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 69aa86591..9b0003797 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -144,7 +144,7 @@ GraphicsContext3DPrivate::GraphicsContext3DPrivate(GraphicsContext3D* context, H
| GraphicsSurface::SupportsSharing;
if (!surfaceSize.isEmpty()) {
- m_graphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags);
+ m_graphicsSurface = GraphicsSurface::create(surfaceSize, m_surfaceFlags, m_platformContext);
}
#endif
}
@@ -284,7 +284,7 @@ uint32_t GraphicsContext3DPrivate::copyToGraphicsSurface()
blitMultisampleFramebufferAndRestoreContext();
makeCurrentIfNeeded();
- m_graphicsSurface->copyFromFramebuffer(m_context->m_fbo, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
+ m_graphicsSurface->copyFromTexture(m_context->m_texture, IntRect(0, 0, m_context->m_currentWidth, m_context->m_currentHeight));
uint32_t frontBuffer = m_graphicsSurface->swapBuffers();
return frontBuffer;
}
@@ -342,7 +342,7 @@ void GraphicsContext3DPrivate::createGraphicsSurfaces(const IntSize& size)
if (size.isEmpty())
m_graphicsSurface.clear();
else
- m_graphicsSurface = GraphicsSurface::create(size, m_surfaceFlags);
+ m_graphicsSurface = GraphicsSurface::create(size, m_surfaceFlags, m_platformContext);
#endif
}
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
index c16a37799..d966dc516 100644
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
@@ -30,9 +30,9 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags f
return platformImport(size, flags, token);
}
-PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, GraphicsSurface::Flags flags)
+PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, GraphicsSurface::Flags flags, const PlatformGraphicsContext3D shareContext)
{
- return platformCreate(size, flags);
+ return platformCreate(size, flags, shareContext);
}
GraphicsSurfaceToken GraphicsSurface::exportToken()
@@ -58,9 +58,9 @@ void GraphicsSurface::copyToGLTexture(uint32_t target, uint32_t texture, const I
platformCopyToGLTexture(target, texture, targetRect, offset);
}
-void GraphicsSurface::copyFromFramebuffer(uint32_t fbo, const IntRect& sourceRect)
+void GraphicsSurface::copyFromTexture(uint32_t texture, const IntRect& sourceRect)
{
- platformCopyFromFramebuffer(fbo, sourceRect);
+ platformCopyFromTexture(texture, sourceRect);
}
void GraphicsSurface::paintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
index e78ebbc0e..bdbb34eb9 100644
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
@@ -21,6 +21,7 @@
#define GraphicsSurface_h
#include "GraphicsContext.h"
+#include "GraphicsContext3D.h"
#include "GraphicsSurfaceToken.h"
#include "IntRect.h"
#include <wtf/OwnPtr.h>
@@ -70,10 +71,10 @@ public:
PlatformGraphicsSurface platformSurface() const { return m_platformSurface; }
IntSize size() const { return m_size; }
- static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags);
+ static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const PlatformGraphicsContext3D shareContext = 0);
static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, const GraphicsSurfaceToken&);
void copyToGLTexture(uint32_t target, uint32_t texture, const IntRect& targetRect, const IntPoint& sourceOffset);
- void copyFromFramebuffer(uint32_t fbo, const IntRect& sourceRect);
+ void copyFromTexture(uint32_t texture, const IntRect& sourceRect);
void paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
uint32_t frontBuffer();
uint32_t swapBuffers();
@@ -84,7 +85,7 @@ public:
~GraphicsSurface();
protected:
- static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags);
+ static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags, const PlatformGraphicsContext3D);
static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, const GraphicsSurfaceToken&);
GraphicsSurfaceToken platformExport();
void platformDestroy();
@@ -93,7 +94,7 @@ protected:
char* platformLock(const IntRect&, int* stride, LockOptions);
void platformUnlock();
void platformCopyToGLTexture(uint32_t target, uint32_t texture, const IntRect&, const IntPoint&);
- void platformCopyFromFramebuffer(uint32_t fbo, const IntRect& sourceRect);
+ void platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect);
void platformPaintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
uint32_t platformFrontBuffer() const;
uint32_t platformSwapBuffers();
diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
index 94c339176..d869eb5cf 100644
--- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
@@ -27,8 +27,15 @@
#include <CGLCurrent.h>
#include <CGLIOSurface.h>
#include <IOSurface/IOSurface.h>
+#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
+#if PLATFORM(QT)
+#include <QGuiApplication>
+#include <QOpenGLContext>
+#include <qpa/qplatformnativeinterface.h>
+#endif
+
namespace WebCore {
static uint32_t createTexture(IOSurfaceRef handle)
@@ -65,18 +72,48 @@ static uint32_t createTexture(IOSurfaceRef handle)
struct GraphicsSurfacePrivate {
public:
GraphicsSurfacePrivate(const GraphicsSurfaceToken& token)
- : m_token(token)
+ : m_context(0)
+ , m_token(token)
, m_frontBufferTexture(0)
, m_backBufferTexture(0)
+ , m_readFbo(0)
+ , m_drawFbo(0)
{
m_frontBuffer = IOSurfaceLookup(m_token.frontBufferHandle);
m_backBuffer = IOSurfaceLookup(m_token.backBufferHandle);
}
- GraphicsSurfacePrivate(const IntSize& size, GraphicsSurface::Flags flags)
- : m_frontBufferTexture(0)
+ GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext, const IntSize& size, GraphicsSurface::Flags flags)
+ : m_context(0)
+ , m_frontBufferTexture(0)
, m_backBufferTexture(0)
+ , m_readFbo(0)
+ , m_drawFbo(0)
{
+#if PLATFORM(QT)
+#if 0
+ // This code path requires QCocoaNativeInterface::nativeResourceForContext() which is not availble in Qt5 on the build bots yet.
+ QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
+ CGLContextObj shareContextObject = static_cast<CGLContextObj>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("cglContextObj"), shareContext));
+ if (!shareContextObject)
+ return;
+#else
+ // This code path should be removed as soon as QCocoaNativeInterface::nativeResourceForContext() has become available in Qt5 on the build bots.
+ CGLContextObj previousContext = CGLGetCurrentContext();
+ QSurface* currentSurface = shareContext->surface();
+ shareContext->makeCurrent(currentSurface);
+
+ CGLContextObj shareContextObject = CGLGetCurrentContext();
+
+ CGLSetCurrentContext(previousContext);
+#endif
+ CGLPixelFormatObj pixelFormatObject = CGLGetPixelFormat(shareContextObject);
+ if (kCGLNoError != CGLCreateContext(pixelFormatObject, shareContextObject, &m_context))
+ return;
+
+ CGLRetainContext(m_context);
+#endif
+
unsigned pixelFormat = 'BGRA';
unsigned bytesPerElement = 4;
int width = size.width();
@@ -130,6 +167,16 @@ public:
if (m_backBuffer)
CFRelease(IOSurfaceRef(m_backBuffer));
+
+ if (m_readFbo)
+ glDeleteFramebuffers(1, &m_readFbo);
+
+ if (m_drawFbo)
+ glDeleteFramebuffers(1, &m_drawFbo);
+
+ if (m_context)
+ CGLReleaseContext(m_context);
+
}
uint32_t swapBuffers()
@@ -140,6 +187,61 @@ public:
return IOSurfaceGetID(m_frontBuffer);
}
+ void makeCurrent()
+ {
+ m_detachedContext = CGLGetCurrentContext();
+
+ if (m_context)
+ CGLSetCurrentContext(m_context);
+ }
+
+ void doneCurrent()
+ {
+ CGLSetCurrentContext(m_detachedContext);
+ m_detachedContext = 0;
+ }
+
+ void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
+ {
+ // FIXME: The following glFlush can possibly be replaced by using the GL_ARB_sync extension.
+ glFlush(); // Make sure the texture has actually been completely written in the original context.
+
+ makeCurrent();
+ glEnable(GL_TEXTURE_RECTANGLE_ARB);
+
+ int x = sourceRect.x();
+ int y = sourceRect.y();
+ int width = sourceRect.width();
+ int height = sourceRect.height();
+
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+ GLint previousFBO;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFBO);
+
+ if (!m_drawFbo)
+ glGenFramebuffers(1, &m_drawFbo);
+
+ if (!m_readFbo)
+ glGenFramebuffers(1, &m_readFbo);
+
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, m_readFbo);
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_drawFbo);
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, backBufferTextureID(), 0);
+ glBlitFramebuffer(x, y, width, height, x, x+height, y+width, y, GL_COLOR_BUFFER_BIT, GL_LINEAR); // Flip the texture upside down.
+
+ glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
+ glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
+ glBindFramebuffer(GL_FRAMEBUFFER, previousFBO);
+ glPopAttrib();
+
+ // Flushing the gl command buffer is necessary to ensure the texture has correctly been bound to the IOSurface.
+ glFlush();
+
+ doneCurrent();
+ }
+
GraphicsSurfaceToken token() const
{
return m_token;
@@ -172,10 +274,14 @@ public:
}
private:
+ CGLContextObj m_context;
+ CGLContextObj m_detachedContext;
PlatformGraphicsSurface m_frontBuffer;
PlatformGraphicsSurface m_backBuffer;
uint32_t m_frontBufferTexture;
uint32_t m_backBufferTexture;
+ uint32_t m_readFbo;
+ uint32_t m_drawFbo;
GraphicsSurfaceToken m_token;
};
@@ -212,25 +318,9 @@ void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, cons
glFlush();
}
-void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect)
+void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
{
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- if (!m_fbo)
- glGenFramebuffers(1, &m_fbo);
-
- GLint oldFBO;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
- glEnable(GL_TEXTURE_RECTANGLE_ARB);
- glBindFramebuffer(GL_READ_FRAMEBUFFER, originFbo);
- glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbo);
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, m_private->backBufferTextureID(), 0);
- glBlitFramebuffer(0, 0, sourceRect.width(), sourceRect.height(), 0, sourceRect.height(), sourceRect.width(), 0, GL_COLOR_BUFFER_BIT, GL_LINEAR); // Flip the texture upside down.
- glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_RECTANGLE_ARB, 0, 0);
- glBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
- glPopAttrib();
-
- // Flushing the gl command buffer is necessary to ensure the texture has correctly been bound to the IOSurface.
- glFlush();
+ m_private->copyFromTexture(texture, sourceRect);
}
void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
@@ -250,7 +340,7 @@ uint32_t GraphicsSurface::platformSwapBuffers()
return m_private->swapBuffers();
}
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags)
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
{
// We currently disable support for CopyToTexture on Mac, because this is used for single buffered Tiles.
// The single buffered nature of this requires a call to glFlush, as described in platformCopyToTexture.
@@ -259,7 +349,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size,
return PassRefPtr<GraphicsSurface>();
RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate(size, flags);
+ surface->m_private = new GraphicsSurfacePrivate(shareContext, size, flags);
if (!surface->m_private->frontBuffer() || !surface->m_private->backBuffer())
return PassRefPtr<GraphicsSurface>();
diff --git a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
index 2fd6cba46..fd62a0038 100644
--- a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
@@ -42,6 +42,9 @@ static PFNGLXBINDTEXIMAGEEXTPROC pGlXBindTexImageEXT = 0;
static PFNGLXRELEASETEXIMAGEEXTPROC pGlXReleaseTexImageEXT = 0;
static PFNGLBINDFRAMEBUFFERPROC pGlBindFramebuffer = 0;
static PFNGLBLITFRAMEBUFFERPROC pGlBlitFramebuffer = 0;
+static PFNGLGENFRAMEBUFFERSPROC pGlGenFramebuffers = 0;
+static PFNGLDELETEFRAMEBUFFERSPROC pGlDeleteFramebuffers = 0;
+static PFNGLFRAMEBUFFERTEXTURE2DPROC pGlFramebufferTexture2D = 0;
class OffScreenRootWindow {
public:
@@ -99,11 +102,13 @@ static const int glxAttributes[] = {
};
struct GraphicsSurfacePrivate {
- GraphicsSurfacePrivate()
+ GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext = 0)
: m_display(0)
, m_xPixmap(0)
, m_glxPixmap(0)
, m_glContext(adoptPtr(new QOpenGLContext))
+ , m_detachedContext(0)
+ , m_detachedSurface(0)
, m_textureIsYInverted(false)
, m_hasAlpha(false)
{
@@ -113,6 +118,7 @@ struct GraphicsSurfacePrivate {
currentSurface = currentContext->surface();
m_display = XOpenDisplay(0);
+ m_glContext->setShareContext(shareContext);
m_glContext->create();
// The GLX implementation of QOpenGLContext will reset the current context when create is being called.
@@ -178,9 +184,18 @@ struct GraphicsSurfacePrivate {
void makeCurrent()
{
- QOpenGLContext* glContext = QOpenGLContext::currentContext();
- if (m_surface && glContext)
- glContext->makeCurrent(m_surface.get());
+ m_detachedContext = QOpenGLContext::currentContext();
+ if (m_detachedContext)
+ m_detachedSurface = m_detachedContext->surface();
+
+ if (m_surface && m_glContext)
+ m_glContext->makeCurrent(m_surface.get());
+ }
+
+ void doneCurrent()
+ {
+ if (m_detachedContext)
+ m_detachedContext->makeCurrent(m_detachedSurface);
}
void swapBuffers()
@@ -209,6 +224,36 @@ struct GraphicsSurfacePrivate {
}
}
+ void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
+ {
+ makeCurrent();
+ int x = sourceRect.x();
+ int y = sourceRect.y();
+ int width = sourceRect.width();
+ int height = sourceRect.height();
+
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+ GLint previousFBO;
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &previousFBO);
+
+ GLuint originFBO;
+ pGlGenFramebuffers(1, &originFBO);
+ pGlBindFramebuffer(GL_READ_FRAMEBUFFER, originFBO);
+ glBindTexture(GL_TEXTURE_2D, texture);
+ pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture, 0);
+
+ pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, glContext()->defaultFramebufferObject());
+ pGlBlitFramebuffer(x, y, width, height, x, y, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
+
+ pGlFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
+ glBindTexture(GL_TEXTURE_2D, 0);
+ pGlBindFramebuffer(GL_FRAMEBUFFER, previousFBO);
+ pGlDeleteFramebuffers(1, &originFBO);
+
+ glPopAttrib();
+ doneCurrent();
+ }
+
Display* display() const { return m_display; }
@@ -226,6 +271,8 @@ private:
GLXPixmap m_glxPixmap;
OwnPtr<QWindow> m_surface;
OwnPtr<QOpenGLContext> m_glContext;
+ QOpenGLContext* m_detachedContext;
+ QSurface* m_detachedSurface;
bool m_textureIsYInverted;
bool m_hasAlpha;
};
@@ -242,6 +289,10 @@ static bool resolveGLMethods(GraphicsSurfacePrivate* p)
pGlBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(glContext->getProcAddress("glBindFramebuffer"));
pGlBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(glContext->getProcAddress("glBlitFramebuffer"));
+ pGlGenFramebuffers = reinterpret_cast<PFNGLGENFRAMEBUFFERSPROC>(glContext->getProcAddress("glGenFramebuffers"));
+ pGlDeleteFramebuffers = reinterpret_cast<PFNGLDELETEFRAMEBUFFERSPROC>(glContext->getProcAddress("glDeleteFramebuffers"));
+ pGlFramebufferTexture2D = reinterpret_cast<PFNGLFRAMEBUFFERTEXTURE2DPROC>(glContext->getProcAddress("glFramebufferTexture2D"));
+
resolved = pGlBlitFramebuffer && pGlBindFramebuffer && pGlXBindTexImageEXT && pGlXReleaseTexImageEXT;
return resolved;
@@ -272,20 +323,9 @@ void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, cons
// This is not supported by GLX/Xcomposite.
}
-void GraphicsSurface::platformCopyFromFramebuffer(uint32_t originFbo, const IntRect& sourceRect)
+void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
{
- m_private->makeCurrent();
- int width = m_size.width();
- int height = m_size.height();
-
- glPushAttrib(GL_ALL_ATTRIB_BITS);
- GLint oldFBO;
- glGetIntegerv(GL_FRAMEBUFFER_BINDING, &oldFBO);
- pGlBindFramebuffer(GL_READ_FRAMEBUFFER, originFbo);
- pGlBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_private->glContext()->defaultFramebufferObject());
- pGlBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_LINEAR);
- pGlBindFramebuffer(GL_FRAMEBUFFER, oldFBO);
- glPopAttrib();
+ m_private->copyFromTexture(texture, sourceRect);
}
@@ -307,7 +347,7 @@ uint32_t GraphicsSurface::platformSwapBuffers()
return 0;
}
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags)
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
{
// X11 does not support CopyToTexture, so we do not create a GraphicsSurface if this is requested.
// GraphicsSurfaceGLX uses an XWindow as native surface. This one always has a front and a back buffer.
@@ -317,7 +357,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size,
RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
- surface->m_private = new GraphicsSurfacePrivate();
+ surface->m_private = new GraphicsSurfacePrivate(shareContext);
if (!resolveGLMethods(surface->m_private))
return PassRefPtr<GraphicsSurface>();
diff --git a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp
index 61fb1c48a..e8d167cae 100644
--- a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp
+++ b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.cpp
@@ -64,155 +64,112 @@ WebKit::WebRTCPeerConnectionHandler* RTCPeerConnectionHandlerChromium::toWebRTCP
PassOwnPtr<RTCPeerConnectionHandler> RTCPeerConnectionHandler::create(RTCPeerConnectionHandlerClient* client)
{
- return adoptPtr(new RTCPeerConnectionHandlerChromium(client));
+ ASSERT(client);
+ OwnPtr<RTCPeerConnectionHandlerChromium> handler = adoptPtr(new RTCPeerConnectionHandlerChromium(client));
+
+ if (!handler->createWebHandler())
+ return nullptr;
+
+ return handler.release();
}
RTCPeerConnectionHandlerChromium::RTCPeerConnectionHandlerChromium(RTCPeerConnectionHandlerClient* client)
: m_client(client)
{
- ASSERT(m_client);
- m_webHandler = adoptPtr(WebKit::Platform::current()->createRTCPeerConnectionHandler(this));
}
RTCPeerConnectionHandlerChromium::~RTCPeerConnectionHandlerChromium()
{
}
-bool RTCPeerConnectionHandlerChromium::initialize(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints)
+bool RTCPeerConnectionHandlerChromium::createWebHandler()
{
- if (!m_webHandler)
- return false;
+ m_webHandler = adoptPtr(WebKit::Platform::current()->createRTCPeerConnectionHandler(this));
+ return m_webHandler;
+}
+bool RTCPeerConnectionHandlerChromium::initialize(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints)
+{
return m_webHandler->initialize(configuration, constraints);
}
void RTCPeerConnectionHandlerChromium::createOffer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)
{
- // FIXME: Should the error callback be triggered here?
- if (!m_webHandler)
- return;
-
m_webHandler->createOffer(request, constraints);
}
void RTCPeerConnectionHandlerChromium::createAnswer(PassRefPtr<RTCSessionDescriptionRequest> request, PassRefPtr<MediaConstraints> constraints)
{
- // FIXME: Should the error callback be triggered here?
- if (!m_webHandler)
- return;
-
m_webHandler->createAnswer(request, constraints);
}
void RTCPeerConnectionHandlerChromium::setLocalDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> sessionDescription)
{
- if (!m_webHandler)
- return;
-
m_webHandler->setLocalDescription(request, sessionDescription);
}
void RTCPeerConnectionHandlerChromium::setRemoteDescription(PassRefPtr<RTCVoidRequest> request, PassRefPtr<RTCSessionDescriptionDescriptor> sessionDescription)
{
- if (!m_webHandler)
- return;
-
m_webHandler->setRemoteDescription(request, sessionDescription);
}
bool RTCPeerConnectionHandlerChromium::updateIce(PassRefPtr<RTCConfiguration> configuration, PassRefPtr<MediaConstraints> constraints)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->updateICE(configuration, constraints);
}
bool RTCPeerConnectionHandlerChromium::addIceCandidate(PassRefPtr<RTCIceCandidateDescriptor> iceCandidate)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->addICECandidate(iceCandidate);
}
PassRefPtr<RTCSessionDescriptionDescriptor> RTCPeerConnectionHandlerChromium::localDescription()
{
- if (!m_webHandler)
- return 0;
-
return m_webHandler->localDescription();
}
PassRefPtr<RTCSessionDescriptionDescriptor> RTCPeerConnectionHandlerChromium::remoteDescription()
{
- if (!m_webHandler)
- return 0;
-
return m_webHandler->remoteDescription();
}
bool RTCPeerConnectionHandlerChromium::addStream(PassRefPtr<MediaStreamDescriptor> mediaStream, PassRefPtr<MediaConstraints> constraints)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->addStream(mediaStream, constraints);
}
void RTCPeerConnectionHandlerChromium::removeStream(PassRefPtr<MediaStreamDescriptor> mediaStream)
{
- if (!m_webHandler)
- return;
-
m_webHandler->removeStream(mediaStream);
}
void RTCPeerConnectionHandlerChromium::getStats(PassRefPtr<RTCStatsRequest> request)
{
- if (!m_webHandler)
- return;
-
m_webHandler->getStats(request);
}
bool RTCPeerConnectionHandlerChromium::openDataChannel(PassRefPtr<RTCDataChannelDescriptor> dataChannel)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->openDataChannel(dataChannel);
}
bool RTCPeerConnectionHandlerChromium::sendStringData(PassRefPtr<RTCDataChannelDescriptor> dataChannel, const String& data)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->sendStringData(dataChannel, data);
}
bool RTCPeerConnectionHandlerChromium::sendRawData(PassRefPtr<RTCDataChannelDescriptor> dataChannel, const char* data, size_t dataLength)
{
- if (!m_webHandler)
- return false;
-
return m_webHandler->sendRawData(dataChannel, data, dataLength);
}
void RTCPeerConnectionHandlerChromium::closeDataChannel(PassRefPtr<RTCDataChannelDescriptor> dataChannel)
{
- if (!m_webHandler)
- return;
-
return m_webHandler->closeDataChannel(dataChannel);
}
void RTCPeerConnectionHandlerChromium::stop()
{
- if (!m_webHandler)
- return;
-
m_webHandler->stop();
}
diff --git a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h
index 6da11957a..36e92d444 100644
--- a/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h
+++ b/Source/WebCore/platform/mediastream/chromium/RTCPeerConnectionHandlerChromium.h
@@ -52,6 +52,8 @@ public:
explicit RTCPeerConnectionHandlerChromium(RTCPeerConnectionHandlerClient*);
virtual ~RTCPeerConnectionHandlerChromium();
+ bool createWebHandler();
+
virtual bool initialize(PassRefPtr<RTCConfiguration>, PassRefPtr<MediaConstraints>) OVERRIDE;
virtual void createOffer(PassRefPtr<RTCSessionDescriptionRequest>, PassRefPtr<MediaConstraints>) OVERRIDE;
diff --git a/Source/WebKit2/CMakeLists.txt b/Source/WebKit2/CMakeLists.txt
index bb746c699..0c2d01604 100644
--- a/Source/WebKit2/CMakeLists.txt
+++ b/Source/WebKit2/CMakeLists.txt
@@ -589,6 +589,10 @@ FOREACH (_file ${WebKit2_MESSAGES_IN_FILES})
ADD_CUSTOM_COMMAND(
OUTPUT ${DERIVED_SOURCES_WEBKIT2_DIR}/${_name}MessageReceiver.cpp ${DERIVED_SOURCES_WEBKIT2_DIR}/${_name}Messages.h
MAIN_DEPENDENCY ${_file}
+ DEPENDS ${WEBKIT2_DIR}/Scripts/webkit2/__init__.py
+ ${WEBKIT2_DIR}/Scripts/webkit2/messages.py
+ ${WEBKIT2_DIR}/Scripts/webkit2/model.py
+ ${WEBKIT2_DIR}/Scripts/webkit2/parser.py
COMMAND ${PYTHON_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-message-receiver.py ${_file} > ${DERIVED_SOURCES_WEBKIT2_DIR}/${_name}MessageReceiver.cpp
COMMAND ${PYTHON_EXECUTABLE} ${WEBKIT2_DIR}/Scripts/generate-messages-header.py ${_file} > ${DERIVED_SOURCES_WEBKIT2_DIR}/${_name}Messages.h
WORKING_DIRECTORY ${WEBKIT2_DIR}
diff --git a/Source/WebKit2/ChangeLog b/Source/WebKit2/ChangeLog
index c80bb5fc1..f8398f3af 100644
--- a/Source/WebKit2/ChangeLog
+++ b/Source/WebKit2/ChangeLog
@@ -1,3 +1,49 @@
+2012-10-15 Balazs Kelemen <kbalazs@webkit.org>
+
+ [Qt][WTR] Do a forced repaint before generating pixel results
+ https://bugs.webkit.org/show_bug.cgi?id=98654
+
+ Reviewed by Jocelyn Turcotte.
+
+ Added API to convert a QImage to a WKImage so we can
+ pass it to cross-platform code.
+
+ * Shared/API/c/qt/WKImageQt.cpp:
+ (WKImageCreateFromQImage):
+ * Shared/API/c/qt/WKImageQt.h:
+
+2012-10-18 Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
+
+ [CMake] Depend on the Python scripts in WebKit2/Scripts/webkit2 when regenerating messages.
+ https://bugs.webkit.org/show_bug.cgi?id=99702
+
+ Reviewed by Gyuyoung Kim.
+
+ Be in line with most (or all) the other build systems and
+ explicitly depend on all the scripts in
+ ${WEBKIT2_DIR}/Scripts/webkit2 for the custom command that
+ generates messages.
+
+ This helps fix the build after the recent change to messages.py,
+ which did not trigger a regeneration of the required files --
+ people were just removing their DerivedSources directory
+ altogether.
+
+ * CMakeLists.txt:
+
+2012-10-18 Byungwoo Lee <bw80.lee@samsung.com>
+
+ [WK2] Fix incorrect test expectations of messages_unittest.py.
+ https://bugs.webkit.org/show_bug.cgi?id=99699
+
+ Reviewed by Gyuyoung Kim.
+
+ Fix the expected results of messages_unittest.py.
+
+ The expected result of messages_unittest.py has bugs, and it makes failure on python test.
+
+ * Scripts/webkit2/messages_unittest.py:
+
2012-10-18 Jussi Kukkonen <jussi.kukkonen@intel.com>
Add PluginProcessProxy::platformInitializeLaunchOptions
diff --git a/Source/WebKit2/Scripts/webkit2/messages_unittest.py b/Source/WebKit2/Scripts/webkit2/messages_unittest.py
index c27e2588c..8ebbfd89d 100644
--- a/Source/WebKit2/Scripts/webkit2/messages_unittest.py
+++ b/Source/WebKit2/Scripts/webkit2/messages_unittest.py
@@ -467,14 +467,14 @@ struct GetPlugins : CoreIPC::Arguments1<bool> {
struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> {
static const Kind messageID = GetPluginProcessConnectionID;
struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
- DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>);
+ DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);
~DelayedReply();
bool send(const CoreIPC::Connection::Handle& connectionHandle);
private:
RefPtr<CoreIPC::Connection> m_connection;
- OwnPtr<CoreIPC::MessageEncoder> m_encoder;
+ OwnPtr<CoreIPC::ArgumentEncoder> m_arguments;
};
typedef CoreIPC::Arguments1<CoreIPC::Connection::Handle&> Reply;
@@ -488,14 +488,14 @@ struct GetPluginProcessConnection : CoreIPC::Arguments1<const WTF::String&> {
struct TestMultipleAttributes : CoreIPC::Arguments0 {
static const Kind messageID = TestMultipleAttributesID;
struct DelayedReply : public ThreadSafeRefCounted<DelayedReply> {
- DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::MessageEncoder>);
+ DelayedReply(PassRefPtr<CoreIPC::Connection>, PassOwnPtr<CoreIPC::ArgumentEncoder>);
~DelayedReply();
bool send();
private:
RefPtr<CoreIPC::Connection> m_connection;
- OwnPtr<CoreIPC::MessageEncoder> m_encoder;
+ OwnPtr<CoreIPC::ArgumentEncoder> m_arguments;
};
typedef CoreIPC::Arguments0 Reply;
@@ -640,9 +640,9 @@ namespace Messages {
namespace WebPage {
-GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::MessageEncoder> arguments)
+GetPluginProcessConnection::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)
: m_connection(connection)
- , m_encoder(arguments)
+ , m_arguments(arguments)
{
}
@@ -653,16 +653,16 @@ GetPluginProcessConnection::DelayedReply::~DelayedReply()
bool GetPluginProcessConnection::DelayedReply::send(const CoreIPC::Connection::Handle& connectionHandle)
{
- ASSERT(m_encoder);
- m_encoder->encode(connectionHandle);
+ ASSERT(m_arguments);
+ m_arguments->encode(connectionHandle);
bool result = m_connection->sendSyncReply(static_pointer_cast<CoreIPC::MessageEncoder>(m_arguments.release()));
m_connection = nullptr;
return result;
}
-TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::MessageEncoder> arguments)
+TestMultipleAttributes::DelayedReply::DelayedReply(PassRefPtr<CoreIPC::Connection> connection, PassOwnPtr<CoreIPC::ArgumentEncoder> arguments)
: m_connection(connection)
- , m_encoder(arguments)
+ , m_arguments(arguments)
{
}
@@ -673,7 +673,7 @@ TestMultipleAttributes::DelayedReply::~DelayedReply()
bool TestMultipleAttributes::DelayedReply::send()
{
- ASSERT(m_encoder);
+ ASSERT(m_arguments);
bool result = m_connection->sendSyncReply(static_pointer_cast<CoreIPC::MessageEncoder>(m_arguments.release()));
m_connection = nullptr;
return result;
@@ -755,7 +755,7 @@ void WebPage::didReceiveWebPageMessage(CoreIPC::Connection*, CoreIPC::MessageID
ASSERT_NOT_REACHED();
}
-void WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::MessageEncoder>& reply)
+void WebPage::didReceiveSyncWebPageMessage(CoreIPC::Connection* connection, CoreIPC::MessageID messageID, CoreIPC::ArgumentDecoder* arguments, OwnPtr<CoreIPC::ArgumentEncoder>& reply)
{
switch (messageID.get<Messages::WebPage::Kind>()) {
case Messages::WebPage::CreatePluginID:
diff --git a/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp b/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp
index d0975f653..60388f4fa 100644
--- a/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp
+++ b/Source/WebKit2/Shared/API/c/qt/WKImageQt.cpp
@@ -25,10 +25,30 @@
#include "ShareableBitmap.h"
#include "WKSharedAPICast.h"
#include "WebImage.h"
+#include <QPainter>
+#include <WebCore/GraphicsContext.h>
+#include <WebCore/IntSize.h>
+using namespace WebCore;
using namespace WebKit;
QImage WKImageCreateQImage(WKImageRef imageRef)
{
return toImpl(imageRef)->bitmap()->createQImage().copy();
}
+
+WKImageRef WKImageCreateFromQImage(const QImage& image)
+{
+ if (image.isNull())
+ return 0;
+
+ ASSERT(image.bytesPerLine() == image.width() * 4);
+
+ RefPtr<WebImage> webImage = WebImage::create(image.size(), static_cast<ImageOptions>(0));
+ if (!webImage->bitmap())
+ return 0;
+ OwnPtr<GraphicsContext> graphicsContext = webImage->bitmap()->createGraphicsContext();
+ QPainter* painter = graphicsContext->platformContext();
+ painter->drawImage(QPoint(0, 0), image);
+ return toAPI(webImage.release().leakRef());
+}
diff --git a/Source/WebKit2/Shared/API/c/qt/WKImageQt.h b/Source/WebKit2/Shared/API/c/qt/WKImageQt.h
index 1e5073a08..5abef4818 100644
--- a/Source/WebKit2/Shared/API/c/qt/WKImageQt.h
+++ b/Source/WebKit2/Shared/API/c/qt/WKImageQt.h
@@ -27,5 +27,6 @@
#include <WebKit2/WKImage.h>
WK_EXPORT QImage WKImageCreateQImage(WKImageRef image);
+WK_EXPORT WKImageRef WKImageCreateFromQImage(const QImage& image);
#endif
diff --git a/Source/api.pri b/Source/api.pri
index bf0aa8558..a47b7359d 100644
--- a/Source/api.pri
+++ b/Source/api.pri
@@ -31,12 +31,9 @@ MODULE = webkitwidgets
QT_API_DEPENDS = core gui network
build?(webkit1): QT_API_DEPENDS += widgets
-qmakeVersion=$$[QMAKE_VERSION]
-equals(qmakeVersion, 3.0) {
- # We want the QtWebKit API forwarding includes to live in the root build dir.
- MODULE_BASE_DIR = $$_PRO_FILE_PWD_
- MODULE_BASE_OUTDIR = $$ROOT_BUILD_DIR
-}
+# We want the QtWebKit API forwarding includes to live in the root build dir.
+MODULE_BASE_DIR = $$_PRO_FILE_PWD_
+MODULE_BASE_OUTDIR = $$ROOT_BUILD_DIR
QMAKE_DOCS = $$PWD/qtwebkit.qdocconf