<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>43416</bug_id>
          
          <creation_ts>2010-08-03 06:09:48 -0700</creation_ts>
          <short_desc>[Qt] Implement GraphicsContext::clipOut more efficiently</short_desc>
          <delta_ts>2010-08-18 22:20:51 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Platform</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>Performance, Qt, QtTriaged</keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Simon Hausmann">hausmann</reporter>
          <assigned_to name="Simon Hausmann">hausmann</assigned_to>
          <cc>ariya.hidayat</cc>
    
    <cc>benjamin</cc>
    
    <cc>commit-queue</cc>
    
    <cc>kling</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>259413</commentid>
    <comment_count>0</comment_count>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2010-08-03 06:09:48 -0700</bug_when>
    <thetext>The current implementation of the function uses QPainter::clipRect().boundingRect(), which is very slow and with complex content it can make text selection very slow or even cause crashes in Qt due to complex regions.

http://bugreports.qt.nokia.com/browse/QTBUG-12618 in Qt tracks adding support for a faster method in Qt that would allow to quickly retrieve the clip bounding rect in device coordinates.

Once that function is implemented, then we can use it in GraphicsContexQt and transform the return value into logical coordinates.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>263178</commentid>
    <comment_count>1</comment_count>
      <attachid>64096</attachid>
    <who name="Simon Hausmann">hausmann</who>
    <bug_when>2010-08-11 04:50:33 -0700</bug_when>
    <thetext>Created attachment 64096
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>263184</commentid>
    <comment_count>2</comment_count>
      <attachid>64096</attachid>
    <who name="Ariya Hidayat">ariya.hidayat</who>
    <bug_when>2010-08-11 04:55:57 -0700</bug_when>
    <thetext>Comment on attachment 64096
Patch

&gt; diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
&gt; index efc27d6e5a204eaeba7775d0a099627bc29adaaf..6b790604d12511157df404aeaad32e0b434add46 100644
&gt; --- a/WebCore/ChangeLog
&gt; +++ b/WebCore/ChangeLog
&gt; @@ -1,3 +1,21 @@
&gt; +2010-08-11  Simon Hausmann  &lt;simon.hausmann@nokia.com&gt;
&gt; +
&gt; +        Reviewed by NOBODY (OOPS!).
&gt; +
&gt; +        [Qt] Implement GraphicsContext::clipOut more efficiently
&gt; +        https://bugs.webkit.org/show_bug.cgi?id=43416
&gt; +
&gt; +        The current implementation of clipOut uses QPainter::clipRegion().boundingRect(),
&gt; +        which is a very slow function because it converts the entire clip region - which
&gt; +        may potentially contain a complex path - into a set of QRegion rectangles, just
&gt; +        to throw away all that information and use the bounding rect.
&gt; +
&gt; +        QTBUG-12618 implements a faster function in QPainter: QPainter::clipBoundingRect().
&gt; +
&gt; +        * platform/graphics/qt/GraphicsContextQt.cpp:
&gt; +        (WebCore::GraphicsContext::clipOut): Use QPainter::clipBoundingRect() with Qt &gt;= 4.8.
&gt; +        (WebCore::GraphicsContext::clipOutEllipseInRect): Ditto.
&gt; +
&gt;  2010-08-11  Adam Barth  &lt;abarth@webkit.org&gt;
&gt;  
&gt;          Reviewed by Eric Seidel.
&gt; diff --git a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
&gt; index d4a145f9f1e875c4bf012fd24fba24d5c1771257..43d0f7eb66e69240312d6e6a7c4a902619a6125a 100644
&gt; --- a/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
&gt; +++ b/WebCore/platform/graphics/qt/GraphicsContextQt.cpp
&gt; @@ -1121,7 +1121,11 @@ void GraphicsContext::clipOut(const Path&amp; path)
&gt;      QPainterPath newClip;
&gt;      newClip.setFillRule(Qt::OddEvenFill);
&gt;      if (p-&gt;hasClipping()) {
&gt; +#if QT_VERSION &gt;= QT_VERSION_CHECK(4, 8, 0)
&gt; +        newClip.addRect(p-&gt;clipBoundingRect());
&gt; +#else
&gt;          newClip.addRect(p-&gt;clipRegion().boundingRect());
&gt; +#endif
&gt;          newClip.addPath(clippedOut);
&gt;          p-&gt;setClipPath(newClip, Qt::IntersectClip);
&gt;      } else {
&gt; @@ -1191,7 +1195,11 @@ void GraphicsContext::clipOut(const IntRect&amp; rect)
&gt;      QPainterPath newClip;
&gt;      newClip.setFillRule(Qt::OddEvenFill);
&gt;      if (p-&gt;hasClipping()) {
&gt; +#if QT_VERSION &gt;= QT_VERSION_CHECK(4, 8, 0)
&gt; +        newClip.addRect(p-&gt;clipBoundingRect());
&gt; +#else
&gt;          newClip.addRect(p-&gt;clipRegion().boundingRect());
&gt; +#endif
&gt;          newClip.addRect(QRect(rect));
&gt;          p-&gt;setClipPath(newClip, Qt::IntersectClip);
&gt;      } else {
&gt; @@ -1213,7 +1221,11 @@ void GraphicsContext::clipOutEllipseInRect(const IntRect&amp; rect)
&gt;      QPainterPath newClip;
&gt;      newClip.setFillRule(Qt::OddEvenFill);
&gt;      if (p-&gt;hasClipping()) {
&gt; +#if QT_VERSION &gt;= QT_VERSION_CHECK(4, 8, 0)
&gt; +        newClip.addRect(p-&gt;clipBoundingRect());
&gt; +#else
&gt;          newClip.addRect(p-&gt;clipRegion().boundingRect());
&gt; +#endif
&gt;          newClip.addEllipse(QRect(rect));
&gt;          p-&gt;setClipPath(newClip, Qt::IntersectClip);
&gt;      } else {</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266527</commentid>
    <comment_count>3</comment_count>
      <attachid>64096</attachid>
    <who name="Andreas Kling">kling</who>
    <bug_when>2010-08-18 20:36:50 -0700</bug_when>
    <thetext>Comment on attachment 64096
Patch

Great stuff :) Setting cq+ since Simon is traveling this week.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266544</commentid>
    <comment_count>4</comment_count>
      <attachid>64096</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-08-18 22:20:47 -0700</bug_when>
    <thetext>Comment on attachment 64096
Patch

Clearing flags on attachment: 64096

Committed r65650: &lt;http://trac.webkit.org/changeset/65650&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266545</commentid>
    <comment_count>5</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2010-08-18 22:20:51 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>64096</attachid>
            <date>2010-08-11 04:50:33 -0700</date>
            <delta_ts>2010-08-18 22:20:46 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-43416-20100811135031.patch</filename>
            <type>text/plain</type>
            <size>2846</size>
            <attacher name="Simon Hausmann">hausmann</attacher>
            
              <data encoding="base64">ZGlmZiAtLWdpdCBhL1dlYkNvcmUvQ2hhbmdlTG9nIGIvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXgg
ZWZjMjdkNmU1YTIwNGVhZWJhNzc3NWQwYTA5OTYyN2JjMjlhZGFhZi4uNmI3OTA2MDRkMTI1MTEx
NTdkZjQwNGFlYWFkMzJlMGI0MzRhZGQ0NiAxMDA2NDQKLS0tIGEvV2ViQ29yZS9DaGFuZ2VMb2cK
KysrIGIvV2ViQ29yZS9DaGFuZ2VMb2cKQEAgLTEsMyArMSwyMSBAQAorMjAxMC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