pub(crate) trait CanvasContext {
type ID;
// Required methods
fn context_id(&self) -> Self::ID;
fn canvas(
&self,
) -> Option<HTMLCanvasElementOrOffscreenCanvas<DomTypeHolder>>;
fn resize(&self);
fn reset_bitmap(&self);
fn get_image_data(&self) -> Option<Snapshot>;
fn mark_as_dirty(&self);
fn image_key(&self) -> Option<ImageKey>;
// Provided methods
fn origin_is_clean(&self) -> bool { ... }
fn size(&self) -> Size2D<u32> { ... }
fn update_rendering(&self, _canvas_epoch: Epoch) -> bool { ... }
fn onscreen(&self) -> bool { ... }
}
Required Associated Types§
Required Methods§
fn context_id(&self) -> Self::ID
fn canvas(&self) -> Option<HTMLCanvasElementOrOffscreenCanvas<DomTypeHolder>>
fn resize(&self)
fn reset_bitmap(&self)
Sourcefn get_image_data(&self) -> Option<Snapshot>
fn get_image_data(&self) -> Option<Snapshot>
Returns none if area of canvas is zero.
In case of other errors it returns cleared snapshot
fn mark_as_dirty(&self)
Provided Methods§
fn origin_is_clean(&self) -> bool
fn size(&self) -> Size2D<u32>
Sourcefn update_rendering(&self, _canvas_epoch: Epoch) -> bool
fn update_rendering(&self, _canvas_epoch: Epoch) -> bool
Request that the CanvasContext
update the rendering of its contents,
returning true
if new image was produced.
Note: If this function returns true
, script will wait for all images to be updated
before updating the rendering again. Be sure that image updates are always sent
even in the failure case by sending transparent black image or return false
in the
case of failure.