[librsvg: 10/30] update per cairo changes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 10/30] update per cairo changes
- Date: Wed, 23 Jun 2021 23:05:39 +0000 (UTC)
commit 02aab1c06a5db7c88d05679985213ad1b7423b37
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Thu Jun 10 20:19:10 2021 +0200
update per cairo changes
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/516>
src/c_api/handle.rs | 2 +-
src/c_api/pixbuf_utils.rs | 2 +-
src/drawing_ctx.rs | 29 ++++++++++++++---------------
src/handle.rs | 4 ++--
src/surface_utils/shared_surface.rs | 20 ++++++++++----------
5 files changed, 28 insertions(+), 29 deletions(-)
---
diff --git a/src/c_api/handle.rs b/src/c_api/handle.rs
index a613f061..fd045934 100644
--- a/src/c_api/handle.rs
+++ b/src/c_api/handle.rs
@@ -968,7 +968,7 @@ impl CHandle {
)?;
{
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface)?;
let cr_raw = cr.to_raw_none();
self.render_cairo_sub(cr_raw, id)?;
}
diff --git a/src/c_api/pixbuf_utils.rs b/src/c_api/pixbuf_utils.rs
index 71e8b3f5..9219ca3c 100644
--- a/src/c_api/pixbuf_utils.rs
+++ b/src/c_api/pixbuf_utils.rs
@@ -126,7 +126,7 @@ fn render_to_pixbuf_at_size(
)?;
{
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface)?;
cr.scale(
desired_width / document_width,
desired_height / document_height,
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index b0825835..b89c5b19 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -40,7 +40,6 @@ use crate::surface_utils::{
};
use crate::transform::Transform;
use crate::unit_interval::UnitInterval;
-use crate::util::check_cairo_context;
use crate::viewbox::ViewBox;
/// Holds values that are required to normalize `CssLength` values to a current viewport.
@@ -597,7 +596,7 @@ impl DrawingCtx {
// Use a scope because mask_cr needs to release the
// reference to the surface before we access the pixels
{
- let mask_cr = cairo::Context::new(&mask_content_surface);
+ let mask_cr = cairo::Context::new(&mask_content_surface)?;
mask_cr.set_matrix(mask_transform.into());
let bbtransform = Transform::new_unchecked(
@@ -718,7 +717,7 @@ impl DrawingCtx {
Filter::List(_) => {
cairo::Context::new(&*self.create_surface_for_toplevel_viewport()?)
}
- };
+ }?;
cr.set_matrix(affines.for_temporary_surface.into());
@@ -738,7 +737,7 @@ impl DrawingCtx {
// Filter
let surface_to_filter = SharedImageSurface::copy_from_surface(
- &cairo::ImageSurface::try_from(temporary_draw_ctx.cr.get_target()).unwrap(),
+ &cairo::ImageSurface::try_from(temporary_draw_ctx.cr.target()).unwrap(),
)?;
let current_color = values.color().0;
@@ -1024,7 +1023,7 @@ impl DrawingCtx {
.target()
.create_similar(cairo::Content::ColorAlpha, pw, ph)?;
- let cr_pattern = cairo::Context::new(&surface);
+ let cr_pattern = cairo::Context::new(&surface)?;
// Set up transformations to be determined by the contents units
cr_pattern.set_matrix(caffine.into());
@@ -1219,7 +1218,7 @@ impl DrawingCtx {
cr.set_fill_rule(cairo::FillRule::from(shape.fill_rule));
path_helper.set()?;
- let bbox = compute_stroke_and_fill_box(&cr, &shape.stroke, &shape.stroke_paint);
+ let bbox = compute_stroke_and_fill_box(&cr, &shape.stroke, &shape.stroke_paint)?;
let stroke_paint = shape.stroke_paint.to_user_space(&bbox, view_params, values);
let fill_paint = shape.fill_paint.to_user_space(&bbox, view_params, values);
@@ -1466,7 +1465,7 @@ impl DrawingCtx {
let save_cr = self.cr.clone();
{
- let cr = cairo::Context::new(&surface);
+ let cr = cairo::Context::new(&surface)?;
cr.set_matrix(affine.into());
self.cr = cr;
@@ -1744,7 +1743,7 @@ fn compute_stroke_and_fill_box(
cr: &cairo::Context,
stroke: &Stroke,
stroke_paint_source: &PaintSource,
-) -> BoundingBox {
+) -> Result<BoundingBox, RenderingError> {
let affine = Transform::from(cr.matrix());
let mut bbox = BoundingBox::new().with_transform(affine);
@@ -1763,7 +1762,7 @@ fn compute_stroke_and_fill_box(
// paths for the icon's shape. We need to be able to compute the bounding
// rectangle's extents, even when it has no fill nor stroke.
- let (x0, y0, x1, y1) = cr.fill_extents();
+ let (x0, y0, x1, y1) = cr.fill_extents()?;
let fb = BoundingBox::new()
.with_transform(affine)
.with_ink_rect(Rect::new(x0, y0, x1, y1));
@@ -1781,7 +1780,7 @@ fn compute_stroke_and_fill_box(
// bounding box if so.
if !stroke.width.approx_eq_cairo(0.0) && !matches!(stroke_paint_source, PaintSource::None) {
- let (x0, y0, x1, y1) = cr.stroke_extents();
+ let (x0, y0, x1, y1) = cr.stroke_extents()?;
let sb = BoundingBox::new()
.with_transform(affine)
.with_ink_rect(Rect::new(x0, y0, x1, y1));
@@ -1790,7 +1789,7 @@ fn compute_stroke_and_fill_box(
// objectBoundingBox
- let (x0, y0, x1, y1) = cr.path_extents();
+ let (x0, y0, x1, y1) = cr.path_extents()?;
let ob = BoundingBox::new()
.with_transform(affine)
.with_rect(Rect::new(x0, y0, x1, y1));
@@ -1800,7 +1799,7 @@ fn compute_stroke_and_fill_box(
cr.set_tolerance(backup_tolerance);
- bbox
+ Ok(bbox)
}
fn compute_text_box(
@@ -1983,7 +1982,7 @@ impl From<&DrawingCtx> for pango::Context {
fn from(draw_ctx: &DrawingCtx) -> pango::Context {
let cr = draw_ctx.cr.clone();
- let mut options = cairo::FontOptions::new();
+ let mut options = cairo::FontOptions::new().unwrap();
if draw_ctx.testing {
options.set_antialias(cairo::Antialias::Gray);
}
@@ -1993,7 +1992,7 @@ impl From<&DrawingCtx> for pango::Context {
cr.set_font_options(&options);
- let font_map = pangocairo::FontMap::get_default().unwrap();
+ let font_map = pangocairo::FontMap::default().unwrap();
let context = font_map.create_context().unwrap();
context.set_round_glyph_positions(false);
@@ -2070,7 +2069,7 @@ impl Path {
// * The *next* call to the cr will probably be something that actually checks the status
// (i.e. in cairo-rs), and we don't want to panic there.
- check_cairo_context(&cr)
+ cr.status().map_err(|e| e.into())
}
}
diff --git a/src/handle.rs b/src/handle.rs
index 64c463da..830f4e6d 100644
--- a/src/handle.rs
+++ b/src/handle.rs
@@ -160,7 +160,7 @@ impl Handle {
let root = self.document.root();
let target = cairo::ImageSurface::create(cairo::Format::Rgb24, 1, 1)?;
- let cr = cairo::Context::new(&target);
+ let cr = cairo::Context::new(&target)?;
let bbox = draw_tree(
DrawingMode::LimitToStack { node, root },
@@ -277,7 +277,7 @@ impl Handle {
is_testing: bool,
) -> Result<BoundingBox, RenderingError> {
let target = cairo::ImageSurface::create(cairo::Format::Rgb24, 1, 1)?;
- let cr = cairo::Context::new(&target);
+ let cr = cairo::Context::new(&target)?;
let node = node.clone();
diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs
index c3e8f002..4eaef349 100644
--- a/src/surface_utils/shared_surface.rs
+++ b/src/surface_utils/shared_surface.rs
@@ -243,7 +243,7 @@ impl ImageSurface<Shared> {
cairo::ImageSurface::create(cairo::Format::ARgb32, surface.width(), surface.height())?;
{
- let cr = cairo::Context::new(©);
+ let cr = cairo::Context::new(©)?;
cr.set_source_surface(surface, 0f64, 0f64);
cr.paint();
}
@@ -403,7 +403,7 @@ impl ImageSurface<Shared> {
let output_surface =
cairo::ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -427,7 +427,7 @@ impl ImageSurface<Shared> {
let output_surface = cairo::ImageSurface::create(cairo::Format::ARgb32, width, height)?;
{
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -988,7 +988,7 @@ impl ImageSurface<Shared> {
cairo::ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
if color.alpha > 0 {
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -1022,7 +1022,7 @@ impl ImageSurface<Shared> {
.translate((dx as i32, dy as i32))
.intersection(&bounds)
{
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(output_bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -1047,7 +1047,7 @@ impl ImageSurface<Shared> {
cairo::ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
if rect.is_none() || !rect.unwrap().is_empty() {
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -1081,7 +1081,7 @@ impl ImageSurface<Shared> {
cairo::ImageSurface::create(cairo::Format::ARgb32, bounds.width(), bounds.height())?;
{
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
self.set_as_source_surface(&cr, f64::from(-bounds.x0), f64::from(-bounds.y0));
cr.paint();
}
@@ -1103,7 +1103,7 @@ impl ImageSurface<Shared> {
cairo::ImageSurface::create(cairo::Format::ARgb32, self.width, self.height)?;
{
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let ptn = image.to_cairo_pattern();
ptn.set_extend(cairo::Extend::Repeat);
@@ -1137,7 +1137,7 @@ impl ImageSurface<Shared> {
let output_surface = other.copy_surface(bounds)?;
{
- let cr = cairo::Context::new(&output_surface);
+ let cr = cairo::Context::new(&output_surface)?;
let r = cairo::Rectangle::from(bounds);
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
@@ -1349,7 +1349,7 @@ impl ImageSurface<Exclusive> {
&mut self,
draw_fn: &mut dyn FnMut(cairo::Context) -> Result<(), cairo::Error>,
) -> Result<(), cairo::Error> {
- let cr = cairo::Context::new(&self.surface);
+ let cr = cairo::Context::new(&self.surface)?;
draw_fn(cr)
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]