w3c / FileAPI

File API
https://w3c.github.io/FileAPI/
Other
104 stars 44 forks source link

URL.createObjectURL should also accept ImageBitmap #107

Closed Zhang-Junzhi closed 6 years ago

Zhang-Junzhi commented 6 years ago

Sometimes, an ImageBitmap has already been created for a Blob for some other uses, before using URL.createObjectURL, so there's no need to again use the Blob to create an object URL. If ImageBitmap were allowed for URL.createObjectURL, code would be more efficient:

createImageBitmap(someBlob).then(imageBitmap =>
{
    // Some other use of the image bitmap
    ...

    // Now create the URL
    const imageURL = URL.createObjectURL(imageBitmap);
});
Zhang-Junzhi commented 6 years ago

Here's the definition of ImageBitmap:

An ImageBitmap object represents a bitmap image that can be painted to a canvas without undue latency.

The exact judgement of what is undue latency of this is left up to the implementer, but in general if making use of the bitmap requires network I/O, or even local disk I/O, then the latency is probably undue; whereas if it only requires a blocking read from a GPU or system RAM, the latency is probably acceptable.

annevk commented 6 years ago

No, we don't want to extend this method. Instead <img> should get srcOjbect or some such.

Zhang-Junzhi commented 6 years ago

Thanks.

That's good to have either.

mkruisselbrink commented 6 years ago

Agreed with @annevk. This does not sound like something we would want to support.

Zhang-Junzhi commented 6 years ago

Is there any current plan to add srcObject or some such to <img>? I can't seem to find it by searching issues.

If not, I feel like filing one.

annevk commented 6 years ago

Please do, I started some cleanup work in https://github.com/whatwg/html/pull/3132 to prepare for it, but I haven't really made the time to start working on it again. Too many things to do.