Conversation
| } | ||
|
|
||
| class DevicePixelContentBoxBinding implements Binding, Disposable { | ||
| class DevicePixelContentBoxBinding<OffscreenAllowed extends boolean> implements Binding<OffscreenAllowed>, Disposable { |
There was a problem hiding this comment.
Let's try to decouple OffscreenCanvas size control logic from the DevicePixelContentBoxBinding.
In fact, only HTMLCanvasElement cares about its content box and occupied space on the screen to sync the bitmap size with content box. OffscreenCanvas bitmap could have any size, for example two times larger or smaller than the target canvas' bitmap.
I think it's more flexible to sync OffscreenCanvas bitmap size with HTMLCanvasElement bitmap size in a separate binding. It should be something like a CHAIN of bindings: HTMLCanvasElement bitmap size is bound with his own content box by DevicePixelContentBoxBinding, and OffscreenCanvas bitmap size is bound with target HTMLCanvasElement bitmap size by another binding, what we are going to implement in this PR)
So the size change propagation chain should look like: CanvasElement's device-pixel-content-box ==> CanvasElement's bitmap size ==> OffscreenCanvas bitmap size. And here enters the flexibility: we could subscribe MULTIPLE OffscreenCanvases to the same CanvasElement, we could introduce some size transform in-between Element and Offscreen (to perform super- or subsampling) and so on.
I'll come back later with some suggestions on naming and module structure.
Add offscreen canvas support.
allowOffscreenCanvasoption, which tells the library to try use OffscreenCanvas if available.