Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define ImageBitmapSource in terms of CanvasImageSource #893

Closed
annevk opened this issue Mar 17, 2016 · 8 comments
Closed

Define ImageBitmapSource in terms of CanvasImageSource #893

annevk opened this issue Mar 17, 2016 · 8 comments
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: canvas

Comments

@annevk
Copy link
Member

annevk commented Mar 17, 2016

It seems CanvasImageSource is a subset.

Anyone happen to know why CanvasImageSource does not take Blob or ImageData?

@annevk annevk added clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: canvas labels Mar 17, 2016
@domenic
Copy link
Member

domenic commented May 19, 2016

@junov do you know why CanvasImageSource does not include Blob or ImageData?

@junov
Copy link
Member

junov commented May 20, 2016

I don't know, but my guess would be lack demand and the existence of reasonable workarounds. Also the workarounds perform well. I kinda like the idea of not allowing drawImage(Blob,...). It encourages devs to go through ImageBitmap, which has better performance characteristics due to it's asynchronous mode of operation. On browsers that do not have ImageBitmap, you would use an intermediate <img>, which still has the advantage of providing internal caching that stores the resource in a form that is pre-decoded, pre-multiplied by alpha, pre-colorcorrected, and possibly cached on the GPU.

Similarly, if you want to do the equivalent of drawImage(ImageData, ...) with today's APIs, you would have to use an intermediate canvas, use putImageData on it, and do a canvas-to-canvas draw. The intermediate canvas allows the image data to be stored in a native internal format (e.g. pre-multiplied by alpha, possibly on the GPU), which will yield higher performance for repetitive draws of the same image data.

@annevk
Copy link
Member Author

annevk commented May 20, 2016

Yeah that makes sense. ImageBitmapSource is only used by an asynchronous API so it can have asynchronous sources.

I take it you have no objections to defining it in terms of CanvasImageSource plus these two types?

@junov
Copy link
Member

junov commented May 20, 2016

Sure, that makes sense.

@annevk
Copy link
Member Author

annevk commented May 20, 2016

Hmm I just noticed CanvasImageSource also takes CanvasRenderingContext2D. Is that a leftover bug from when the constructor of that interface was removed?

@junov
Copy link
Member

junov commented May 20, 2016

Oh yeah, that should not be there.

@annevk
Copy link
Member Author

annevk commented May 20, 2016

I'll try to clean that up.

@junov
Copy link
Member

junov commented May 20, 2016

Thanks.

annevk added a commit that referenced this issue May 20, 2016
Also remove erroneous mentions of CanvasRenderingContext2D as a
CanvasImageSource type. Further cleanup of #790.

See 740634d and
43ad288 for prior commits in this area.

Fixes #893.
annevk added a commit that referenced this issue May 20, 2016
Also remove erroneous mentions of CanvasRenderingContext2D as a
CanvasImageSource type. Further cleanup of #790.

See 740634d and
43ad288 for prior commits in this area.

Fixes #893.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer good first issue Ideal for someone new to a WHATWG standard or software project topic: canvas
Development

No branches or pull requests

3 participants