[whatwg] I believe source rectangles for HTML5 Canvas drawImage are specified incorrectly
cabanier at gmail.com
Mon Dec 17 13:23:41 PST 2012
On Mon, Dec 17, 2012 at 11:49 AM, Justin Novosad <junov at chromium.org> wrote:
> Isn't this the same as what Ian suggested: copy it to a temporary canvas
>> and use the temporary canvas scales.
>> It seems that you can optimize that case too.
> Hmm... It would one of those optimizations that only works if you perform
> the secret handshake just right.
> If I understand correctly, the hypothetical optimization would work
> something like this: When a 2d canvas context is created, do not allocate a
> backing store immediately. If the first draw operation into the canvas is a
> drawImage from an image element and covers the entire canvas, then use a
> shallow copy of the bitmap as the backing store. If anything else is drawn
> into the canvas, then a proper backing store should be allocated and used.
> I guess it could work... but I would fear that this behavior would be
> perceived as idiosyncratic.
I don't disagree. However, there probably are other occasions in canvas
today where a common idiom gets optimized.
In addition, developers have proven that they are quite comfortable with
idiosyncrasies. For instance, many sites force their CSS animations to run
in 3D because it tricks the browser into hardware acceleration.
More information about the whatwg