<?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>41396</bug_id>
          
          <creation_ts>2010-06-30 02:08:52 -0700</creation_ts>
          <short_desc>Pattern is rasterized</short_desc>
          <delta_ts>2010-08-22 03:35:28 -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>SVG</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>PC</rep_platform>
          <op_sys>OS X 10.6</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Dusan Maliarik">dusan.maliarik</reporter>
          <assigned_to name="Nikolas Zimmermann">zimmermann</assigned_to>
          <cc>abarth</cc>
    
    <cc>eric</cc>
    
    <cc>jamesr</cc>
    
    <cc>kbr</cc>
    
    <cc>krit</cc>
    
    <cc>pkchan+bugzilla=webkit</cc>
    
    <cc>rspierer</cc>
    
    <cc>s3lance</cc>
    
    <cc>simon.fraser</cc>
    
    <cc>webkit.review.bot</cc>
    
    <cc>zimmermann</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>244694</commentid>
    <comment_count>0</comment_count>
    <who name="Dusan Maliarik">dusan.maliarik</who>
    <bug_when>2010-06-30 02:08:52 -0700</bug_when>
    <thetext>After scaling an element with a pattern fill, the pattern is pixelized. This effectively cripples any usage of patterns. It becomes even bigger issue when one wants to use different coordinate space. Let&apos;s say our SVG is 500px for 500px, and we use meter units, which means the whole graphic is scaled up, with viewBox around 0 0 50 50. Sample SVG demonstrating this issue is attached, please compare with other SVG implementations (mozilla&apos;s)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>244695</commentid>
    <comment_count>1</comment_count>
      <attachid>60101</attachid>
    <who name="Dusan Maliarik">dusan.maliarik</who>
    <bug_when>2010-06-30 02:09:59 -0700</bug_when>
    <thetext>Created attachment 60101
pattern scale test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>244699</commentid>
    <comment_count>2</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-06-30 02:31:20 -0700</bug_when>
    <thetext>I&apos;m not sure if this is expected behavior or not.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>244703</commentid>
    <comment_count>3</comment_count>
    <who name="Dusan Maliarik">dusan.maliarik</who>
    <bug_when>2010-06-30 02:49:35 -0700</bug_when>
    <thetext>There is no mention of rasterization in SVG spec. so I believe this is some premature optimization (evil) that kicks in, and destroys developer&apos;s day ;) Otherwise it works like a charm, much faster than mozilla&apos;s impl.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>244704</commentid>
    <comment_count>4</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2010-06-30 02:53:06 -0700</bug_when>
    <thetext>The Pattern and Gradient resources need to invalidate, on scaling or resizing the window. This doesn&apos;t happen at the moment, that&apos;s why you see the rasterization. We have some more bug reports about this. And this is also a duplication of another bug report (don&apos;t know the bug number atm).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>244705</commentid>
    <comment_count>5</comment_count>
    <who name="Dusan Maliarik">dusan.maliarik</who>
    <bug_when>2010-06-30 02:56:11 -0700</bug_when>
    <thetext>I searched for similar bug reports but couldn&apos;t find any. Anyway, is there any workaround we can use until it&apos;s fixed?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>249476</commentid>
    <comment_count>6</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-07-09 23:24:47 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; The Pattern and Gradient resources need to invalidate, on scaling or resizing the window. This doesn&apos;t happen at the moment, that&apos;s why you see the rasterization. We have some more bug reports about this. And this is also a duplication of another bug report (don&apos;t know the bug number atm).

No, this has nothing to do with invalidation.
A pattern of a specific size is created and applied to an object, which gets scaled - this alone creates the artifacts.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266651</commentid>
    <comment_count>7</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-19 04:55:43 -0700</bug_when>
    <thetext>*** Bug 38704 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266654</commentid>
    <comment_count>8</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-19 04:55:50 -0700</bug_when>
    <thetext>*** Bug 41603 has been marked as a duplicate of this bug. ***</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266656</commentid>
    <comment_count>9</comment_count>
      <attachid>64828</attachid>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-19 04:59:26 -0700</bug_when>
    <thetext>Created attachment 64828
Patch

Patch is large, as it contains several new tests and pixel results.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266675</commentid>
    <comment_count>10</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-19 05:33:21 -0700</bug_when>
    <thetext>Forgot to mention: integrated the testcase from Dusan, and the ones from the other bug reports, that I marked as duplicate in the patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266676</commentid>
    <comment_count>11</comment_count>
      <attachid>64828</attachid>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2010-08-19 05:36:13 -0700</bug_when>
    <thetext>Comment on attachment 64828
Patch

r=me With some changes discussed on IRC</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266687</commentid>
    <comment_count>12</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-19 06:01:41 -0700</bug_when>
    <thetext>Landed in r65665.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266697</commentid>
    <comment_count>13</comment_count>
    <who name="WebKit Review Bot">webkit.review.bot</who>
    <bug_when>2010-08-19 06:22:57 -0700</bug_when>
    <thetext>http://trac.webkit.org/changeset/65665 might have broken SnowLeopard Intel Release (Tests)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266702</commentid>
    <comment_count>14</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2010-08-19 06:52:02 -0700</bug_when>
    <thetext>(In reply to comment #13)
&gt; http://trac.webkit.org/changeset/65665 might have broken SnowLeopard Intel Release (Tests)

Not caused by this patch.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266722</commentid>
    <comment_count>15</comment_count>
      <attachid>64828</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-19 07:36:01 -0700</bug_when>
    <thetext>Comment on attachment 64828
Patch

WebCore/rendering/RenderSVGResourcePattern.cpp:191
 +          return FloatRect(attributes.x().valueAsPercentage() * objectBoundingBox.width() + objectBoundingBox.x(),
Why this change?

WebCore/rendering/RenderSVGResourcePattern.cpp:202
 +  AffineTransform RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
I&apos;ve been told to avoid returning AffineTransforms as they&apos;re very expensive to copy.

return PassOwnPtr&lt;ImageBuffer&gt;();:
Can&apos;t you just reuturn 0 here?

// Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
I&apos;m not sure I understand what you&apos;re doing here?

WebCore/rendering/RenderSVGResourcePattern.cpp:263
 +      if (!tileImageTransform.isIdentity())
Does concatCTM assert it&apos;s not identity?  I&apos;m surprised we have to check outisde concatCTM.

WebCore/rendering/SVGImageBufferTools.cpp:32
 +  AffineTransform SVGImageBufferTools::screenCoordinateSystemForRenderer(const RenderObject* renderer)
Yeah, these should probably be changed to return the AffineTransform as a reference variable.  At least according to smfr last time I talked with him about it.

WebCore/rendering/SVGImageBufferTools.cpp:37
 +      ASSERT(current);
This assert is redundant.  No need to even put renderer in a local variable, the argument is already a local variable, I would just use it as the loop variable.

WebCore/rendering/SVGImageBufferTools.cpp:81
 +      return IntSize(static_cast&lt;int&gt;(lroundf(size.width())), static_cast&lt;int&gt;(lroundf(size.height())));
Really?  We don&apos;t already have a method like this on IntSize? Why wouldn&apos;t this go on IntSize?

WebCore/rendering/SVGRenderSupport.h:83
 +      static const RenderObject* findTextRootObject(const RenderObject* start);
We should just remove the RenderObject* one.

I don&apos;t think I really fully understand the patch, but in general it looked fine.  I&apos;m surprised krit had 0 comments. :p  I guess he made them all over IRC.  Thanks for doing this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266723</commentid>
    <comment_count>16</comment_count>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2010-08-19 07:37:15 -0700</bug_when>
    <thetext>Just an FYI CC to other folks affected by SVG rendering tree changes.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>266736</commentid>
    <comment_count>17</comment_count>
    <who name="Dirk Schulze">krit</who>
    <bug_when>2010-08-19 07:52:20 -0700</bug_when>
    <thetext>(In reply to comment #15)
&gt; (From update of attachment 64828 [details])
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:191
&gt;  +          return FloatRect(attributes.x().valueAsPercentage() * objectBoundingBox.width() + objectBoundingBox.x(),
&gt; Why this change?
Because it was wrong not to do it.

&gt; 
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:202
&gt;  +  AffineTransform RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
&gt; I&apos;ve been told to avoid returning AffineTransforms as they&apos;re very expensive to copy.
Not AffineTransform, maybe TransformationMatrix with it&apos;s 16 floats.

&gt; 
&gt; return PassOwnPtr&lt;ImageBuffer&gt;();:
&gt; Can&apos;t you just reuturn 0 here?
&gt; 
&gt; // Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
&gt; I&apos;m not sure I understand what you&apos;re doing here?
Because we may have a width or height with decimal places, but don&apos;t want artefacts on the tile.

&gt; 
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:263
&gt;  +      if (!tileImageTransform.isIdentity())
&gt; Does concatCTM assert it&apos;s not identity?  I&apos;m surprised we have to check outisde concatCTM.
tileImageTransform is the AffineTransform for the tile. Why shouldn&apos;t we check if it is identity? If it is, we don&apos;t need to transform the ctm.

&gt; 
&gt; WebCore/rendering/SVGImageBufferTools.cpp:81
&gt;  +      return IntSize(static_cast&lt;int&gt;(lroundf(size.width())), static_cast&lt;int&gt;(lroundf(size.height())));
&gt; Really?  We don&apos;t already have a method like this on IntSize? Why wouldn&apos;t this go on IntSize?
Just IntRect has it.

&gt; 
&gt; WebCore/rendering/SVGRenderSupport.h:83
&gt;  +      static const RenderObject* findTextRootObject(const RenderObject* start);
&gt; We should just remove the RenderObject* one.
No, the first is searching for the text root, the second one for the outermost svg renderer.

&gt; 
&gt; I don&apos;t think I really fully understand the patch, but in general it looked fine.  I&apos;m surprised krit had 0 comments. :p  I guess he made them all over IRC.  Thanks for doing this.

Like I wrote on my r=me comment, I gave comments on IRC. But thanks for rechecking the patch. Four eyes are better than two.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>267673</commentid>
    <comment_count>18</comment_count>
    <who name="Nikolas Zimmermann">zimmermann</who>
    <bug_when>2010-08-22 03:35:28 -0700</bug_when>
    <thetext>(In reply to comment #15)
&gt; (From update of attachment 64828 [details])
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:191
&gt;  +          return FloatRect(attributes.x().valueAsPercentage() * objectBoundingBox.width() + objectBoundingBox.x(),
&gt; Why this change?
Because it was not correct before, we hacked around it with an additional transformation before.
I just fixed it.
 
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:202
&gt;  +  AffineTransform RenderSVGResourcePattern::buildTileImageTransform(RenderObject* renderer,
&gt; I&apos;ve been told to avoid returning AffineTransforms as they&apos;re very expensive to copy.
Going to fix this in my next patch.

&gt; 
&gt; return PassOwnPtr&lt;ImageBuffer&gt;();:
&gt; Can&apos;t you just reuturn 0 here?
#ifdef LOOSE_PASS_OWN_PTR
        PassOwnPtr(PtrType ptr) : m_ptr(ptr) { }
        PassOwnPtr&amp; operator=(PtrType);
...

// Remove this once we make all WebKit code compatible with stricter rules about PassOwnPtr.
#define LOOSE_PASS_OWN_PTR

My understanding is that the implicit 0 -&gt; PassOwnPtr conversion is deprecated.

&gt; 
&gt; // Compensate rounding effects, as the absolute target rect is using floating-point numbers and the image buffer size is integer.
&gt; I&apos;m not sure I understand what you&apos;re doing here?
I&apos;m fixing scaling artefacts. ImageBuffers are using integer based sizes, and the content may use floating-point numbers, so we scale so it fits inside the integer based box.

&gt; 
&gt; WebCore/rendering/RenderSVGResourcePattern.cpp:263
&gt;  +      if (!tileImageTransform.isIdentity())
&gt; Does concatCTM assert it&apos;s not identity?  I&apos;m surprised we have to check outisde concatCTM.
It doesn&apos;t :( We should fix this ASAP, and remove lots of these checks from SVG code.

&gt; WebCore/rendering/SVGImageBufferTools.cpp:32
&gt;  +  AffineTransform SVGImageBufferTools::screenCoordinateSystemForRenderer(const RenderObject* renderer)
&gt; Yeah, these should probably be changed to return the AffineTransform as a reference variable.  At least according to smfr last time I talked with him about it.
Fixing in my next patch, thanks for the hint.

&gt; 
&gt; WebCore/rendering/SVGImageBufferTools.cpp:37
&gt;  +      ASSERT(current);
&gt; This assert is redundant.  No need to even put renderer in a local variable, the argument is already a local variable, I would just use it as the loop variable.
Yes, fixing in my next patch.

&gt; 
&gt; WebCore/rendering/SVGImageBufferTools.cpp:81
&gt;  +      return IntSize(static_cast&lt;int&gt;(lroundf(size.width())), static_cast&lt;int&gt;(lroundf(size.height())));
&gt; Really?  We don&apos;t already have a method like this on IntSize? Why wouldn&apos;t this go on IntSize?
Because I specifically need lroundf here, no ceil or floor solution.

&gt; 
&gt; WebCore/rendering/SVGRenderSupport.h:83
&gt;  +      static const RenderObject* findTextRootObject(const RenderObject* start);
&gt; We should just remove the RenderObject* one.
As Dirk already said, there&apos;s findTextRootObject and findTreeRootObject, yes looks confusing, that&apos;s why there&apos;s a FIXME above, that it should be moved away :-)

&gt; 
&gt; I don&apos;t think I really fully understand the patch, but in general it looked fine.  I&apos;m surprised krit had 0 comments. :p  I guess he made them all over IRC.  Thanks for doing this.
Yeah, we generally talk a lot on IRC before I submit the acutal patch, and after submitting. Usually Dirk has comments :-)</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="0"
              isprivate="0"
          >
            <attachid>60101</attachid>
            <date>2010-06-30 02:09:59 -0700</date>
            <delta_ts>2010-08-19 04:59:26 -0700</delta_ts>
            <desc>pattern scale test case</desc>
            <filename>webkitfail.svg</filename>
            <type>image/svg+xml</type>
            <size>436</size>
            <attacher name="Dusan Maliarik">dusan.maliarik</attacher>
            
              <data encoding="base64">PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciCiAgICB3aWR0aD0iNDAwcHgi
IGhlaWdodD0iNDAwcHgiPgogICAgCiAgICA8ZGVmcz4KICAgICAgICA8cGF0dGVybiBpZD0iZmFp
bCIKICAgICAgICAgICAgeD0iMCIgeT0iMCIKICAgICAgICAgICAgd2lkdGg9IjMwIiBoZWlnaHQ9
IjMwIiAKICAgICAgICAgICAgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+CgogICAgICAg
ICAgICA8Y2lyY2xlIGN4PSIxNSIgY3k9IjE1IiByPSIxNSIgZmlsbD0iI2YwMCIgLz4KICAgICAg
ICA8L3BhdHRlcm4+CiAgICA8L2RlZnM+CgogICAgPHJlY3QgeD0iLTQwIiB5PSItNDAiIHdpZHRo
PSI4MCIgaGVpZ2h0PSI4MCIgZmlsbD0idXJsKCNmYWlsKSIKICAgICAgICB0cmFuc2Zvcm09InRy
YW5zbGF0ZSgyMDAsMjAwKSBzY2FsZSg0KSIgLz4KPC9zdmc+Cg==
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>64828</attachid>
            <date>2010-08-19 04:59:26 -0700</date>
            <delta_ts>2010-08-19 07:36:01 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>PatternPatch.diff</filename>
            <type>text/plain</type>
            <size>0</size>
            <attacher name="Nikolas Zimmermann">zimmermann</attacher>
            
              <data encoding="base64"></data>
<flag name="review"
          id="53468"
          type_id="1"
          status="+"
          setter="krit"
    />
          </attachment>
      

    </bug>

</bugzilla>