summaryrefslogtreecommitdiff
path: root/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp')
-rw-r--r--Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp80
1 files changed, 72 insertions, 8 deletions
diff --git a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
index a0bc40357..51d5db650 100644
--- a/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
+++ b/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp
@@ -36,7 +36,14 @@
#include <OpenGLES/ES2/glext.h>
#elif PLATFORM(MAC)
#include <OpenGL/gl.h>
-#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(QT) || PLATFORM(WIN)
+#elif PLATFORM(QT)
+#define FUNCTIONS m_context->m_functions
+#include "OpenGLShimsQt.h"
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+#define VAO_FUNCTIONS m_vaoFunctions
+#include "OpenGLShimsQtVAO.h"
+#endif
+#elif PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN)
#include "OpenGLShims.h"
#endif
@@ -44,15 +51,25 @@
#include "GraphicsContext3DIOS.h"
#endif
+// Note this implementation serves a double role for Qt where it also handles OpenGLES.
+
namespace WebCore {
Extensions3DOpenGL::Extensions3DOpenGL(GraphicsContext3D* context)
: Extensions3DOpenGLCommon(context)
{
+#if PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ context->makeContextCurrent();
+ m_vaoFunctions = new QOpenGLVertexArrayObjectHelper(context->platformGraphicsContext3D());
+#endif
}
Extensions3DOpenGL::~Extensions3DOpenGL()
{
+#if PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ delete m_vaoFunctions;
+ m_vaoFunctions = 0;
+#endif
}
@@ -119,6 +136,8 @@ GC3Dboolean Extensions3DOpenGL::isVertexArrayOES(Platform3DObject array)
#elif defined(GL_APPLE_vertex_array_object) && GL_APPLE_vertex_array_object
return glIsVertexArrayAPPLE(array);
#endif
+
+ m_context->synthesizeGLError(GL_INVALID_OPERATION);
return GL_FALSE;
}
@@ -157,6 +176,23 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
{
// GL_ANGLE_framebuffer_blit and GL_ANGLE_framebuffer_multisample are "fake". They are implemented using other
// extensions. In particular GL_EXT_framebuffer_blit and GL_EXT_framebuffer_multisample/GL_APPLE_framebuffer_multisample.
+#if PLATFORM(QT)
+ m_context->makeContextCurrent();
+
+ if (name == "GL_ANGLE_framebuffer_blit" || name == "GL_EXT_framebuffer_blit")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferBlit);
+ if (name == "GL_ANGLE_framebuffer_multisample" || name == "GL_EXT_framebuffer_multisample")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample);
+
+ if (name == "GL_OES_texture_npot" || name == "GL_ARB_texture_non_power_of_two")
+ return m_context->m_functions->hasOpenGLFeature(QOpenGLFunctions::NPOTTextures);
+ if (name == "GL_OES_packed_depth_stencil" || name == "GL_EXT_packed_depth_stencil")
+ return m_context->m_functions->hasOpenGLExtension(QOpenGLExtensions::PackedDepthStencil);
+
+ // FIXME: We don't have the robustness methods from Extensions3DOpenGLES.
+ if (name == "GL_EXT_robustness")
+ return false;
+#else
if (name == "GL_ANGLE_framebuffer_blit")
return m_availableExtensions.contains("GL_EXT_framebuffer_blit");
if (name == "GL_ANGLE_framebuffer_multisample")
@@ -165,6 +201,7 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
#else
return m_availableExtensions.contains("GL_EXT_framebuffer_multisample");
#endif
+#endif // !PLATFORM(QT)
if (name == "GL_ANGLE_instanced_arrays") {
return (m_availableExtensions.contains("GL_ARB_instanced_arrays") || m_availableExtensions.contains("GL_EXT_instanced_arrays"))
@@ -185,6 +222,10 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
return m_availableExtensions.contains("GL_EXT_frag_depth");
#endif
+#if PLATFORM(QT)
+ if (!m_context->isGLES2Compliant()) {
+#endif
+
// Desktop GL always supports GL_OES_rgb8_rgba8.
if (name == "GL_OES_rgb8_rgba8")
return true;
@@ -194,17 +235,27 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
if (name == "GL_OES_texture_float" || name == "GL_OES_texture_half_float" || name == "GL_OES_texture_float_linear" || name == "GL_OES_texture_half_float_linear")
return m_availableExtensions.contains("GL_ARB_texture_float") || m_availableExtensions.contains("GL_OES_texture_float");
+#if PLATFORM(QT)
+ }
+#endif
+
// GL_OES_vertex_array_object
if (name == "GL_OES_vertex_array_object") {
-#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL))
+#if (PLATFORM(GTK) || PLATFORM(EFL))
return m_availableExtensions.contains("GL_ARB_vertex_array_object");
#elif PLATFORM(IOS)
return m_availableExtensions.contains("GL_OES_vertex_array_object");
+#elif PLATFORM(QT)
+ return isVertexArrayObjectSupported();
#else
return m_availableExtensions.contains("GL_APPLE_vertex_array_object");
#endif
}
+#if PLATFORM(QT)
+ if (!m_context->isGLES2Compliant()) {
+#endif
+
// Desktop GL always supports the standard derivative functions
if (name == "GL_OES_standard_derivatives")
return true;
@@ -212,6 +263,10 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
// Desktop GL always supports UNSIGNED_INT indices
if (name == "GL_OES_element_index_uint")
return true;
+
+#if PLATFORM(QT)
+ }
+#endif
if (name == "GL_EXT_shader_texture_lod")
return m_availableExtensions.contains("GL_EXT_shader_texture_lod");
@@ -222,7 +277,7 @@ bool Extensions3DOpenGL::supportsExtension(const String& name)
if (name == "GL_EXT_draw_buffers") {
#if PLATFORM(IOS)
return m_availableExtensions.contains(name);
-#elif PLATFORM(MAC) || PLATFORM(GTK)
+#elif PLATFORM(MAC) || PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
return m_availableExtensions.contains("GL_ARB_draw_buffers");
#else
// FIXME: implement support for other platforms.
@@ -243,7 +298,7 @@ void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
// FIXME: implement support for other platforms.
#if PLATFORM(MAC)
::glDrawBuffersARB(n, bufs);
-#elif PLATFORM(GTK)
+#elif PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawBuffers(n, bufs);
#else
UNUSED_PARAM(n);
@@ -254,7 +309,7 @@ void Extensions3DOpenGL::drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs)
void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawArraysInstanced(mode, first, count, primcount);
#elif PLATFORM(COCOA)
::glDrawArraysInstancedARB(mode, first, count, primcount);
@@ -269,7 +324,7 @@ void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Ds
void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
#elif PLATFORM(COCOA)
::glDrawElementsInstancedARB(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
@@ -285,7 +340,7 @@ void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, G
void Extensions3DOpenGL::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
{
m_context->makeContextCurrent();
-#if PLATFORM(GTK)
+#if PLATFORM(GTK) || (PLATFORM(QT) && QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
::glVertexAttribDivisor(index, divisor);
#elif PLATFORM(COCOA)
::glVertexAttribDivisorARB(index, divisor);
@@ -300,12 +355,21 @@ String Extensions3DOpenGL::getExtensions()
return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS)));
}
-#if (PLATFORM(GTK) || PLATFORM(QT) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
+#if (PLATFORM(GTK) || PLATFORM(EFL) || PLATFORM(WIN) || PLATFORM(IOS))
bool Extensions3DOpenGL::isVertexArrayObjectSupported()
{
static const bool supportsVertexArrayObject = supports("GL_OES_vertex_array_object");
return supportsVertexArrayObject;
}
+#elif PLATFORM(QT)
+bool Extensions3DOpenGL::isVertexArrayObjectSupported()
+{
+#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)
+ return m_vaoFunctions && m_vaoFunctions->isValid();
+#else
+ return false;
+#endif
+}
#endif
} // namespace WebCore