Log Message
Implement GraphicsSurface for Windows. https://bugs.webkit.org/show_bug.cgi?id=98147
Source/WebCore:
Reviewed by Kenneth Rohde Christiansen.
* Target.pri:
Include GraphicsSurfaceWin.cpp in SOURCES on Windows.
* platform/graphics/surfaces/GraphicsSurface.h:
Add typedef for PlatformGraphicsSurface on Windows.
* platform/graphics/surfaces/GraphicsSurfaceToken.h:
Add typedef for BufferHandle on Windows.
(GraphicsSurfaceToken):
* platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp: Added.
The GraphicsSurface implementation on Windows relies on the
availability of ANGLE and the EGL_ANGLE_query_surface_pointer extension.
For Qt this requirements are implicitly satisfied, when Qt is built
on Windows and QT_CONFIG contains OpenGLES2.
The GraphicsSurface then renders a given texture onto an offscreen
pixel buffer surface, queries the surface pointer using the
EGL_ANGLE_query_surface_pointer extension, and transmits the received
surface pointer (share handle) over IPC.
On the UIProcess side, the surface pointer can then be resolved
using eglCreatePbufferFromClientBuffer.
(WebCore):
(WebCore::loadShader):
Initialize the shaders needed for drawing onto the GraphicsSurface.
(GraphicsSurfacePrivate):
(WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
In case of the instance being on the WebProcess side,
create an EGLContext that shares the texture objects with the provided
share context. Also create two pixel buffer surfaces, one as front- and
one as backbuffer.
Query the surface pointers for the pixel buffer surfaces and initialize
the GraphicsSurfaceToken that can be passed over IPC later.
(WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
Release all aquired resources and destroy the pixel buffer surfaces.
Also close the EGL-Display connection.
(WebCore::GraphicsSurfacePrivate::copyFromTexture):
Make the belonging context current on the back buffer surface
and use drawTexture() to draw the provided texture onto the GraphicsSurface.
(WebCore::GraphicsSurfacePrivate::makeCurrent):
Save the previously current context, then make the context belonging
to the GraphicsSurface current.
(WebCore::GraphicsSurfacePrivate::doneCurrent):
Restore the context that was current before calling makeCurrent().
(WebCore::GraphicsSurfacePrivate::swapBuffers):
Swap front and back buffer surfaces and handles.
(WebCore::GraphicsSurfacePrivate::token):
(WebCore::GraphicsSurfacePrivate::frontBufferTextureID):
This function is meant to be called from the UIProcess side.
If no front buffer surface has been created before for the current
front buffer handle, one will be created.
Then eglBindTexImage will be used to actually bind the current
front buffer surface to a texture as a source for drawing.
(WebCore::GraphicsSurfacePrivate::initialFrontBufferShareHandle):
(WebCore::GraphicsSurfacePrivate::frontBufferShareHandle):
(WebCore::GraphicsSurfacePrivate::backBufferShareHandle):
(WebCore::GraphicsSurfacePrivate::releaseFrontBufferTexture):
Free the resources related to the front buffer surface.
On the UIProcess side we never actually bind the back buffer.
(WebCore::GraphicsSurfacePrivate::initializeShaderProgram):
Initialize and link the shader programs necessary for drawing
onto the GraphicsSurface.
(WebCore::GraphicsSurfacePrivate::createSurfaceFromShareHandle):
Creates a single pixel buffer surface from a share Handle.
This function will be called on the UIProcess side,
for the front buffer handle, whenever the buffers have been swapped.
(WebCore::GraphicsSurfacePrivate::drawTexture):
The WebProcess uses this function to draw a given
texture onto the GraphicsSurface's back buffer.
(WebCore::GraphicsSurface::platformExport):
(WebCore::GraphicsSurface::platformGetTextureID):
(WebCore::GraphicsSurface::platformCopyToGLTexture):
(WebCore::GraphicsSurface::platformCopyFromTexture):
(WebCore::GraphicsSurface::platformPaintToTextureMapper):
Uses TextureMapperGL::drawTexture() to draw the front buffer texture
to the TextureMapper on the UIProcess side.
(WebCore::GraphicsSurface::platformFrontBuffer):
(WebCore::GraphicsSurface::platformSwapBuffers):
(WebCore::GraphicsSurface::platformCreate):
(WebCore::GraphicsSurface::platformImport):
(WebCore::GraphicsSurface::platformLock):
(WebCore::GraphicsSurface::platformUnlock):
(WebCore::GraphicsSurface::platformDestroy):
Source/WebKit2:
Add encode and decode implementation for GraphicsSurfaceToken on Windows.
Reviewed by Kenneth Rohde Christiansen.
* Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
(CoreIPC::::encode):
(CoreIPC::::decode):
Tools:
Reviewed by Kenneth Rohde Christiansen.
* qmake/mkspecs/features/features.prf:
Activate GraphicsSurface on windows in case opengles2 (ANGLE)
is available in QT_CONFIG.
Modified Paths
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/Target.pri
- trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h
- trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h
- trunk/Source/WebKit2/ChangeLog
- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp
- trunk/Tools/ChangeLog
- trunk/Tools/qmake/mkspecs/features/features.prf
Added Paths
- trunk/Source/WebCore/platform/graphics/surfaces/win/
- trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
Diff
Modified: trunk/Source/WebCore/ChangeLog (132342 => 132343)
--- trunk/Source/WebCore/ChangeLog 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebCore/ChangeLog 2012-10-24 13:18:49 UTC (rev 132343)
@@ -1,3 +1,90 @@
+2012-10-24 Zeno Albisser <[email protected]>
+
+ Implement GraphicsSurface for Windows.
+ https://bugs.webkit.org/show_bug.cgi?id=98147
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ * Target.pri:
+ Include GraphicsSurfaceWin.cpp in SOURCES on Windows.
+ * platform/graphics/surfaces/GraphicsSurface.h:
+ Add typedef for PlatformGraphicsSurface on Windows.
+ * platform/graphics/surfaces/GraphicsSurfaceToken.h:
+ Add typedef for BufferHandle on Windows.
+ (GraphicsSurfaceToken):
+ * platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp: Added.
+ The GraphicsSurface implementation on Windows relies on the
+ availability of ANGLE and the EGL_ANGLE_query_surface_pointer extension.
+ For Qt this requirements are implicitly satisfied, when Qt is built
+ on Windows and QT_CONFIG contains OpenGLES2.
+ The GraphicsSurface then renders a given texture onto an offscreen
+ pixel buffer surface, queries the surface pointer using the
+ EGL_ANGLE_query_surface_pointer extension, and transmits the received
+ surface pointer (share handle) over IPC.
+ On the UIProcess side, the surface pointer can then be resolved
+ using eglCreatePbufferFromClientBuffer.
+ (WebCore):
+ (WebCore::loadShader):
+ Initialize the shaders needed for drawing onto the GraphicsSurface.
+ (GraphicsSurfacePrivate):
+ (WebCore::GraphicsSurfacePrivate::GraphicsSurfacePrivate):
+ In case of the instance being on the WebProcess side,
+ create an EGLContext that shares the texture objects with the provided
+ share context. Also create two pixel buffer surfaces, one as front- and
+ one as backbuffer.
+ Query the surface pointers for the pixel buffer surfaces and initialize
+ the GraphicsSurfaceToken that can be passed over IPC later.
+ (WebCore::GraphicsSurfacePrivate::~GraphicsSurfacePrivate):
+ Release all aquired resources and destroy the pixel buffer surfaces.
+ Also close the EGL-Display connection.
+ (WebCore::GraphicsSurfacePrivate::copyFromTexture):
+ Make the belonging context current on the back buffer surface
+ and use drawTexture() to draw the provided texture onto the GraphicsSurface.
+ (WebCore::GraphicsSurfacePrivate::makeCurrent):
+ Save the previously current context, then make the context belonging
+ to the GraphicsSurface current.
+ (WebCore::GraphicsSurfacePrivate::doneCurrent):
+ Restore the context that was current before calling makeCurrent().
+ (WebCore::GraphicsSurfacePrivate::swapBuffers):
+ Swap front and back buffer surfaces and handles.
+ (WebCore::GraphicsSurfacePrivate::token):
+ (WebCore::GraphicsSurfacePrivate::frontBufferTextureID):
+ This function is meant to be called from the UIProcess side.
+ If no front buffer surface has been created before for the current
+ front buffer handle, one will be created.
+ Then eglBindTexImage will be used to actually bind the current
+ front buffer surface to a texture as a source for drawing.
+ (WebCore::GraphicsSurfacePrivate::initialFrontBufferShareHandle):
+ (WebCore::GraphicsSurfacePrivate::frontBufferShareHandle):
+ (WebCore::GraphicsSurfacePrivate::backBufferShareHandle):
+ (WebCore::GraphicsSurfacePrivate::releaseFrontBufferTexture):
+ Free the resources related to the front buffer surface.
+ On the UIProcess side we never actually bind the back buffer.
+ (WebCore::GraphicsSurfacePrivate::initializeShaderProgram):
+ Initialize and link the shader programs necessary for drawing
+ onto the GraphicsSurface.
+ (WebCore::GraphicsSurfacePrivate::createSurfaceFromShareHandle):
+ Creates a single pixel buffer surface from a share Handle.
+ This function will be called on the UIProcess side,
+ for the front buffer handle, whenever the buffers have been swapped.
+ (WebCore::GraphicsSurfacePrivate::drawTexture):
+ The WebProcess uses this function to draw a given
+ texture onto the GraphicsSurface's back buffer.
+ (WebCore::GraphicsSurface::platformExport):
+ (WebCore::GraphicsSurface::platformGetTextureID):
+ (WebCore::GraphicsSurface::platformCopyToGLTexture):
+ (WebCore::GraphicsSurface::platformCopyFromTexture):
+ (WebCore::GraphicsSurface::platformPaintToTextureMapper):
+ Uses TextureMapperGL::drawTexture() to draw the front buffer texture
+ to the TextureMapper on the UIProcess side.
+ (WebCore::GraphicsSurface::platformFrontBuffer):
+ (WebCore::GraphicsSurface::platformSwapBuffers):
+ (WebCore::GraphicsSurface::platformCreate):
+ (WebCore::GraphicsSurface::platformImport):
+ (WebCore::GraphicsSurface::platformLock):
+ (WebCore::GraphicsSurface::platformUnlock):
+ (WebCore::GraphicsSurface::platformDestroy):
+
2012-09-27 Yury Semikhatsky <[email protected]>
Web Inspector: provide memory instrumentation for ListHashSet
Modified: trunk/Source/WebCore/Target.pri (132342 => 132343)
--- trunk/Source/WebCore/Target.pri 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebCore/Target.pri 2012-10-24 13:18:49 UTC (rev 132343)
@@ -4062,6 +4062,9 @@
SOURCES += platform/graphics/surfaces/mac/GraphicsSurfaceMac.cpp
INCLUDEPATH += /System/Library/Frameworks/CoreFoundation.framework/Headers
}
+ win32 {
+ SOURCES += platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp
+ }
have?(XCOMPOSITE) {
SOURCES += platform/graphics/surfaces/qt/GraphicsSurfaceGLX.cpp
}
Modified: trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h (132342 => 132343)
--- trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurface.h 2012-10-24 13:18:49 UTC (rev 132343)
@@ -35,10 +35,15 @@
typedef struct __IOSurface* IOSurfaceRef;
typedef IOSurfaceRef PlatformGraphicsSurface;
#endif
+
#if OS(LINUX)
typedef uint32_t PlatformGraphicsSurface;
#endif
+#if OS(WINDOWS)
+typedef HANDLE PlatformGraphicsSurface;
+#endif
+
namespace WebCore {
class BitmapTexture;
Modified: trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h (132342 => 132343)
--- trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebCore/platform/graphics/surfaces/GraphicsSurfaceToken.h 2012-10-24 13:18:49 UTC (rev 132343)
@@ -33,7 +33,12 @@
struct GraphicsSurfaceToken {
-typedef uint32_t BufferHandle;
+#if OS(DARWIN) || OS(LINUX)
+ typedef uint32_t BufferHandle;
+#endif
+#if OS(WINDOWS)
+ typedef HANDLE BufferHandle;
+#endif
#if HAVE(GLX)
GraphicsSurfaceToken(uint32_t windowID = 0)
@@ -52,7 +57,7 @@
#endif
-#if OS(DARWIN)
+#if OS(DARWIN) || OS(WINDOWS)
GraphicsSurfaceToken(BufferHandle frontBuffer = 0, BufferHandle backBuffer = 0)
: frontBufferHandle(frontBuffer)
, backBufferHandle(backBuffer)
Added: trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp (0 => 132343)
--- trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp (rev 0)
+++ trunk/Source/WebCore/platform/graphics/surfaces/win/GraphicsSurfaceWin.cpp 2012-10-24 13:18:49 UTC (rev 132343)
@@ -0,0 +1,492 @@
+/*
+
+ Copyright (C) 2012 Zeno Albisser <[email protected]>
+
+ 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.
+ */
+
+#include "config.h"
+#include "GraphicsSurface.h"
+
+#if USE(GRAPHICS_SURFACE)
+#include "TextureMapperGL.h"
+
+#define EGL_EGLEXT_PROTOTYPES // This must be defined before including egl.h and eglext.h.
+#include <EGL/egl.h>
+#include <EGL/eglext.h>
+
+#if PLATFORM(QT)
+#include <QGuiApplication>
+#include <QOpenGLContext>
+#include <qpa/qplatformnativeinterface.h>
+#endif
+
+namespace WebCore {
+
+#define STRINGIFY(...) #__VA_ARGS__
+
+static GLuint loadShader(GLenum type, const GLchar *shaderSrc)
+{
+ GLuint shader;
+ GLint compiled;
+
+ shader = glCreateShader(type);
+ if (!shader)
+ return 0;
+
+ glShaderSource(shader, 1, &shaderSrc, 0);
+ glCompileShader(shader);
+ glGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
+ if (!compiled) {
+ glDeleteShader(shader);
+ return 0;
+ }
+ return shader;
+}
+
+struct GraphicsSurfacePrivate {
+public:
+ GraphicsSurfacePrivate(const IntSize& size, GraphicsSurfaceToken token)
+ : m_token(token)
+ , m_detachedContext(0)
+ , m_detachedReadSurface(0)
+ , m_detachedDrawSurface(0)
+ , m_size(size)
+ , m_eglDisplay(0)
+ , m_eglContext(0)
+ , m_eglConfig(0)
+ , m_eglFrontBufferSurface(0)
+ , m_eglBackBufferSurface(0)
+ , m_initialFrontBufferShareHandle(token.frontBufferHandle)
+ , m_frontBufferShareHandle(token.frontBufferHandle)
+ , m_backBufferShareHandle(token.backBufferHandle)
+ , m_frontBufferTexture(0)
+ , m_shaderProgram(0)
+ {
+ initializeShaderProgram();
+ }
+
+
+ GraphicsSurfacePrivate(const PlatformGraphicsContext3D shareContext, const IntSize& size, GraphicsSurface::Flags flags)
+ : m_detachedContext(0)
+ , m_detachedReadSurface(0)
+ , m_detachedDrawSurface(0)
+ , m_size(size)
+ , m_eglDisplay(0)
+ , m_eglContext(0)
+ , m_eglConfig(0)
+ , m_eglFrontBufferSurface(0)
+ , m_eglBackBufferSurface(0)
+ , m_initialFrontBufferShareHandle(0)
+ , m_frontBufferShareHandle(0)
+ , m_backBufferShareHandle(0)
+ , m_frontBufferTexture(0)
+ , m_shaderProgram(0)
+ {
+ initializeShaderProgram();
+
+ static PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE = 0;
+ if (!eglQuerySurfacePointerANGLE) {
+ eglQuerySurfacePointerANGLE = reinterpret_cast<PFNEGLQUERYSURFACEPOINTERANGLEPROC>(eglGetProcAddress("eglQuerySurfacePointerANGLE"));
+ if (!eglQuerySurfacePointerANGLE)
+ return;
+ }
+
+ if (!m_eglDisplay || !m_eglContext || !m_eglConfig) {
+ m_eglDisplay = eglGetCurrentDisplay();
+
+#if PLATFORM(QT)
+ QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
+ m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglConfig"), shareContext));
+ EGLContext eglShareContext = static_cast<EGLContext>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglContext"), shareContext));
+#endif
+ EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NONE };
+ m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, eglShareContext, contextAttributes);
+ }
+
+ EGLint attributes[] = {
+ EGL_WIDTH, size.width(),
+ EGL_HEIGHT, size.height(),
+ EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
+ EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
+ EGL_NONE
+ };
+
+ m_eglFrontBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
+ m_eglBackBufferSurface = eglCreatePbufferSurface(m_eglDisplay, m_eglConfig, attributes);
+ if (m_eglFrontBufferSurface == EGL_NO_SURFACE || m_eglBackBufferSurface == EGL_NO_SURFACE)
+ return;
+
+ eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglFrontBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_frontBufferShareHandle);
+ eglQuerySurfacePointerANGLE(m_eglDisplay, m_eglBackBufferSurface, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, &m_backBufferShareHandle);
+
+ m_initialFrontBufferShareHandle = m_frontBufferShareHandle;
+
+ m_token = GraphicsSurfaceToken(m_frontBufferShareHandle, m_backBufferShareHandle);
+ }
+
+ ~GraphicsSurfacePrivate()
+ {
+ releaseFrontBufferTexture();
+
+ if (m_eglBackBufferSurface)
+ eglDestroySurface(m_eglDisplay, m_eglBackBufferSurface);
+
+ if (m_shaderProgram)
+ glDeleteProgram(m_shaderProgram);
+ m_shaderProgram = 0;
+
+ if (m_eglDisplay && m_eglContext)
+ eglDestroyContext(m_eglDisplay, m_eglContext);
+ }
+
+ void copyFromTexture(uint32_t texture, const IntRect& sourceRect)
+ {
+ if (!makeCurrent())
+ return;
+ glBindFramebuffer(GL_FRAMEBUFFER, 0);
+ drawTexture(texture);
+ glFinish();
+ doneCurrent();
+ }
+
+ bool makeCurrent()
+ {
+ m_detachedContext = eglGetCurrentContext();
+ m_detachedReadSurface = eglGetCurrentSurface(EGL_READ);
+ m_detachedDrawSurface = eglGetCurrentSurface(EGL_DRAW);
+
+ return eglMakeCurrent(m_eglDisplay, m_eglBackBufferSurface, m_eglBackBufferSurface, m_eglContext);
+ }
+
+ bool doneCurrent()
+ {
+ if (!m_detachedContext || !m_detachedDrawSurface || !m_detachedReadSurface)
+ return false;
+
+ bool success = eglMakeCurrent(m_eglDisplay, m_detachedDrawSurface, m_detachedReadSurface, m_detachedContext);
+ m_detachedContext = 0;
+ m_detachedReadSurface = 0;
+ m_detachedDrawSurface = 0;
+ return success;
+ }
+
+ PlatformGraphicsSurface swapBuffers()
+ {
+ if (m_frontBufferTexture)
+ releaseFrontBufferTexture();
+ std::swap(m_eglFrontBufferSurface, m_eglBackBufferSurface);
+ std::swap(m_frontBufferShareHandle, m_backBufferShareHandle);
+
+ return m_frontBufferShareHandle;
+ }
+
+ GraphicsSurfaceToken token() const
+ {
+ return m_token;
+ }
+
+ uint32_t frontBufferTextureID()
+ {
+ if (!m_eglFrontBufferSurface) {
+ m_eglFrontBufferSurface = createSurfaceFromShareHandle(m_size, m_frontBufferShareHandle);
+
+ glGenTextures(1, &m_frontBufferTexture);
+ glActiveTexture(GL_TEXTURE0);
+ glBindTexture(GL_TEXTURE_2D, m_frontBufferTexture);
+ eglBindTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+
+ return m_frontBufferTexture;
+ }
+
+ PlatformGraphicsSurface initialFrontBufferShareHandle() const
+ {
+ return m_initialFrontBufferShareHandle;
+ }
+
+ PlatformGraphicsSurface frontBufferShareHandle() const
+ {
+ return m_frontBufferShareHandle;
+ }
+
+ PlatformGraphicsSurface backBufferShareHandle() const
+ {
+ return m_backBufferShareHandle;
+ }
+
+ void releaseFrontBufferTexture()
+ {
+ if (m_frontBufferTexture) {
+ eglReleaseTexImage(m_eglDisplay, m_eglFrontBufferSurface, EGL_BACK_BUFFER);
+ glDeleteTextures(1, &m_frontBufferTexture);
+ m_frontBufferTexture = 0;
+ }
+
+ if (m_eglFrontBufferSurface)
+ eglDestroySurface(m_eglDisplay, m_eglFrontBufferSurface);
+ m_eglFrontBufferSurface = 0;
+ }
+
+
+protected:
+ void initializeShaderProgram()
+ {
+ if (m_shaderProgram)
+ return;
+
+ GLchar vShaderStr[] =
+ STRINGIFY(
+ attribute highp vec2 vertex;
+ attribute highp vec2 textureCoordinates;
+ varying highp vec2 textureCoords;
+ void main(void)
+ {
+ gl_Position = vec4(vertex, 0.0, 1.0);
+ textureCoords = textureCoordinates;
+ }
+ );
+
+ GLchar fShaderStr[] =
+ STRINGIFY(
+ varying highp vec2 textureCoords;
+ uniform sampler2D texture;
+ void main(void)
+ {
+ highp vec3 color = texture2D(texture, textureCoords).rgb;
+ gl_FragColor = vec4(clamp(color, 0.0, 1.0), 1.0);
+ }
+ );
+
+ GLuint vertexShader;
+ GLuint fragmentShader;
+ GLint linked;
+
+ vertexShader = loadShader(GL_VERTEX_SHADER, vShaderStr);
+ fragmentShader = loadShader(GL_FRAGMENT_SHADER, fShaderStr);
+ if (!vertexShader || !fragmentShader)
+ return;
+
+ m_shaderProgram = glCreateProgram();
+ if (!m_shaderProgram)
+ return;
+
+ glAttachShader(m_shaderProgram, vertexShader);
+ glAttachShader(m_shaderProgram, fragmentShader);
+
+ glLinkProgram(m_shaderProgram);
+ glGetProgramiv(m_shaderProgram, GL_LINK_STATUS, &linked);
+ if (!linked) {
+ glDeleteProgram(m_shaderProgram);
+ m_shaderProgram = 0;
+ }
+
+ m_vertexAttr = glGetAttribLocation(m_shaderProgram, "vertex");
+ m_textureCoordinatesAttr = glGetAttribLocation(m_shaderProgram, "textureCoordinates");
+ m_textureUniform = glGetAttribLocation(m_shaderProgram, "texture");
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ }
+
+ EGLSurface createSurfaceFromShareHandle(const IntSize& size, HANDLE shareHandle)
+ {
+ if (!m_eglDisplay || !m_eglConfig) {
+ m_eglDisplay = eglGetCurrentDisplay();
+
+#if PLATFORM(QT)
+ QPlatformNativeInterface* nativeInterface = QGuiApplication::platformNativeInterface();
+ m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResourceForContext(QByteArrayLiteral("eglConfig"), QOpenGLContext::currentContext()));
+#endif
+ }
+
+ EGLint attributes[] = {
+ EGL_WIDTH, size.width(),
+ EGL_HEIGHT, size.height(),
+ EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
+ EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
+ EGL_NONE
+ };
+
+ EGLSurface surface = eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<EGLClientBuffer>(shareHandle), m_eglConfig, attributes);
+ ASSERT(surface);
+
+ return surface;
+ }
+
+ void drawTexture(uint32_t texture)
+ {
+ glUseProgram(m_shaderProgram);
+
+ glBindBuffer(GL_ARRAY_BUFFER, 0);
+ glBindTexture(GL_TEXTURE_2D, texture);
+
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+
+ GLfloat afVertices[] = {
+ -1, -1,
+ 1, -1,
+ -1, 1,
+ 1, 1
+ };
+ glVertexAttribPointer(m_vertexAttr, 2, GL_FLOAT, GL_FALSE, 0, afVertices);
+
+ GLfloat aftextureCoordinates[] = {
+ 0, 1,
+ 1, 1,
+ 0, 0,
+ 1, 0
+ };
+ glVertexAttribPointer(m_textureCoordinatesAttr, 2, GL_FLOAT, GL_FALSE, 0, aftextureCoordinates);
+
+ glUniform1i(m_textureUniform, 0);
+
+ glEnableVertexAttribArray(m_vertexAttr);
+ glEnableVertexAttribArray(m_textureCoordinatesAttr);
+
+ glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
+
+ glDisableVertexAttribArray(m_vertexAttr);
+ glDisableVertexAttribArray(m_textureCoordinatesAttr);
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ }
+
+private:
+ GraphicsSurfaceToken m_token;
+ EGLContext m_detachedContext;
+ EGLSurface m_detachedReadSurface;
+ EGLSurface m_detachedDrawSurface;
+ IntSize m_size;
+ EGLDisplay m_eglDisplay;
+ EGLContext m_eglContext;
+ EGLConfig m_eglConfig;
+ EGLSurface m_eglFrontBufferSurface;
+ EGLSurface m_eglBackBufferSurface;
+ PlatformGraphicsSurface m_initialFrontBufferShareHandle;
+ PlatformGraphicsSurface m_frontBufferShareHandle;
+ PlatformGraphicsSurface m_backBufferShareHandle;
+ GLuint m_frontBufferTexture;
+ GLint m_shaderProgram;
+
+ GLuint m_vertexAttr;
+ GLuint m_textureCoordinatesAttr;
+ GLuint m_textureUniform;
+};
+
+GraphicsSurfaceToken GraphicsSurface::platformExport()
+{
+ return m_private->token();
+}
+
+uint32_t GraphicsSurface::platformGetTextureID()
+{
+ return m_private->frontBufferTextureID();
+}
+
+void GraphicsSurface::platformCopyToGLTexture(uint32_t target, uint32_t id, const IntRect& targetRect, const IntPoint& offset)
+{
+ // Currently not implemented.
+}
+
+void GraphicsSurface::platformCopyFromTexture(uint32_t texture, const IntRect& sourceRect)
+{
+ m_private->copyFromTexture(texture, sourceRect);
+}
+
+void GraphicsSurface::platformPaintToTextureMapper(TextureMapper* textureMapper, const FloatRect& targetRect, const TransformationMatrix& transform, float opacity, BitmapTexture* mask)
+{
+ GLuint frontBufferTexture = platformGetTextureID();
+
+ TransformationMatrix adjustedTransform = transform;
+ adjustedTransform.multiply(TransformationMatrix::rectToRect(FloatRect(FloatPoint::zero(), m_size), targetRect));
+ static_cast<TextureMapperGL*>(textureMapper)->drawTexture(frontBufferTexture, 0, m_size, targetRect, adjustedTransform, opacity, mask);
+}
+
+uint32_t GraphicsSurface::platformFrontBuffer() const
+{
+ if (m_private->initialFrontBufferShareHandle() == m_private->frontBufferShareHandle())
+ return 0;
+ if (m_private->initialFrontBufferShareHandle() == m_private->backBufferShareHandle())
+ return 1;
+ return 0xFFFF;
+}
+
+uint32_t GraphicsSurface::platformSwapBuffers()
+{
+ m_private->swapBuffers();
+ return platformFrontBuffer();
+}
+
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformCreate(const IntSize& size, Flags flags, const PlatformGraphicsContext3D shareContext)
+{
+ // Single buffered GraphicsSurface is currently not supported.
+ if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
+ return PassRefPtr<GraphicsSurface>();
+
+ RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
+ surface->m_private = new GraphicsSurfacePrivate(shareContext, size, flags);
+
+ if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
+ return PassRefPtr<GraphicsSurface>();
+
+ return surface;
+}
+
+PassRefPtr<GraphicsSurface> GraphicsSurface::platformImport(const IntSize& size, Flags flags, const GraphicsSurfaceToken& token)
+{
+ // Single buffered GraphicsSurface is currently not supported.
+ if (flags & SupportsCopyToTexture || flags & SupportsSingleBuffered)
+ return PassRefPtr<GraphicsSurface>();
+
+ RefPtr<GraphicsSurface> surface = adoptRef(new GraphicsSurface(size, flags));
+ surface->m_private = new GraphicsSurfacePrivate(size, token);
+
+ if (!surface->m_private->frontBufferShareHandle() || !surface->m_private->backBufferShareHandle())
+ return PassRefPtr<GraphicsSurface>();
+
+ return surface;
+}
+
+char* GraphicsSurface::platformLock(const IntRect& rect, int* outputStride, LockOptions lockOptions)
+{
+ // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
+ return 0;
+}
+
+void GraphicsSurface::platformUnlock()
+{
+ // GraphicsSurface is currently only being used for WebGL, which does not require this locking mechanism.
+}
+
+void GraphicsSurface::platformDestroy()
+{
+ delete m_private;
+ m_private = 0;
+}
+
+}
+#endif
Modified: trunk/Source/WebKit2/ChangeLog (132342 => 132343)
--- trunk/Source/WebKit2/ChangeLog 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebKit2/ChangeLog 2012-10-24 13:18:49 UTC (rev 132343)
@@ -1,3 +1,16 @@
+2012-10-24 Zeno Albisser <[email protected]>
+
+ Implement GraphicsSurface for Windows.
+ https://bugs.webkit.org/show_bug.cgi?id=98147
+
+ Add encode and decode implementation for GraphicsSurfaceToken on Windows.
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ * Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp:
+ (CoreIPC::::encode):
+ (CoreIPC::::decode):
+
2012-10-24 Sudarsana Nagineni <[email protected]>
[EFL][WK2] ASSERTION FAILED: edje(): could not paint native HTML part due to missing theme
Modified: trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp (132342 => 132343)
--- trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Source/WebKit2/Shared/CoordinatedGraphics/CoordinatedGraphicsArgumentCoders.cpp 2012-10-24 13:18:49 UTC (rev 132343)
@@ -717,24 +717,40 @@
void ArgumentCoder<WebCore::GraphicsSurfaceToken>::encode(ArgumentEncoder* encoder, const WebCore::GraphicsSurfaceToken& token)
{
#if OS(DARWIN)
- encoder->encode(static_cast<uint32_t>(token.frontBufferHandle));
- encoder->encode(static_cast<uint32_t>(token.backBufferHandle));
+ encoder->encode(token.frontBufferHandle);
+ encoder->encode(token.backBufferHandle);
#endif
+#if OS(WINDOWS)
+ uint64_t frontBuffer = reinterpret_cast<uintptr_t>(token.frontBufferHandle);
+ encoder->encode(frontBuffer);
+ uint64_t backBuffer = reinterpret_cast<uintptr_t>(token.backBufferHandle);
+ encoder->encode(backBuffer);
+#endif
#if OS(LINUX)
- encoder->encode(static_cast<uint32_t>(token.frontBufferHandle));
+ encoder->encode(token.frontBufferHandle);
#endif
}
bool ArgumentCoder<WebCore::GraphicsSurfaceToken>::decode(ArgumentDecoder* decoder, WebCore::GraphicsSurfaceToken& token)
{
#if OS(DARWIN)
- if (!decoder->decodeUInt32(token.frontBufferHandle))
+ if (!decoder->decode(token.frontBufferHandle))
return false;
- if (!decoder->decodeUInt32(token.backBufferHandle))
+ if (!decoder->decode(token.backBufferHandle))
return false;
#endif
+#if OS(WINDOWS)
+ uint64_t frontBufferHandle;
+ if (!decoder->decode(frontBufferHandle))
+ return false;
+ token.frontBufferHandle = reinterpret_cast<GraphicsSurfaceToken::BufferHandle>(frontBufferHandle);
+ uint64_t backBufferHandle;
+ if (!decoder->decode(backBufferHandle))
+ return false;
+ token.backBufferHandle = reinterpret_cast<GraphicsSurfaceToken::BufferHandle>(backBufferHandle);
+#endif
#if OS(LINUX)
- if (!decoder->decodeUInt32(token.frontBufferHandle))
+ if (!decoder->decode(token.frontBufferHandle))
return false;
#endif
return true;
Modified: trunk/Tools/ChangeLog (132342 => 132343)
--- trunk/Tools/ChangeLog 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Tools/ChangeLog 2012-10-24 13:18:49 UTC (rev 132343)
@@ -1,3 +1,14 @@
+2012-10-24 Zeno Albisser <[email protected]>
+
+ Implement GraphicsSurface for Windows.
+ https://bugs.webkit.org/show_bug.cgi?id=98147
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ * qmake/mkspecs/features/features.prf:
+ Activate GraphicsSurface on windows in case opengles2 (ANGLE)
+ is available in QT_CONFIG.
+
2012-10-24 Raphael Kubo da Costa <[email protected]>
[EFL][WK2] fast/repaint/delete-into-nested-block.html and fast/repaint/4776765.html are flaky
Modified: trunk/Tools/qmake/mkspecs/features/features.prf (132342 => 132343)
--- trunk/Tools/qmake/mkspecs/features/features.prf 2012-10-24 12:38:10 UTC (rev 132342)
+++ trunk/Tools/qmake/mkspecs/features/features.prf 2012-10-24 13:18:49 UTC (rev 132343)
@@ -127,6 +127,7 @@
# GraphicsSurface requires GraphicsContext3D and hence use_3d_graphics
use?(3d_graphics) {
mac: WEBKIT_CONFIG += use_graphics_surface
+ win32:contains(QT_CONFIG, opengles2): WEBKIT_CONFIG += use_graphics_surface
linux-*:contains(WEBKIT_CONFIG, have_glx):contains(WEBKIT_CONFIG, have_xcomposite):contains(WEBKIT_CONFIG, have_xrender): WEBKIT_CONFIG += use_graphics_surface
}
_______________________________________________ webkit-changes mailing list [email protected] http://lists.webkit.org/mailman/listinfo/webkit-changes
