[][src]Struct rsvg_internals::drawing_ctx::DrawingCtx

pub struct DrawingCtx {
    initial_transform: Transform,
    rect: Rect,
    dpi: Dpi,
    cr_stack: Vec<Context>,
    cr: Context,
    view_box_stack: Rc<RefCell<Vec<ViewBox>>>,
    drawsub_stack: Vec<Node<NodeData>>,
    measuring: bool,
    testing: bool,
}

Fields

initial_transform: Transformrect: Rectdpi: Dpicr_stack: Vec<Context>cr: Contextview_box_stack: Rc<RefCell<Vec<ViewBox>>>drawsub_stack: Vec<Node<NodeData>>measuring: booltesting: bool

Methods

impl DrawingCtx[src]

pub fn new(
    node: Option<&Node<NodeData>>,
    cr: &Context,
    viewport: Rect,
    dpi: Dpi,
    measuring: bool,
    testing: bool
) -> DrawingCtx
[src]

pub fn toplevel_viewport(&self) -> Rect[src]

pub fn is_measuring(&self) -> bool[src]

fn get_transform(&self) -> Transform[src]

pub fn empty_bbox(&self) -> BoundingBox[src]

fn set_cairo_context(&mut self, cr: &Context)[src]

fn push_cairo_context(&mut self, cr: Context)[src]

fn pop_cairo_context(&mut self)[src]

fn size_for_temporary_surface(&self) -> (i32, i32)[src]

pub fn create_surface_for_toplevel_viewport(
    &self
) -> Result<ImageSurface, RenderingError>
[src]

fn create_similar_surface_for_toplevel_viewport(
    &self,
    surface: &Surface
) -> Result<Surface, RenderingError>
[src]

pub fn get_view_params(&self) -> ViewParams[src]

Gets the viewport that was last pushed with push_view_box().

pub fn push_view_box(&self, width: f64, height: f64) -> ViewParams[src]

Pushes a viewport size for normalizing Length values.

You should pass the returned ViewParams to all subsequent Length.normalize() calls that correspond to this viewport.

The viewport will stay in place, and will be the one returned by get_view_params(), until the returned ViewParams is dropped.

pub fn push_new_viewport(
    &self,
    vbox: Option<ViewBox>,
    viewport: Rect,
    preserve_aspect_ratio: AspectRatio,
    clip_mode: Option<ClipMode>
) -> Option<ViewParams>
[src]

Creates a new coordinate space inside a viewport.

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 ViewParams is dropped. Thus, this function must be called inside draw_ctx.with_saved_cr or draw_ctx.with_discrete_layer.

fn clip_to_node(
    &mut self,
    clip_node: &Option<Node<NodeData>>,
    acquired_nodes: &mut AcquiredNodes,
    bbox: &BoundingBox
) -> Result<(), RenderingError>
[src]

fn generate_cairo_mask(
    &mut self,
    mask: &Mask,
    mask_node: &Node<NodeData>,
    transform: Transform,
    bbox: &BoundingBox,
    acquired_nodes: &mut AcquiredNodes
) -> Result<Option<ImageSurface>, RenderingError>
[src]

pub fn with_discrete_layer(
    &mut self,
    node: &Node<NodeData>,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    clipping: bool,
    draw_fn: &mut dyn FnMut(&mut AcquiredNodes, &mut DrawingCtx) -> Result<BoundingBox, RenderingError>
) -> Result<BoundingBox, RenderingError>
[src]

fn initial_transform_with_offset(&self) -> Transform[src]

pub fn with_saved_transform(
    &mut self,
    transform: Option<Transform>,
    draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, RenderingError>
) -> Result<BoundingBox, RenderingError>
[src]

Saves the current transform, applies a new transform if specified, runs the draw_fn, and restores the original transform

This is slightly cheaper than a cr.save() / cr.restore() pair, but more importantly, it does not reset the whole graphics state, i.e. it leaves a clipping path in place if it was set by the draw_fn.

pub fn with_clip_rect(
    &mut self,
    clip: Option<Rect>,
    draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, RenderingError>
) -> Result<BoundingBox, RenderingError>
[src]

if a rectangle is specified, clips and runs the draw_fn, otherwise simply run the draw_fn

pub fn with_alpha(
    &mut self,
    opacity: UnitInterval,
    draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, RenderingError>
) -> Result<BoundingBox, RenderingError>
[src]

Run the drawing function with the specified opacity

fn with_saved_cr(
    &mut self,
    draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, RenderingError>
) -> Result<BoundingBox, RenderingError>
[src]

Saves the current Cairo context, runs the draw_fn, and restores the context

Wraps the draw_fn in a link to the given target

fn run_filters(
    &mut self,
    filters: &Filter,
    acquired_nodes: &mut AcquiredNodes,
    node: &Node<NodeData>,
    values: &ComputedValues,
    node_bbox: BoundingBox
) -> Result<Surface, RenderingError>
[src]

fn run_filter(
    &mut self,
    acquired_nodes: &mut AcquiredNodes,
    filter_uri: &Fragment,
    node: &Node<NodeData>,
    values: &ComputedValues,
    child_surface: SharedImageSurface,
    node_bbox: BoundingBox
) -> Result<SharedImageSurface, RenderingError>
[src]

fn set_gradient(
    self: &mut DrawingCtx,
    gradient: &Gradient,
    _acquired_nodes: &mut AcquiredNodes,
    opacity: UnitInterval,
    values: &ComputedValues,
    bbox: &BoundingBox
) -> Result<bool, RenderingError>
[src]

fn set_pattern(
    &mut self,
    pattern: &ResolvedPattern,
    acquired_nodes: &mut AcquiredNodes,
    opacity: UnitInterval,
    values: &ComputedValues,
    bbox: &BoundingBox
) -> Result<bool, RenderingError>
[src]

fn set_color(
    &self,
    color: Color,
    opacity: UnitInterval,
    current_color: RGBA
) -> Result<bool, RenderingError>
[src]

fn set_source_paint_server(
    &mut self,
    acquired_nodes: &mut AcquiredNodes,
    paint_server: &PaintServer,
    opacity: UnitInterval,
    bbox: &BoundingBox,
    current_color: RGBA,
    values: &ComputedValues
) -> Result<bool, RenderingError>
[src]

pub fn get_paint_server_surface(
    &mut self,
    width: i32,
    height: i32,
    acquired_nodes: &mut AcquiredNodes,
    paint_server: &PaintServer,
    opacity: UnitInterval,
    bbox: &BoundingBox,
    current_color: RGBA,
    values: &ComputedValues
) -> Result<SharedImageSurface, Status>
[src]

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

fn setup_cr_for_stroke(&self, cr: &Context, values: &ComputedValues)[src]

fn stroke(
    &mut self,
    cr: &Context,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    bbox: &BoundingBox,
    current_color: RGBA
) -> Result<(), RenderingError>
[src]

fn fill(
    &mut self,
    cr: &Context,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    bbox: &BoundingBox,
    current_color: RGBA
) -> Result<(), RenderingError>
[src]

pub fn draw_path(
    &mut self,
    path: &Path,
    node: &Node<NodeData>,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    markers: Markers,
    clipping: bool
) -> Result<BoundingBox, RenderingError>
[src]

pub fn draw_image(
    &mut self,
    surface: &SharedImageSurface,
    rect: Rect,
    aspect: AspectRatio,
    node: &Node<NodeData>,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    clipping: bool
) -> Result<BoundingBox, RenderingError>
[src]

pub fn draw_text(
    &mut self,
    layout: &Layout,
    x: f64,
    y: f64,
    acquired_nodes: &mut AcquiredNodes,
    values: &ComputedValues,
    clipping: bool
) -> Result<BoundingBox, RenderingError>
[src]

pub fn get_snapshot(
    &self,
    width: i32,
    height: i32
) -> Result<SharedImageSurface, Status>
[src]

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, RenderingError>
[src]

pub fn draw_node_from_stack(
    &mut self,
    node: &Node<NodeData>,
    acquired_nodes: &mut AcquiredNodes,
    cascaded: &CascadedValues,
    clipping: bool
) -> Result<BoundingBox, RenderingError>
[src]

pub fn draw_from_use_node(
    &mut self,
    node: &Node<NodeData>,
    acquired_nodes: &mut AcquiredNodes,
    cascaded: &CascadedValues,
    link: Option<&Fragment>,
    clipping: bool
) -> Result<BoundingBox, RenderingError>
[src]

Trait Implementations

impl<'_> From<&'_ DrawingCtx> for Context[src]

Auto Trait Implementations

impl !RefUnwindSafe for DrawingCtx

impl !Send for DrawingCtx

impl !Sync for DrawingCtx

impl Unpin for DrawingCtx

impl !UnwindSafe for DrawingCtx

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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