Struct rsvg::drawing_ctx::DrawingCtx
source · pub struct DrawingCtx {
session: Session,
initial_viewport: Viewport,
cr_stack: Rc<RefCell<Vec<Context>>>,
cr: Context,
drawsub_stack: Vec<Node<NodeData>>,
config: RenderingConfiguration,
}
Fields§
§session: Session
§initial_viewport: Viewport
§cr_stack: Rc<RefCell<Vec<Context>>>
§cr: Context
§drawsub_stack: Vec<Node<NodeData>>
§config: RenderingConfiguration
Implementations§
source§impl DrawingCtx
impl DrawingCtx
fn new( session: Session, cr: &Context, initial_viewport: &Viewport, config: RenderingConfiguration, drawsub_stack: Vec<Node<NodeData>>, ) -> DrawingCtx
sourcefn nested(&self, cr: Context) -> DrawingCtx
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
.
pub fn session(&self) -> &Session
sourcepub fn rendering_options(&self, svg_nesting: SvgNesting) -> RenderingOptions
pub fn rendering_options(&self, svg_nesting: SvgNesting) -> RenderingOptions
Returns the RenderingOptions
being used for rendering.
pub fn user_language(&self) -> &UserLanguage
pub fn toplevel_viewport(&self) -> Rect
sourcepub fn get_transform_for_stacking_ctx(
&self,
stacking_ctx: &StackingContext,
clipping: bool,
) -> Result<ValidTransform, InternalRenderingError>
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.
pub fn svg_nesting(&self) -> SvgNesting
pub fn is_measuring(&self) -> bool
pub fn is_testing(&self) -> bool
pub fn get_transform(&self) -> ValidTransform
pub fn empty_bbox(&self) -> BoundingBox
fn size_for_temporary_surface(&self) -> (i32, i32)
pub fn create_surface_for_toplevel_viewport( &self, ) -> Result<ImageSurface, InternalRenderingError>
fn create_similar_surface_for_toplevel_viewport( &self, surface: &Surface, ) -> Result<Surface, InternalRenderingError>
sourcepub fn push_new_viewport(
&self,
current_viewport: &Viewport,
layout_viewport: &LayoutViewport,
) -> Option<Viewport>
pub fn push_new_viewport( &self, current_viewport: &Viewport, layout_viewport: &LayoutViewport, ) -> 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
.
fn clip_to_node( &mut self, clip_node: &Option<Node<NodeData>>, acquired_nodes: &mut AcquiredNodes<'_>, viewport: &Viewport, bbox: &BoundingBox, ) -> Result<(), InternalRenderingError>
fn generate_cairo_mask( &mut self, mask_node: &Node<NodeData>, viewport: &Viewport, transform: Transform, bbox: &BoundingBox, acquired_nodes: &mut AcquiredNodes<'_>, ) -> Result<Option<ImageSurface>, InternalRenderingError>
fn is_rendering_cancelled(&self) -> bool
pub fn with_discrete_layer( &mut self, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, viewport: &Viewport, layout_viewport: Option<LayoutViewport>, clipping: bool, draw_fn: &mut dyn FnMut(&mut AcquiredNodes<'_>, &mut DrawingCtx, &Viewport) -> Result<BoundingBox, InternalRenderingError>, ) -> Result<BoundingBox, InternalRenderingError>
sourcefn with_alpha(
&mut self,
opacity: UnitInterval,
draw_fn: &mut dyn FnMut(&mut DrawingCtx) -> Result<BoundingBox, InternalRenderingError>,
) -> Result<BoundingBox, InternalRenderingError>
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
sourcefn link_tag_begin(&mut self, link_target: &str)
fn link_tag_begin(&mut self, link_target: &str)
Start a Cairo tag for PDF links
sourcefn link_tag_end(&mut self)
fn link_tag_end(&mut self)
End a Cairo tag for PDF links
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>
fn set_gradient( &mut self, gradient: &UserSpaceGradient, ) -> Result<(), InternalRenderingError>
fn set_pattern( &mut self, pattern: &UserSpacePattern, acquired_nodes: &mut AcquiredNodes<'_>, ) -> Result<bool, InternalRenderingError>
fn set_paint_source( &mut self, paint_source: &UserSpacePaintSource, acquired_nodes: &mut AcquiredNodes<'_>, ) -> Result<bool, InternalRenderingError>
sourcepub fn get_paint_source_surface(
&mut self,
width: i32,
height: i32,
acquired_nodes: &mut AcquiredNodes<'_>,
paint_source: &UserSpacePaintSource,
) -> Result<SharedImageSurface, InternalRenderingError>
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.
fn stroke( &mut self, cr: &Context, acquired_nodes: &mut AcquiredNodes<'_>, paint_source: &UserSpacePaintSource, ) -> Result<(), InternalRenderingError>
fn fill( &mut self, cr: &Context, acquired_nodes: &mut AcquiredNodes<'_>, paint_source: &UserSpacePaintSource, ) -> Result<(), InternalRenderingError>
pub fn draw_layer( &mut self, layer: &Layer, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport, ) -> Result<BoundingBox, InternalRenderingError>
fn draw_shape( &mut self, shape: &Shape, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport, ) -> Result<BoundingBox, InternalRenderingError>
fn paint_surface( &mut self, surface: &SharedImageSurface, width: f64, height: f64, image_rendering: ImageRendering, ) -> Result<(), Error>
fn draw_image( &mut self, image: &Image, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport, ) -> Result<BoundingBox, InternalRenderingError>
fn draw_group( &mut self, _group: &Group, _stacking_ctx: &StackingContext, _acquired_nodes: &mut AcquiredNodes<'_>, _clipping: bool, _viewport: &Viewport, ) -> Result<BoundingBox, InternalRenderingError>
fn draw_text_span( &mut self, span: &TextSpan, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, ) -> Result<BoundingBox, InternalRenderingError>
fn draw_text( &mut self, text: &Text, stacking_ctx: &StackingContext, acquired_nodes: &mut AcquiredNodes<'_>, clipping: bool, viewport: &Viewport, ) -> Result<BoundingBox, InternalRenderingError>
pub fn get_snapshot( &self, width: i32, height: i32, ) -> Result<SharedImageSurface, InternalRenderingError>
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>
pub fn draw_node_from_stack( &mut self, node: &Node<NodeData>, acquired_nodes: &mut AcquiredNodes<'_>, cascaded: &CascadedValues<'_>, viewport: &Viewport, clipping: bool, ) -> Result<BoundingBox, InternalRenderingError>
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>
sourcepub fn get_font_options(&self) -> FontOptions
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§
Auto Trait Implementations§
impl Freeze for DrawingCtx
impl !RefUnwindSafe for DrawingCtx
impl !Send for DrawingCtx
impl !Sync for DrawingCtx
impl Unpin for DrawingCtx
impl !UnwindSafe for DrawingCtx
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.