Changeset 69452 in webkit
- Timestamp:
- Oct 9, 2010 11:36:15 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r69450 r69452 1 2010-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 14 2010-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 1 27 2010-10-09 Kwang Yul Seo <skyul@company100.net> 2 28 -
trunk/WebCore/GNUmakefile.am
r69381 r69452 3456 3456 WebCore/platform/graphics/cairo/CairoUtilities.h \ 3457 3457 WebCore/platform/graphics/cairo/ContextShadowCairo.cpp \ 3458 WebCore/platform/graphics/cairo/FloatRectCairo.cpp \ 3458 3459 WebCore/platform/graphics/cairo/FontCairo.cpp \ 3459 3460 WebCore/platform/graphics/cairo/FontCustomPlatformData.h \ -
trunk/WebCore/platform/graphics/FloatRect.h
r66611 r69452 60 60 #endif 61 61 62 #if PLATFORM(CAIRO) 63 typedef struct _cairo_rectangle cairo_rectangle_t; 64 #endif 65 62 66 namespace WebCore { 63 67 … … 173 177 #endif 174 178 179 #if PLATFORM(CAIRO) 180 FloatRect(const cairo_rectangle_t&); 181 operator cairo_rectangle_t() const; 182 #endif 183 175 184 private: 176 185 FloatPoint m_location; -
trunk/WebKit/gtk/webkit/webkitwebview.cpp
r69444 r69452 484 484 } 485 485 486 static 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 506 static 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 } 486 535 #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 space495 // 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 507 536 static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event) 508 537 { … … 522 551 GOwnPtr<GdkRectangle> rects; 523 552 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); 550 558 } 551 559 … … 566 574 GraphicsContext ctx(cr); 567 575 IntRect rect = clipRect; 576 cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr); 568 577 569 578 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); 576 588 } 577 589
Note: See TracChangeset
for help on using the changeset viewer.