Struct canvas::canvas_data::CanvasData

source ·
pub struct CanvasData<'a> {
    backend: Box<dyn Backend>,
    drawtarget: Box<dyn GenericDrawTarget>,
    path_state: Option<PathState>,
    state: CanvasPaintState<'a>,
    saved_states: Vec<CanvasPaintState<'a>>,
    compositor_api: CrossProcessCompositorApi,
    image_key: Option<ImageKey>,
    old_image_key: Option<ImageKey>,
    very_old_image_key: Option<ImageKey>,
    font_context: Arc<FontContext>,
}

Fields§

§backend: Box<dyn Backend>§drawtarget: Box<dyn GenericDrawTarget>§path_state: Option<PathState>§state: CanvasPaintState<'a>§saved_states: Vec<CanvasPaintState<'a>>§compositor_api: CrossProcessCompositorApi§image_key: Option<ImageKey>§old_image_key: Option<ImageKey>

An old webrender image key that can be deleted when the next epoch ends.

§very_old_image_key: Option<ImageKey>

An old webrender image key that can be deleted when the current epoch ends.

§font_context: Arc<FontContext>

Implementations§

source§

impl<'a> CanvasData<'a>

source

pub fn new( size: Size2D<u64>, compositor_api: CrossProcessCompositorApi, antialias: AntialiasMode, font_context: Arc<FontContext>, ) -> CanvasData<'a>

source

pub fn draw_image( &mut self, image_data: &[u8], image_size: Size2D<f64>, dest_rect: Rect<f64>, source_rect: Rect<f64>, smoothing_enabled: bool, premultiply: bool, )

source

pub fn save_context_state(&mut self)

source

pub fn restore_context_state(&mut self)

source

pub fn fill_text_with_size( &mut self, text: String, x: f64, y: f64, max_width: Option<f64>, is_rtl: bool, size: f64, )

source

pub fn fill_text( &mut self, text: String, x: f64, y: f64, max_width: Option<f64>, is_rtl: bool, )

source

pub fn measure_text(&mut self, text: String) -> TextMetrics

source

fn build_unshaped_text_runs<'b>( &self, text: &'b str, font_group: &mut FontGroup, ) -> Vec<UnshapedTextRun<'b>>

source

fn find_anchor_point_for_line_of_text( &self, x: f32, y: f32, metrics: &FontMetrics, width: f32, is_rtl: bool, ) -> Point2D<f32>

Find the anchor_point for the given parameters of a line of text. See https://html.spec.whatwg.org/multipage/#text-preparation-algorithm.

source

pub fn fill_rect(&mut self, rect: &Rect<f32>)

source

pub fn clear_rect(&mut self, rect: &Rect<f32>)

source

pub fn stroke_rect(&mut self, rect: &Rect<f32>)

source

pub fn begin_path(&mut self)

source

pub fn close_path(&mut self)

source

fn ensure_path(&mut self)

source

fn path(&self) -> &Path

source

pub fn fill(&mut self)

source

pub fn stroke(&mut self)

source

pub fn clip(&mut self)

source

pub fn is_point_in_path( &mut self, x: f64, y: f64, _fill_rule: FillRule, chan: IpcSender<bool>, )

source

pub fn move_to(&mut self, point: &Point2D<f32>)

source

pub fn line_to(&mut self, point: &Point2D<f32>)

source

fn path_builder(&mut self) -> PathBuilderRef<'_>

source

pub fn rect(&mut self, rect: &Rect<f32>)

source

pub fn quadratic_curve_to(&mut self, cp: &Point2D<f32>, endpoint: &Point2D<f32>)

source

pub fn bezier_curve_to( &mut self, cp1: &Point2D<f32>, cp2: &Point2D<f32>, endpoint: &Point2D<f32>, )

source

pub fn arc( &mut self, center: &Point2D<f32>, radius: f32, start_angle: f32, end_angle: f32, ccw: bool, )

source

pub fn arc_to(&mut self, cp1: &Point2D<f32>, cp2: &Point2D<f32>, radius: f32)

source

pub fn ellipse( &mut self, center: &Point2D<f32>, radius_x: f32, radius_y: f32, rotation_angle: f32, start_angle: f32, end_angle: f32, ccw: bool, )

source

pub fn set_fill_style(&mut self, style: FillOrStrokeStyle)

source

pub fn set_stroke_style(&mut self, style: FillOrStrokeStyle)

source

pub fn set_line_width(&mut self, width: f32)

source

pub fn set_line_cap(&mut self, cap: LineCapStyle)

source

pub fn set_line_join(&mut self, join: LineJoinStyle)

source

pub fn set_miter_limit(&mut self, limit: f32)

source

pub fn get_transform(&self) -> Transform2D<f32>

source

pub fn set_transform(&mut self, transform: &Transform2D<f32>)

source

pub fn set_global_alpha(&mut self, alpha: f32)

source

pub fn set_global_composition(&mut self, op: CompositionOrBlending)

source

pub fn recreate(&mut self, size: Option<Size2D<u64>>)

source

pub fn send_pixels(&mut self, chan: IpcSender<IpcSharedMemory>)

source

pub fn send_data(&mut self, chan: IpcSender<CanvasImageData>)

source

pub fn put_image_data(&mut self, imagedata: Vec<u8>, rect: Rect<u64>)

source

pub fn set_shadow_offset_x(&mut self, value: f64)

source

pub fn set_shadow_offset_y(&mut self, value: f64)

source

pub fn set_shadow_blur(&mut self, value: f64)

source

pub fn set_shadow_color(&mut self, value: AbsoluteColor)

source

pub fn set_font(&mut self, font_style: FontStyleStruct)

source

pub fn set_text_align(&mut self, text_align: TextAlign)

source

pub fn set_text_baseline(&mut self, text_baseline: TextBaseline)

source

fn need_to_draw_shadow(&self) -> bool

source

fn create_draw_target_for_shadow( &self, source_rect: &Rect<f32>, ) -> Box<dyn GenericDrawTarget>

source

fn draw_with_shadow<F>(&self, rect: &Rect<f32>, draw_shadow_source: F)
where F: FnOnce(&mut dyn GenericDrawTarget),

source

pub fn read_pixels( &self, read_rect: Rect<u64>, canvas_size: Size2D<u64>, ) -> Vec<u8>

It reads image data from the canvas canvas_size: The size of the canvas we’re reading from read_rect: The area of the canvas we want to read from

Trait Implementations§

source§

impl<'a> Drop for CanvasData<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CanvasData<'a>

§

impl<'a> !RefUnwindSafe for CanvasData<'a>

§

impl<'a> !Send for CanvasData<'a>

§

impl<'a> !Sync for CanvasData<'a>

§

impl<'a> Unpin for CanvasData<'a>

§

impl<'a> !UnwindSafe for CanvasData<'a>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> MaybeBoxed<Box<T>> for T

source§

fn maybe_boxed(self) -> Box<T>

Convert
source§

impl<T> MaybeBoxed<T> for T

source§

fn maybe_boxed(self) -> T

Convert
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> ErasedDestructor for T
where T: 'static,

source§

impl<T> MaybeSendSync for T