Changeset 81298 in webkit


Ignore:
Timestamp:
Mar 16, 2011 5:16:12 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-03-16 Jarkko Sakkinen <jarkko.j.sakkinen@gmail.com>

Reviewed by Kenneth Rohde Christiansen.

[Qt] WebGL content not shown when accelerated compositing is enabled
https://bugs.webkit.org/show_bug.cgi?id=56339

Removed all previously implemented WebGL code from GraphicsLayerQt
because API has changed. GraphicsContext3D provides PlatformLayer
that is added as a child of GraphicsLayer and is therefore painted
through QGraphicsView pipeline.

  • platform/graphics/GraphicsContext3D.h:
  • platform/graphics/qt/GraphicsContext3DQt.cpp: (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal): (WebCore::GraphicsContext3DInternal::paint): (WebCore::GraphicsContext3DInternal::boundingRect): (WebCore::GraphicsContext3D::platformLayer): (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas): (WebCore::GraphicsContext3D::reshape):
  • platform/graphics/qt/GraphicsLayerQt.cpp: (WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl): (WebCore::GraphicsLayerQtImpl::paint): (WebCore::GraphicsLayerQtImpl::flushChanges): (WebCore::GraphicsLayerQt::setContentsToCanvas):
  • platform/graphics/qt/GraphicsLayerQt.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r81295 r81298  
     12011-03-16  Jarkko Sakkinen  <jarkko.j.sakkinen@gmail.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] WebGL content not shown when accelerated compositing is enabled
     6        https://bugs.webkit.org/show_bug.cgi?id=56339
     7
     8        Removed all previously implemented WebGL code from GraphicsLayerQt
     9        because API has changed. GraphicsContext3D provides PlatformLayer
     10        that is added as a child of GraphicsLayer and is therefore painted
     11        through QGraphicsView pipeline.
     12
     13        * platform/graphics/GraphicsContext3D.h:
     14        * platform/graphics/qt/GraphicsContext3DQt.cpp:
     15        (WebCore::GraphicsContext3DInternal::GraphicsContext3DInternal):
     16        (WebCore::GraphicsContext3DInternal::paint):
     17        (WebCore::GraphicsContext3DInternal::boundingRect):
     18        (WebCore::GraphicsContext3D::platformLayer):
     19        (WebCore::GraphicsContext3D::paintRenderingResultsToCanvas):
     20        (WebCore::GraphicsContext3D::reshape):
     21        * platform/graphics/qt/GraphicsLayerQt.cpp:
     22        (WebCore::GraphicsLayerQtImpl::GraphicsLayerQtImpl):
     23        (WebCore::GraphicsLayerQtImpl::paint):
     24        (WebCore::GraphicsLayerQtImpl::flushChanges):
     25        (WebCore::GraphicsLayerQt::setContentsToCanvas):
     26        * platform/graphics/qt/GraphicsLayerQt.h:
     27
    1282011-03-16  Ryosuke Niwa  <rniwa@webkit.org>
    229
  • trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h

    r81213 r81298  
    462462    Platform3DObject platformTexture() const;
    463463#if USE(ACCELERATED_COMPOSITING)
    464     PlatformLayer* platformLayer() const { return 0; }
     464    PlatformLayer* platformLayer() const;
    465465#endif
    466466#else
     
    761761
    762762#if PLATFORM(QT)
    763     void paint(QPainter* painter, const QRect& rect) const;
    764763    bool paintsIntoCanvasBuffer() const { return true; }
    765764#elif PLATFORM(CHROMIUM)
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsContext3DQt.cpp

    r81213 r81298  
    2828#include "HostWindow.h"
    2929#include "ImageBuffer.h"
     30#include "ImageData.h"
    3031#include "NotImplemented.h"
    31 #include "QWebPageClient.h"
     32#include "PageClientQt.h"
     33#include "qwebpage.h"
    3234#include <QAbstractScrollArea>
     35#include <QGraphicsObject>
    3336#include <QGLContext>
     37#include <QStyleOptionGraphicsItem>
    3438#include <wtf/UnusedParam.h>
    3539#include <wtf/text/CString.h>
     
    146150typedef void (APIENTRY* glVertexAttribPointerType) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*);
    147151
    148 class GraphicsContext3DInternal {
     152class GraphicsContext3DInternal : public QGraphicsObject {
    149153public:
    150154    GraphicsContext3DInternal(GraphicsContext3D::Attributes attrs, HostWindow* hostWindow);
     
    153157    bool isContextValid() { return m_contextValid; }
    154158    QGLWidget* getOwnerGLWidget(QWebPageClient* webPageClient);
     159    void paint(QPainter*, const QStyleOptionGraphicsItem*, QWidget*);
     160    QRectF boundingRect() const;
    155161
    156162    glActiveTextureType activeTexture;
     
    248254    HostWindow* m_hostWindow;
    249255    QGLWidget* m_glWidget;
     256    QGLWidget* m_ownerGLWidget;
     257    QRectF m_boundingRect;
    250258    GLuint m_texture;
    251259    GLuint m_mainFbo;
     
    282290    , m_hostWindow(hostWindow)
    283291    , m_glWidget(0)
     292    , m_ownerGLWidget(0)
    284293    , m_texture(0)
    285294    , m_mainFbo(0)
     
    288297    , m_contextValid(true)
    289298{
    290     QWebPageClient* webPageClient = hostWindow->platformPageClient();
    291     QGLWidget* ownerGLWidget  = getOwnerGLWidget(webPageClient);
    292 
    293     if (ownerGLWidget)
    294         m_glWidget = new QGLWidget(0, ownerGLWidget);
     299    PageClientQWidget* webPageClient
     300        = static_cast<PageClientQWidget*>(hostWindow->platformPageClient());
     301
     302#if USE(ACCELERATED_COMPOSITING)
     303    if (webPageClient->page->settings()->testAttribute(QWebSettings::AcceleratedCompositingEnabled)) {
     304        QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget());
     305        if (scrollArea)
     306            m_ownerGLWidget = qobject_cast<QGLWidget*>(scrollArea->viewport());
     307    }
     308#endif
     309
     310    if (m_ownerGLWidget)
     311        m_glWidget = new QGLWidget(0, m_ownerGLWidget);
    295312    else {
    296313        QGLFormat format;
     
    455472}
    456473
    457 QGLWidget* GraphicsContext3DInternal::getOwnerGLWidget(QWebPageClient* webPageClient)
    458 {
    459     QAbstractScrollArea* scrollArea = qobject_cast<QAbstractScrollArea*>(webPageClient->ownerWidget());
    460 
    461     if (scrollArea)
    462         return qobject_cast<QGLWidget*>(scrollArea->viewport());
    463 
    464     return 0;
     474void GraphicsContext3DInternal::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget)
     475{
     476    Q_UNUSED(widget);
     477
     478    QRectF rect = option ? option->rect : boundingRect();
     479
     480#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
     481    // Use direct texture mapping if WebGL canvas has a shared OpenGL context
     482    // with browsers OpenGL context.
     483    if (m_ownerGLWidget) {
     484        m_ownerGLWidget->drawTexture(rect, m_texture);
     485        return;
     486    }
     487#endif
     488
     489    // Alternatively read pixels to a memory buffer.
     490    m_glWidget->makeCurrent();
     491    bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_mainFbo);
     492    glReadPixels(/* x */ 0, /* y */ 0, rect.width(), rect.height(), GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, m_pixels.bits());
     493    painter->drawImage(/* x */ 0, /* y */ 0, m_pixels.rgbSwapped().transformed(QMatrix().rotate(180)));
     494    bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_currentFbo);
     495}
     496
     497QRectF GraphicsContext3DInternal::boundingRect() const
     498{
     499    return m_boundingRect;
    465500}
    466501
     
    512547}
    513548
     549PlatformLayer* GraphicsContext3D::platformLayer() const
     550{
     551    return m_internal.get();
     552}
     553
    514554void GraphicsContext3D::makeContextCurrent()
    515555{
     
    523563    ImageBuffer* imageBuffer = canvas->buffer();
    524564    QPainter* painter = imageBuffer->context()->platformContext();
    525     paint(painter, QRect(QPoint(0, 0), QSize(m_currentWidth, m_currentHeight)));
     565    m_internal->paint(painter, 0, 0);
    526566}
    527567
     
    531571    // support.
    532572    return 0;
    533 }
    534 
    535 void GraphicsContext3D::paint(QPainter* painter, const QRect& rect) const
    536 {
    537 #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
    538     QWebPageClient* webPageClient = m_internal->m_hostWindow->platformPageClient();
    539     QGLWidget* ownerGLWidget  = m_internal->getOwnerGLWidget(webPageClient);
    540     if (ownerGLWidget) {
    541         ownerGLWidget->drawTexture(rect, m_internal->m_texture);
    542         return;
    543     }
    544 #endif
    545     m_internal->m_glWidget->makeCurrent();
    546     m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_mainFbo);
    547     glReadPixels(/* x */ 0, /* y */ 0, m_currentWidth, m_currentHeight, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, m_internal->m_pixels.bits());
    548     painter->drawImage(/* x */ 0, /* y */ 0, m_internal->m_pixels.rgbSwapped().transformed(QMatrix().rotate(180)));
    549     m_internal->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_internal->m_currentFbo);
    550573}
    551574
     
    558581    m_currentHeight = height;
    559582
     583    m_internal->m_boundingRect = QRectF(QPointF(0, 0), QSizeF(width, height));
    560584    m_internal->m_pixels = QImage(m_currentWidth, m_currentHeight, QImage::Format_ARGB32);
    561585
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp

    r79595 r81298  
    311311    } m_state;
    312312
    313 #if ENABLE(WEBGL)
    314     const GraphicsContext3D* m_gc3D;
    315 #endif
    316 
    317313#ifndef QT_NO_ANIMATION
    318314    friend class AnimationQtBase;
     
    340336#if ENABLE(TILED_BACKING_STORE)
    341337    , m_tiledBackingStore(0)
    342 #endif
    343 #if ENABLE(WEBGL)
    344     , m_gc3D(0)
    345338#endif
    346339{
     
    666659        // we don't need to paint anything: we have a QGraphicsItem from the media element
    667660        break;
    668 #if ENABLE(WEBGL)
    669     case Canvas3DContentType:
    670         m_gc3D->paint(painter, option->rect);
    671         break;
    672 #endif
    673661    }
    674662}
     
    809797            setFlag(ItemHasNoContents, !m_layer->drawsContent());
    810798            break;
    811 
    812 #if ENABLE(WEBGL)
    813         case Canvas3DContentType:
    814             if (m_pendingContent.contentType != m_currentContent.contentType)
    815                 update();
    816 
    817             setCacheMode(NoCache);
    818             setFlag(ItemHasNoContents, false);
    819             break;
    820 #endif
    821799        }
    822800    }
     
    12691247}
    12701248
    1271 #if ENABLE(WEBGL)
    1272 void GraphicsLayerQt::setContentsToGraphicsContext3D(const GraphicsContext3D* ctx)
    1273 {
    1274     if (ctx == m_impl->m_gc3D)
    1275         return;
    1276 
    1277     m_impl->m_pendingContent.contentType = GraphicsLayerQtImpl::Canvas3DContentType;
    1278     m_impl->m_gc3D = ctx;
    1279     m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange);
    1280 }
    1281 
    1282 void GraphicsLayerQt::setGraphicsContext3DNeedsDisplay()
    1283 {
    1284     setNeedsDisplay();
    1285 }
    1286 #endif
    1287 
    12881249void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media)
    12891250{
     
    12961257    m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange);
    12971258    GraphicsLayer::setContentsToMedia(media);
     1259}
     1260
     1261void GraphicsLayerQt::setContentsToCanvas(PlatformLayer* canvas)
     1262{
     1263    setContentsToMedia(canvas);
    12981264}
    12991265
  • trunk/Source/WebCore/platform/graphics/qt/GraphicsLayerQt.h

    r76600 r81298  
    2121#define GraphicsLayerQt_h
    2222
    23 #if ENABLE(WEBGL)
    24 #include "GraphicsContext3D.h"
    25 #endif
    2623#include "GraphicsLayer.h"
    2724#include "GraphicsLayerClient.h"
     
    7976    virtual void setContentsNeedsDisplay();
    8077    virtual void setContentsToMedia(PlatformLayer*);
     78    virtual void setContentsToCanvas(PlatformLayer*);
    8179    virtual void setContentsBackgroundColor(const Color&);
    82 #if ENABLE(WEBGL)
    83     virtual void setContentsToGraphicsContext3D(const GraphicsContext3D*);
    84     virtual void setGraphicsContext3DNeedsDisplay();
    85 #endif
    8680    virtual void setContentsOrientation(CompositingCoordinatesOrientation orientation);
    8781    virtual void distributeOpacity(float);
Note: See TracChangeset for help on using the changeset viewer.