[librsvg: 12/14] DrawingCtx::set_gradient can't fail, so don't return a Result
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 12/14] DrawingCtx::set_gradient can't fail, so don't return a Result
- Date: Tue, 23 Mar 2021 19:57:56 +0000 (UTC)
commit 3507762ef651a13dabf38e87e1e014dcc0debe7a
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Mar 23 13:34:40 2021 -0600
DrawingCtx::set_gradient can't fail, so don't return a Result
It turns out that gradients are resolved to the fallback color within
PaintServer::resolve(); maybe we should remove the fallback color from
UserSpacePaintSource, but that needs tests first.
src/drawing_ctx.rs | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
---
diff --git a/src/drawing_ctx.rs b/src/drawing_ctx.rs
index 0526b7c6..75d989c9 100644
--- a/src/drawing_ctx.rs
+++ b/src/drawing_ctx.rs
@@ -981,7 +981,7 @@ impl DrawingCtx {
fn set_gradient(
self: &mut DrawingCtx,
gradient: &UserSpaceGradient,
- ) -> Result<bool, RenderingError> {
+ ) {
let g = match gradient.variant {
GradientVariant::Linear { x1, y1, x2, y2 } => {
cairo::Gradient::clone(&cairo::LinearGradient::new(x1, y1, x2, y2))
@@ -1014,8 +1014,6 @@ impl DrawingCtx {
let cr = self.cr.clone();
cr.set_source(&g);
-
- Ok(true)
}
fn set_pattern(
@@ -1113,15 +1111,9 @@ impl DrawingCtx {
acquired_nodes: &mut AcquiredNodes<'_>,
) -> Result<bool, RenderingError> {
match *paint_source {
- UserSpacePaintSource::Gradient(ref gradient, c) => {
- if self.set_gradient(gradient)? {
- Ok(true)
- } else if let Some(c) = c {
- self.set_color(c);
- Ok(true)
- } else {
- Ok(false)
- }
+ UserSpacePaintSource::Gradient(ref gradient, _c) => {
+ self.set_gradient(gradient);
+ Ok(true)
}
UserSpacePaintSource::Pattern(ref pattern, c) => {
if self.set_pattern(pattern, acquired_nodes)? {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]