Changeset 56158 in webkit


Ignore:
Timestamp:
Mar 18, 2010 7:42:22 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-18 Noam Rosenthal <noam.rosenthal@nokia.com>

Reviewed by Antti Koivisto.

[Qt] [Performance] GraphicsLayerQt updates the scene too often
https://bugs.webkit.org/show_bug.cgi?id=36158

This fix makes sure that flushChanges is only called when necessary,
by calling the notifySync function asynchronously, which makes sure flushChanges() is called
after the WebCore compositor has made all its changes.

This has shown a visual improvement on several test-cases.

  • Makefile:
  • platform/graphics/qt/GraphicsLayerQt.cpp: (WebCore::GraphicsLayerQtImpl::): (WebCore::GraphicsLayerQtImpl::notifySyncRequired): (WebCore::GraphicsLayerQtImpl::notifyChange): (WebCore::GraphicsLayerQtImpl::flushChanges): (WebCore::GraphicsLayerQt::setMaskLayer): (WebCore::GraphicsLayerQt::setPosition): (WebCore::GraphicsLayerQt::setAnchorPoint): (WebCore::GraphicsLayerQt::setSize): (WebCore::GraphicsLayerQt::setTransform): (WebCore::GraphicsLayerQt::setChildrenTransform): (WebCore::GraphicsLayerQt::setPreserves3D): (WebCore::GraphicsLayerQt::setMasksToBounds): (WebCore::GraphicsLayerQt::setDrawsContent): (WebCore::GraphicsLayerQt::setBackgroundColor): (WebCore::GraphicsLayerQt::clearBackgroundColor): (WebCore::GraphicsLayerQt::setContentsOpaque): (WebCore::GraphicsLayerQt::setBackfaceVisibility): (WebCore::GraphicsLayerQt::setOpacity): (WebCore::GraphicsLayerQt::setContentsRect):
Location:
trunk/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r56155 r56158  
     12010-03-18  Noam Rosenthal  <noam.rosenthal@nokia.com>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        [Qt] [Performance] GraphicsLayerQt updates the scene too often
     6        https://bugs.webkit.org/show_bug.cgi?id=36158
     7
     8        This fix makes sure that flushChanges is only called when necessary,
     9        by calling the notifySync function asynchronously, which makes sure flushChanges() is called
     10        after the WebCore compositor has made all its changes.
     11
     12        This has shown a visual improvement on several test-cases.
     13
     14        * Makefile:
     15        * platform/graphics/qt/GraphicsLayerQt.cpp:
     16        (WebCore::GraphicsLayerQtImpl::):
     17        (WebCore::GraphicsLayerQtImpl::notifySyncRequired):
     18        (WebCore::GraphicsLayerQtImpl::notifyChange):
     19        (WebCore::GraphicsLayerQtImpl::flushChanges):
     20        (WebCore::GraphicsLayerQt::setMaskLayer):
     21        (WebCore::GraphicsLayerQt::setPosition):
     22        (WebCore::GraphicsLayerQt::setAnchorPoint):
     23        (WebCore::GraphicsLayerQt::setSize):
     24        (WebCore::GraphicsLayerQt::setTransform):
     25        (WebCore::GraphicsLayerQt::setChildrenTransform):
     26        (WebCore::GraphicsLayerQt::setPreserves3D):
     27        (WebCore::GraphicsLayerQt::setMasksToBounds):
     28        (WebCore::GraphicsLayerQt::setDrawsContent):
     29        (WebCore::GraphicsLayerQt::setBackgroundColor):
     30        (WebCore::GraphicsLayerQt::clearBackgroundColor):
     31        (WebCore::GraphicsLayerQt::setContentsOpaque):
     32        (WebCore::GraphicsLayerQt::setBackfaceVisibility):
     33        (WebCore::GraphicsLayerQt::setOpacity):
     34        (WebCore::GraphicsLayerQt::setContentsRect):
     35
    1362010-03-18  Stephen White  <senorblanco@chromium.org>
    237
  • trunk/WebCore/platform/graphics/qt/GraphicsLayerQt.cpp

    r55967 r56158  
    3030#include <QtCore/qabstractanimation.h>
    3131#include <QtCore/qdebug.h>
     32#include <QtCore/qmetaobject.h>
    3233#include <QtCore/qset.h>
    3334#include <QtCore/qtimer.h>
     
    102103    enum ChangeMask {
    103104        NoChanges =                 0,
     105
     106        ParentChange =              (1L << 0),
    104107        ChildrenChange =            (1L << 1),
    105108        MaskLayerChange =           (1L << 2),
    106109        PositionChange =            (1L << 3),
     110
    107111        AnchorPointChange =         (1L << 4),
    108112        SizeChange  =               (1L << 5),
    109113        TransformChange =           (1L << 6),
    110114        ContentChange =             (1L << 7),
     115
    111116        GeometryOrientationChange = (1L << 8),
    112117        ContentsOrientationChange = (1L << 9),
    113118        OpacityChange =             (1L << 10),
    114119        ContentsRectChange =        (1L << 11),
     120
    115121        Preserves3DChange =         (1L << 12),
    116122        MasksToBoundsChange =       (1L << 13),
    117123        DrawsContentChange =        (1L << 14),
    118124        ContentsOpaqueChange =      (1L << 15),
     125
    119126        BackfaceVisibilityChange =  (1L << 16),
    120127        ChildrenTransformChange =   (1L << 17),
    121128        DisplayChange =             (1L << 18),
    122129        BackgroundColorChange =     (1L << 19),
    123         ParentChange =              (1L << 20),
    124         DistributesOpacityChange =  (1L << 21)
     130
     131        DistributesOpacityChange =  (1L << 20)
    125132    };
    126133
     
    161168    // we need to notify the client (aka the layer compositor) when the animation actually starts
    162169    void notifyAnimationStarted();
     170
     171    // we notify WebCore of a layer changed asynchronously; otherwise we end up calling flushChanges too often.
     172    void notifySyncRequired();
    163173
    164174signals:
     
    391401}
    392402
    393 void GraphicsLayerQtImpl::notifyChange(ChangeMask changeMask)
    394 {
    395     Q_ASSERT(this);
    396 
    397     m_changeMask |= changeMask;
    398 
     403void GraphicsLayerQtImpl::notifySyncRequired()
     404{
    399405    if (m_layer->client())
    400406        m_layer->client()->notifySyncRequired(m_layer);
     407}
     408
     409void GraphicsLayerQtImpl::notifyChange(ChangeMask changeMask)
     410{
     411    m_changeMask |= changeMask;
     412    static QMetaMethod syncMethod = staticMetaObject.method(staticMetaObject.indexOfMethod("notifySyncRequired()"));
     413    syncMethod.invoke(this, Qt::QueuedConnection);
    401414}
    402415
     
    522535    }
    523536
    524     if ((m_changeMask & OpacityChange) && m_state.opacity != m_layer->opacity())
     537    if ((m_changeMask & OpacityChange) && m_state.opacity != m_layer->opacity() && !m_opacityAnimationRunning)
    525538        setOpacity(m_layer->opacity());
    526539
     
    710723
    711724// reimp from GraphicsLayer.h
    712 void GraphicsLayerQt::setMaskLayer(GraphicsLayer* layer)
    713 {
    714     GraphicsLayer::setMaskLayer(layer);
     725void GraphicsLayerQt::setMaskLayer(GraphicsLayer* value)
     726{
     727    if (value == maskLayer())
     728        return;
     729    GraphicsLayer::setMaskLayer(value);
    715730    m_impl->notifyChange(GraphicsLayerQtImpl::MaskLayerChange);
    716731}
    717732
    718733// reimp from GraphicsLayer.h
    719 void GraphicsLayerQt::setPosition(const FloatPoint& p)
    720 {
    721     if (position() != p)
    722        m_impl->notifyChange(GraphicsLayerQtImpl::PositionChange);
    723     GraphicsLayer::setPosition(p);
    724 }
    725 
    726 // reimp from GraphicsLayer.h
    727 void GraphicsLayerQt::setAnchorPoint(const FloatPoint3D& p)
    728 {
    729     if (anchorPoint() != p)
    730         m_impl->notifyChange(GraphicsLayerQtImpl::AnchorPointChange);
    731     GraphicsLayer::setAnchorPoint(p);
    732 }
    733 
    734 // reimp from GraphicsLayer.h
    735 void GraphicsLayerQt::setSize(const FloatSize& size)
    736 {
    737     if (this->size() != size)
    738         m_impl->notifyChange(GraphicsLayerQtImpl::SizeChange);
    739     GraphicsLayer::setSize(size);
    740 }
    741 
    742 // reimp from GraphicsLayer.h
    743 void GraphicsLayerQt::setTransform(const TransformationMatrix& t)
    744 {
    745     if (!m_impl->m_transformAnimationRunning && transform() != t)
    746        m_impl->notifyChange(GraphicsLayerQtImpl::TransformChange);
    747     GraphicsLayer::setTransform(t);
    748 }
    749 
    750 // reimp from GraphicsLayer.h
    751 void GraphicsLayerQt::setChildrenTransform(const TransformationMatrix& t)
    752 {
    753     GraphicsLayer::setChildrenTransform(t);
     734void GraphicsLayerQt::setPosition(const FloatPoint& value)
     735{
     736    if (value == position())
     737        return;
     738    GraphicsLayer::setPosition(value);
     739    m_impl->notifyChange(GraphicsLayerQtImpl::PositionChange);
     740}
     741
     742// reimp from GraphicsLayer.h
     743void GraphicsLayerQt::setAnchorPoint(const FloatPoint3D& value)
     744{
     745    if (value == anchorPoint())
     746        return;
     747    GraphicsLayer::setAnchorPoint(value);
     748    m_impl->notifyChange(GraphicsLayerQtImpl::AnchorPointChange);
     749}
     750
     751// reimp from GraphicsLayer.h
     752void GraphicsLayerQt::setSize(const FloatSize& value)
     753{
     754    if (value == size())
     755        return;
     756    GraphicsLayer::setSize(value);
     757    m_impl->notifyChange(GraphicsLayerQtImpl::SizeChange);
     758}
     759
     760// reimp from GraphicsLayer.h
     761void GraphicsLayerQt::setTransform(const TransformationMatrix& value)
     762{
     763    if (value == transform())
     764        return;
     765    GraphicsLayer::setTransform(value);
     766    m_impl->notifyChange(GraphicsLayerQtImpl::TransformChange);
     767}
     768
     769// reimp from GraphicsLayer.h
     770void GraphicsLayerQt::setChildrenTransform(const TransformationMatrix& value)
     771{
     772    if (value == childrenTransform())
     773        return;
     774    GraphicsLayer::setChildrenTransform(value);
    754775    m_impl->notifyChange(GraphicsLayerQtImpl::ChildrenTransformChange);
    755776}
    756777
    757778// reimp from GraphicsLayer.h
    758 void GraphicsLayerQt::setPreserves3D(bool b)
    759 {
    760     if (b != preserves3D());
    761        m_impl->notifyChange(GraphicsLayerQtImpl::Preserves3DChange);
    762     GraphicsLayer::setPreserves3D(b);
    763 }
    764 
    765 // reimp from GraphicsLayer.h
    766 void GraphicsLayerQt::setMasksToBounds(bool b)
    767 {
    768     GraphicsLayer::setMasksToBounds(b);
     779void GraphicsLayerQt::setPreserves3D(bool value)
     780{
     781    if (value == preserves3D())
     782        return;
     783    GraphicsLayer::setPreserves3D(value);
     784    m_impl->notifyChange(GraphicsLayerQtImpl::Preserves3DChange);
     785}
     786
     787// reimp from GraphicsLayer.h
     788void GraphicsLayerQt::setMasksToBounds(bool value)
     789{
     790    if (value == masksToBounds())
     791        return;
     792    GraphicsLayer::setMasksToBounds(value);
    769793    m_impl->notifyChange(GraphicsLayerQtImpl::MasksToBoundsChange);
    770794}
    771795
    772796// reimp from GraphicsLayer.h
    773 void GraphicsLayerQt::setDrawsContent(bool b)
    774 {
     797void GraphicsLayerQt::setDrawsContent(bool value)
     798{
     799    if (value == drawsContent())
     800        return;
    775801    m_impl->notifyChange(GraphicsLayerQtImpl::DrawsContentChange);
    776     GraphicsLayer::setDrawsContent(b);
    777 }
    778 
    779 // reimp from GraphicsLayer.h
    780 void GraphicsLayerQt::setBackgroundColor(const Color& c)
    781 {
     802    GraphicsLayer::setDrawsContent(value);
     803}
     804
     805// reimp from GraphicsLayer.h
     806void GraphicsLayerQt::setBackgroundColor(const Color& value)
     807{
     808    if (value == m_impl->m_pendingContent.backgroundColor)
     809        return;
     810    m_impl->m_pendingContent.backgroundColor = value;
     811    GraphicsLayer::setBackgroundColor(value);
    782812    m_impl->notifyChange(GraphicsLayerQtImpl::BackgroundColorChange);
    783     m_impl->m_pendingContent.backgroundColor = c;
    784     GraphicsLayer::setBackgroundColor(c);
    785813}
    786814
     
    788816void GraphicsLayerQt::clearBackgroundColor()
    789817{
     818    if (!m_impl->m_pendingContent.backgroundColor.isValid())
     819        return;
    790820    m_impl->m_pendingContent.backgroundColor = QColor();
     821    GraphicsLayer::clearBackgroundColor();
    791822    m_impl->notifyChange(GraphicsLayerQtImpl::BackgroundColorChange);
    792     GraphicsLayer::clearBackgroundColor();
    793 }
    794 
    795 // reimp from GraphicsLayer.h
    796 void GraphicsLayerQt::setContentsOpaque(bool b)
    797 {
     823}
     824
     825// reimp from GraphicsLayer.h
     826void GraphicsLayerQt::setContentsOpaque(bool value)
     827{
     828    if (value == contentsOpaque())
     829        return;
    798830    m_impl->notifyChange(GraphicsLayerQtImpl::ContentsOpaqueChange);
    799     GraphicsLayer::setContentsOpaque(b);
    800 }
    801 
    802 // reimp from GraphicsLayer.h
    803 void GraphicsLayerQt::setBackfaceVisibility(bool b)
    804 {
     831    GraphicsLayer::setContentsOpaque(value);
     832}
     833
     834// reimp from GraphicsLayer.h
     835void GraphicsLayerQt::setBackfaceVisibility(bool value)
     836{
     837    if (value == backfaceVisibility())
     838        return;
     839    GraphicsLayer::setBackfaceVisibility(value);
    805840    m_impl->notifyChange(GraphicsLayerQtImpl::BackfaceVisibilityChange);
    806     GraphicsLayer::setBackfaceVisibility(b);
    807 }
    808 
    809 // reimp from GraphicsLayer.h
    810 void GraphicsLayerQt::setOpacity(float o)
    811 {
    812     if (!m_impl->m_opacityAnimationRunning && opacity() != o)
    813        m_impl->notifyChange(GraphicsLayerQtImpl::OpacityChange);
    814     GraphicsLayer::setOpacity(o);
    815 }
    816 
    817 // reimp from GraphicsLayer.h
    818 void GraphicsLayerQt::setContentsRect(const IntRect& r)
    819 {
     841}
     842
     843// reimp from GraphicsLayer.h
     844void GraphicsLayerQt::setOpacity(float value)
     845{
     846    if (value == opacity())
     847        return;
     848    GraphicsLayer::setOpacity(value);
     849    m_impl->notifyChange(GraphicsLayerQtImpl::OpacityChange);
     850}
     851
     852// reimp from GraphicsLayer.h
     853void GraphicsLayerQt::setContentsRect(const IntRect& value)
     854{
     855    if (value == contentsRect())
     856        return;
     857    GraphicsLayer::setContentsRect(value);
    820858    m_impl->notifyChange(GraphicsLayerQtImpl::ContentsRectChange);
    821     GraphicsLayer::setContentsRect(r);
    822859}
    823860
Note: See TracChangeset for help on using the changeset viewer.