Changeset 69452 in webkit


Ignore:
Timestamp:
Oct 9, 2010 11:36:15 AM (14 years ago)
Author:
commit-queue@webkit.org
Message:

2010-10-09 Carlos Garcia Campos <cgarcia@igalia.com>

Reviewed by Martin Robinson.

[GTK] Implement subregion rendering in WebView when using gtk3
https://bugs.webkit.org/show_bug.cgi?id=47411

  • GNUmakefile.am:
  • platform/graphics/FloatRect.h:
  • platform/graphics/cairo/FloatRectCairo.cpp: Added. (WebCore::FloatRect::FloatRect): (WebCore::FloatRect::operator cairo_rectangle_t):
Location:
trunk
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r69450 r69452  
     12010-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        Reviewed by Martin Robinson.
     4
     5        [GTK] Implement subregion rendering in WebView when using gtk3
     6        https://bugs.webkit.org/show_bug.cgi?id=47411
     7
     8        * GNUmakefile.am:
     9        * platform/graphics/FloatRect.h:
     10        * platform/graphics/cairo/FloatRectCairo.cpp: Added.
     11        (WebCore::FloatRect::FloatRect):
     12        (WebCore::FloatRect::operator cairo_rectangle_t):
     13
     142010-10-09  Carlos Garcia Campos  <cgarcia@igalia.com>
     15
     16        Reviewed by Martin Robinson.
     17
     18        [GTK] Implement subregion rendering in WebView when using gtk3
     19        https://bugs.webkit.org/show_bug.cgi?id=47411
     20
     21        * GNUmakefile.am:
     22        * platform/graphics/FloatRect.h:
     23        * platform/graphics/cairo/FloatRectCairo.cpp: Added.
     24        (WebCore::FloatRect::FloatRect):
     25        (WebCore::FloatRect::operator cairo_rectangle_t):
     26
    1272010-10-09  Kwang Yul Seo  <skyul@company100.net>
    228
  • trunk/WebCore/GNUmakefile.am

    r69381 r69452  
    34563456        WebCore/platform/graphics/cairo/CairoUtilities.h \
    34573457        WebCore/platform/graphics/cairo/ContextShadowCairo.cpp \
     3458        WebCore/platform/graphics/cairo/FloatRectCairo.cpp \
    34583459        WebCore/platform/graphics/cairo/FontCairo.cpp \
    34593460        WebCore/platform/graphics/cairo/FontCustomPlatformData.h \
  • trunk/WebCore/platform/graphics/FloatRect.h

    r66611 r69452  
    6060#endif
    6161
     62#if PLATFORM(CAIRO)
     63typedef struct _cairo_rectangle cairo_rectangle_t;
     64#endif
     65
    6266namespace WebCore {
    6367
     
    173177#endif
    174178
     179#if PLATFORM(CAIRO)
     180    FloatRect(const cairo_rectangle_t&);
     181    operator cairo_rectangle_t() const;
     182#endif
     183
    175184private:
    176185    FloatPoint m_location;
  • trunk/WebKit/gtk/webkit/webkitwebview.cpp

    r69444 r69452  
    484484}
    485485
     486static bool shouldCoalesce(const IntRect& rect, const Vector<IntRect>& rects)
     487{
     488    const unsigned int cRectThreshold = 10;
     489    const float cWastedSpaceThreshold = 0.75f;
     490    bool useUnionedRect = (rects.size() <= 1) || (rects.size() > cRectThreshold);
     491    if (useUnionedRect)
     492        return true;
     493    // Attempt to guess whether or not we should use the unioned rect or the individual rects.
     494    // We do this by computing the percentage of "wasted space" in the union.  If that wasted space
     495    // is too large, then we will do individual rect painting instead.
     496    float unionPixels = (rect.width() * rect.height());
     497    float singlePixels = 0;
     498    for (size_t i = 0; i < rects.size(); ++i)
     499        singlePixels += rects[i].width() * rects[i].height();
     500    float wastedSpace = 1 - (singlePixels / unionPixels);
     501    if (wastedSpace <= cWastedSpaceThreshold)
     502        useUnionedRect = true;
     503    return useUnionedRect;
     504}
     505
     506static void paintWebView(Frame* frame, gboolean transparent, GraphicsContext& context, const IntRect& clipRect, const Vector<IntRect>& rects)
     507{
     508    bool coalesce = true;
     509
     510    if (rects.size() > 0)
     511        coalesce = shouldCoalesce(clipRect, rects);
     512
     513    if (coalesce) {
     514        context.clip(clipRect);
     515        if (transparent)
     516            context.clearRect(clipRect);
     517        frame->view()->paint(&context, clipRect);
     518    } else {
     519        for (size_t i = 0; i < rects.size(); i++) {
     520            IntRect rect = rects[i];
     521            context.save();
     522            context.clip(rect);
     523            if (transparent)
     524                context.clearRect(rect);
     525            frame->view()->paint(&context, rect);
     526            context.restore();
     527        }
     528    }
     529
     530    context.save();
     531    context.clip(clipRect);
     532    frame->page()->inspectorController()->drawNodeHighlight(context);
     533    context.restore();
     534}
    486535#ifdef GTK_API_VERSION_2
    487 static bool shouldCoalesce(GdkRectangle rect, GdkRectangle* rects, int count)
    488 {
    489     const int cRectThreshold = 10;
    490     const float cWastedSpaceThreshold = 0.75f;
    491     bool useUnionedRect = (count <= 1) || (count > cRectThreshold);
    492     if (!useUnionedRect) {
    493         // Attempt to guess whether or not we should use the unioned rect or the individual rects.
    494         // We do this by computing the percentage of "wasted space" in the union.  If that wasted space
    495         // is too large, then we will do individual rect painting instead.
    496         float unionPixels = (rect.width * rect.height);
    497         float singlePixels = 0;
    498         for (int i = 0; i < count; ++i)
    499             singlePixels += rects[i].width * rects[i].height;
    500         float wastedSpace = 1 - (singlePixels / unionPixels);
    501         if (wastedSpace <= cWastedSpaceThreshold)
    502             useUnionedRect = true;
    503     }
    504     return useUnionedRect;
    505 }
    506 
    507536static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
    508537{
     
    522551        GOwnPtr<GdkRectangle> rects;
    523552        gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
    524 
    525         // Avoid recursing into the render tree excessively
    526         bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount);
    527 
    528         if (coalesce) {
    529             IntRect rect = event->area;
    530             ctx.clip(rect);
    531             if (priv->transparent)
    532                 ctx.clearRect(rect);
    533             frame->view()->paint(&ctx, rect);
    534         } else {
    535             for (int i = 0; i < rectCount; i++) {
    536                 IntRect rect = rects.get()[i];
    537                 ctx.save();
    538                 ctx.clip(rect);
    539                 if (priv->transparent)
    540                     ctx.clearRect(rect);
    541                 frame->view()->paint(&ctx, rect);
    542                 ctx.restore();
    543             }
    544         }
    545 
    546         ctx.save();
    547         ctx.clip(static_cast<IntRect>(event->area));
    548         frame->page()->inspectorController()->drawNodeHighlight(ctx);
    549         ctx.restore();
     553        Vector<IntRect> paintRects;
     554        for (int i = 0; i < rectCount; i++)
     555            paintRects.append(IntRect(rects.get()[i]));
     556
     557        paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects);
    550558    }
    551559
     
    566574        GraphicsContext ctx(cr);
    567575        IntRect rect = clipRect;
     576        cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
    568577
    569578        frame->view()->updateLayoutAndStyleIfNeededRecursive();
    570         if (priv->transparent)
    571             ctx.clearRect(rect);
    572         frame->view()->paint(&ctx, rect);
    573         ctx.save();
    574         frame->page()->inspectorController()->drawNodeHighlight(ctx);
    575         ctx.restore();
     579
     580        Vector<IntRect> rects;
     581        if (!rectList->status && rectList->num_rectangles > 0) {
     582            for (int i = 0; i < rectList->num_rectangles; i++)
     583                rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i])));
     584        }
     585        paintWebView(frame, priv->transparent, ctx, rect, rects);
     586
     587        cairo_rectangle_list_destroy(rectList);
    576588    }
    577589
Note: See TracChangeset for help on using the changeset viewer.