[librsvg: 86/90] Extract function to compute the size of the temporary surface
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 86/90] Extract function to compute the size of the temporary surface
- Date: Tue, 26 Mar 2019 19:19:18 +0000 (UTC)
commit 9d9a17ca156477ef52cb9d77a56f441b5a6f4bbc
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Mar 26 09:02:14 2019 -0600
Extract function to compute the size of the temporary surface
rsvg_internals/src/drawing_ctx.rs | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
---
diff --git a/rsvg_internals/src/drawing_ctx.rs b/rsvg_internals/src/drawing_ctx.rs
index b27fc6e4..acf8ecce 100644
--- a/rsvg_internals/src/drawing_ctx.rs
+++ b/rsvg_internals/src/drawing_ctx.rs
@@ -216,34 +216,31 @@ impl DrawingCtx {
self.cr = self.cr_stack.pop().unwrap();
}
- pub fn create_surface_for_toplevel_viewport(
- &self,
- ) -> Result<cairo::ImageSurface, RenderingError> {
+ fn size_for_temporary_surface(&self) -> (i32, i32) {
// This truncation may mean that we clip off the rightmost/bottommost row of pixels.
// See https://gitlab.gnome.org/GNOME/librsvg/issues/295
let width = self.rect.width as i32;
let height = self.rect.height as i32;
- Ok(cairo::ImageSurface::create(
- cairo::Format::ARgb32,
- width,
- height,
- )?)
+ (width, height)
+ }
+
+ pub fn create_surface_for_toplevel_viewport(
+ &self,
+ ) -> Result<cairo::ImageSurface, RenderingError> {
+ let (w, h) = self.size_for_temporary_surface();
+
+ Ok(cairo::ImageSurface::create(cairo::Format::ARgb32, w, h)?)
}
fn create_similar_surface_for_toplevel_viewport(
&self,
surface: &cairo::Surface,
) -> Result<cairo::Surface, RenderingError> {
- // This truncation may mean that we clip off the rightmost/bottommost row of pixels.
- // See https://gitlab.gnome.org/GNOME/librsvg/issues/295
-
- let width = self.rect.width as i32;
- let height = self.rect.height as i32;
+ let (w, h) = self.size_for_temporary_surface();
- let surface =
- cairo::Surface::create_similar(surface, cairo::Content::ColorAlpha, width, height);
+ let surface = cairo::Surface::create_similar(surface, cairo::Content::ColorAlpha, w, h);
// FIXME: cairo-rs should return a Result from create_similar()!
// Since it doesn't, we need to check its status by hand...
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]