Changeset 162947 in webkit


Ignore:
Timestamp:
Jan 28, 2014 11:40:05 AM (10 years ago)
Author:
Antti Koivisto
Message:

REGRESSION(r162837): 5% regression on html5-full-render and 3% regression in DoYouEvenBench
https://bugs.webkit.org/show_bug.cgi?id=127722

Reviewed by Darin Adler.

Accumulate repaint region in RendeView instead of flushing rects directly to the system.

  • dom/Document.cpp:

(WebCore::Document::recalcStyle):
(WebCore::Document::updateLayout):
(WebCore::Document::topDocument):

Make less silly.

  • page/FrameView.cpp:

(WebCore::FrameView::layout):

  • rendering/RenderView.cpp:

(WebCore::RenderView::repaintViewRectangle):
(WebCore::RenderView::flushAccumulatedRepaintRegion):
(WebCore::RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator):
(WebCore::RenderView::RepaintRegionAccumulator::~RepaintRegionAccumulator):

  • rendering/RenderView.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r162945 r162947  
     12014-01-28  Antti Koivisto  <antti@apple.com>
     2
     3        REGRESSION(r162837): 5% regression on html5-full-render and 3% regression in DoYouEvenBench
     4        https://bugs.webkit.org/show_bug.cgi?id=127722
     5
     6        Reviewed by Darin Adler.
     7
     8        Accumulate repaint region in RendeView instead of flushing rects directly to the system.
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::recalcStyle):
     12        (WebCore::Document::updateLayout):
     13        (WebCore::Document::topDocument):
     14       
     15            Make less silly.
     16
     17        * page/FrameView.cpp:
     18        (WebCore::FrameView::layout):
     19        * rendering/RenderView.cpp:
     20        (WebCore::RenderView::repaintViewRectangle):
     21        (WebCore::RenderView::flushAccumulatedRepaintRegion):
     22        (WebCore::RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator):
     23        (WebCore::RenderView::RepaintRegionAccumulator::~RepaintRegionAccumulator):
     24        * rendering/RenderView.h:
     25
    1262014-01-28  Jeremy Jones  <jeremyj@apple.com>
    227
  • trunk/Source/WebCore/dom/Document.cpp

    r162837 r162947  
    17211721        return; // Guard against re-entrancy. -dwh
    17221722
     1723    RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
     1724
    17231725    // FIXME: We should update style on our ancestor chain before proceeding (especially for seamless),
    17241726    // however doing so currently causes several tests to crash, as Frame::setDocument calls Document::attach
     
    18111813        return;
    18121814    }
     1815
     1816    RenderView::RepaintRegionAccumulator repaintRegionAccumulator(renderView());
    18131817
    18141818    if (Element* oe = ownerElement())
     
    43104314Document* Document::topDocument() const
    43114315{
    4312     // FIXME: Why does this walk up owner elements instead using the frame tree as parentDocument does?
    4313     // The frame tree even has a top() function.
    4314     Document* document = const_cast<Document*>(this);
    4315     while (Element* element = document->ownerElement())
    4316         document = &element->document();
    4317     return document;
     4316    return m_frame ? m_frame->mainFrame().document() : const_cast<Document*>(this);
    43184317}
    43194318
  • trunk/Source/WebCore/page/FrameView.cpp

    r162840 r162947  
    12771277        }
    12781278        LayoutStateDisabler layoutStateDisabler(disableLayoutState ? &root->view() : 0);
     1279        RenderView::RepaintRegionAccumulator repaintRegionAccumulator(&root->view());
    12791280
    12801281        ASSERT(m_layoutPhase == InPreLayout);
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r162837 r162947  
    606606}
    607607
    608 void RenderView::repaintViewRectangle(const LayoutRect& ur, bool immediate) const
    609 {
    610     if (!shouldRepaint(ur))
    611         return;
    612 
    613     // We always just invalidate the root view, since we could be an iframe that is clipped out
    614     // or even invisible.
    615     Element* elt = document().ownerElement();
    616     if (!elt)
    617         frameView().repaintContentRectangle(pixelSnappedIntRect(ur), immediate);
    618     else if (RenderBox* obj = elt->renderBox()) {
    619         LayoutRect vr = viewRect();
     608void RenderView::repaintViewRectangle(const LayoutRect& repaintRect, bool immediate) const
     609{
     610    // FIXME: Get rid of the 'immediate' argument. It only works on Mac WK1 and should never be used.
     611    if (!shouldRepaint(repaintRect))
     612        return;
     613
     614    if (auto ownerElement = document().ownerElement()) {
     615        if (!ownerElement->renderer())
     616            return;
     617        auto& ownerBox = toRenderBox(*ownerElement->renderer());
     618        LayoutRect viewRect = this->viewRect();
    620619#if PLATFORM(IOS)
    621620        // Don't clip using the visible rect since clipping is handled at a higher level on iPhone.
    622         LayoutRect r = ur;
     621        LayoutRect adjustedRect = repaintRect;
    623622#else
    624         LayoutRect r = intersection(ur, vr);
    625 #endif
    626        
    627         // Subtract out the contentsX and contentsY offsets to get our coords within the viewing
    628         // rectangle.
    629         r.moveBy(-vr.location());
    630 
    631         // FIXME: Hardcoded offsets here are not good.
    632         r.moveBy(obj->contentBoxRect().location());
    633         obj->repaintRectangle(r, immediate);
    634     }
     623        LayoutRect adjustedRect = intersection(repaintRect, viewRect);
     624#endif
     625        adjustedRect.moveBy(-viewRect.location());
     626        adjustedRect.moveBy(ownerBox.contentBoxRect().location());
     627        ownerBox.repaintRectangle(adjustedRect, immediate);
     628        return;
     629    }
     630
     631    IntRect pixelSnappedRect = pixelSnappedIntRect(repaintRect);
     632    if (!m_accumulatedRepaintRegion || immediate) {
     633        frameView().repaintContentRectangle(pixelSnappedRect, immediate);
     634        return;
     635    }
     636    m_accumulatedRepaintRegion->unite(pixelSnappedRect);
     637}
     638
     639void RenderView::flushAccumulatedRepaintRegion() const
     640{
     641    ASSERT(!document().ownerElement());
     642    ASSERT(m_accumulatedRepaintRegion);
     643    auto repaintRects = m_accumulatedRepaintRegion->rects();
     644    for (auto& rect : repaintRects)
     645        frameView().repaintContentRectangle(rect, false);
     646    m_accumulatedRepaintRegion = nullptr;
    635647}
    636648
     
    12541266}
    12551267
     1268RenderView::RepaintRegionAccumulator::RepaintRegionAccumulator(RenderView* view)
     1269    : m_rootView(view ? view->document().topDocument()->renderView() : nullptr)
     1270{
     1271    if (!m_rootView)
     1272        return;
     1273    m_wasAccumulatingRepaintRegion = !!m_rootView->m_accumulatedRepaintRegion;
     1274    if (!m_wasAccumulatingRepaintRegion)
     1275        m_rootView->m_accumulatedRepaintRegion = std::make_unique<Region>();
     1276}
     1277
     1278RenderView::RepaintRegionAccumulator::~RepaintRegionAccumulator()
     1279{
     1280    if (!m_rootView)
     1281        return;
     1282    if (m_wasAccumulatingRepaintRegion)
     1283        return;
     1284    m_rootView->flushAccumulatedRepaintRegion();
     1285}
     1286
    12561287} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderView.h

    r162726 r162947  
    2626#include "LayoutState.h"
    2727#include "PODFreeListArena.h"
     28#include "Region.h"
    2829#include "RenderBlockFlow.h"
    2930#include <wtf/OwnPtr.h>
     
    235236    void didDestroyRenderer() { --m_rendererCount; }
    236237
     238    class RepaintRegionAccumulator {
     239        WTF_MAKE_NONCOPYABLE(RepaintRegionAccumulator);
     240    public:
     241        RepaintRegionAccumulator(RenderView*);
     242        ~RepaintRegionAccumulator();
     243
     244    private:
     245        RenderView* m_rootView;
     246        bool m_wasAccumulatingRepaintRegion;
     247    };
     248
    237249protected:
    238250    virtual void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags = ApplyContainerFlip, bool* wasFixed = 0) const override;
     
    248260
    249261    bool shouldRepaint(const LayoutRect&) const;
     262    void flushAccumulatedRepaintRegion() const;
    250263
    251264    // These functions may only be accessed by LayoutStateMaintainer.
     
    303316
    304317    uint64_t m_rendererCount;
     318
     319    mutable std::unique_ptr<Region> m_accumulatedRepaintRegion;
    305320
    306321    // FIXME: Only used by embedded WebViews inside AppKit NSViews.  Find a way to remove.
Note: See TracChangeset for help on using the changeset viewer.