Changeset 55132 in webkit


Ignore:
Timestamp:
Feb 23, 2010, 1:47:16 AM (16 years ago)
Author:
eric@webkit.org
Message:

2010-02-23 Noam Rosenthal <noam.rosenthal@nokia.com>

Reviewed by Ariya Hidayat.

[Qt] Connect video with accelerated compositing
https://bugs.webkit.org/show_bug.cgi?id=35276

MediaControlPrivate and GraphicsLayer are patched together via
a shared PlatformLayer (QGraphicsItem). This patch makes sure that the
QGraphicsVideoItem from MediaControl becomes part of the scene
associsated with GraphicsLayer

Test: http://double.co.nz/video_test/test1.html with AC turned on

  • platform/graphics/qt/GraphicsLayerQt.cpp: (WebCore::GraphicsLayerQtImpl::): mediaLayer member (WebCore::GraphicsLayerQtImpl::opaqueArea): video is opaque (WebCore::GraphicsLayerQtImpl::paint): don't paint video (WebCore::GraphicsLayerQtImpl::flushChanges): flush mediaLayer (WebCore::GraphicsLayerQt::setContentsToMedia): notify
  • platform/graphics/qt/GraphicsLayerQt.h: reimp setContentsToMedia
  • platform/graphics/qt/MediaPlayerPrivateQt.cpp: (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): m_compositing (WebCore::MediaPlayerPrivate::paint): don't paint if compositing (WebCore::MediaPlayerPrivate::acceleratedRenderingStateChanged): reimp from MediaPlayerPrivateInterface to support AC (WebCore::MediaPlayerPrivate::platformLayer): ditto
  • platform/graphics/qt/MediaPlayerPrivateQt.h: (WebCore::MediaPlayerPrivate::supportsAcceleratedRendering): ditto
Location:
trunk/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r55130 r55132  
     12010-02-23  Noam Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Ariya Hidayat.
     4
     5        [Qt] Connect video with accelerated compositing
     6        https://bugs.webkit.org/show_bug.cgi?id=35276
     7
     8        MediaControlPrivate and GraphicsLayer are patched together via
     9        a shared PlatformLayer (QGraphicsItem). This patch makes sure that the
     10        QGraphicsVideoItem from MediaControl becomes part of the scene
     11        associsated with GraphicsLayer
     12
     13        Test: http://double.co.nz/video_test/test1.html with AC turned on
     14
     15        * platform/graphics/qt/GraphicsLayerQt.cpp:
     16        (WebCore::GraphicsLayerQtImpl::): mediaLayer member
     17        (WebCore::GraphicsLayerQtImpl::opaqueArea): video is opaque
     18        (WebCore::GraphicsLayerQtImpl::paint): don't paint video
     19        (WebCore::GraphicsLayerQtImpl::flushChanges): flush mediaLayer
     20        (WebCore::GraphicsLayerQt::setContentsToMedia): notify
     21        * platform/graphics/qt/GraphicsLayerQt.h: reimp setContentsToMedia
     22        * platform/graphics/qt/MediaPlayerPrivateQt.cpp:
     23        (WebCore::MediaPlayerPrivate::MediaPlayerPrivate): m_compositing
     24        (WebCore::MediaPlayerPrivate::paint): don't paint if compositing
     25        (WebCore::MediaPlayerPrivate::acceleratedRenderingStateChanged):
     26        reimp from MediaPlayerPrivateInterface to support AC
     27        (WebCore::MediaPlayerPrivate::platformLayer): ditto
     28        * platform/graphics/qt/MediaPlayerPrivateQt.h:
     29        (WebCore::MediaPlayerPrivate::supportsAcceleratedRendering): ditto
     30
    1312010-02-23  Stephan Aßmus  <superstippi@gmx.de>
    232
  • trunk/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp

    r55028 r55132  
    126126
    127127    // the compositor lets us special-case images and colors, so we try to do so
    128     enum StaticContentType { HTMLContentType, PixmapContentType, ColorContentType};
     128    enum StaticContentType { HTMLContentType, PixmapContentType, ColorContentType, MediaContentType};
    129129
    130130    GraphicsLayerQtImpl(GraphicsLayerQt* newLayer);
     
    180180        QColor contentsBackgroundColor;
    181181        QColor backgroundColor;
     182        QWeakPointer<QGraphicsObject> mediaLayer;
    182183        StaticContentType contentType;
    183184        float opacity;
     
    354355        if (m_state.contentsOpaque
    355356            || (m_currentContent.contentType == ColorContentType && m_currentContent.contentsBackgroundColor.alpha() == 0xff)
     357            || (m_currentContent.contentType == MediaContentType)
    356358            || (m_currentContent.contentType == PixmapContentType && !m_currentContent.pixmap.hasAlpha())) {
    357359
     
    386388        painter->fillRect(m_state.contentsRect, m_currentContent.contentsBackgroundColor);
    387389        break;
     390    case MediaContentType:
     391        // we don't need to paint anything: we have a QGraphicsItem from the media element
     392        break;
    388393    }
    389394}
     
    434439
    435440        for (QSet<QGraphicsItem*>::const_iterator it = childrenToRemove.begin(); it != childrenToRemove.end(); ++it)
    436              if (QGraphicsItem* w = *it)
     441             if (GraphicsLayerQtImpl* w = qobject_cast<GraphicsLayerQtImpl*>((*it)->toGraphicsObject()))
    437442                w->setParentItem(0);
    438443
     
    466471        }
    467472    }
    468 
    469473    // FIXME: this is a hack, due to a probable QGraphicsScene bug when rapidly modifying the perspective
    470474    // but without this line we get graphic artifacts
     
    484488            setFlag(ItemHasNoContents, false);
    485489
     490            break;
     491        case MediaContentType:
     492            setFlag(ItemHasNoContents, true);
     493            m_pendingContent.mediaLayer.data()->setParentItem(this);
    486494            break;
    487495
     
    570578    m_currentContent.pixmap = m_pendingContent.pixmap;
    571579    m_currentContent.contentType = m_pendingContent.contentType;
     580    m_currentContent.mediaLayer = m_pendingContent.mediaLayer;
    572581    m_currentContent.backgroundColor = m_pendingContent.backgroundColor;
    573582    m_currentContent.regionToUpdate |= m_pendingContent.regionToUpdate;
     
    845854    GraphicsLayer::setContentsBackgroundColor(color);
    846855}
     856
     857void GraphicsLayerQt::setContentsToMedia(PlatformLayer* media)
     858{
     859    m_impl->notifyChange(GraphicsLayerQtImpl::ContentChange);
     860    m_impl->m_pendingContent.contentType = GraphicsLayerQtImpl::MediaContentType;
     861    m_impl->m_pendingContent.mediaLayer = media->toGraphicsObject();
     862    GraphicsLayer::setContentsToMedia(media);
     863}
     864
    847865
    848866// reimp from GraphicsLayer.h
  • trunk/WebCore/platform/graphics/qt/GraphicsLayerQt.h

    r53618 r55132  
    7171    virtual void resumeAnimations();
    7272    virtual void setContentsToImage(Image*);
     73    virtual void setContentsToMedia(PlatformLayer*);
    7374    virtual void setContentsBackgroundColor(const Color&);
    7475    virtual void setGeometryOrientation(CompositingCoordinatesOrientation orientation);
  • trunk/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.cpp

    r55079 r55132  
    8787    , m_isVisible(false)
    8888    , m_isSeeking(false)
     89    , m_composited(false)
    8990    , m_queuedSeek(-1)
    9091{
     
    517518void MediaPlayerPrivate::paint(GraphicsContext* context, const IntRect& rect)
    518519{
     520#if USE(ACCELERATED_COMPOSITING)
     521    if (m_composited)
     522        return;
     523#endif
    519524    if (context->paintingDisabled())
    520525        return;
     
    535540}
    536541
     542#if USE(ACCELERATED_COMPOSITING)
     543void MediaPlayerPrivate::acceleratedRenderingStateChanged()
     544{
     545    bool composited = m_player->mediaPlayerClient()->mediaPlayerRenderingCanBeAccelerated(m_player);
     546    if (composited == m_composited)
     547        return;
     548
     549    m_composited = composited;
     550    if (composited)
     551        m_videoScene->removeItem(m_videoItem);
     552    else
     553        m_videoScene->addItem(m_videoItem);
     554}
     555
     556PlatformLayer* MediaPlayerPrivate::platformLayer() const
     557{
     558    return m_composited ? m_videoItem : 0;
     559}
     560#endif
     561
    537562} // namespace WebCore
    538563
  • trunk/WebCore/platform/graphics/qt/MediaPlayerPrivateQt.h

    r55079 r55132  
    8484    bool supportsFullscreen() const { return false; }
    8585
     86#if USE(ACCELERATED_COMPOSITING)
     87    // whether accelerated rendering is supported by the media engine for the current media.
     88    virtual bool supportsAcceleratedRendering() const { return true; }
     89    // called when the rendering system flips the into or out of accelerated rendering mode.
     90    virtual void acceleratedRenderingStateChanged();
     91    // returns an object that can be directly composited via GraphicsLayerQt (essentially a QGraphicsItem*)
     92    virtual PlatformLayer* platformLayer() const;
     93#endif
     94
    8695private slots:
    8796    void mediaStatusChanged(QMediaPlayer::MediaStatus);
     
    115124    bool m_isVisible;
    116125    bool m_isSeeking;
     126    bool m_composited;
    117127    qint64 m_queuedSeek;
    118128};
Note: See TracChangeset for help on using the changeset viewer.