summaryrefslogtreecommitdiffstats
path: root/src/display/cairo-utils.cpp
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2012-12-23 09:55:50 +0000
committertavmjong-free <tavmjong@free.fr>2012-12-23 09:55:50 +0000
commitd1e043d27a35b00c9e49a2deef1c2ee5bc8b2cc5 (patch)
tree1e38179576836ab002e2824a9438c3de3718e130 /src/display/cairo-utils.cpp
parentruler: Use border widths for Gtk+ 3 rendering (diff)
downloadinkscape-d1e043d27a35b00c9e49a2deef1c2ee5bc8b2cc5.tar.gz
inkscape-d1e043d27a35b00c9e49a2deef1c2ee5bc8b2cc5.zip
Move some code from filter primitives to cairo-utils.cpp. Fix bug in lighting primitives.
(bzr r11976)
Diffstat (limited to 'src/display/cairo-utils.cpp')
-rw-r--r--src/display/cairo-utils.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp
index 92303fed8..692e31837 100644
--- a/src/display/cairo-utils.cpp
+++ b/src/display/cairo-utils.cpp
@@ -287,9 +287,26 @@ get_cairo_surface_ci(cairo_surface_t *surface) {
}
}
+/** Set the color_interpolation_value for a Cairo surface.
+ * Transform the surface between sRGB and linearRGB if necessary. */
void
set_cairo_surface_ci(cairo_surface_t *surface, SPColorInterpolation ci) {
- cairo_surface_set_user_data(surface, &ci_key, GINT_TO_POINTER (ci), NULL);
+
+ if( cairo_surface_get_content( surface ) != CAIRO_CONTENT_ALPHA ) {
+
+ SPColorInterpolation ci_in = get_cairo_surface_ci( surface );
+
+ if( ci_in == SP_CSS_COLOR_INTERPOLATION_SRGB &&
+ ci == SP_CSS_COLOR_INTERPOLATION_LINEARRGB ) {
+ ink_cairo_surface_srgb_to_linear( surface );
+ }
+ if( ci_in == SP_CSS_COLOR_INTERPOLATION_LINEARRGB &&
+ ci == SP_CSS_COLOR_INTERPOLATION_SRGB ) {
+ ink_cairo_surface_linear_to_srgb( surface );
+ }
+
+ cairo_surface_set_user_data(surface, &ci_key, GINT_TO_POINTER (ci), NULL);
+ }
}
void
@@ -627,7 +644,6 @@ int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface)
*reinterpret_cast<guint32*>(data + 4*x) = px2;
}
}
- set_cairo_surface_ci( surface, SP_CSS_COLOR_INTERPOLATION_LINEARRGB );
return width * height;
}
@@ -653,7 +669,6 @@ int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface)
*reinterpret_cast<guint32*>(data + 4*x) = px2;
}
}
- set_cairo_surface_ci( surface, SP_CSS_COLOR_INTERPOLATION_SRGB );
return width * height;
}