[librsvg: 13/30] update per cairo/gio api changes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 13/30] update per cairo/gio api changes
- Date: Wed, 23 Jun 2021 23:05:39 +0000 (UTC)
commit 72b67ae517a8c42bff175c9ed3c2fd99be2ddc9c
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date: Thu Jun 17 13:52:52 2021 +0200
update per cairo/gio api changes
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/516>
src/api.rs | 2 +-
src/bin/rsvg-convert.rs | 14 +++++++-------
src/drawing_ctx.rs | 10 +++++-----
src/filters/displacement_map.rs | 2 +-
src/lib.rs | 2 +-
src/surface_utils/shared_surface.rs | 24 ++++++++++++------------
6 files changed, 27 insertions(+), 27 deletions(-)
---
diff --git a/src/api.rs b/src/api.rs
index 3618b853..c3837332 100644
--- a/src/api.rs
+++ b/src/api.rs
@@ -108,7 +108,7 @@ impl Loader {
/// let mut output = env::temp_dir();
/// output.push("output.pdf");
/// let surface = cairo::PdfSurface::new(640.0, 480.0, output)?;
- /// let cr = cairo::Context::new(&surface);
+ /// let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
///
/// let renderer = librsvg::CairoRenderer::new(&svg_handle);
/// renderer.render_document(
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index 6b5d2947..cd1a699e 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -2,7 +2,7 @@
extern crate clap;
use gio::prelude::*;
-use gio::{Cancellable, FileCreateFlags, FileExt, InputStream, OutputStream};
+use gio::{Cancellable, FileCreateFlags, InputStream, OutputStream};
#[cfg(unix)]
use gio::{UnixInputStream, UnixOutputStream};
@@ -263,7 +263,7 @@ impl Surface {
background_color: Option<Color>,
id: Option<&str>,
) -> Result<(), Error> {
- let cr = cairo::Context::new(self);
+ let cr = cairo::Context::new(self)?;
if let Some(Color::RGBA(rgba)) = background_color {
cr.set_source_rgba(
@@ -273,7 +273,7 @@ impl Surface {
rgba.alpha_f32().into(),
);
- cr.paint();
+ cr.paint()?;
}
cr.translate(left, top);
@@ -303,7 +303,7 @@ impl Surface {
}
if !matches!(self, Self::Png(_, _)) {
- cr.show_page();
+ cr.show_page()?;
}
Ok(())
@@ -351,7 +351,7 @@ struct Stdin;
impl Stdin {
#[cfg(unix)]
pub fn stream() -> InputStream {
- let stream = unsafe { UnixInputStream::new(0) };
+ let stream = unsafe { UnixInputStream::with_fd(0) };
stream.upcast::<InputStream>()
}
@@ -366,7 +366,7 @@ struct Stdout;
impl Stdout {
#[cfg(unix)]
pub fn stream() -> OutputStream {
- let stream = unsafe { UnixOutputStream::new(1) };
+ let stream = unsafe { UnixOutputStream::with_fd(1) };
stream.upcast::<OutputStream>()
}
@@ -594,7 +594,7 @@ impl Converter {
let output_stream = match self.output {
Output::Stdout => Stdout::stream(),
Output::Path(ref p) => {
- let file = gio::File::new_for_path(p);
+ let file = gio::File::for_path(p);
let stream = file
.replace(None, false, FileCreateFlags::NONE, None::<&Cancellable>)
.map_err(|e| error!("Error opening output \"{}\": {}", self.output, e))?;
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index b89c5b19..d078e249 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -868,8 +868,8 @@ impl DrawingCtx {
if o < 1.0 {
self.cr.push_group();
res = draw_fn(self);
- self.cr.pop_group_to_source();
- self.cr.paint_with_alpha(o);
+ self.cr.pop_group_to_source()?;
+ self.cr.paint_with_alpha(o)?;
} else {
res = draw_fn(self);
}
@@ -1075,7 +1075,7 @@ impl DrawingCtx {
}
pattern.set_extend(cairo::Extend::Repeat);
pattern.set_filter(cairo::Filter::Best);
- self.cr.set_source(&pattern);
+ self.cr.set_source(&pattern)?;
Ok(true)
}
@@ -1440,8 +1440,8 @@ impl DrawingCtx {
);
cr.set_matrix(affines.for_snapshot.into());
- cr.set_source_surface(&draw.target(), 0.0, 0.0);
- cr.paint();
+ cr.set_source_surface(&draw.target(), 0.0, 0.0)?;
+ cr.paint()?;
}
Ok(())
diff --git a/src/filters/displacement_map.rs b/src/filters/displacement_map.rs
index ed6e5ba7..39bf7a22 100644
--- a/src/filters/displacement_map.rs
+++ b/src/filters/displacement_map.rs
@@ -141,7 +141,7 @@ impl DisplacementMap {
cr.clip();
input_1.surface().set_as_source_surface(&cr, -ox, -oy);
- cr.paint();
+ cr.paint()?;
}
Ok(())
diff --git a/src/lib.rs b/src/lib.rs
index 15aeb750..3802b56a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -39,7 +39,7 @@
//! let handle = librsvg::Loader::new().read_path("example.svg").unwrap();
//!
//! let surface = cairo::ImageSurface::create(cairo::Format::ARgb32, WIDTH, HEIGHT).unwrap();
-//! let cr = cairo::Context::new(&surface);
+//! let cr = cairo::Context::new(&surface).expect("Failed to create a cairo context");
//!
//! let renderer = librsvg::CairoRenderer::new(&handle);
//! renderer.render_document(
diff --git a/src/surface_utils/shared_surface.rs b/src/surface_utils/shared_surface.rs
index 4eaef349..4d25111a 100644
--- a/src/surface_utils/shared_surface.rs
+++ b/src/surface_utils/shared_surface.rs
@@ -244,8 +244,8 @@ impl ImageSurface<Shared> {
{
let cr = cairo::Context::new(©)?;
- cr.set_source_surface(surface, 0f64, 0f64);
- cr.paint();
+ cr.set_source_surface(surface, 0f64, 0f64)?;
+ cr.paint()?;
}
SharedImageSurface::wrap(copy, SurfaceType::SRgb)
@@ -408,8 +408,8 @@ impl ImageSurface<Shared> {
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
- cr.set_source_surface(&self.surface, 0f64, 0f64);
- cr.paint();
+ cr.set_source_surface(&self.surface, 0f64, 0f64)?;
+ cr.paint()?;
Ok(output_surface)
}
@@ -434,7 +434,7 @@ impl ImageSurface<Shared> {
cr.scale(x, y);
self.set_as_source_surface(&cr, 0.0, 0.0);
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, self.surface_type)
@@ -999,7 +999,7 @@ impl ImageSurface<Shared> {
f64::from(color.blue_f32()),
f64::from(color.alpha_f32()),
);
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, self.surface_type)
@@ -1028,7 +1028,7 @@ impl ImageSurface<Shared> {
cr.clip();
self.set_as_source_surface(&cr, dx, dy);
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, self.surface_type)
@@ -1068,7 +1068,7 @@ impl ImageSurface<Shared> {
cr.source().set_matrix(matrix);
}
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, image.surface_type)
@@ -1083,7 +1083,7 @@ impl ImageSurface<Shared> {
{
let cr = cairo::Context::new(&output_surface)?;
self.set_as_source_surface(&cr, f64::from(-bounds.x0), f64::from(-bounds.y0));
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, self.surface_type)
@@ -1115,8 +1115,8 @@ impl ImageSurface<Shared> {
cr.rectangle(r.x, r.y, r.width, r.height);
cr.clip();
- cr.set_source(&ptn);
- cr.paint();
+ cr.set_source(&ptn)?;
+ cr.paint()?;
}
SharedImageSurface::wrap(output_surface, image.surface_type)
@@ -1144,7 +1144,7 @@ impl ImageSurface<Shared> {
self.set_as_source_surface(&cr, 0.0, 0.0);
cr.set_operator(operator.into());
- cr.paint();
+ cr.paint()?;
}
SharedImageSurface::wrap(
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]