summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/surfaces
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/surfaces')
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp4
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h12
-rw-r--r--Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h80
-rw-r--r--Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp25
-rw-r--r--Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp18
-rw-r--r--Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp3
6 files changed, 113 insertions, 29 deletions
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
index 9ff3881d0..c16a37799 100644
--- a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.cpp
@@ -25,7 +25,7 @@
#if USE(GRAPHICS_SURFACE)
namespace WebCore {
-PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags flags, uint64_t token)
+PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
{
return platformImport(size, flags, token);
}
@@ -35,7 +35,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::create(const IntSize& size, Graphic
return platformCreate(size, flags);
}
-uint64_t GraphicsSurface::exportToken()
+GraphicsSurfaceToken GraphicsSurface::exportToken()
{
return platformExport();
}
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
index 0ee68cf3d..e78ebbc0e 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 "GraphicsSurfaceToken.h"
#include "IntRect.h"
#include <wtf/OwnPtr.h>
#include <wtf/PassOwnPtr.h>
@@ -32,7 +33,8 @@
#if OS(DARWIN)
typedef struct __IOSurface* IOSurfaceRef;
typedef IOSurfaceRef PlatformGraphicsSurface;
-#else
+#endif
+#if OS(LINUX)
typedef uint32_t PlatformGraphicsSurface;
#endif
@@ -69,13 +71,13 @@ public:
IntSize size() const { return m_size; }
static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags);
- static PassRefPtr<GraphicsSurface> create(const IntSize&, Flags, uint64_t token);
+ 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 paintToTextureMapper(TextureMapper*, const FloatRect& targetRect, const TransformationMatrix&, float opacity, BitmapTexture* mask);
uint32_t frontBuffer();
uint32_t swapBuffers();
- uint64_t exportToken();
+ GraphicsSurfaceToken exportToken();
uint32_t getTextureID();
PassOwnPtr<GraphicsContext> beginPaint(const IntRect&, LockOptions);
PassRefPtr<Image> createReadOnlyImage(const IntRect&);
@@ -83,8 +85,8 @@ public:
protected:
static PassRefPtr<GraphicsSurface> platformCreate(const IntSize&, Flags);
- static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, uint64_t);
- uint64_t platformExport();
+ static PassRefPtr<GraphicsSurface> platformImport(const IntSize&, Flags, const GraphicsSurfaceToken&);
+ GraphicsSurfaceToken platformExport();
void platformDestroy();
uint32_t platformGetTextureID();
diff --git a/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h b/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h
new file mode 100644
index 000000000..45342f141
--- /dev/null
+++ b/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h
@@ -0,0 +1,80 @@
+/*
+ Copyright (C) 2012 Digia Corporation and/or its subsidiary(-ies)
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Library General Public
+ License as published by the Free Software Foundation; either
+ version 2 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Library General Public License
+ along with this library; see the file COPYING.LIB. If not, write to
+ the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02110-1301, USA.
+ */
+
+#ifndef GraphicsSurfaceToken_h
+#define GraphicsSurfaceToken_h
+
+#include "GraphicsContext.h"
+#include "IntRect.h"
+#include <wtf/OwnPtr.h>
+#include <wtf/PassOwnPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+
+#if USE(GRAPHICS_SURFACE)
+
+namespace WebCore {
+
+struct GraphicsSurfaceToken {
+
+typedef uint32_t BufferHandle;
+
+#if HAVE(GLX)
+ GraphicsSurfaceToken(uint32_t windowID = 0)
+ : frontBufferHandle(windowID)
+ { }
+
+ bool operator!=(const GraphicsSurfaceToken &rhs) const
+ {
+ return frontBufferHandle != rhs.frontBufferHandle;
+ }
+
+ bool isValid() const
+ {
+ return frontBufferHandle;
+ }
+
+#endif
+
+#if OS(DARWIN)
+ GraphicsSurfaceToken(BufferHandle frontBuffer = 0, BufferHandle backBuffer = 0)
+ : frontBufferHandle(frontBuffer)
+ , backBufferHandle(backBuffer)
+ { }
+
+ bool operator!=(const GraphicsSurfaceToken &rhs) const
+ {
+ return (frontBufferHandle != rhs.frontBufferHandle || backBufferHandle != rhs.backBufferHandle);
+ }
+
+ bool isValid() const
+ {
+ return frontBufferHandle && backBufferHandle;
+ }
+
+ BufferHandle backBufferHandle;
+#endif
+
+ BufferHandle frontBufferHandle;
+};
+
+}
+#endif // USE(GRAPHICS_SURFACE)
+
+#endif // GraphicsSurfaceToken_h
diff --git a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
index 8a8322df8..94c339176 100644
--- a/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
@@ -64,18 +64,13 @@ static uint32_t createTexture(IOSurfaceRef handle)
struct GraphicsSurfacePrivate {
public:
- GraphicsSurfacePrivate(uint64_t token)
+ GraphicsSurfacePrivate(const GraphicsSurfaceToken& token)
: m_token(token)
, m_frontBufferTexture(0)
, m_backBufferTexture(0)
{
- // The token contains the IOSurfaceID of the fist surface/buffer in the first 32 Bit
- // and the IOSurfaceID of the second surface/buffer in the second 32 Bit.
- uint32_t frontBuffer = token >> 32;
- uint32_t backBuffer = token & 0xffff;
-
- m_frontBuffer = IOSurfaceLookup(frontBuffer);
- m_backBuffer = IOSurfaceLookup(backBuffer);
+ m_frontBuffer = IOSurfaceLookup(m_token.frontBufferHandle);
+ m_backBuffer = IOSurfaceLookup(m_token.backBufferHandle);
}
GraphicsSurfacePrivate(const IntSize& size, GraphicsSurface::Flags flags)
@@ -119,11 +114,7 @@ public:
m_frontBuffer = IOSurfaceCreate(dict);
m_backBuffer = IOSurfaceCreate(dict);
- uint64_t token = IOSurfaceGetID(m_frontBuffer);
- token <<= 32;
- token |= IOSurfaceGetID(m_backBuffer);
-
- m_token = token;
+ m_token = GraphicsSurfaceToken(IOSurfaceGetID(m_frontBuffer), IOSurfaceGetID(m_backBuffer));
}
~GraphicsSurfacePrivate()
@@ -149,7 +140,7 @@ public:
return IOSurfaceGetID(m_frontBuffer);
}
- uint64_t token() const
+ GraphicsSurfaceToken token() const
{
return m_token;
}
@@ -185,10 +176,10 @@ private:
PlatformGraphicsSurface m_backBuffer;
uint32_t m_frontBufferTexture;
uint32_t m_backBufferTexture;
- uint64_t m_token;
+ GraphicsSurfaceToken m_token;
};
-uint64_t GraphicsSurface::platformExport()
+GraphicsSurfaceToken GraphicsSurface::platformExport()
{
return m_private->token();
}
@@ -276,7 +267,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size,
return surface;
}
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, uint64_t token)
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
{
// 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.
diff --git a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
index 1bbeb73b9..2fd6cba46 100644
--- a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
@@ -107,8 +107,18 @@ struct GraphicsSurfacePrivate {
, m_textureIsYInverted(false)
, m_hasAlpha(false)
{
+ QSurface* currentSurface = 0;
+ QOpenGLContext* currentContext = QOpenGLContext::currentContext();
+ if (currentContext)
+ currentSurface = currentContext->surface();
+
m_display = XOpenDisplay(0);
m_glContext->create();
+
+ // The GLX implementation of QOpenGLContext will reset the current context when create is being called.
+ // Therefore we have to make the previous context current again.
+ if (currentContext)
+ currentContext->makeCurrent(currentSurface);
}
~GraphicsSurfacePrivate()
@@ -237,9 +247,9 @@ static bool resolveGLMethods(GraphicsSurfacePrivate* p)
return resolved;
}
-uint64_t GraphicsSurface::platformExport()
+GraphicsSurfaceToken GraphicsSurface::platformExport()
{
- return m_platformSurface;
+ return GraphicsSurfaceToken(m_platformSurface);
}
uint32_t GraphicsSurface::platformGetTextureID()
@@ -316,7 +326,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size,
return surface;
}
-PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, uint64_t token)
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
{
// 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.
@@ -330,7 +340,7 @@ PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size,
if (!resolveGLMethods(surface->m_private))
return PassRefPtr<GraphicsSurface>();
- surface->m_platformSurface = token;
+ surface->m_platformSurface = token.frontBufferHandle;
surface->m_private->createPixmap(surface->m_platformSurface);
surface->m_size = surface->m_private->size();
diff --git a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp
index e1b275893..734a093ae 100644
--- a/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp
+++ b/Source/WebCore/platform/graphics/surfaces/qt/GraphicsSurfaceQt.cpp
@@ -52,7 +52,8 @@ PassRefPtr<Image> GraphicsSurface::createReadOnlyImage(const IntRect& rect)
int stride;
QImage::Format format = (flags() & SupportsAlpha) ? QImage::Format_ARGB32_Premultiplied : QImage::Format_RGB32;
char* data = platformLock(rect, &stride, RetainPixels | ReadOnly);
- return BitmapImage::create(new QImage(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this));
+ QImage image(reinterpret_cast<uchar*>(data), rect.width(), rect.height(), stride, format, didReleaseImage, this);
+ return BitmapImage::create(new QPixmap(QPixmap::fromImage(image)));
}
}