Trait CanvasContext

Source
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§

Source

fn context_id(&self) -> Self::ID

Source

fn canvas(&self) -> Option<HTMLCanvasElementOrOffscreenCanvas<DomTypeHolder>>

Source

fn resize(&self)

Source

fn reset_bitmap(&self)

Source

fn get_image_data(&self) -> Option<Snapshot>

Returns none if area of canvas is zero.

In case of other errors it returns cleared snapshot

Source

fn mark_as_dirty(&self)

Source

fn image_key(&self) -> Option<ImageKey>

The WebRender ImageKey of this CanvasContext if any.

Provided Methods§

Source

fn origin_is_clean(&self) -> bool

Source

fn size(&self) -> Size2D<u32>

Source

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.

Source

fn onscreen(&self) -> bool

Implementors§