Commit b194e6fb authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

addec const qualifiers to GimpRGB parameters.

2007-12-28  Sven Neumann  <sven@gimp.org>

	* libgimpwidgets/gimpcairo-utils.[ch]: addec const qualifiers to
	GimpRGB parameters.

	* app/widgets/gimprender.[ch]: removed global variables for
	checkerboard colors and introduced functions to get the
	checkerboard colors as pointers to GimpRGB structs.

	* app/actions/view-actions.c
	* app/display/gimpdisplayshell-appearance.c
	* app/widgets/gimpviewrenderer.c
	* app/widgets/gimpcolormapeditor.c: changed accordingly.


svn path=/trunk/; revision=24451
parent 26f6ca6d
2007-12-28 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcairo-utils.[ch]: addec const qualifiers to
GimpRGB parameters.
* app/widgets/gimprender.[ch]: removed global variables for
checkerboard colors and introduced functions to get the
checkerboard colors as pointers to GimpRGB structs.
* app/actions/view-actions.c
* app/display/gimpdisplayshell-appearance.c
* app/widgets/gimpviewrenderer.c
* app/widgets/gimpcolormapeditor.c: changed accordingly.
2007-12-28 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimpcairo-utils.[ch]: added light and dark check
......
......@@ -725,21 +725,10 @@ view_actions_check_type_notify (GimpDisplayConfig *config,
GParamSpec *pspec,
GimpActionGroup *group)
{
GimpRGB color;
gimp_rgba_set_uchar (&color,
gimp_render_light_check,
gimp_render_light_check,
gimp_render_light_check,
255);
gimp_action_group_set_action_color (group, "view-padding-color-light-check",
&color, FALSE);
gimp_rgba_set_uchar (&color,
gimp_render_dark_check,
gimp_render_dark_check,
gimp_render_dark_check,
255);
gimp_render_light_check_color (),
FALSE);
gimp_action_group_set_action_color (group, "view-padding-color-dark-check",
&color, FALSE);
gimp_render_dark_check_color (),
FALSE);
}
......@@ -539,17 +539,11 @@ gimp_display_shell_set_padding (GimpDisplayShell *shell,
break;
case GIMP_CANVAS_PADDING_MODE_LIGHT_CHECK:
gimp_rgb_set_uchar (&color,
gimp_render_light_check,
gimp_render_light_check,
gimp_render_light_check);
color = *gimp_render_light_check_color ();
break;
case GIMP_CANVAS_PADDING_MODE_DARK_CHECK:
gimp_rgb_set_uchar (&color,
gimp_render_dark_check,
gimp_render_dark_check,
gimp_render_dark_check);
color = *gimp_render_dark_check_color ();
break;
case GIMP_CANVAS_PADDING_MODE_CUSTOM:
......
......@@ -510,8 +510,8 @@ gimp_colormap_editor_draw (GimpColormapEditor *editor)
row[l * 3 + b] = (((((i * cellsize + k) & 0x4) ?
(l) :
(l + 0x4)) & 0x4) ?
gimp_render_light_check :
gimp_render_dark_check);
gimp_render_blend_dark_check[0] :
gimp_render_blend_light_check[0]);
gtk_preview_draw_row (GTK_PREVIEW (editor->preview), row, 0,
i * cellsize + k,
......@@ -622,7 +622,7 @@ gimp_colormap_editor_clear (GimpColormapEditor *editor,
{
row[j * 3 + 0] = row[j * 3 + 1] = row[j * 3 + 2] =
((j + offset) & 0x4) ?
gimp_render_dark_check : gimp_render_light_check;
gimp_render_blend_dark_check[0] : gimp_render_blend_light_check[0];
}
for (j = 0; j < (4 - (start_row & 0x3)) && start_row + j < height; j++)
......
......@@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "widgets-types.h"
......@@ -37,9 +38,7 @@ static void gimp_render_setup_notify (gpointer config,
Gimp *gimp);
/* accelerate transparency of image scaling */
guchar gimp_render_dark_check;
guchar gimp_render_light_check;
/* accelerate blending on the checkerboard */
guchar *gimp_render_check_buf = NULL;
guchar *gimp_render_empty_buf = NULL;
......@@ -50,6 +49,10 @@ guchar *gimp_render_blend_light_check = NULL;
guchar *gimp_render_blend_white = NULL;
static GimpRGB light;
static GimpRGB dark;
void
gimp_render_init (Gimp *gimp)
{
......@@ -108,6 +111,17 @@ gimp_render_exit (Gimp *gimp)
}
}
const GimpRGB *
gimp_render_light_check_color (void)
{
return &light;
}
const GimpRGB *
gimp_render_dark_check_color (void)
{
return &dark;
}
static void
gimp_render_setup_notify (gpointer config,
......@@ -115,14 +129,18 @@ gimp_render_setup_notify (gpointer config,
Gimp *gimp)
{
GimpCheckType check_type;
guchar dark_check;
guchar light_check;
gint i, j;
g_object_get (config,
"transparency-type", &check_type,
NULL);
gimp_checks_get_shades (check_type,
&gimp_render_light_check, &gimp_render_dark_check);
gimp_checks_get_shades (check_type, &light_check, &dark_check);
gimp_rgba_set_uchar (&light, light_check, light_check, light_check, 255);
gimp_rgba_set_uchar (&dark, dark_check, dark_check, dark_check, 255);
if (! gimp_render_blend_dark_check)
gimp_render_blend_dark_check = g_new (guchar, 65536);
......@@ -137,10 +155,10 @@ gimp_render_setup_notify (gpointer config,
for (j = 0; j < 256; j++)
{
gimp_render_blend_dark_check [(i << 8) + j] =
(guchar) ((j * i + gimp_render_dark_check * (255 - i)) / 255);
(guchar) ((j * i + dark_check * (255 - i)) / 255);
gimp_render_blend_light_check [(i << 8) + j] =
(guchar) ((j * i + gimp_render_light_check * (255 - i)) / 255);
(guchar) ((j * i + light_check * (255 - i)) / 255);
gimp_render_blend_white [(i << 8) + j] =
(guchar) ((j * i + 255 * (255 - i)) / 255);
......@@ -165,15 +183,15 @@ gimp_render_setup_notify (gpointer config,
{
if (i & 0x4)
{
gimp_render_check_buf[i * 3 + 0] = gimp_render_dark_check;
gimp_render_check_buf[i * 3 + 1] = gimp_render_dark_check;
gimp_render_check_buf[i * 3 + 2] = gimp_render_dark_check;
gimp_render_check_buf[i * 3 + 0] = dark_check;
gimp_render_check_buf[i * 3 + 1] = dark_check;
gimp_render_check_buf[i * 3 + 2] = dark_check;
}
else
{
gimp_render_check_buf[i * 3 + 0] = gimp_render_light_check;
gimp_render_check_buf[i * 3 + 1] = gimp_render_light_check;
gimp_render_check_buf[i * 3 + 2] = gimp_render_light_check;
gimp_render_check_buf[i * 3 + 0] = light_check;
gimp_render_check_buf[i * 3 + 1] = light_check;
gimp_render_check_buf[i * 3 + 2] = light_check;
}
}
......
......@@ -23,10 +23,6 @@
#define GIMP_RENDER_BUF_WIDTH 256
#define GIMP_RENDER_BUF_HEIGHT 256
/* the dark and light checkerboard colors */
extern guchar gimp_render_dark_check;
extern guchar gimp_render_light_check;
/* buffers that contain pre-rendered patterns/colors */
extern guchar *gimp_render_check_buf;
extern guchar *gimp_render_empty_buf;
......@@ -38,8 +34,11 @@ extern guchar *gimp_render_blend_light_check;
extern guchar *gimp_render_blend_white;
void gimp_render_init (Gimp *gimp);
void gimp_render_exit (Gimp *gimp);
void gimp_render_init (Gimp *gimp);
void gimp_render_exit (Gimp *gimp);
const GimpRGB * gimp_render_light_check_color (void);
const GimpRGB * gimp_render_dark_check_color (void);
#endif /* __GIMP_RENDER_H__ */
......@@ -727,22 +727,10 @@ gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
{
if (! renderer->pattern)
{
GimpRGB light;
GimpRGB dark;
gimp_rgb_set_uchar (&light,
gimp_render_light_check,
gimp_render_light_check,
gimp_render_light_check);
gimp_rgb_set_uchar (&dark,
gimp_render_dark_check,
gimp_render_dark_check,
gimp_render_dark_check);
renderer->pattern =
gimp_cairo_checkerboard_create (cr,
GIMP_CHECK_SIZE_SM,
&light, &dark);
gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM,
gimp_render_light_check_color (),
gimp_render_dark_check_color ());
}
cairo_set_source (cr, renderer->pattern);
......
......@@ -45,8 +45,8 @@
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgb (cairo_t *cr,
GimpRGB *color)
gimp_cairo_set_source_rgb (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgb (cr, color->r, color->g, color->b);
}
......@@ -64,8 +64,8 @@ gimp_cairo_set_source_rgb (cairo_t *cr,
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgba (cairo_t *cr,
GimpRGB *color)
gimp_cairo_set_source_rgba (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgba (cr, color->r, color->g, color->b, color->a);
}
......@@ -138,10 +138,10 @@ gimp_cairo_set_focus_line_pattern (cairo_t *cr,
* Since: GIMP 2.6
**/
cairo_pattern_t *
gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
GimpRGB *light,
GimpRGB *dark)
gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark)
{
cairo_t *context;
cairo_surface_t *surface;
......
......@@ -24,18 +24,20 @@
#define __GIMP_CAIRO_UTILS_H__
void gimp_cairo_set_source_rgb (cairo_t *cr,
GimpRGB *color);
void gimp_cairo_set_source_rgba (cairo_t *cr,
GimpRGB *color);
gboolean gimp_cairo_set_focus_line_pattern (cairo_t *cr,
GtkWidget *widget);
void gimp_cairo_set_source_rgb (cairo_t *cr,
const GimpRGB *color);
void gimp_cairo_set_source_rgba (cairo_t *cr,
const GimpRGB *color);
cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
GimpRGB *light,
GimpRGB *dark);
cairo_surface_t * gimp_cairo_surface_create_from_pixbuf (GdkPixbuf *pixbuf);
gboolean gimp_cairo_set_focus_line_pattern (cairo_t *cr,
GtkWidget *widget);
cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark);
cairo_surface_t * gimp_cairo_surface_create_from_pixbuf (GdkPixbuf *pixbuf);
/* some useful macros for writing directly to a Cairo surface */
......
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