Verified Commit 05a3465a authored by Jordan Petridis's avatar Jordan Petridis 🌱

Upgrade gtk-rs crates

Cairo borke API, we now link against cairo-gobject
parent c5f85131
This diff is collapsed.
......@@ -132,6 +132,7 @@ AC_SUBST(GLIB_MKENUMS)
PKG_CHECK_MODULES(LIBRSVG, \
cairo >= $CAIRO_REQUIRED \
cairo-png >= $CAIRO_REQUIRED \
cairo-gobject >= $CAIRO_REQUIRED \
freetype2 >= $FREETYPE2_REQUIRED \
gdk-pixbuf-2.0 >= $GDK_PIXBUF_REQUIRED \
gio-2.0 >= $GIO_REQUIRED \
......
......@@ -25,10 +25,10 @@ downcast-rs = "^1.0.0"
encoding = "0.2.33"
regex = "1"
itertools = "0.7.4"
pango = "0.4"
pangocairo = "0.5"
pango-sys = "0.6"
pangocairo-sys = "0.7"
pango = "0.5.0"
pangocairo = "0.6.0"
pango-sys = "0.7.0"
pangocairo-sys = "0.8.0"
cssparser = "0.25.1"
lazy_static = "1.0.0"
phf = "0.7.21"
......@@ -39,35 +39,11 @@ nalgebra = "0.16"
num-traits = "0.2"
owning_ref = "0.3.0"
rayon = "1"
[dependencies.cairo-sys-rs]
version = "0.6"
#git = "https://github.com/gtk-rs/cairo.git"
#branch = "master"
#git = "https://github.com/federicomenaquintero/cairo.git"
#branch = "matrix-try-invert"
#git = "file:///home/federico/src/gtk-rs/cairo"
#features = ["png"]
[dependencies.cairo-rs]
version = "0.4"
#git = "https://github.com/gtk-rs/cairo.git"
#branch = "master"
#git = "file:///home/federico/src/gtk-rs/cairo"
#features = ["png"]
[dependencies.glib]
version = "0.5"
#git = "https://github.com/gtk-rs/glib.git"
#branch = "master"
[dependencies.glib-sys]
version = "0.6"
#git = "https://github.com/gtk-rs/sys"
#branch = "master"
[dependencies.gdk-pixbuf]
version = "0.4"
cairo-sys-rs = "0.7.0"
cairo-rs = "0.5.0"
glib = "0.6.0"
glib-sys = "0.7.0"
gdk-pixbuf = "0.5.0"
[dev-dependencies]
criterion = "0.2"
......
use std::cell::{Cell, RefCell};
use std::ptr;
use cairo::{self, ImageSurface, MatrixTrait, Pattern};
use cairo::{self, ImageSurface, MatrixTrait, PatternTrait};
use aspect_ratio::AspectRatio;
use attributes::Attribute;
......@@ -160,7 +160,7 @@ impl Image {
f64::from(bounds.y1 - bounds.y0),
);
cr.clip();
cr.set_source(&ptn);
cr.set_source(&cairo::Pattern::SurfacePattern(ptn));
cr.paint();
}
......
use cairo::{self, ImageSurface, Matrix, MatrixTrait, Pattern};
use cairo::{self, ImageSurface, Matrix, MatrixTrait, PatternTrait};
use drawing_ctx::DrawingCtx;
use handle::RsvgHandle;
......@@ -93,7 +93,7 @@ impl Filter for Tile {
);
cr.clip();
cr.set_source(&ptn);
cr.set_source(&cairo::Pattern::SurfacePattern(ptn));
cr.paint();
}
......
......@@ -399,7 +399,11 @@ impl Gradient {
self.common.add_color_stop(offset, rgba, opacity);
}
fn add_color_stops_to_pattern(&self, pattern: &mut cairo::Gradient, opacity: &UnitInterval) {
fn add_color_stops_to_pattern<T, G: cairo::Gradient<PatternType = T>>(
&self,
pattern: &mut G,
opacity: &UnitInterval,
) {
if let Some(stops) = self.common.stops.as_ref() {
for stop in stops {
let &UnitInterval(o) = opacity;
......@@ -466,15 +470,12 @@ fn resolve_gradient(gradient: &Gradient, draw_ctx: &mut DrawingCtx<'_>) -> Gradi
result
}
fn set_common_on_pattern<P: cairo::Pattern + cairo::Gradient>(
fn set_common_on_pattern<P: cairo::PatternTrait + cairo::Gradient>(
gradient: &Gradient,
draw_ctx: &mut DrawingCtx<'_>,
pattern: &mut P,
bbox: &BoundingBox,
opacity: &UnitInterval,
) {
let cr = draw_ctx.get_cairo_context();
let mut affine = gradient.common.affine.unwrap();
let units = gradient.common.units.unwrap();
......@@ -499,8 +500,6 @@ fn set_common_on_pattern<P: cairo::Pattern + cairo::Gradient>(
));
gradient.add_color_stops_to_pattern(pattern, opacity);
cr.set_source(pattern);
}
// SVG defines radial gradients as being inside a circle (cx, cy, radius). The
......@@ -567,7 +566,9 @@ fn set_pattern_on_draw_context(
y2.as_ref().unwrap().normalize(values, &params),
);
set_common_on_pattern(gradient, draw_ctx, &mut pattern, bbox, opacity)
let cr = draw_ctx.get_cairo_context();
set_common_on_pattern(gradient, &mut pattern, bbox, opacity);
cr.set_source(&cairo::Pattern::LinearGradient(pattern));
}
GradientVariant::Radial { cx, cy, r, fx, fy } => {
......@@ -580,7 +581,9 @@ fn set_pattern_on_draw_context(
let (new_fx, new_fy) = fix_focus_point(n_fx, n_fy, n_cx, n_cy, n_r);
let mut pattern = cairo::RadialGradient::new(new_fx, new_fy, 0.0, n_cx, n_cy, n_r);
set_common_on_pattern(gradient, draw_ctx, &mut pattern, bbox, opacity)
let cr = draw_ctx.get_cairo_context();
set_common_on_pattern(gradient, &mut pattern, bbox, opacity);
cr.set_source(&cairo::Pattern::RadialGradient(pattern));
}
}
}
......
use cairo;
use cairo::{MatrixTrait, Pattern};
use cairo::{MatrixTrait, PatternTrait};
use std::cell::{Cell, RefCell};
use aspect_ratio::AspectRatio;
......@@ -158,7 +158,7 @@ impl NodeTrait for NodeImage {
matrix.translate(-x, -y);
ptn.set_matrix(matrix);
ptn.set_extend(cairo::Extend::Pad);
cr.set_source(&ptn);
cr.set_source(&cairo::Pattern::SurfacePattern(ptn));
// Clip is needed due to extend being set to pad.
cr.rectangle(x, y, width, height);
......
use cairo::{Matrix, MatrixTrait};
use downcast_rs::*;
use glib;
use glib::translate::*;
use glib_sys;
use std::cell::{Cell, Ref, RefCell};
use std::ptr;
use std::rc::{Rc, Weak};
......
use cairo;
use cairo::MatrixTrait;
use cairo::Pattern as CairoPattern;
use cairo::PatternTrait;
use std::cell::RefCell;
use std::f64;
use std::rc::*;
......@@ -442,7 +442,7 @@ fn set_pattern_on_draw_context(
surface_pattern.set_matrix(matrix);
surface_pattern.set_filter(cairo::Filter::Best);
cr_save.set_source(&surface_pattern);
cr_save.set_source(&cairo::Pattern::SurfacePattern(surface_pattern));
res.and_then(|_| Ok(true))
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment