Skip to content

Commit

Permalink
Change {get,put,create}ImageData() arguments to long
Browse files Browse the repository at this point in the history
getImageData(), putImageData(), and createImageData() double arguments had undefined behavior and implementation incompatibilities. Reverting them back to long makes it well defined.

Tests: web-platform-tests/wpt#5180.

Fixes #2433.
  • Loading branch information
fserb authored and annevk committed Mar 22, 2017
1 parent 1308ec0 commit 362c931
Showing 1 changed file with 5 additions and 24 deletions.
29 changes: 5 additions & 24 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -60164,11 +60164,11 @@ interface <dfn>CanvasDrawImage</dfn> {
[NoInterfaceObject, Exposed=(Window,Worker)]
interface <dfn>CanvasImageData</dfn> {
// <span>pixel manipulation</span>
<span>ImageData</span> <span data-x="dom-context-2d-createImageData">createImageData</span>(double sw, double sh);
<span>ImageData</span> <span data-x="dom-context-2d-createImageData">createImageData</span>(long sw, long sh);
<span>ImageData</span> <span data-x="dom-context-2d-createImageData">createImageData</span>(<span>ImageData</span> imagedata);
<span>ImageData</span> <span data-x="dom-context-2d-getImageData">getImageData</span>(double sx, double sy, double sw, double sh);
void <span data-x="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, double dx, double dy);
void <span data-x="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, double dx, double dy, double dirtyX, double dirtyY, double dirtyWidth, double dirtyHeight);
<span>ImageData</span> <span data-x="dom-context-2d-getImageData">getImageData</span>(long sx, long sy, long sw, long sh);
void <span data-x="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, long dx, long dy);
void <span data-x="dom-context-2d-putImageData">putImageData</span>(<span>ImageData</span> imagedata, long dx, long dy, long dirtyX, long dirtyY, long dirtyWidth, long dirtyHeight);
};

enum <dfn>CanvasLineCap</dfn> { "butt", "round", "square" };
Expand Down Expand Up @@ -64452,26 +64452,6 @@ v6DVT (also check for '- -' bits in the part above) -->

</ol>

<p>The handling of pixel rounding when the specified coordinates are not integers is not defined
by this specification, except that the following must result in no visible changes to the
rendering:</p>

<pre>context.putImageData(context.getImageData(x, y, w, h), p, q);</pre>

<p>...for any value of <var>x</var>, <var>y</var>, <var>w</var>, and
<var>h</var> and where <var>p</var> is the smaller of <var>x</var>
and the sum of <var>x</var> and <var>w</var>, and <var>q</var> is
the smaller of <var>y</var> and the sum of <var>y</var> and <var>h</var>; and except that the following two calls:</p>

<pre>context.createImageData(w, h);
context.getImageData(0, 0, w, h);</pre>

<p>...must return <code>ImageData</code> objects with the same dimensions as each other, for any
value of <var>w</var> and <var>h</var>. In other words, while user agents may
round the arguments of these methods, any rounding performed must be performed consistently for
all of the methods described in this section. (The constructors only work with integer
values.)</p>

<p class="note">Due to the lossy nature of converting to and from premultiplied alpha color
values, pixels that have just been set using <code
data-x="dom-context-2d-putImageData">putImageData()</code> might be returned to an equivalent
Expand Down Expand Up @@ -120003,6 +119983,7 @@ INSERT INTERFACES HERE
fantasai,
Felix Sanz,
Felix Sasaki,
Fernando Altomare Serboncini,
Francesco Schwarz,
Francis Brosnan Blazquez,
Franck 'Shift' Qu&eacute;lain,
Expand Down

1 comment on commit 362c931

@annevk
Copy link
Member

@annevk annevk commented on 362c931 Mar 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rolivo no feature was removed here.

Please sign in to comment.