Use Region instead of IntRect in PageClient and WebPageProxy setViewNeedsDisplay...
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2016 08:51:59 +0000 (08:51 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Mar 2016 08:51:59 +0000 (08:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155747

Reviewed by Darin Adler.

Source/WebCore:

Add helper function to make cairo region out of a WebCore::Region.

* platform/graphics/cairo/CairoUtilities.cpp:
(WebCore::toCairoRegion):
* platform/graphics/cairo/CairoUtilities.h:

Source/WebKit2:

This way instead of calling setViewNeedsDisplay() for every
rectangle in the damage area, we can build a region and call
setViewNeedsDisplay() once. GTK+ has API to queue a redraw for a
given region, so we also avoid scheduling multiple redraws in GTK+
port.

* UIProcess/API/gtk/PageClientImpl.cpp:
(WebKit::PageClientImpl::setViewNeedsDisplay): Convert the Region
into a cairo_region_t and use gtk_widget_queue_draw_region()
instyead of gtk_widget_queue_draw_area().
* UIProcess/API/gtk/PageClientImpl.h:
* UIProcess/DrawingAreaProxyImpl.cpp:
(WebKit::DrawingAreaProxyImpl::incorporateUpdate): Build a Region
with the damage rectangles and call
WebPageProxy::setViewNeedsDisplay() once.
* UIProcess/PageClient.h:
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::setViewNeedsDisplay):
* UIProcess/WebPageProxy.h:
* UIProcess/efl/WebView.cpp:
(WebKit::WebView::setViewNeedsDisplay):
* UIProcess/efl/WebView.h:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::setViewNeedsDisplay):
* UIProcess/mac/PageClientImpl.h:
* UIProcess/mac/PageClientImpl.mm:
(WebKit::PageClientImpl::setViewNeedsDisplay):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198580 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/cairo/CairoUtilities.cpp
Source/WebCore/platform/graphics/cairo/CairoUtilities.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
Source/WebKit2/UIProcess/API/gtk/PageClientImpl.h
Source/WebKit2/UIProcess/DrawingAreaProxyImpl.cpp
Source/WebKit2/UIProcess/PageClient.h
Source/WebKit2/UIProcess/WebPageProxy.cpp
Source/WebKit2/UIProcess/WebPageProxy.h
Source/WebKit2/UIProcess/efl/WebView.cpp
Source/WebKit2/UIProcess/efl/WebView.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.h
Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm
Source/WebKit2/UIProcess/mac/PageClientImpl.h
Source/WebKit2/UIProcess/mac/PageClientImpl.mm

index c58bdac..ef35f51 100644 (file)
@@ -1,3 +1,16 @@
+2016-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Use Region instead of IntRect in PageClient and WebPageProxy setViewNeedsDisplay method
+        https://bugs.webkit.org/show_bug.cgi?id=155747
+
+        Reviewed by Darin Adler.
+
+        Add helper function to make cairo region out of a WebCore::Region.
+
+        * platform/graphics/cairo/CairoUtilities.cpp:
+        (WebCore::toCairoRegion):
+        * platform/graphics/cairo/CairoUtilities.h:
+
 2016-03-22  Tim Horton  <timothy_horton@apple.com>
 
         Invoking a link preview on a complex link (e.g. an image) results in an empty TextIndicator
index be97010..65e3162 100644 (file)
@@ -37,6 +37,7 @@
 #include "Path.h"
 #include "PlatformPathCairo.h"
 #include "RefPtrCairo.h"
+#include "Region.h"
 #include <wtf/Assertions.h>
 #include <wtf/Vector.h>
 
@@ -308,6 +309,16 @@ void cairoSurfaceGetDeviceScale(cairo_surface_t* surface, double& xScale, double
 #endif
 }
 
+RefPtr<cairo_region_t> toCairoRegion(const Region& region)
+{
+    RefPtr<cairo_region_t> cairoRegion = adoptRef(cairo_region_create());
+    for (const auto& rect : region.rects()) {
+        cairo_rectangle_int_t cairoRect = rect;
+        cairo_region_union_rectangle(cairoRegion.get(), &cairoRect);
+    }
+    return cairoRegion;
+}
+
 } // namespace WebCore
 
 #endif // USE(CAIRO)
index adab0e5..0ebe3c4 100644 (file)
@@ -44,6 +44,7 @@ class FloatPoint;
 class IntSize;
 class IntRect;
 class Path;
+class Region;
 
 void copyContextProperties(cairo_t* srcCr, cairo_t* dstCr);
 void setSourceRGBAFromColor(cairo_t*, const Color&);
@@ -65,6 +66,8 @@ void flipImageSurfaceVertically(cairo_surface_t*);
 void cairoSurfaceSetDeviceScale(cairo_surface_t*, double xScale, double yScale);
 void cairoSurfaceGetDeviceScale(cairo_surface_t*, double& xScale, double& yScale);
 
+RefPtr<cairo_region_t> toCairoRegion(const Region&);
+
 } // namespace WebCore
 
 #endif // USE(CAIRO)
index cbaf29a..f2c9f4e 100644 (file)
@@ -1,3 +1,39 @@
+2016-03-23  Carlos Garcia Campos  <cgarcia@igalia.com>
+
+        Use Region instead of IntRect in PageClient and WebPageProxy setViewNeedsDisplay method
+        https://bugs.webkit.org/show_bug.cgi?id=155747
+
+        Reviewed by Darin Adler.
+
+        This way instead of calling setViewNeedsDisplay() for every
+        rectangle in the damage area, we can build a region and call
+        setViewNeedsDisplay() once. GTK+ has API to queue a redraw for a
+        given region, so we also avoid scheduling multiple redraws in GTK+
+        port.
+
+        * UIProcess/API/gtk/PageClientImpl.cpp:
+        (WebKit::PageClientImpl::setViewNeedsDisplay): Convert the Region
+        into a cairo_region_t and use gtk_widget_queue_draw_region()
+        instyead of gtk_widget_queue_draw_area().
+        * UIProcess/API/gtk/PageClientImpl.h:
+        * UIProcess/DrawingAreaProxyImpl.cpp:
+        (WebKit::DrawingAreaProxyImpl::incorporateUpdate): Build a Region
+        with the damage rectangles and call
+        WebPageProxy::setViewNeedsDisplay() once.
+        * UIProcess/PageClient.h:
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::setViewNeedsDisplay):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/efl/WebView.cpp:
+        (WebKit::WebView::setViewNeedsDisplay):
+        * UIProcess/efl/WebView.h:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::setViewNeedsDisplay):
+        * UIProcess/mac/PageClientImpl.h:
+        * UIProcess/mac/PageClientImpl.mm:
+        (WebKit::PageClientImpl::setViewNeedsDisplay):
+
 2016-03-22  Tim Horton  <timothy_horton@apple.com>
 
         Invoking a link preview on a complex link (e.g. an image) results in an empty TextIndicator
index df4158b..0799d43 100644 (file)
 #include "WebPageProxy.h"
 #include "WebPopupMenuProxyGtk.h"
 #include "WebProcessPool.h"
+#include <WebCore/CairoUtilities.h>
 #include <WebCore/Cursor.h>
 #include <WebCore/EventNames.h>
 #include <WebCore/GtkUtilities.h>
+#include <WebCore/RefPtrCairo.h>
 #include <wtf/text/CString.h>
 #include <wtf/text/WTFString.h>
 
@@ -62,9 +64,10 @@ std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
     return std::make_unique<DrawingAreaProxyImpl>(*webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(m_viewWidget)));
 }
 
-void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
+void PageClientImpl::setViewNeedsDisplay(const WebCore::Region& region)
 {
-    gtk_widget_queue_draw_area(m_viewWidget, rect.x(), rect.y(), rect.width(), rect.height());
+    RefPtr<cairo_region_t> damageRegion = toCairoRegion(region);
+    gtk_widget_queue_draw_region(m_viewWidget, damageRegion.get());
 }
 
 void PageClientImpl::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool)
index 7337fa9..70732be 100644 (file)
@@ -55,7 +55,7 @@ public:
 private:
     // PageClient
     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
-    void setViewNeedsDisplay(const WebCore::IntRect&) override;
+    void setViewNeedsDisplay(const WebCore::Region&) override;
     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
     WebCore::IntSize viewSize() override;
     bool isViewWindowActive() override;
index ee2ac0d..cd523bc 100644 (file)
@@ -228,11 +228,14 @@ void DrawingAreaProxyImpl::incorporateUpdate(const UpdateInfo& updateInfo)
         m_backingStore = std::make_unique<BackingStore>(updateInfo.viewSize, updateInfo.deviceScaleFactor, m_webPageProxy);
 
     m_backingStore->incorporateUpdate(updateInfo);
+
+    Region damageRegion;
     if (updateInfo.scrollRect.isEmpty()) {
         for (const auto& rect : updateInfo.updateRects)
-            m_webPageProxy.setViewNeedsDisplay(rect);
+            damageRegion.unite(rect);
     } else
-        m_webPageProxy.setViewNeedsDisplay(IntRect(IntPoint(), m_webPageProxy.viewSize()));
+        damageRegion = IntRect(IntPoint(), m_webPageProxy.viewSize());
+    m_webPageProxy.setViewNeedsDisplay(damageRegion);
 }
 
 void DrawingAreaProxyImpl::backingStoreStateDidChange(RespondImmediatelyOrNot respondImmediatelyOrNot)
index 17f7968..87b83ab 100644 (file)
@@ -93,8 +93,8 @@ public:
     // Create a new drawing area proxy for the given page.
     virtual std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() = 0;
 
-    // Tell the view to invalidate the given rect. The rect is in view coordinates.
-    virtual void setViewNeedsDisplay(const WebCore::IntRect&) = 0;
+    // Tell the view to invalidate the given region. The region is in view coordinates.
+    virtual void setViewNeedsDisplay(const WebCore::Region&) = 0;
 
     // Tell the view to scroll to the given position, and whether this was a programmatic scroll.
     virtual void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) = 0;
index 771b363..e8c0762 100644 (file)
@@ -1319,9 +1319,9 @@ void WebPageProxy::viewWillEndLiveResize()
     m_process->send(Messages::WebPage::ViewWillEndLiveResize(), m_pageID);
 }
 
-void WebPageProxy::setViewNeedsDisplay(const IntRect& rect)
+void WebPageProxy::setViewNeedsDisplay(const Region& region)
 {
-    m_pageClient.setViewNeedsDisplay(rect);
+    m_pageClient.setViewNeedsDisplay(region);
 }
 
 void WebPageProxy::requestScroll(const FloatPoint& scrollPosition, const IntPoint& scrollOrigin, bool isProgrammaticScroll)
index 5230061..414ebed 100644 (file)
@@ -413,7 +413,7 @@ public:
     void clearSelection();
     void restoreSelectionInFocusedEditableElement();
 
-    void setViewNeedsDisplay(const WebCore::IntRect&);
+    void setViewNeedsDisplay(const WebCore::Region&);
     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll);
     
     void setDelegatesScrolling(bool delegatesScrolling) { m_delegatesScrolling = delegatesScrolling; }
index bd2ef13..e06af30 100644 (file)
@@ -409,9 +409,10 @@ std::unique_ptr<DrawingAreaProxy> WebView::createDrawingAreaProxy()
     return std::make_unique<CoordinatedDrawingAreaProxy>(*m_page);
 }
 
-void WebView::setViewNeedsDisplay(const WebCore::IntRect& area)
+void WebView::setViewNeedsDisplay(const WebCore::Region& region)
 {
-    m_client.viewNeedsDisplay(this, area);
+    for (const auto& rect : region.rects())
+        m_client.viewNeedsDisplay(this, rect);
 }
 
 void WebView::requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool)
index b59e7e8..a2801a7 100644 (file)
@@ -154,7 +154,7 @@ private:
     // PageClient
     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
 
-    void setViewNeedsDisplay(const WebCore::IntRect&) override;
+    void setViewNeedsDisplay(const WebCore::Region&) override;
 
     void requestScroll(const WebCore::FloatPoint&, const WebCore::IntPoint&, bool) override;
 
index 78ce265..d1d2521 100644 (file)
@@ -50,7 +50,7 @@ public:
 private:
     // PageClient
     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
-    void setViewNeedsDisplay(const WebCore::IntRect&) override;
+    void setViewNeedsDisplay(const WebCore::Region&) override;
     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
     WebCore::IntSize viewSize() override;
     bool isViewWindowActive() override;
index c3e9995..52b3104 100644 (file)
@@ -123,7 +123,7 @@ std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
     return [m_contentView _createDrawingAreaProxy];
 }
 
-void PageClientImpl::setViewNeedsDisplay(const IntRect& rect)
+void PageClientImpl::setViewNeedsDisplay(const Region&)
 {
     ASSERT_NOT_REACHED();
 }
index 8502e61..08df581 100644 (file)
@@ -62,7 +62,7 @@ public:
 private:
     // PageClient
     std::unique_ptr<DrawingAreaProxy> createDrawingAreaProxy() override;
-    void setViewNeedsDisplay(const WebCore::IntRect&) override;
+    void setViewNeedsDisplay(const WebCore::Region&) override;
     void requestScroll(const WebCore::FloatPoint& scrollPosition, const WebCore::IntPoint& scrollOrigin, bool isProgrammaticScroll) override;
 
     WebCore::IntSize viewSize() override;
index 6889a6f..d9b1a3b 100644 (file)
@@ -115,7 +115,7 @@ std::unique_ptr<DrawingAreaProxy> PageClientImpl::createDrawingAreaProxy()
     return m_impl->createDrawingAreaProxy();
 }
 
-void PageClientImpl::setViewNeedsDisplay(const WebCore::IntRect& rect)
+void PageClientImpl::setViewNeedsDisplay(const WebCore::Region&)
 {
     ASSERT_NOT_REACHED();
 }