pub struct DrawingCtx {
    session: Session,
    initial_viewport: Viewport,
    dpi: Dpi,
    cr_stack: Rc<RefCell<Vec<Context>>>,
    cr: Context,
    user_language: UserLanguage,
    drawsub_stack: Vec<Node<NodeData>>,
    svg_nesting: SvgNesting,
    measuring: bool,
    testing: bool,
}

Fields§

§session: Session§initial_viewport: Viewport§dpi: Dpi§cr_stack: Rc<RefCell<Vec<Context>>>§cr: Context§user_language: UserLanguage§drawsub_stack: Vec<Node<NodeData>>§svg_nesting: SvgNesting§measuring: bool§testing: bool

Implementations§

source§

impl DrawingCtx

source

fn new( session: Session, cr: &Context, initial_viewport: &Viewport, user_language: UserLanguage, dpi: Dpi, svg_nesting: SvgNesting, measuring: bool, testing: bool, drawsub_stack: Vec<Node<NodeData>> ) -> DrawingCtx

source

fn nested(&self, cr: Context) -> DrawingCtx

Copies a DrawingCtx for temporary use on a Cairo surface.

DrawingCtx maintains state using during the drawing process, and sometimes we would like to use that same state but on a different Cairo surface and context than the ones being used on self. This function copies the self state into a new DrawingCtx, and ties the copied one to the supplied cr.

source

pub fn session(&self) -> &Session

source

pub fn user_language(&self) -> &UserLanguage

source

pub fn toplevel_viewport(&self) -> Rect

source

pub fn get_transform_for_stacking_ctx( &self, stacking_ctx: &StackingContext, clipping: bool ) -> Result<ValidTransform, InternalRenderingError>

Gets the transform that will be used on the target surface, whether using an isolated stacking context or not.

This is only used in the text code, and we should probably try to remove it.

source

pub fn svg_nesting(&self) -> SvgNesting

source

pub fn is_measuring(&self) -> bool

source

pub fn is_testing(&self) -> bool

source

pub fn get_transform(&self) -> ValidTransform

source

pub fn empty_bbox(&self) -> BoundingBox

source

fn size_for_temporary_surface(&self) -> (i32, i32)

source

pub fn create_surface_for_toplevel_viewport( &self ) -> Result<ImageSurface, InternalRenderingError>

source

fn create_similar_surface_for_toplevel_viewport( &self, surface: &Surface ) -> Result<Surface, InternalRenderingError>

source

pub fn push_new_viewport( &self, current_viewport: &Viewport, vbox: Option<ViewBox>, viewport_rect: Rect, preserve_aspect_ratio: AspectRatio, clip_mode: ClipMode ) -> Option<Viewport>

Creates a new coordinate space inside a viewport and sets a clipping rectangle.

Note that this actually changes the draw_ctx.cr’s transformation to match the new coordinate space, but the old one is not restored after the result’s Viewport is dropped. Thus, this function must be called inside with_saved_cr or draw_ctx.with_discrete_layer.

source

fn clip_to_node( &mut self, clip_node: &Option<Node<NodeData>>, acquired_nodes: &mut AcquiredNodes<'_>, viewport: &Viewport, bbox: &BoundingBox ) -> Result<(), InternalRenderingError>

source

fn generate_cairo_mask( &mut self, mask_node: &Node<NodeData>, viewport: &Viewport, transform: Transform, bbox: &BoundingBox, acquired_nodes: &mut AcquiredNodes<'_> ) -> Result<Option<ImageSurface>, InternalRenderingError>

source

pub fn with_discrete_layer( &mut self, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, viewport: &Viewport, clipping: bool, draw_fn: &mut dyn FnMut(&mut AcquiredNodes<'_>, &mut DrawingCtx) -> Result<BoundingBox, InternalRenderingError> ) -> Result<BoundingBox, InternalRenderingError>

source

fn with_alpha( &mut self, opacity: UnitInterval, draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, InternalRenderingError> ) -> Result<BoundingBox, InternalRenderingError>

Run the drawing function with the specified opacity

Start a Cairo tag for PDF links

End a Cairo tag for PDF links

source

fn run_filters( &mut self, viewport: &Viewport, surface_to_filter: SharedImageSurface, filter: &Filter, acquired_nodes: &mut AcquiredNodes<'_>, node_name: &str, user_space_params: &NormalizeParams, stroke_paint_source: Rc<UserSpacePaintSource>, fill_paint_source: Rc<UserSpacePaintSource>, node_bbox: BoundingBox ) -> Result<SharedImageSurface, InternalRenderingError>

source

fn set_gradient( &mut self, gradient: &UserSpaceGradient ) -> Result<(), InternalRenderingError>

source

fn set_pattern( &mut self, pattern: &UserSpacePattern, acquired_nodes: &mut AcquiredNodes<'_> ) -> Result<bool, InternalRenderingError>

source

fn set_paint_source( &mut self, paint_source: &UserSpacePaintSource, acquired_nodes: &mut AcquiredNodes<'_> ) -> Result<bool, InternalRenderingError>

source

pub fn get_paint_source_surface( &mut self, width: i32, height: i32, acquired_nodes: &mut AcquiredNodes<'_>, paint_source: &UserSpacePaintSource ) -> Result<SharedImageSurface, InternalRenderingError>

Computes and returns a surface corresponding to the given paint server.

source

fn stroke( &mut self, cr: &Context, acquired_nodes: &mut AcquiredNodes<'_>, paint_source: &UserSpacePaintSource ) -> Result<(), InternalRenderingError>

source

fn fill( &mut self, cr: &Context, acquired_nodes: &mut AcquiredNodes<'_>, paint_source: &UserSpacePaintSource ) -> Result<(), InternalRenderingError>

source

pub fn compute_path_extents( &self, path: &Path ) -> Result<Option<Rect>, InternalRenderingError>

source

pub fn draw_layer( &mut self, layer: &Layer, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport ) -> Result<BoundingBox, InternalRenderingError>

source

fn draw_shape( &mut self, shape: &Shape, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport ) -> Result<BoundingBox, InternalRenderingError>

source

fn paint_surface( &mut self, surface: &SharedImageSurface, width: f64, height: f64, image_rendering: ImageRendering ) -> Result<(), Error>

source

fn draw_image( &mut self, image: &Image, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport ) -> Result<BoundingBox, InternalRenderingError>

source

fn draw_text_span( &mut self, span: &TextSpan, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool ) -> Result<BoundingBox, InternalRenderingError>

source

fn draw_text( &mut self, text: &Text, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport ) -> Result<BoundingBox, InternalRenderingError>

source

pub fn get_snapshot( &self, width: i32, height: i32 ) -> Result<SharedImageSurface, InternalRenderingError>

source

pub fn draw_node_to_surface( &mut self, node: &Node<NodeData>, acquired_nodes: &mut AcquiredNodes<'_>, cascaded: &CascadedValues<'_>, affine: Transform, width: i32, height: i32 ) -> Result<SharedImageSurface, InternalRenderingError>

source

pub fn draw_node_from_stack( &mut self, node: &Node<NodeData>, acquired_nodes: &mut AcquiredNodes<'_>, cascaded: &CascadedValues<'_>, viewport: &Viewport, clipping: bool ) -> Result<BoundingBox, InternalRenderingError>

source

pub fn draw_from_use_node( &mut self, node: &Node<NodeData>, acquired_nodes: &mut AcquiredNodes<'_>, values: &ComputedValues, use_rect: Rect, link: &NodeId, clipping: bool, viewport: &Viewport, fill_paint: Rc<PaintSource>, stroke_paint: Rc<PaintSource> ) -> Result<BoundingBox, InternalRenderingError>

source

pub fn get_font_options(&self) -> FontOptions

Extracts the font options for the current state of the DrawingCtx.

You can use the font options later with create_pango_context().

Trait Implementations§

source§

impl Drop for DrawingCtx

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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, 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

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

§

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>,

§

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.