Changeset 122507 in webkit


Ignore:
Timestamp:
Jul 12, 2012 2:37:30 PM (12 years ago)
Author:
kseo@webkit.org
Message:

[Qt] Increase the drawing performance by merging dirty rects.
https://bugs.webkit.org/show_bug.cgi?id=91075

Patch by Huang Dongsung <luxtella@company100.net> on 2012-07-12
Reviewed by Noam Rosenthal.

QWebFramePrivate calls FrameView::paintContents as many as the number of dirty
rects, so it causes too many redundant render tree traversals.
I changed it to merge dirty rects and call FrameView::paintContents only once.
The algorithm to merge rects is copied from GTK.

When parallel image decoders are in use, each image is independently repainted
when decoding is finished. This creates a lot by repaint requests. So by merging
these repaint requests, I could improve rendering performance.

For example, I tested parallel image decoders on the locally mirrored Pinterest site.
QWebFramePrivate called FrameView::paintContents 165 times after parallel image
decoders decoded all the images. It took about 120ms on my six-core Intel Xeon machine.
This patch decreases painting time from 120ms to 30ms.

  • Api/qwebframe.cpp:

(coalesceRectsIfPossible):
(QWebFramePrivate::renderRelativeCoords):

Location:
trunk/Source/WebKit/qt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/qt/Api/qwebframe.cpp

    r121710 r122507  
    357357#endif
    358358
     359// This code is copied from ChromeClientGtk.cpp.
     360static void coalesceRectsIfPossible(const QRect& clipRect, QVector<QRect>& rects)
     361{
     362    const unsigned int rectThreshold = 10;
     363    const float wastedSpaceThreshold = 0.75f;
     364    bool useUnionedRect = (rects.size() <= 1) || (rects.size() > rectThreshold);
     365    if (!useUnionedRect) {
     366        // Attempt to guess whether or not we should use the unioned rect or the individual rects.
     367        // We do this by computing the percentage of "wasted space" in the union. If that wasted space
     368        // is too large, then we will do individual rect painting instead.
     369        float unionPixels = (clipRect.width() * clipRect.height());
     370        float singlePixels = 0;
     371        for (size_t i = 0; i < rects.size(); ++i)
     372            singlePixels += rects[i].width() * rects[i].height();
     373        float wastedSpace = 1 - (singlePixels / unionPixels);
     374        if (wastedSpace <= wastedSpaceThreshold)
     375            useUnionedRect = true;
     376    }
     377
     378    if (!useUnionedRect)
     379        return;
     380
     381    rects.clear();
     382    rects.append(clipRect);
     383}
     384
    359385void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QFlags<QWebFrame::RenderLayer> layers, const QRegion& clip)
    360386{
     
    372398
    373399    if (layers & QWebFrame::ContentsLayer) {
     400        QRect clipBoundingRect = clip.boundingRect();
     401        coalesceRectsIfPossible(clipBoundingRect, vector);
    374402        for (int i = 0; i < vector.size(); ++i) {
    375403            const QRect& clipRect = vector.at(i);
     
    397425        }
    398426#if USE(ACCELERATED_COMPOSITING)
    399         renderCompositedLayers(context, IntRect(clip.boundingRect()));
     427        renderCompositedLayers(context, IntRect(clipBoundingRect));
    400428#endif
    401429    }
  • trunk/Source/WebKit/qt/ChangeLog

    r122333 r122507  
     12012-07-12  Huang Dongsung  <luxtella@company100.net>
     2
     3        [Qt] Increase the drawing performance by merging dirty rects.
     4        https://bugs.webkit.org/show_bug.cgi?id=91075
     5
     6        Reviewed by Noam Rosenthal.
     7
     8        QWebFramePrivate calls FrameView::paintContents as many as the number of dirty
     9        rects, so it causes too many redundant render tree traversals.
     10        I changed it to merge dirty rects and call FrameView::paintContents only once.
     11        The algorithm to merge rects is copied from GTK.
     12
     13        When parallel image decoders are in use, each image is independently repainted
     14        when decoding is finished. This creates a lot by repaint requests. So by merging
     15        these repaint requests, I could improve rendering performance.
     16
     17        For example, I tested parallel image decoders on the locally mirrored Pinterest site.
     18        QWebFramePrivate called FrameView::paintContents 165 times after parallel image
     19        decoders decoded all the images. It took about 120ms on my six-core Intel Xeon machine.
     20        This patch decreases painting time from 120ms to 30ms.
     21
     22        * Api/qwebframe.cpp:
     23        (coalesceRectsIfPossible):
     24        (QWebFramePrivate::renderRelativeCoords):
     25
    1262012-07-11  Steffen Imhof  <steffen.imhof@basyskom.com>
    227
Note: See TracChangeset for help on using the changeset viewer.