[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
commit-queue at webkit.org
commit-queue at webkit.org
Wed Dec 22 14:27:46 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 5fd87e34f5b28b4d9a7e1ce1cdffda8e9fd4e6cb
Author: commit-queue at webkit.org <commit-queue at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Oct 9 18:36:15 2010 +0000
2010-10-09 Carlos Garcia Campos <cgarcia at 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):
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69452 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f20cefa..5afe066 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,29 @@
+2010-10-09 Carlos Garcia Campos <cgarcia at 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):
+
+2010-10-09 Carlos Garcia Campos <cgarcia at 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):
+
2010-10-09 Kwang Yul Seo <skyul at company100.net>
Reviewed by Andreas Kling.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 4a2547b..c1f2190 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -3455,6 +3455,7 @@ webcoregtk_sources += \
WebCore/platform/graphics/cairo/CairoUtilities.cpp \
WebCore/platform/graphics/cairo/CairoUtilities.h \
WebCore/platform/graphics/cairo/ContextShadowCairo.cpp \
+ WebCore/platform/graphics/cairo/FloatRectCairo.cpp \
WebCore/platform/graphics/cairo/FontCairo.cpp \
WebCore/platform/graphics/cairo/FontCustomPlatformData.h \
WebCore/platform/graphics/cairo/FontPlatformData.h \
diff --git a/WebCore/platform/graphics/FloatRect.h b/WebCore/platform/graphics/FloatRect.h
index e387927..10ad838 100644
--- a/WebCore/platform/graphics/FloatRect.h
+++ b/WebCore/platform/graphics/FloatRect.h
@@ -59,6 +59,10 @@ class BRect;
struct SkRect;
#endif
+#if PLATFORM(CAIRO)
+typedef struct _cairo_rectangle cairo_rectangle_t;
+#endif
+
namespace WebCore {
#if PLATFORM(OPENVG)
@@ -172,6 +176,11 @@ public:
operator VGRect() const;
#endif
+#if PLATFORM(CAIRO)
+ FloatRect(const cairo_rectangle_t&);
+ operator cairo_rectangle_t() const;
+#endif
+
private:
FloatPoint m_location;
FloatSize m_size;
diff --git a/WebCore/platform/graphics/cairo/FloatRectCairo.cpp b/WebCore/platform/graphics/cairo/FloatRectCairo.cpp
new file mode 100644
index 0000000..9f86f74
--- /dev/null
+++ b/WebCore/platform/graphics/cairo/FloatRectCairo.cpp
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2010 Igalia S.L.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "FloatRect.h"
+
+#include <cairo.h>
+
+namespace WebCore {
+
+FloatRect::FloatRect(const cairo_rectangle_t& r)
+ : m_location(r.x, r.y)
+ , m_size(r.width, r.height)
+{
+}
+
+FloatRect::operator cairo_rectangle_t() const
+{
+ cairo_rectangle_t r = { x(), y(), width(), height() };
+ return r;
+}
+
+} // namespace WebCore
diff --git a/WebKit/gtk/webkit/webkitwebview.cpp b/WebKit/gtk/webkit/webkitwebview.cpp
index 446b3b7..00ac926 100644
--- a/WebKit/gtk/webkit/webkitwebview.cpp
+++ b/WebKit/gtk/webkit/webkitwebview.cpp
@@ -483,27 +483,56 @@ static void webkit_web_view_set_property(GObject* object, guint prop_id, const G
}
}
-#ifdef GTK_API_VERSION_2
-static bool shouldCoalesce(GdkRectangle rect, GdkRectangle* rects, int count)
+static bool shouldCoalesce(const IntRect& rect, const Vector<IntRect>& rects)
{
- const int cRectThreshold = 10;
+ const unsigned int cRectThreshold = 10;
const float cWastedSpaceThreshold = 0.75f;
- bool useUnionedRect = (count <= 1) || (count > cRectThreshold);
- if (!useUnionedRect) {
- // Attempt to guess whether or not we should use the unioned rect or the individual rects.
- // We do this by computing the percentage of "wasted space" in the union. If that wasted space
- // is too large, then we will do individual rect painting instead.
- float unionPixels = (rect.width * rect.height);
- float singlePixels = 0;
- for (int i = 0; i < count; ++i)
- singlePixels += rects[i].width * rects[i].height;
- float wastedSpace = 1 - (singlePixels / unionPixels);
- if (wastedSpace <= cWastedSpaceThreshold)
- useUnionedRect = true;
- }
+ bool useUnionedRect = (rects.size() <= 1) || (rects.size() > cRectThreshold);
+ if (useUnionedRect)
+ return true;
+ // Attempt to guess whether or not we should use the unioned rect or the individual rects.
+ // We do this by computing the percentage of "wasted space" in the union. If that wasted space
+ // is too large, then we will do individual rect painting instead.
+ float unionPixels = (rect.width() * rect.height());
+ float singlePixels = 0;
+ for (size_t i = 0; i < rects.size(); ++i)
+ singlePixels += rects[i].width() * rects[i].height();
+ float wastedSpace = 1 - (singlePixels / unionPixels);
+ if (wastedSpace <= cWastedSpaceThreshold)
+ useUnionedRect = true;
return useUnionedRect;
}
+static void paintWebView(Frame* frame, gboolean transparent, GraphicsContext& context, const IntRect& clipRect, const Vector<IntRect>& rects)
+{
+ bool coalesce = true;
+
+ if (rects.size() > 0)
+ coalesce = shouldCoalesce(clipRect, rects);
+
+ if (coalesce) {
+ context.clip(clipRect);
+ if (transparent)
+ context.clearRect(clipRect);
+ frame->view()->paint(&context, clipRect);
+ } else {
+ for (size_t i = 0; i < rects.size(); i++) {
+ IntRect rect = rects[i];
+ context.save();
+ context.clip(rect);
+ if (transparent)
+ context.clearRect(rect);
+ frame->view()->paint(&context, rect);
+ context.restore();
+ }
+ }
+
+ context.save();
+ context.clip(clipRect);
+ frame->page()->inspectorController()->drawNodeHighlight(context);
+ context.restore();
+}
+#ifdef GTK_API_VERSION_2
static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose* event)
{
WebKitWebView* webView = WEBKIT_WEB_VIEW(widget);
@@ -521,32 +550,11 @@ static gboolean webkit_web_view_expose_event(GtkWidget* widget, GdkEventExpose*
int rectCount;
GOwnPtr<GdkRectangle> rects;
gdk_region_get_rectangles(event->region, &rects.outPtr(), &rectCount);
+ Vector<IntRect> paintRects;
+ for (int i = 0; i < rectCount; i++)
+ paintRects.append(IntRect(rects.get()[i]));
- // Avoid recursing into the render tree excessively
- bool coalesce = shouldCoalesce(event->area, rects.get(), rectCount);
-
- if (coalesce) {
- IntRect rect = event->area;
- ctx.clip(rect);
- if (priv->transparent)
- ctx.clearRect(rect);
- frame->view()->paint(&ctx, rect);
- } else {
- for (int i = 0; i < rectCount; i++) {
- IntRect rect = rects.get()[i];
- ctx.save();
- ctx.clip(rect);
- if (priv->transparent)
- ctx.clearRect(rect);
- frame->view()->paint(&ctx, rect);
- ctx.restore();
- }
- }
-
- ctx.save();
- ctx.clip(static_cast<IntRect>(event->area));
- frame->page()->inspectorController()->drawNodeHighlight(ctx);
- ctx.restore();
+ paintWebView(frame, priv->transparent, ctx, static_cast<IntRect>(event->area), paintRects);
}
return FALSE;
@@ -565,14 +573,18 @@ static gboolean webkit_web_view_draw(GtkWidget* widget, cairo_t* cr)
if (frame->contentRenderer() && frame->view()) {
GraphicsContext ctx(cr);
IntRect rect = clipRect;
+ cairo_rectangle_list_t* rectList = cairo_copy_clip_rectangle_list(cr);
frame->view()->updateLayoutAndStyleIfNeededRecursive();
- if (priv->transparent)
- ctx.clearRect(rect);
- frame->view()->paint(&ctx, rect);
- ctx.save();
- frame->page()->inspectorController()->drawNodeHighlight(ctx);
- ctx.restore();
+
+ Vector<IntRect> rects;
+ if (!rectList->status && rectList->num_rectangles > 0) {
+ for (int i = 0; i < rectList->num_rectangles; i++)
+ rects.append(enclosingIntRect(FloatRect(rectList->rectangles[i])));
+ }
+ paintWebView(frame, priv->transparent, ctx, rect, rects);
+
+ cairo_rectangle_list_destroy(rectList);
}
return FALSE;
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list