Changeset 51698 in webkit


Ignore:
Timestamp:
Dec 4, 2009 9:43:29 AM (14 years ago)
Author:
eric@webkit.org
Message:

2009-12-04 Kenneth Rohde Christiansen <kenneth@webkit.org>

Reviewed by Antti Koivisto.

Split out the renderPrivate in two methods, one for working on
relative coordinates (relative to the viewport) and one for
working on absolute coordinates. The latter is more effecient
for implementing tiling, as you don't need translate the coords,
and because it avoid clipping to the viewport.

No behaviour changes, so no new tests.

  • Api/qwebframe.cpp: (QWebFramePrivate::renderContentsLayerAbsoluteCoords): (QWebFramePrivate::renderRelativeCoords): (QWebFrame::render):
  • Api/qwebframe_p.h:
Location:
trunk/WebKit/qt
Files:
3 edited

Legend:

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

    r51658 r51698  
    268268}
    269269
    270 void QWebFramePrivate::renderPrivate(QPainter *painter, QWebFrame::RenderLayer layer, const QRegion &clip)
     270void QWebFramePrivate::renderContentsLayerAbsoluteCoords(GraphicsContext* context, const QRegion& clip)
    271271{
    272272    if (!frame->view() || !frame->contentRenderer())
     
    277277        return;
    278278
    279     GraphicsContext context(painter);
    280     if (context.paintingDisabled() && !context.updatingControlTints())
    281         return;
     279    QPainter* painter = context->platformContext();
    282280
    283281    WebCore::FrameView* view = frame->view();
     
    286284    for (int i = 0; i < vector.size(); ++i) {
    287285        const QRect& clipRect = vector.at(i);
    288         QRect intersectedRect = clipRect.intersected(view->frameRect());
    289286
    290287        painter->save();
    291288        painter->setClipRect(clipRect, Qt::IntersectClip);
    292289
     290        context->save();
     291        view->paintContents(context, clipRect);
     292        context->restore();
     293
     294        painter->restore();
     295    }
     296}
     297
     298void QWebFramePrivate::renderRelativeCoords(GraphicsContext* context, QWebFrame::RenderLayer layer, const QRegion& clip)
     299{
     300    if (!frame->view() || !frame->contentRenderer())
     301        return;
     302
     303    QVector<QRect> vector = clip.rects();
     304    if (vector.isEmpty())
     305        return;
     306
     307    QPainter* painter = context->platformContext();
     308
     309    WebCore::FrameView* view = frame->view();
     310    view->layoutIfNeededRecursive();
     311
     312    for (int i = 0; i < vector.size(); ++i) {
     313        const QRect& clipRect = vector.at(i);
     314
     315        QRect intersectedRect = clipRect.intersected(view->frameRect());
     316
     317        painter->save();
     318        painter->setClipRect(clipRect, Qt::IntersectClip);
     319
    293320        int x = view->x();
    294321        int y = view->y();
    295322
    296323        if (layer & QWebFrame::ContentsLayer) {
    297             context.save();
     324            context->save();
    298325
    299326            int scrollX = view->scrollX();
     
    301328
    302329            QRect rect = intersectedRect;
    303             context.translate(x, y);
     330            context->translate(x, y);
    304331            rect.translate(-x, -y);
    305             context.translate(-scrollX, -scrollY);
     332            context->translate(-scrollX, -scrollY);
    306333            rect.translate(scrollX, scrollY);
    307             context.clip(view->visibleContentRect());
    308 
    309             view->paintContents(&context, rect);
    310 
    311             context.restore();
     334            context->clip(view->visibleContentRect());
     335
     336            view->paintContents(context, rect);
     337
     338            context->restore();
    312339        }
    313340
     
    315342            && !view->scrollbarsSuppressed()
    316343            && (view->horizontalScrollbar() || view->verticalScrollbar())) {
    317             context.save();
     344            context->save();
    318345
    319346            QRect rect = intersectedRect;
    320             context.translate(x, y);
     347            context->translate(x, y);
    321348            rect.translate(-x, -y);
    322349
    323             view->paintScrollbars(&context, rect);
    324 
    325             context.restore();
     350            view->paintScrollbars(context, rect);
     351
     352            context->restore();
    326353        }
    327354
     355#if ENABLE(PAN_SCROLLING)
    328356        if (layer & QWebFrame::PanIconLayer)
    329             view->paintPanScrollIcon(&context);
     357            view->paintPanScrollIcon(context);
     358#endif
    330359
    331360        painter->restore();
     
    10031032void QWebFrame::render(QPainter* painter, RenderLayer layer, const QRegion& clip)
    10041033{
     1034    GraphicsContext context(painter);
     1035    if (context.paintingDisabled() && !context.updatingControlTints())
     1036        return;
     1037
    10051038    if (!clip.isEmpty())
    1006         d->renderPrivate(painter, layer, clip);
     1039        d->renderRelativeCoords(&context, layer, clip);
    10071040    else if (d->frame->view())
    1008         d->renderPrivate(painter, layer, QRegion(d->frame->view()->frameRect()));
     1041        d->renderRelativeCoords(&context, layer, QRegion(d->frame->view()->frameRect()));
    10091042}
    10101043
     
    10121045  Render the frame into \a painter clipping to \a clip.
    10131046*/
    1014 void QWebFrame::render(QPainter *painter, const QRegion &clip)
    1015 {
    1016     d->renderPrivate(painter, AllLayers, clip);
     1047void QWebFrame::render(QPainter* painter, const QRegion& clip)
     1048{
     1049    GraphicsContext context(painter);
     1050    if (context.paintingDisabled() && !context.updatingControlTints())
     1051        return;
     1052
     1053    d->renderRelativeCoords(&context, AllLayers, clip);
    10171054}
    10181055
     
    10201057  Render the frame into \a painter.
    10211058*/
    1022 void QWebFrame::render(QPainter *painter)
     1059void QWebFrame::render(QPainter* painter)
    10231060{
    10241061    if (!d->frame->view())
    10251062        return;
    10261063
    1027     d->renderPrivate(painter, AllLayers, QRegion(d->frame->view()->frameRect()));
     1064    GraphicsContext context(painter);
     1065    if (context.paintingDisabled() && !context.updatingControlTints())
     1066        return;
     1067
     1068    d->renderRelativeCoords(&context, AllLayers, QRegion(d->frame->view()->frameRect()));
    10281069}
    10291070
  • trunk/WebKit/qt/Api/qwebframe_p.h

    r49870 r51698  
    2626
    2727#include "EventHandler.h"
     28#include "GraphicsContext.h"
    2829#include "KURL.h"
    2930#include "PlatformString.h"
     
    8283    static QWebFrame* kit(WebCore::Frame*);
    8384
    84     void renderPrivate(QPainter*, QWebFrame::RenderLayer, const QRegion& clip);
     85    void renderRelativeCoords(WebCore::GraphicsContext*, QWebFrame::RenderLayer, const QRegion& clip);
     86    void renderContentsLayerAbsoluteCoords(WebCore::GraphicsContext*, const QRegion& clip);
    8587
    8688    QWebFrame *q;
  • trunk/WebKit/qt/ChangeLog

    r51696 r51698  
     12009-12-04  Kenneth Rohde Christiansen  <kenneth@webkit.org>
     2
     3        Reviewed by Antti Koivisto.
     4
     5        Split out the renderPrivate in two methods, one for working on
     6        relative coordinates (relative to the viewport) and one for
     7        working on absolute coordinates. The latter is more effecient
     8        for implementing tiling, as you don't need translate the coords,
     9        and because it avoid clipping to the viewport.
     10
     11        No behaviour changes, so no new tests.
     12
     13        * Api/qwebframe.cpp:
     14        (QWebFramePrivate::renderContentsLayerAbsoluteCoords):
     15        (QWebFramePrivate::renderRelativeCoords):
     16        (QWebFrame::render):
     17        * Api/qwebframe_p.h:
     18
    1192009-12-04  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
    220
Note: See TracChangeset for help on using the changeset viewer.