Changeset 57747 in webkit


Ignore:
Timestamp:
Apr 16, 2010 2:39:36 PM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-16 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com>

Reviewed by Simon Hausmann.

[Qt] WebGL is not visible when QGLWidget viewport is used
https://bugs.webkit.org/show_bug.cgi?id=37070

Added HostWindow parameter to the constructor of GraphicsContext3D.
Shared OpenGL context is initialized with parent QGLWidget.

  • html/canvas/WebGLRenderingContext.cpp: (WebCore::WebGLRenderingContext::create):
  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/mac/GraphicsContext3DMac.cpp: (WebCore::GraphicsContext3D::create): (WebCore::GraphicsContext3D::GraphicsContext3D):
  • platform/graphics/qt/GraphicsContext3DQt.cpp: (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal): (WebCore::GraphicsContext3DInternal::getOwnerGLWidget): (WebCore::GraphicsContext3D::create): (WebCore::GraphicsContext3D::GraphicsContext3D):

2010-04-16 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com>

Reviewed by Simon Hausmann.

[Qt] WebGL is not visible when QGLWidget viewport is used
https://bugs.webkit.org/show_bug.cgi?id=37070

Added HostWindow parameter to the constructor of GraphicsContext3D.
Shared OpenGL context is initialized with parent QGLWidget.

  • src/GraphicsContext3D.cpp: (WebCore::GraphicsContext3D::GraphicsContext3D):
Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r57745 r57747  
     12010-04-16  Jarkko Sakkinen  <jarkko.j.sakkinen@gmail.com>
     2 
     3        Reviewed by Simon Hausmann.
     4 
     5        [Qt] WebGL is not visible when QGLWidget viewport is used
     6        https://bugs.webkit.org/show_bug.cgi?id=37070
     7 
     8        Added HostWindow parameter to the constructor of GraphicsContext3D.
     9        Shared OpenGL context is initialized with parent QGLWidget.
     10 
     11        * html/canvas/WebGLRenderingContext.cpp:
     12        (WebCore::WebGLRenderingContext::create):
     13        * platform/graphics/GraphicsContext3D.h:
     14        * platform/graphics/mac/GraphicsContext3DMac.cpp:
     15        (WebCore::GraphicsContext3D::create):
     16        (WebCore::GraphicsContext3D::GraphicsContext3D):
     17        * platform/graphics/qt/GraphicsContext3DQt.cpp:
     18        (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal):
     19        (WebCore::GraphicsContext3DInternal::~GraphicsContext3DInternal):
     20        (WebCore::GraphicsContext3DInternal::getOwnerGLWidget):
     21        (WebCore::GraphicsContext3D::create):
     22        (WebCore::GraphicsContext3D::GraphicsContext3D):
     23
    1242010-04-16  Jarkko Sakkinen  <jarkko.j.sakkinen@gmail.com>
    225
  • trunk/WebCore/html/canvas/WebGLRenderingContext.cpp

    r57709 r57747  
    3131
    3232#include "CanvasPixelArray.h"
     33#include "FrameView.h"
    3334#include "HTMLCanvasElement.h"
    3435#include "HTMLImageElement.h"
     
    7475PassOwnPtr<WebGLRenderingContext> WebGLRenderingContext::create(HTMLCanvasElement* canvas, WebGLContextAttributes* attrs)
    7576{
    76     OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs->attributes()));
     77    HostWindow* hostWindow = canvas->document()->view()->root()->hostWindow();
     78    OwnPtr<GraphicsContext3D> context(GraphicsContext3D::create(attrs->attributes(), hostWindow));
     79
    7780    if (!context)
    7881        return 0;
  • trunk/WebCore/platform/graphics/GraphicsContext3D.h

    r57574 r57747  
    7474    class Image;
    7575    class ImageData;
     76    class HostWindow;
    7677
    7778    struct ActiveInfo {
     
    411412        };
    412413
    413         static PassOwnPtr<GraphicsContext3D> create(Attributes attrs);
     414        static PassOwnPtr<GraphicsContext3D> create(Attributes attrs, HostWindow* hostWindow);
    414415        virtual ~GraphicsContext3D();
    415416
     
    686687
    687688    private:       
    688         GraphicsContext3D(Attributes attrs);
     689        GraphicsContext3D(Attributes attrs, HostWindow* hostWindow);
    689690
    690691        // Helpers for texture uploading.
  • trunk/WebCore/platform/graphics/mac/GraphicsContext3DMac.cpp

    r57694 r57747  
    7676}
    7777
    78 PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs)
    79 {
    80     OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs));
     78PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
     79{
     80    OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow));
    8181    return context->m_contextObj ? context.release() : 0;
    8282}
    8383
    84 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs)
     84GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
    8585    : m_currentWidth(0)
    8686    , m_currentHeight(0)
     
    9595    , m_multisampleColorBuffer(0)
    9696{
     97    UNUSED_PARAM(hostWindow);
     98
    9799    Vector<CGLPixelFormatAttribute> attribs;
    98100    CGLPixelFormatObj pixelFormatObj = 0;
  • trunk/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r57745 r57747  
    2424#include "GraphicsContext.h"
    2525#include "HTMLCanvasElement.h"
     26#include "HostWindow.h"
    2627#include "ImageBuffer.h"
    2728#include "NotImplemented.h"
     29#include "QWebPageClient.h"
    2830#include "WebGLActiveInfo.h"
    2931#include "WebGLArray.h"
     
    3840#include "WebGLTexture.h"
    3941#include "WebGLUnsignedByteArray.h"
     42#include <QAbstractScrollArea>
    4043#include <wtf/UnusedParam.h>
    4144#include <wtf/text/CString.h>
     
    148151class GraphicsContext3DInternal {
    149152public:
    150     GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs);
     153    GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow);
    151154    ~GraphicsContext3DInternal();
    152155
     
    256259private:
    257260
     261    QGLWidget* getOwnerGLWidget(QWebPageClient* webPageClient);
    258262    void* getProcAddress(const String& proc);
    259263    bool m_contextValid;
     
    266270#endif
    267271 
    268 GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs)
     272GraphicsContext3DInternal::GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
    269273    : m_attrs(attrs)
    270274    , m_glWidget(0)
     
    275279    , m_contextValid(true)
    276280{
    277     m_attrs.alpha = true;
    278     m_attrs.depth = true;
    279     m_attrs.stencil = false;
    280     m_attrs.antialias = false;
    281     m_attrs.premultipliedAlpha = true;
    282 
    283     QGLFormat format;
    284 
    285     format.setDepth(true);
    286     format.setSampleBuffers(true);
    287     format.setStencil(false);
    288 
    289     m_glWidget = new QGLWidget(format);
     281    QWebPageClient* webPageClient = hostWindow->platformPageClient();
     282    QGLWidget* ownerGLWidget  = getOwnerGLWidget(webPageClient);
     283
     284    if (ownerGLWidget)
     285        m_glWidget = new QGLWidget(0, ownerGLWidget);
     286    else {
     287        QGLFormat format;
     288        format.setDepth(true);
     289        format.setSampleBuffers(true);
     290        format.setStencil(false);
     291
     292        m_glWidget = new QGLWidget(format);
     293    }
     294
    290295    if (!m_glWidget->isValid()) {
    291296        LOG_ERROR("GraphicsContext3D: QGLWidget does not have a valid context");
     
    293298        return;
    294299    }
     300 
     301    QGLFormat format = m_glWidget->format();
     302
     303    m_attrs.alpha = format.alpha();
     304    m_attrs.depth = format.depth();
     305    m_attrs.stencil = format.stencil();
     306    m_attrs.antialias = false;
     307    m_attrs.premultipliedAlpha = true;
    295308
    296309    m_glWidget->makeCurrent();
     
    432445}
    433446
     447QGLWidget* GraphicsContext3DInternal::getOwnerGLWidget(QWebPageClient* webPageClient)
     448{
     449    QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget());
     450
     451    if (scrollArea)
     452        return qobject_cast<QGLWidget*>(scrollArea->viewport());
     453
     454    return 0;
     455}
     456
    434457void* GraphicsContext3DInternal::getProcAddress(const String& proc)
    435458{
     
    449472}
    450473
    451 PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs)
    452 {
    453     OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs));
     474PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
     475{
     476    OwnPtr<GraphicsContext3D> context(new GraphicsContext3D(attrs, hostWindow));
    454477    return context->m_internal ? context.release() : 0;
    455478}
    456479
    457 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs)
    458     : m_internal(new GraphicsContext3DInternal(attrs))
     480GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
     481    : m_internal(new GraphicsContext3DInternal(attrs, hostWindow))
    459482{
    460483    if (!m_internal->isContextValid())
  • trunk/WebKit/chromium/ChangeLog

    r57728 r57747  
     12010-04-16  Jarkko Sakkinen  <jarkko.j.sakkinen@gmail.com>
     2 
     3        Reviewed by Simon Hausmann.
     4 
     5        [Qt] WebGL is not visible when QGLWidget viewport is used
     6        https://bugs.webkit.org/show_bug.cgi?id=37070
     7 
     8        Added HostWindow parameter to the constructor of GraphicsContext3D.
     9        Shared OpenGL context is initialized with parent QGLWidget.
     10 
     11        * src/GraphicsContext3D.cpp:
     12        (WebCore::GraphicsContext3D::GraphicsContext3D):
     13
    1142010-04-16  Fumitoshi Ukai  <ukai@chromium.org>
    215
  • trunk/WebKit/chromium/src/GraphicsContext3D.cpp

    r57574 r57747  
    10491049}
    10501050
    1051 GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs)
    1052 {
     1051GraphicsContext3D::GraphicsContext3D(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
     1052{
     1053    UNUSED_PARAM(hostWindow);
    10531054}
    10541055
     
    10571058}
    10581059
    1059 PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs)
     1060PassOwnPtr<GraphicsContext3D> GraphicsContext3D::create(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow)
    10601061{
    10611062    GraphicsContext3DInternal* internal = new GraphicsContext3DInternal();
     
    10641065        return 0;
    10651066    }
    1066     PassOwnPtr<GraphicsContext3D> result = new GraphicsContext3D(attrs);
     1067    PassOwnPtr<GraphicsContext3D> result = new GraphicsContext3D(attrs, hostWindow);
    10671068    result->m_internal.set(internal);
    10681069    return result;
Note: See TracChangeset for help on using the changeset viewer.