summaryrefslogtreecommitdiffstats
path: root/src/display/cairo-utils.h
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2013-01-30 20:47:35 +0000
committerJohan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl>2013-01-30 20:47:35 +0000
commita7c6061c0b32affc13bfb818161ca7fc002ef210 (patch)
tree502ca040c51e2a2adfd973bbc2472c1b7e20f84f /src/display/cairo-utils.h
parentremoving some more unused functions (diff)
downloadinkscape-a7c6061c0b32affc13bfb818161ca7fc002ef210.tar.gz
inkscape-a7c6061c0b32affc13bfb818161ca7fc002ef210.zip
code cleanup. don't use pointers when you don't have to. use const whereever you can.
(bzr r12077)
Diffstat (limited to 'src/display/cairo-utils.h')
-rw-r--r--src/display/cairo-utils.h17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h
index 04d6c6810..2596cd969 100644
--- a/src/display/cairo-utils.h
+++ b/src/display/cairo-utils.h
@@ -108,7 +108,7 @@ guint32 ink_cairo_surface_average_color(cairo_surface_t *surface);
void ink_cairo_surface_average_color(cairo_surface_t *surface, double &r, double &g, double &b, double &a);
void ink_cairo_surface_average_color_premul(cairo_surface_t *surface, double &r, double &g, double &b, double &a);
-void srgb_to_linear( double *c);
+double srgb_to_linear( const double c );
int ink_cairo_surface_srgb_to_linear(cairo_surface_t *surface);
int ink_cairo_surface_linear_to_srgb(cairo_surface_t *surface);
@@ -128,13 +128,13 @@ G_GNUC_CONST guint32 argb32_from_rgba(guint32 in);
G_GNUC_CONST inline guint32
-premul_alpha(guint32 color, guint32 alpha)
+premul_alpha(const guint32 color, const guint32 alpha)
{
- guint32 temp = alpha * color + 128;
+ const guint32 temp = alpha * color + 128;
return (temp + (temp >> 8)) >> 8;
}
G_GNUC_CONST inline guint32
-unpremul_alpha(guint32 color, guint32 alpha)
+unpremul_alpha(const guint32 color, const guint32 alpha)
{
// NOTE: you must check for alpha != 0 yourself.
return (255 * color + alpha/2) / alpha;
@@ -154,6 +154,15 @@ void feed_pathvector_to_cairo (cairo_t *ct, Geom::PathVector const &pathv);
#define ASSEMBLE_ARGB32(px,a,r,g,b) \
guint32 px = (a << 24) | (r << 16) | (g << 8) | b;
+inline double srgb_to_linear( const double c ) {
+ if( c < 0.04045 ) {
+ return c / 12.92;
+ } else {
+ return pow( (c+0.055)/1.055, 2.4 );
+ }
+}
+
+
namespace Inkscape {
namespace Display