jnordberg / gif.js

JavaScript GIF encoding library
http://jnordberg.github.io/gif.js/
MIT License
4.74k stars 668 forks source link

[suggestion] desynchronized canvas and offscreencanvas in a worker (processing w/o 'client-side') #108

Open ghost opened 5 years ago

ghost commented 5 years ago

Hi, There are few new stuff (to this date) that might be helpful,

  1. the desynchronized-canvas is a new feature added https://www.chromestatus.com/features/6360971442388992 and explained mostly just by example below and https://blog.chromium.org/2019/05/chrome-75-beta-low-latency-canvas.html. It should be fine (ignored) if not supported, and if it does have support it should accelerate in some way your existing canvas operation. ```js let context_type = '2d'; // Or 'webgl' canvas.getContext(context_type, {desynchronized: true}); ```
  2. the offscreencanvas API got a lot more documentations, and few example pages created by Chrome. Essentially you can do most of the processing in a canvas that exist on a worker alone, without (or limiting) the need of placing a canvas on the 'main-thread', it was designed mostly for webGL but you can use it in 2d as well. https://ebidel.github.io/demos/offscreencanvas.html try view-source:https://ebidel.github.io/demos/offscreencanvas.html https://wiki.whatwg.org/wiki/OffscreenCanvas (just for reference) https://html.spec.whatwg.org/multipage/canvas.html#the-offscreencanvas-interface (and when done you can still postMessage back the typed-array's context (Transferable) as you do now).