| OLD | NEW |
| 1 /* | 1 /* |
| 2 | 2 |
| 3 Copyright (C) 2012 Zeno Albisser <zeno@webkit.org> | 3 Copyright (C) 2012 Zeno Albisser <zeno@webkit.org> |
| 4 | 4 |
| 5 This library is free software; you can redistribute it and/or | 5 This library is free software; you can redistribute it and/or |
| 6 modify it under the terms of the GNU Library General Public | 6 modify it under the terms of the GNU Library General Public |
| 7 License as published by the Free Software Foundation; either | 7 License as published by the Free Software Foundation; either |
| 8 version 2 of the License, or (at your option) any later version. | 8 version 2 of the License, or (at your option) any later version. |
| 9 | 9 |
| 10 This library is distributed in the hope that it will be useful, | 10 This library is distributed in the hope that it will be useful, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "config.h" | 21 #include "config.h" |
| 22 #include "GraphicsSurface.h" | 22 #include "GraphicsSurface.h" |
| 23 | 23 |
| 24 #if USE(GRAPHICS_SURFACE) | 24 #if USE(GRAPHICS_SURFACE) |
| 25 #include "TextureMapperGL.h" | 25 #include "TextureMapperGL.h" |
| 26 | 26 |
| 27 #define EGL_EGLEXT_PROTOTYPES // This must be defined before including egl.h and
eglext.h. | 27 #define EGL_EGLEXT_PROTOTYPES // This must be defined before including egl.h and
eglext.h. |
| 28 #include <EGL/egl.h> | 28 #include <EGL/egl.h> |
| 29 #include <EGL/eglext.h> | 29 #include <EGL/eglext.h> |
| 30 | 30 |
| 31 #if PLATFORM(QT) | |
| 32 #include <QGuiApplication> | |
| 33 #include <QOpenGLContext> | |
| 34 #include <qpa/qplatformnativeinterface.h> | |
| 35 #endif | |
| 36 | |
| 37 namespace WebCore { | 31 namespace WebCore { |
| 38 | 32 |
| 39 #define STRINGIFY(...) #__VA_ARGS__ | 33 #define STRINGIFY(...) #__VA_ARGS__ |
| 40 | 34 |
| 41 static GLuint loadShader(GLenum type, const GLchar *shaderSrc) | 35 static GLuint loadShader(GLenum type, const GLchar *shaderSrc) |
| 42 { | 36 { |
| 43 GLuint shader; | 37 GLuint shader; |
| 44 GLint compiled; | 38 GLint compiled; |
| 45 | 39 |
| 46 shader = glCreateShader(type); | 40 shader = glCreateShader(type); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 94 |
| 101 static PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE =
0; | 95 static PFNEGLQUERYSURFACEPOINTERANGLEPROC eglQuerySurfacePointerANGLE =
0; |
| 102 if (!eglQuerySurfacePointerANGLE) { | 96 if (!eglQuerySurfacePointerANGLE) { |
| 103 eglQuerySurfacePointerANGLE = reinterpret_cast<PFNEGLQUERYSURFACEPOI
NTERANGLEPROC>(eglGetProcAddress("eglQuerySurfacePointerANGLE")); | 97 eglQuerySurfacePointerANGLE = reinterpret_cast<PFNEGLQUERYSURFACEPOI
NTERANGLEPROC>(eglGetProcAddress("eglQuerySurfacePointerANGLE")); |
| 104 if (!eglQuerySurfacePointerANGLE) | 98 if (!eglQuerySurfacePointerANGLE) |
| 105 return; | 99 return; |
| 106 } | 100 } |
| 107 | 101 |
| 108 if (!m_eglDisplay || !m_eglContext || !m_eglConfig) { | 102 if (!m_eglDisplay || !m_eglContext || !m_eglConfig) { |
| 109 m_eglDisplay = eglGetCurrentDisplay(); | 103 m_eglDisplay = eglGetCurrentDisplay(); |
| 110 | |
| 111 #if PLATFORM(QT) | |
| 112 QPlatformNativeInterface* nativeInterface = QGuiApplication::platfor
mNativeInterface(); | |
| 113 m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResource
ForContext(QByteArrayLiteral("eglConfig"), shareContext)); | |
| 114 EGLContext eglShareContext = static_cast<EGLContext>(nativeInterface
->nativeResourceForContext(QByteArrayLiteral("eglContext"), shareContext)); | |
| 115 #endif | |
| 116 EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NO
NE }; | 104 EGLint contextAttributes[] = { EGL_CONTEXT_CLIENT_VERSION, 2, EGL_NO
NE }; |
| 117 m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, eglShareC
ontext, contextAttributes); | 105 m_eglContext = eglCreateContext(m_eglDisplay, m_eglConfig, eglShareC
ontext, contextAttributes); |
| 118 } | 106 } |
| 119 | 107 |
| 120 EGLint attributes[] = { | 108 EGLint attributes[] = { |
| 121 EGL_WIDTH, size.width(), | 109 EGL_WIDTH, size.width(), |
| 122 EGL_HEIGHT, size.height(), | 110 EGL_HEIGHT, size.height(), |
| 123 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, | 111 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, |
| 124 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, | 112 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, |
| 125 EGL_NONE | 113 EGL_NONE |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 m_textureUniform = glGetAttribLocation(m_shaderProgram, "texture"); | 296 m_textureUniform = glGetAttribLocation(m_shaderProgram, "texture"); |
| 309 | 297 |
| 310 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 298 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 311 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | 299 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
| 312 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); | 300 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); |
| 313 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | 301 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |
| 314 } | 302 } |
| 315 | 303 |
| 316 EGLSurface createSurfaceFromShareHandle(const IntSize& size, HANDLE shareHan
dle) | 304 EGLSurface createSurfaceFromShareHandle(const IntSize& size, HANDLE shareHan
dle) |
| 317 { | 305 { |
| 318 if (!m_eglDisplay || !m_eglConfig) { | 306 if (!m_eglDisplay || !m_eglConfig) |
| 319 m_eglDisplay = eglGetCurrentDisplay(); | 307 m_eglDisplay = eglGetCurrentDisplay(); |
| 320 | 308 |
| 321 #if PLATFORM(QT) | |
| 322 QPlatformNativeInterface* nativeInterface = QGuiApplication::platfor
mNativeInterface(); | |
| 323 m_eglConfig = static_cast<EGLConfig>(nativeInterface->nativeResource
ForContext(QByteArrayLiteral("eglConfig"), QOpenGLContext::currentContext())); | |
| 324 #endif | |
| 325 } | |
| 326 | |
| 327 EGLint attributes[] = { | 309 EGLint attributes[] = { |
| 328 EGL_WIDTH, size.width(), | 310 EGL_WIDTH, size.width(), |
| 329 EGL_HEIGHT, size.height(), | 311 EGL_HEIGHT, size.height(), |
| 330 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, | 312 EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB, |
| 331 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, | 313 EGL_TEXTURE_TARGET, EGL_TEXTURE_2D, |
| 332 EGL_NONE | 314 EGL_NONE |
| 333 }; | 315 }; |
| 334 | 316 |
| 335 EGLSurface surface = eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_
D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<EGLClientBuffer>(shareHandle
), m_eglConfig, attributes); | 317 EGLSurface surface = eglCreatePbufferFromClientBuffer(m_eglDisplay, EGL_
D3D_TEXTURE_2D_SHARE_HANDLE_ANGLE, reinterpret_cast<EGLClientBuffer>(shareHandle
), m_eglConfig, attributes); |
| 336 ASSERT(surface); | 318 ASSERT(surface); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 492 } | 474 } |
| 493 | 475 |
| 494 void GraphicsSurface::platformDestroy() | 476 void GraphicsSurface::platformDestroy() |
| 495 { | 477 { |
| 496 delete m_private; | 478 delete m_private; |
| 497 m_private = 0; | 479 m_private = 0; |
| 498 } | 480 } |
| 499 | 481 |
| 500 } | 482 } |
| 501 #endif | 483 #endif |
| OLD | NEW |