2011-02-14 Andrew Wason <rectalogic@rectalogic.com>
Reviewed by Kenneth Russell.
[Qt] WebKit fails to compile for Qt when WebGL enabled
https://bugs.webkit.org/show_bug.cgi?id=53431
No new tests.
* WebCore.pro:
Add source and header files and include directory to Qt project.
* html/canvas/WebGLRenderingContext.cpp:
File uses 'emit' which is a Qt keyword - #undef emit.
* platform/graphics/gpu/qt: Added.
* platform/graphics/gpu/qt/DrawingBufferQt.cpp: Added.
Partial implementation of DrawingBuffer for Qt.
(WebCore::DrawingBuffer::DrawingBuffer):
(WebCore::DrawingBuffer::~DrawingBuffer):
(WebCore::DrawingBuffer::didReset):
(WebCore::DrawingBuffer::platformLayer):
(WebCore::DrawingBuffer::platformColorBuffer):
* platform/graphics/qt/Extensions3DQt.cpp:
Noop implementation for pure virtual methods added to Extensions3D.h
(WebCore::Extensions3DQt::blitFramebuffer):
(WebCore::Extensions3DQt::renderbufferStorageMultisample):
* platform/graphics/qt/Extensions3DQt.h:
Declare new methods added to Extensions3D.h
* platform/graphics/qt/GraphicsContext3DQt.cpp:
Remove method implementations no longer in GraphicsContext3D.h.
Change m_syntheticErrors to use unsigned int to match new
GC3Denum type.
(WebCore::GraphicsContext3D::create):
Change return type to match GraphicsContext3D.h
(WebCore::GraphicsContext3D::lineWidth):
Change argument type to GC3Dfloat to match GraphicsContext3D.h
(WebCore::GraphicsContext3D::getUniformLocation):
Change return type to GC3Dfloat to match GraphicsContext3D.h
(WebCore::GraphicsContext3D::getExtensions):
Need to call get() on OwnPtr.
(WebCore::GraphicsContext3D::getImageData):
Rename enum values to match declarations in GraphicsContext3D.h
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78495 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index df1f443..9b26dae 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,45 @@
+2011-02-14 Andrew Wason <rectalogic@rectalogic.com>
+
+ Reviewed by Kenneth Russell.
+
+ [Qt] WebKit fails to compile for Qt when WebGL enabled
+ https://bugs.webkit.org/show_bug.cgi?id=53431
+
+ No new tests.
+
+ * WebCore.pro:
+ Add source and header files and include directory to Qt project.
+ * html/canvas/WebGLRenderingContext.cpp:
+ File uses 'emit' which is a Qt keyword - #undef emit.
+ * platform/graphics/gpu/qt: Added.
+ * platform/graphics/gpu/qt/DrawingBufferQt.cpp: Added.
+ Partial implementation of DrawingBuffer for Qt.
+ (WebCore::DrawingBuffer::DrawingBuffer):
+ (WebCore::DrawingBuffer::~DrawingBuffer):
+ (WebCore::DrawingBuffer::didReset):
+ (WebCore::DrawingBuffer::platformLayer):
+ (WebCore::DrawingBuffer::platformColorBuffer):
+ * platform/graphics/qt/Extensions3DQt.cpp:
+ Noop implementation for pure virtual methods added to Extensions3D.h
+ (WebCore::Extensions3DQt::blitFramebuffer):
+ (WebCore::Extensions3DQt::renderbufferStorageMultisample):
+ * platform/graphics/qt/Extensions3DQt.h:
+ Declare new methods added to Extensions3D.h
+ * platform/graphics/qt/GraphicsContext3DQt.cpp:
+ Remove method implementations no longer in GraphicsContext3D.h.
+ Change m_syntheticErrors to use unsigned int to match new
+ GC3Denum type.
+ (WebCore::GraphicsContext3D::create):
+ Change return type to match GraphicsContext3D.h
+ (WebCore::GraphicsContext3D::lineWidth):
+ Change argument type to GC3Dfloat to match GraphicsContext3D.h
+ (WebCore::GraphicsContext3D::getUniformLocation):
+ Change return type to GC3Dfloat to match GraphicsContext3D.h
+ (WebCore::GraphicsContext3D::getExtensions):
+ Need to call get() on OwnPtr.
+ (WebCore::GraphicsContext3D::getImageData):
+ Rename enum values to match declarations in GraphicsContext3D.h
+
2011-02-14 Tony Chang <tony@chromium.org>
Reviewed by Dimitri Glazkov.
diff --git a/Source/WebCore/WebCore.pro b/Source/WebCore/WebCore.pro
index 748c032..bbb9e84 100644
--- a/Source/WebCore/WebCore.pro
+++ b/Source/WebCore/WebCore.pro
@@ -3810,6 +3810,7 @@
html/canvas/WebGLActiveInfo.h \
html/canvas/WebGLBuffer.h \
html/canvas/WebGLContextAttributes.h \
+ html/canvas/WebGLContextEvent.h \
html/canvas/WebGLExtension.h \
html/canvas/WebGLFramebuffer.h \
html/canvas/WebGLGetInfo.h \
@@ -3824,6 +3825,7 @@
html/canvas/WebKitLoseContext.h \
platform/graphics/Extensions3D.h \
platform/graphics/GraphicsContext3D.h \
+ platform/graphics/gpu/DrawingBuffer.h \
platform/graphics/qt/Extensions3DQt.h
!v8 {
@@ -3835,6 +3837,7 @@
html/canvas/WebGLObject.cpp \
html/canvas/WebGLBuffer.cpp \
html/canvas/WebGLContextAttributes.cpp \
+ html/canvas/WebGLContextEvent.cpp \
html/canvas/WebGLExtension.cpp \
html/canvas/WebGLFramebuffer.cpp \
html/canvas/WebGLGetInfo.cpp \
@@ -3848,8 +3851,12 @@
html/canvas/WebGLUniformLocation.cpp \
html/canvas/WebKitLoseContext.cpp \
platform/graphics/GraphicsContext3D.cpp \
+ platform/graphics/gpu/DrawingBuffer.cpp \
+ platform/graphics/gpu/qt/DrawingBufferQt.cpp \
platform/graphics/qt/Extensions3DQt.cpp \
platform/graphics/qt/GraphicsContext3DQt.cpp
+
+ INCLUDEPATH += $$PWD/platform/graphics/gpu
}
contains(DEFINES, ENABLE_SYMBIAN_DIALOG_PROVIDERS) {
diff --git a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
index bd155c9..34251f5 100644
--- a/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/Source/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -66,6 +66,10 @@
#include <wtf/PassOwnArrayPtr.h>
#include <wtf/text/StringBuilder.h>
+#if PLATFORM(QT)
+#undef emit
+#endif
+
namespace WebCore {
const double secondsBetweenRestoreAttempts = 1.0;
diff --git a/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp b/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
new file mode 100644
index 0000000..b8c3b3d
--- /dev/null
+++ b/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2011 Andrew Wason (rectalogic@rectalogic.com)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(ACCELERATED_2D_CANVAS) || ENABLE(WEBGL)
+
+#include "DrawingBuffer.h"
+
+namespace WebCore {
+
+DrawingBuffer::DrawingBuffer(GraphicsContext3D* context,
+ const IntSize& size,
+ bool multisampleExtensionSupported,
+ bool packedDepthStencilExtensionSupported)
+ : m_context(context)
+ , m_size(-1, -1)
+ , m_multisampleExtensionSupported(multisampleExtensionSupported)
+ , m_packedDepthStencilExtensionSupported(packedDepthStencilExtensionSupported)
+ , m_fbo(context->createFramebuffer())
+ , m_colorBuffer(0)
+ , m_depthStencilBuffer(0)
+ , m_depthBuffer(0)
+ , m_stencilBuffer(0)
+ , m_multisampleFBO(0)
+ , m_multisampleColorBuffer(0)
+{
+ ASSERT(m_fbo);
+ if (!m_fbo) {
+ clear();
+ return;
+ }
+
+ // create a texture to render into
+ m_colorBuffer = context->createTexture();
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_colorBuffer);
+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR);
+ context->texParameterf(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR);
+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE);
+ context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE);
+ context->bindTexture(GraphicsContext3D::TEXTURE_2D, 0);
+
+ // Create the FBO
+ m_fbo = context->createFramebuffer();
+ ASSERT(m_fbo);
+ if (!m_fbo) {
+ clear();
+ return;
+ }
+
+ createSecondaryBuffers();
+ reset(size);
+}
+
+DrawingBuffer::~DrawingBuffer()
+{
+ clear();
+}
+
+void DrawingBuffer::didReset()
+{
+}
+
+#if USE(ACCELERATED_COMPOSITING)
+PlatformLayer* DrawingBuffer::platformLayer()
+{
+ return 0;
+}
+#endif
+
+Platform3DObject DrawingBuffer::platformColorBuffer() const
+{
+ return m_colorBuffer;
+}
+
+}
+
+#endif
diff --git a/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp b/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp
index 5238d46..ee57593 100644
--- a/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/Extensions3DQt.cpp
@@ -56,6 +56,14 @@
return GraphicsContext3D::NO_ERROR;
}
+void Extensions3DQt::blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter)
+{
+}
+
+void Extensions3DQt::renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height)
+{
+}
+
} // namespace WebCore
#endif // ENABLE(WEBGL)
diff --git a/Source/WebCore/platform/graphics/qt/Extensions3DQt.h b/Source/WebCore/platform/graphics/qt/Extensions3DQt.h
index ae4b375..419b99c 100644
--- a/Source/WebCore/platform/graphics/qt/Extensions3DQt.h
+++ b/Source/WebCore/platform/graphics/qt/Extensions3DQt.h
@@ -38,6 +38,8 @@
virtual bool supports(const String&);
virtual void ensureEnabled(const String&);
virtual int getGraphicsResetStatusARB();
+ virtual void blitFramebuffer(long srcX0, long srcY0, long srcX1, long srcY1, long dstX0, long dstY0, long dstX1, long dstY1, unsigned long mask, unsigned long filter);
+ virtual void renderbufferStorageMultisample(unsigned long target, unsigned long samples, unsigned long internalformat, unsigned long width, unsigned long height);
private:
// This class only needs to be instantiated by GraphicsContext3D implementations.
diff --git a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
index 8b87f5f..b849214 100644
--- a/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
+++ b/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
@@ -252,7 +252,7 @@
GLuint m_currentFbo;
GLuint m_depthBuffer;
QImage m_pixels;
- ListHashSet<unsigned long> m_syntheticErrors;
+ ListHashSet<unsigned int> m_syntheticErrors;
OwnPtr<Extensions3DQt> m_extensions;
@@ -277,24 +277,6 @@
#endif
}
-// Even with underlying GLES2 driver, the below flags should still be set to
-// false if extentions exist (and they almost always do).
-bool GraphicsContext3D::isGLES2NPOTStrict() const
-{
- return false;
-}
-
-bool GraphicsContext3D::isErrorGeneratedOnOutOfBoundsAccesses() const
-{
- return false;
-}
-
-int GraphicsContext3D::getGraphicsResetStatusARB()
-{
- return NO_ERROR;
-}
-
-
GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
: m_attrs(attrs)
, m_hostWindow(hostWindow)
@@ -499,12 +481,12 @@
return 0;
}
-PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
+PassRefPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow, GraphicsContext3D::RenderStyle renderStyle)
{
// This implementation doesn't currently support rendering directly to the HostWindow.
if (renderStyle == RenderDirectlyToHostWindow)
return 0;
- OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow, false));
+ RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(attrs, hostWindow, false));
return context->m_internal ? context.release() : 0;
}
@@ -1038,7 +1020,7 @@
return glIsTexture(texture);
}
-void GraphicsContext3D::lineWidth(double width)
+void GraphicsContext3D::lineWidth(GC3Dfloat width)
{
m_internal->m_glWidget->makeCurrent();
glLineWidth(static_cast<float>(width));
@@ -1489,7 +1471,7 @@
m_internal->getUniformiv(program, location, value);
}
-long GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
+GC3Dint GraphicsContext3D::getUniformLocation(Platform3DObject program, const String& name)
{
ASSERT(program);
@@ -1620,7 +1602,7 @@
{
if (!m_internal->m_extensions)
m_internal->m_extensions = adoptPtr(new Extensions3DQt);
- return m_internal->m_extensions;
+ return m_internal->m_extensions.get();
}
bool GraphicsContext3D::getImageData(Image* image,
@@ -1637,13 +1619,13 @@
if (!nativePixmap)
return false;
- AlphaOp neededAlphaOp = kAlphaDoNothing;
+ AlphaOp neededAlphaOp = AlphaDoNothing;
if (!premultiplyAlpha)
// FIXME: must fetch the image data before the premultiplication step
- neededAlphaOp = kAlphaDoUnmultiply;
+ neededAlphaOp = AlphaDoUnmultiply;
QImage nativeImage = nativePixmap->toImage().convertToFormat(QImage::Format_ARGB32);
outputVector.resize(nativeImage.byteCount());
- return packPixels(nativeImage.rgbSwapped().bits(), kSourceFormatRGBA8, image->width(), image->height(), 0,
+ return packPixels(nativeImage.rgbSwapped().bits(), SourceFormatRGBA8, image->width(), image->height(), 0,
format, type, neededAlphaOp, outputVector.data());
}