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

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>10799</bug_id>
          
          <creation_ts>2010-09-29 03:57:12 +0000</creation_ts>
          <short_desc>drawImage/pattern filters underspecified</short_desc>
          <delta_ts>2010-12-08 00:19:11 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>HTML WG</product>
          <component>pre-LC1 HTML Canvas 2D Context (editor: Ian Hickson)</component>
          <version>unspecified</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></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladimir Vukicevic (Mozilla)">vladimir</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>excors</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-html-admin</cc>
    
    <cc>public-html-wg-issue-tracking</cc>
          
          <qa_contact name="HTML WG Bugzilla archive list">public-html-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>39857</commentid>
    <comment_count>0</comment_count>
      <attachid>915</attachid>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-09-29 03:57:12 +0000</bug_when>
    <thetext>Created attachment 915
testcase

This came from mozilla bugzilla bug https://bugzilla.mozilla.org/show_bug.cgi?id=600390.  The canvas spec doesn&apos;t really say anything about filters, and especially how they apply to drawImage/patterns.

The attached testcase demonstrates the problem -- it doesn&apos;t render identically on any of the canvas-implementing browsers (firefox, opera, chrome, ie9 -- don&apos;t have safari handy to test).

The two sets in the testcase are using a canvas as a source and using an image, both with the same contents; usually there&apos;s no difference between the two.  The large squares are, from left to right:

1) straight drawImage 0,0,60,60 -&gt; 0,0,300,300
2) stairstepped drawImage, doing 2 draws per horizontal band
3) stairstepped fill() using a no-repeat pattern source
4) 300x300 rectangle fill, but with source offset by 150,150
5) same as #4, but rotated as well to examine antialiasing effects

I -think- Firefox renders it the most &quot;correctly&quot;, even though it&apos;s almost never what you want; but mathematically it&apos;s correct, and it causes the least change when under transforms -- with no repeat, the area outside of the source&apos;s defined bounds is transparent black; so at edge pixels when scaling up, when you sample acros that boundary, you get half of the transition between transparent black and the edge color.

IE9 renders &quot;what I want&quot;, but it&apos;s also the most difficult to specify precisely.  Opera also gets close, except all their paths are offset by 5 pixels for some reason.

Chrome is quite bad here, because I think it&apos;s trying to be smart about using the source rect for drawImage as a standalone image in its own right -- this causes problems if you, for example, try to draw a scaled-up image piecemeal, as you&apos;ll get seams.  It also uses pad/clamp behaviour for a pattern that&apos;s specified as no-repeat -- however, the spec doesn&apos;t actually define no-repeat, so their interpretation is as good as any other.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40103</commentid>
    <comment_count>1</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2010-09-30 08:53:28 +0000</bug_when>
    <thetext>Philip`: If you have any advice here, before I take a look properly, experience suggests it would be very helpful.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40325</commentid>
    <comment_count>2</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-09-30 22:32:57 +0000</bug_when>
    <thetext>Hmm, I&apos;m assuming this is something that can resolved without having to change the spec&apos;s basic assumption that it&apos;s drawing to an infinitely precise buffer (which is why it doesn&apos;t talk about antialiasing or rounding etc). Even with infinitely precise output, it matters how you compute each point from the low-resolution input image, so it seems a useful thing to specify.

It sounds like perhaps the desired behaviour is for the computation of the sampled colour at (possibly non-integer) position (x, y) on a w*h bitmap image to be something like (in random pseudocode since it helps me think about this):

  filtered(x, y, clamped) =
    if not (0.0 &lt;= x &lt;= w and 0.0 &lt;= y &lt;= h)
      return transparent black
    else
      compute filtered value at (x, y) (using standard bilinear interpolation or nearest neighbour or whatever), such that whenever the filtering algorithm chooses to sample the image at pixel index (ix, iy):

        if clamped: clamp ix to (0 .. w-1), iy to (0 .. h-1);
	else: wrap ix to (0 .. w-1), iy to (0 .. h-1);

        then return the pixel at the new (ix, iy).

  drawimage(x, y) =
    if not (sx &lt;= x &lt;= sx+sw and sy &lt;= y &lt;= sy+sh)
      return transparent black
    else
      filtered(x, y, true)

  pattern_norepeat(x, y) = filtered(x, y, false)

  pattern_repeatx(x, y) = filtered(x % w, y, false)

  pattern_repeaty(x, y) = filtered(x, y % h, false)

  pattern_repeat(x, y) = filtered(x % w, y % h, false)

The relevant points are:

* drawImage clamps to the edge pixels when doing bilinear interpolation, instead of wrapping or padding with transparency outside the image.

* All patterns wrap instead of clamping (even no-repeat).

* drawImage clamps to the edge pixels of the whole image, not to the edges of the source rectangle segment of the image.

* Areas of patterns outside the image region are transparent black.

It looks like this is what IE9 does. Opera mostly does this, except patterns get clamped in their non-repeating directions (e.g. repeat-x wraps on left/right edges and clamps on top/bottom; no-repeat clamps on both) (and there&apos;s the weird offset thing). Firefox interpolates with transparency around the edges (instead of wrapping/clamping), except in repeating patterns where it wraps. Chrome is nothing like this and all its scaling looks terrible if you go above 16x.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40577</commentid>
    <comment_count>3</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2010-10-04 23:00:23 +0000</bug_when>
    <thetext>Could I convince one of you to write this up formally? I&apos;d be happy to massage such text into RFC2119ese, but I&apos;m concerned that I don&apos;t really understand this issue well enough to write text that makes sense. (In particular, I can&apos;t see any difference between what any of the four browsers on my platform are doing with the attached test case  they all look identical to me.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40588</commentid>
    <comment_count>4</comment_count>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-10-04 23:37:33 +0000</bug_when>
    <thetext>Hm, I&apos;m not sure what Philip wrote up is correct/possible to implement efficiently.. but I&apos;d have to study it in more detail.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40590</commentid>
    <comment_count>5</comment_count>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-10-04 23:42:42 +0000</bug_when>
    <thetext>I&apos;m surprised you don&apos;t see a difference.. for reference, here&apos;s Firefox and Chrome:

  http://i.imgur.com/QLrAo.png

And Opera and IE9:

  http://i.imgur.com/ugLYQ.png

Some differences:
- fuzzy edge vs sharp edge in the fourth/fifth large squares
- note fuzzy inner edges vs sharp inner edges in the first three squares, esp on chrome where bits of the second square are incorrectly sharp (due to the stairstep rendering)
- blue fill on fourth and fifth in chrome instead of white (transparent) fill
- no linear filtering in third, fourth and fifth in chrome, compared to first and most of the second</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40598</commentid>
    <comment_count>6</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-10-05 00:03:28 +0000</bug_when>
    <thetext>My intention was that this was basically EXTEND_REPEAT for patterns and EXTEND_PAD for images (given that you set the extend mode for a gfxPattern representing the whole image, not just the source rectangle), so I think I&apos;m missing where the problem would be (unless it&apos;s that those EXTEND modes can&apos;t be implemented efficiently).

Hmm, I just realised this EXTEND_PAD thing interact with the change hidden in http://html5.org/tools/web-apps-tracker?from=5372&amp;to=5373 (&quot;Pixels of the source rectangle that are not entirely within the source image must be treated as transparent black&quot;) - not sure if that&apos;s going to be an issue.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40601</commentid>
    <comment_count>7</comment_count>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-10-05 00:31:19 +0000</bug_when>
    <thetext>Nope, PAD and REPEAT are totally fine hw-wise, but I&apos;m not sure how that works with the &quot;no-repeat&quot; canvas pattern mode.. you still have the question of what to do at the edges, no?  According to what you put above, for no-repeat it would just use x y without clamping, thus giving transparent black.. which would give you the fuzzy edges on scaled-up drawImage.  (This is essentially what firefox does currently.)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40780</commentid>
    <comment_count>8</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-10-07 15:14:41 +0000</bug_when>
    <thetext>What I (I think) put above for no-repeat patterns was that it wouldn&apos;t clamp, but would instead wrap. It&apos;s equivalent to repeat patterns for the purposes of filtering, it&apos;s just cut off sharply to transparent outside the area of the first repetition. (This is what IE9 seemed to do.)

If no-repeat were to have some other filtering behaviour, then repeat-x and repeat-y ought to have that behaviour on their non-repeating edges (for consistency). They should still have the wrap behaviour on their repeating edges, which means different behaviour in different directions on one pattern. Opera does that but it looks like the Cairo API assumes a single mode for both directions - would that be a problem?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>41276</commentid>
    <comment_count>9</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2010-10-14 01:00:06 +0000</bug_when>
    <thetext>Would it be possible to have the proposal written in terms that the spec uses? Pseudo-code isn&apos;t really workable since we&apos;d have to define the syntax of the pseudo-code to make it formal, which is why I don&apos;t really think we can use comment 2 as written (even with RFC2119 massaging).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>42013</commentid>
    <comment_count>10</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2010-11-03 08:26:13 +0000</bug_when>
    <thetext>Philip, I&apos;m reassigning this to you on the basis that I have no idea what I&apos;m doing here and you do. Please feel free to reassign it to me if you can&apos;t do anything here. I likely would just close it NEEDSINFO though.

If you are able to do something, all I need is text that says the technical bits, so that I can then massage it into spec prose.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43148</commentid>
    <comment_count>11</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-12-07 17:25:18 +0000</bug_when>
    <thetext>(Sorry, been a bit distracted and didn&apos;t get around to this earlier.)

I think this should do what I suggested (though if this text is adopted I make no guarantees that I will not file further bugs saying it&apos;s all wrong):

For drawImage:

Remove the text &quot;Pixels of the source rectangle that are not entirely within the source image must be treated as transparent black.&quot;

Somewhere in this section, add the text:

&quot;&quot;&quot;
If the original image data is a bitmap image, the value painted at a point in the destination rectangle is computed by filtering the original image data. The user agent may use any filtering algorithm (for example bilinear interpolation or nearest-neighbor). When the filtering algorithm requires a pixel value from outside the original image data, it must instead use the value from the nearest edge pixel. (That is, the filter uses &apos;clamp-to-edge&apos; behavior.)
&quot;&quot;&quot;

For createPattern, add the text:

&quot;&quot;&quot;
If the original image data is a bitmap image, the value painted at a point in the area of the repetitions is computed by filtering the original image data. The user agent may use any filtering algorithm (for example bilinear interpolation or nearest-neighbor). When the filtering algorithm requires a pixel value from outside the original image data, it must instead use the value from wrapping the pixel&apos;s coordinates to the original image&apos;s dimensions. (That is, the filter uses &apos;repeat&apos; behavior, regardless of the value of &lt;var&gt;repetition&lt;/var&gt;.)
&quot;&quot;&quot;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43150</commentid>
    <comment_count>12</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2010-12-07 20:56:56 +0000</bug_when>
    <thetext>EDITOR&apos;S RESPONSE: This is an Editor&apos;s Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Accepted
Change Description: see diff given below
Rationale: Seems reasonable.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43151</commentid>
    <comment_count>13</comment_count>
    <who name="">contributor</who>
    <bug_when>2010-12-07 20:57:05 +0000</bug_when>
    <thetext>Checked in as WHATWG revision r5708.
Check-in comment: &lt;canvas&gt; drawImage() and pattern filtering issue
http://html5.org/tools/web-apps-tracker?from=5707&amp;to=5708</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43156</commentid>
    <comment_count>14</comment_count>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-12-07 21:16:59 +0000</bug_when>
    <thetext>(In reply to comment #11)
&gt; For createPattern, add the text:
&gt; 
&gt; &quot;&quot;&quot;
&gt; If the original image data is a bitmap image, the value painted at a point in
&gt; the area of the repetitions is computed by filtering the original image data.
&gt; The user agent may use any filtering algorithm (for example bilinear
&gt; interpolation or nearest-neighbor). When the filtering algorithm requires a
&gt; pixel value from outside the original image data, it must instead use the value
&gt; from wrapping the pixel&apos;s coordinates to the original image&apos;s dimensions. (That
&gt; is, the filter uses &apos;repeat&apos; behavior, regardless of the value of
&gt; &lt;var&gt;repetition&lt;/var&gt;.)

Hm, isn&apos;t this inconsistent?  For example, if the pattern uses no-repeat, and is used to fill a rectangle larger than the pattern image size, this seems to say that the no-repeat setting is ignored.  That seems odd and unexpected.

The clamp-to-edge behavior is fine for drawImage, but for patterns, I think the only thing that mathematically makes sense is for the area outside of the source pixels to be treated as transparent black for no-repeat.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43160</commentid>
    <comment_count>15</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-12-07 22:16:11 +0000</bug_when>
    <thetext>By &quot;in the area of the repetitions&quot;, I meant the area where the previous paragraph says the pattern will be painted (anchored in a certain point and repeated in certain directions). Outside that area, the pattern won&apos;t be painted at all - it&apos;s only inside the area that the wrapping filter is used. So no-repeat patterns and drawImage will both draw a single copy of the image with sharp edges when scaled up, but will filter differently when computing the pixels just inside the edges.

An alternative way to see it is that the pattern is always based on an infinitely-repeating-in-both-directions image, with filtering applied to that, and then the repeat-x/y/no-repeat setting is cropping the resulting image in one or both directions. This is similar to how drawImage takes the entire input image, filters that, and then crops to the specified source rectangle, rather than cropping before filtering. So I think it&apos;s logically justifiable in that way.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43162</commentid>
    <comment_count>16</comment_count>
    <who name="Vladimir Vukicevic (Mozilla)">vladimir</who>
    <bug_when>2010-12-07 22:24:07 +0000</bug_when>
    <thetext>Maybe, though I don&apos;t think the language makes that clear.  (If I was implementing canvas reading just the spec, I&apos;d be scratching my head at that language.)

However, you&apos;re basically describing an algorithm that&apos;s more than just sampling from a pattern with repeat; I&apos;m not sure there&apos;s any need to do that, given that canvas already provides the primitives needed to get the effect you describe (draw with a repeating pattern, clip to a rectangle).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>43168</commentid>
    <comment_count>17</comment_count>
    <who name="Philip Taylor">excors</who>
    <bug_when>2010-12-08 00:19:11 +0000</bug_when>
    <thetext>The language isn&apos;t ideal, but I&apos;m not sure how better to describe it in prose - if you can suggest changes that would make it clearer, that would be great.

Canvas provides the primitives to emulate any filtering effect (take the source image and surround it with transparency or repeats or clamped edges, then clip to a rectangle) so I&apos;m not sure what you mean with that.

The advantage I see in the repeat-in-both-directions pattern filtering is just that it seems the easiest way for browsers to converge (without being a clearly crazy behaviour to converge on). IE appears to implement it already; Opera is not far off. Firefox doesn&apos;t support repeat-x or repeat-y yet so it will have to change in any case, and per comment 8 it looks like the Cairo API doesn&apos;t like different extend modes in different directions, so it will be simpler to use consistent modes. Is this incorrect?</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>915</attachid>
            <date>2010-09-29 03:57:12 +0000</date>
            <delta_ts>2010-09-29 03:57:12 +0000</delta_ts>
            <desc>testcase</desc>
            <filename>t2.html</filename>
            <type>text/html</type>
            <size>2967</size>
            <attacher name="Vladimir Vukicevic (Mozilla)">vladimir</attacher>
            
              <data enc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