[Webkit-unassigned] [Bug 37070] [Qt] WebGL is not visible when QGLWidget viewport is used
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Tue Apr 13 09:42:09 PDT 2010
https://bugs.webkit.org/show_bug.cgi?id=37070
--- Comment #8 from Kenneth Russell <kbr at google.com> 2010-04-13 09:42:09 PST ---
(From update of attachment 53090)
> diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
> index 6a38cff..55153cf 100644
> --- a/WebCore/ChangeLog
> +++ b/WebCore/ChangeLog
> @@ -1,3 +1,20 @@
> +2010-04-10 Jarkko Sakkinen <jarkko.j.sakkinen at gmail.com>
> +
> + Reviewed by NOBODY (OOPS!).
> +
> + [Qt] WebGL is not visible when QGLWidget viewport is used
> + https://bugs.webkit.org/show_bug.cgi?id=37070
> +
> + * html/canvas/WebGLRenderingContext.cpp:
> + (WebCore::WebGLRenderingContext::create):
> + * platform/graphics/GraphicsContext3D.h:
> + * platform/graphics/qt/GraphicsContext3DQt.cpp:
> + (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal):
> + (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal):
> + (WebCore::GraphicsContext3DInternal::getOwnerGLWidget):
> + (WebCore::GraphicsContext3D::create):
> + (WebCore::GraphicsContext3D::GraphicsContext3D):
> +
> 2010-04-09 Tasuku Suzuki <tasuku.suzuki at nokia.com>
>
> Reviewed by Simon Hausmann.
> diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
> index bde49ad..94e9bb6 100644
> --- a/WebCore/html/canvas/WebGLRenderingContext.cpp
> +++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
> @@ -72,7 +72,12 @@ private:
>
> PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs)
> {
> +#if PLATFORM(QT)
> + OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs->attributes(), canvas));
> +#else
> OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs->attributes()));
> +#endif
> +
> if (!context)
> return 0;
>
> diff --git a/WebCore/platform/graphics/GraphicsContext3D.h b/WebCore/platform/graphics/GraphicsContext3D.h
> index 96f77d9..4f8d1b6 100644
> --- a/WebCore/platform/graphics/GraphicsContext3D.h
> +++ b/WebCore/platform/graphics/GraphicsContext3D.h
> @@ -49,7 +49,7 @@ const Platform3DObject NullPlatform3DObject = 0;
>
> typedef void* PlatformGraphicsContext3D;
> const PlatformGraphicsContext3D NullPlatformGraphicsContext3D = 0;
> -typedef int Platform3DObject;
> +typedef GLuint Platform3DObject;
> const Platform3DObject NullPlatform3DObject = 0;
> #else
> typedef void* PlatformGraphicsContext3D;
> @@ -73,6 +73,7 @@ namespace WebCore {
> class WebGLTexture;
> class Image;
> class ImageData;
> + class HTMLCanvasElement;
>
> struct ActiveInfo {
> String name;
> @@ -410,7 +411,11 @@ namespace WebCore {
> bool premultipliedAlpha;
> };
>
> +#if PLATFORM(QT)
> + static PassOwnPtr<GraphicsContext3D> create(Attributes attrs, HTMLCanvasElement* canvas);
> +#else
> static PassOwnPtr<GraphicsContext3D> create(Attributes attrs);
> +#endif
> virtual ~GraphicsContext3D();
>
> #if PLATFORM(MAC)
> @@ -685,7 +690,11 @@ namespace WebCore {
> void synthesizeGLError(unsigned long error);
>
> private:
> +#if PLATFORM(QT)
> + GraphicsContext3D(Attributes attrs, HTMLCanvasElement* canvas);
> +#else
> GraphicsContext3D(Attributes attrs);
> +#endif
>
> // Helpers for texture uploading.
> void premultiplyAlpha(unsigned char* rgbaData, int numPixels);
> diff --git a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
> index caa805c..ae42739 100644
> --- a/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
> +++ b/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp
> @@ -21,10 +21,13 @@
> #include "GraphicsContext3D.h"
>
> #include "CanvasObject.h"
> +#include "FrameView.h"
> #include "GraphicsContext.h"
> #include "HTMLCanvasElement.h"
> +#include "HostWindow.h"
> #include "ImageBuffer.h"
> #include "NotImplemented.h"
> +#include "QWebPageClient.h"
> #include "WebGLActiveInfo.h"
> #include "WebGLArray.h"
> #include "WebGLBuffer.h"
> @@ -37,6 +40,8 @@
> #include "WebGLShader.h"
> #include "WebGLTexture.h"
> #include "WebGLUnsignedByteArray.h"
> +#include "Widget.h"
> +#include <QGraphicsView>
> #include <wtf/UnusedParam.h>
> #include <wtf/text/CString.h>
>
> @@ -147,13 +152,11 @@ typedef void (APIENTRY* glVertexAttribPointerType) (GLuint, GLint, GLenum, GLboo
>
> class GraphicsContext3DInternal {
> public:
> - GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs);
> + GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HTMLCanvasElement* canvas);
> ~GraphicsContext3DInternal();
>
> bool isContextValid() { return m_contextValid; }
>
> -
> -
> glActiveTextureType activeTexture;
> glAttachShaderType attachShader;
> glBindAttribLocationType bindAttribLocation;
> @@ -255,6 +258,7 @@ public:
>
> private:
>
> + QGLWidget* getOwnerGLWidget(QWebPageClient* webPageClient);
> void* getProcAddress(const String& proc);
> bool m_contextValid;
> };
> @@ -265,7 +269,7 @@ private:
> #define GET_PROC_ADDRESS(Proc) reinterpret_cast<Proc##Type>(getProcAddress(#Proc));
> #endif
>
> -GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs)
> +GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HTMLCanvasElement* canvas)
> : m_attrs(attrs)
> , m_glWidget(0)
> , m_texture(0)
> @@ -274,24 +278,33 @@ GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attribut
> , m_depthBuffer(0)
> , m_contextValid(true)
> {
> - m_attrs.alpha = true;
> - m_attrs.depth = true;
> - m_attrs.stencil = false;
> - m_attrs.antialias = false;
> - m_attrs.premultipliedAlpha = true;
> + QWebPageClient* webPageClient = canvas->document()->view()->root()->hostWindow()->platformPageClient();
Passing the HTMLCanvasElement* is a layering violation. Eric Seidel and Adam
Treat point out that the HostWindow* can and should be passed instead. The
chain of calls above should be done in higher-level code.
Also, please make the change to
WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp and
WebKit/chromium/src/GraphicsContext3D.cpp, and use an UNUSED_PARAM for the
incoming HostView* on those platforms.
> + QGLWidget* ownerGLWidget = getOwnerGLWidget(webPageClient);
>
> - QGLFormat format;
> + if (ownerGLWidget)
> + m_glWidget = new QGLWidget(0, ownerGLWidget);
> + else {
> + QGLFormat format;
> + format.setDepth(true);
> + format.setSampleBuffers(true);
> + format.setStencil(false);
>
> - format.setDepth(true);
> - format.setSampleBuffers(true);
> - format.setStencil(false);
> + m_glWidget = new QGLWidget(format);
> + }
>
> - m_glWidget = new QGLWidget(format);
> if (!m_glWidget->isValid()) {
> LOG_ERROR("GraphicsContext3D: QGLWidget does not have a valid context");
> m_contextValid = false;
> return;
> }
> +
> + QGLFormat format = m_glWidget->format();
> +
> + m_attrs.alpha = format.alpha();
> + m_attrs.depth = format.depth();
> + m_attrs.stencil = format.stencil();
> + m_attrs.antialias = false;
> + m_attrs.premultipliedAlpha = true;
>
> m_glWidget->makeCurrent();
>
> @@ -428,7 +441,16 @@ GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attribut
> GraphicsContext3DInternal::~GraphicsContext3DInternal()
> {
> delete m_glWidget;
> - m_glWidget = 0;
> +}
> +
> +QGLWidget* GraphicsContext3DInternal::getOwnerGLWidget(QWebPageClient* webPageClient)
> +{
> + QGraphicsView* ownerGraphicsView = qobject_cast<QGraphicsView*>(webPageClient->ownerWidget());
> +
> + if (ownerGraphicsView)
> + return qobject_cast<QGLWidget*>(ownerGraphicsView->viewport());
> +
> + return 0;
> }
>
> void* GraphicsContext3DInternal::getProcAddress(const String& proc)
> @@ -448,14 +470,14 @@ void* GraphicsContext3DInternal::getProcAddress(const String& proc)
> return 0;
> }
>
> -PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs)
> +PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HTMLCanvasElement* canvas)
> {
> - OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs));
> + OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, canvas));
> return context->m_internal ? context.release() : 0;
> }
>
> -GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs)
> - : m_internal(new GraphicsContext3DInternal(attrs))
> +GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HTMLCanvasElement* canvas)
> + : m_internal(new GraphicsContext3DInternal(attrs, canvas))
> {
> if (!m_internal->isContextValid())
> m_internal = 0;
--
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
More information about the webkit-unassigned
mailing list