Commit cff05ac1 authored by Sebastian Ramacher's avatar Sebastian Ramacher

Replace some GdkColors with GdkRGBA

Signed-off-by: Sebastian Ramacher's avatarSebastian Ramacher <sebastian+dev@ramacher.at>
parent 08a72c46
...@@ -464,9 +464,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) ...@@ -464,9 +464,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
} else { } else {
/* set background color */ /* set background color */
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) { if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
GdkColor color; GdkRGBA color;
zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, &color, NULL); zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, &color, NULL);
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); cairo_set_source_rgb(cairo, color.red, color.green, color.blue);
} else { } else {
GdkColor color = priv->zathura->ui.colors.render_loading_bg; GdkColor color = priv->zathura->ui.colors.render_loading_bg;
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0);
...@@ -480,9 +480,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo) ...@@ -480,9 +480,9 @@ zathura_page_widget_draw(GtkWidget* widget, cairo_t* cairo)
/* write text */ /* write text */
if (render_loading == true) { if (render_loading == true) {
if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) { if (zathura_renderer_recolor_enabled(priv->zathura->sync.render_thread) == true) {
GdkColor color; GdkRGBA color;
zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, NULL, &color); zathura_renderer_get_recolor_colors(priv->zathura->sync.render_thread, NULL, &color);
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); cairo_set_source_rgb(cairo, color.red, color.green, color.blue);
} else { } else {
GdkColor color = priv->zathura->ui.colors.render_loading_fg; GdkColor color = priv->zathura->ui.colors.render_loading_fg;
cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0); cairo_set_source_rgb(cairo, color.red/65535.0, color.green/65535.0, color.blue/65535.0);
......
/* See LICENSE file for license and copyright information */ /* See LICENSE file for license and copyright information */
#include <math.h> #include <math.h>
#include <string.h>
#include <girara/datastructures.h> #include <girara/datastructures.h>
#include <girara/utils.h> #include <girara/utils.h>
#include "glib-compat.h" #include "glib-compat.h"
...@@ -24,7 +25,6 @@ static void render_request_finalize(GObject* object); ...@@ -24,7 +25,6 @@ static void render_request_finalize(GObject* object);
static void render_job(void* data, void* user_data); static void render_job(void* data, void* user_data);
static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data); static gint render_thread_sort(gconstpointer a, gconstpointer b, gpointer data);
static void color2double(const GdkColor* col, double* v);
static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer); static ssize_t page_cache_lru_invalidate(ZathuraRenderer* renderer);
static void page_cache_invalidate_all(ZathuraRenderer* renderer); static void page_cache_invalidate_all(ZathuraRenderer* renderer);
static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result); static bool page_cache_is_full(ZathuraRenderer* renderer, bool* result);
...@@ -43,10 +43,8 @@ typedef struct private_s { ...@@ -43,10 +43,8 @@ typedef struct private_s {
bool enabled; bool enabled;
bool hue; bool hue;
double light[3]; GdkRGBA light;
GdkColor light_gdk; GdkRGBA dark;
double dark[3];
GdkColor dark_gdk;
} recolor; } recolor;
/* /*
...@@ -317,22 +315,16 @@ zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable) ...@@ -317,22 +315,16 @@ zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, bool enable)
void void
zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer, zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
const GdkColor* light, const GdkColor* dark) const GdkRGBA* light, const GdkRGBA* dark)
{ {
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
private_t* priv = GET_PRIVATE(renderer); private_t* priv = GET_PRIVATE(renderer);
if (light != NULL) { if (light != NULL) {
priv->recolor.light_gdk.red = light->red; memcpy(&priv->recolor.light, light, sizeof(GdkRGBA));
priv->recolor.light_gdk.blue = light->blue;
priv->recolor.light_gdk.green = light->green;
color2double(light, priv->recolor.light);
} }
if (dark != NULL) { if (dark != NULL) {
priv->recolor.dark_gdk.red = dark->red; memcpy(&priv->recolor.dark, dark, sizeof(GdkRGBA));
priv->recolor.dark_gdk.blue = dark->blue;
priv->recolor.dark_gdk.green = dark->green;
color2double(dark, priv->recolor.dark);
} }
} }
...@@ -343,33 +335,29 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer, ...@@ -343,33 +335,29 @@ zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
if (dark != NULL) { if (dark != NULL) {
GdkColor color; GdkRGBA color;
gdk_color_parse(dark, &color); gdk_rgba_parse(&color, dark);
zathura_renderer_set_recolor_colors(renderer, NULL, &color); zathura_renderer_set_recolor_colors(renderer, NULL, &color);
} }
if (light != NULL) { if (light != NULL) {
GdkColor color; GdkRGBA color;
gdk_color_parse(light, &color); gdk_rgba_parse(&color, light);
zathura_renderer_set_recolor_colors(renderer, &color, NULL); zathura_renderer_set_recolor_colors(renderer, &color, NULL);
} }
} }
void void
zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer, zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
GdkColor* light, GdkColor* dark) GdkRGBA* light, GdkRGBA* dark)
{ {
g_return_if_fail(ZATHURA_IS_RENDERER(renderer)); g_return_if_fail(ZATHURA_IS_RENDERER(renderer));
private_t* priv = GET_PRIVATE(renderer); private_t* priv = GET_PRIVATE(renderer);
if (light != NULL) { if (light != NULL) {
light->red = priv->recolor.light_gdk.red; memcpy(light, &priv->recolor.light, sizeof(GdkRGBA));
light->blue = priv->recolor.light_gdk.blue;
light->green = priv->recolor.light_gdk.green;
} }
if (dark != NULL) { if (dark != NULL) {
dark->red = priv->recolor.dark_gdk.red; memcpy(dark, &priv->recolor.dark, sizeof(GdkRGBA));
dark->blue = priv->recolor.dark_gdk.blue;
dark->green = priv->recolor.dark_gdk.green;
} }
} }
...@@ -503,14 +491,6 @@ emit_completed_signal(void* data) ...@@ -503,14 +491,6 @@ emit_completed_signal(void* data)
return FALSE; return FALSE;
} }
static void
color2double(const GdkColor* col, double* v)
{
v[0] = (double) col->red / 65535.;
v[1] = (double) col->green / 65535.;
v[2] = (double) col->blue / 65535.;
}
/* Returns the maximum possible saturation for given h and l. /* Returns the maximum possible saturation for given h and l.
Assumes that l is in the interval l1, l2 and corrects the value to Assumes that l is in the interval l1, l2 and corrects the value to
force u=0 on l1 and l2 */ force u=0 on l1 and l2 */
...@@ -575,13 +555,13 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height, ...@@ -575,13 +555,13 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height,
#define rgb1 priv->recolor.dark #define rgb1 priv->recolor.dark
#define rgb2 priv->recolor.light #define rgb2 priv->recolor.light
const double l1 = (a[0]*rgb1[0] + a[1]*rgb1[1] + a[2]*rgb1[2]); const double l1 = a[0]*rgb1.red + a[1]*rgb1.green + a[2]*rgb1.blue;
const double l2 = (a[0]*rgb2[0] + a[1]*rgb2[1] + a[2]*rgb2[2]); const double l2 = a[0]*rgb2.red + a[1]*rgb2.green + a[2]*rgb2.blue;
const double rgb_diff[] = { const double rgb_diff[] = {
rgb2[0] - rgb1[0], rgb2.red - rgb1.red,
rgb2[1] - rgb1[1], rgb2.green - rgb1.green,
rgb2[2] - rgb1[2] rgb2.blue - rgb1.blue
}; };
for (unsigned int y = 0; y < page_height; y++) { for (unsigned int y = 0; y < page_height; y++) {
...@@ -626,9 +606,9 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height, ...@@ -626,9 +606,9 @@ recolor(private_t* priv, unsigned int page_width, unsigned int page_height,
} else { } else {
/* linear interpolation between dark and light with color ligtness as /* linear interpolation between dark and light with color ligtness as
* a parameter */ * a parameter */
data[2] = (unsigned char)round(255.*(l * rgb_diff[0] + rgb1[0])); data[2] = (unsigned char)round(255.*(l * rgb_diff[0] + rgb1.red));
data[1] = (unsigned char)round(255.*(l * rgb_diff[1] + rgb1[1])); data[1] = (unsigned char)round(255.*(l * rgb_diff[1] + rgb1.green));
data[0] = (unsigned char)round(255.*(l * rgb_diff[2] + rgb1[2])); data[0] = (unsigned char)round(255.*(l * rgb_diff[2] + rgb1.blue));
} }
} }
} }
......
...@@ -78,7 +78,7 @@ void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer, ...@@ -78,7 +78,7 @@ void zathura_renderer_enable_recolor_hue(ZathuraRenderer* renderer,
* @param dark dark color * @param dark dark color
*/ */
void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer, void zathura_renderer_set_recolor_colors(ZathuraRenderer* renderer,
const GdkColor* light, const GdkColor* dark); const GdkRGBA* light, const GdkRGBA* dark);
/** /**
* Set light and dark colors for recoloring. * Set light and dark colors for recoloring.
* @param renderer a renderer object * @param renderer a renderer object
...@@ -94,7 +94,7 @@ void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer, ...@@ -94,7 +94,7 @@ void zathura_renderer_set_recolor_colors_str(ZathuraRenderer* renderer,
* @param dark dark color * @param dark dark color
*/ */
void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer, void zathura_renderer_get_recolor_colors(ZathuraRenderer* renderer,
GdkColor* light, GdkColor* dark); GdkRGBA* light, GdkRGBA* dark);
/** /**
* Stop rendering. * Stop rendering.
* @param renderer a render object * @param renderer a render object
......
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