libgimpcolor: Port gimp_cairo_checkerboard_create ()...

to GeglColor.
This commit is contained in:
Alx Sa 2024-03-31 01:09:45 +00:00
parent 796ff8233d
commit 99e0446dfd
5 changed files with 43 additions and 33 deletions

View File

@ -114,18 +114,18 @@ gimp_display_shell_draw_checkerboard (GimpDisplayShell *shell,
if (G_UNLIKELY (! shell->checkerboard))
{
GimpCheckSize check_size;
GimpRGB rgb1;
GimpRGB rgb2;
const GeglColor *rgb1;
const GeglColor *rgb2;
g_object_get (shell->display->config,
"transparency-size", &check_size,
NULL);
gegl_color_get_pixel (GEGL_COLOR (gimp_render_check_color1 ()), babl_format ("R'G'B'A double"), &rgb1);
gegl_color_get_pixel (GEGL_COLOR (gimp_render_check_color2 ()), babl_format ("R'G'B'A double"), &rgb2);
rgb1 = gimp_render_check_color1 ();
rgb2 = gimp_render_check_color2 ();
shell->checkerboard =
gimp_cairo_checkerboard_create (cr, 1 << (check_size + 2), &rgb1, &rgb2);
gimp_cairo_checkerboard_create (cr, 1 << (check_size + 2), rgb1, rgb2);
}
cairo_translate (cr, - shell->offset_x, - shell->offset_y);

View File

@ -778,12 +778,12 @@ gimp_view_renderer_real_draw (GimpViewRenderer *renderer,
{
if (! renderer->priv->pattern)
{
GimpRGB rgb1;
GimpRGB rgb2;
const GeglColor *rgb1;
const GeglColor *rgb2;
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color1 (), babl_format ("R'G'B'A double"), &rgb1);
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color2 (), babl_format ("R'G'B'A double"), &rgb2);
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, &rgb1, &rgb2);
rgb1 = gimp_render_check_color1 ();
rgb2 = gimp_render_check_color2 ();
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, rgb1, rgb2);
}
cairo_set_source (cr, renderer->priv->pattern);
@ -1158,12 +1158,12 @@ gimp_view_render_temp_buf_to_surface (GimpViewRenderer *renderer,
{
if (! renderer->priv->pattern)
{
GimpRGB rgb1;
GimpRGB rgb2;
const GeglColor *rgb1;
const GeglColor *rgb2;
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color1 (), babl_format ("R'G'B'A double"), &rgb1);
gegl_color_get_pixel ((GeglColor *) gimp_render_check_color2 (), babl_format ("R'G'B'A double"), &rgb2);
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, &rgb1, &rgb2);
rgb1 = gimp_render_check_color1 ();
rgb2 = gimp_render_check_color2 ();
renderer->priv->pattern = gimp_cairo_checkerboard_create (cr, GIMP_CHECK_SIZE_SM, rgb1, rgb2);
}
}

View File

@ -97,8 +97,8 @@ gimp_cairo_set_source_rgba (cairo_t *cr,
cairo_pattern_t *
gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark)
const GeglColor *light,
const GeglColor *dark)
{
cairo_t *context;
cairo_surface_t *surface;
@ -113,20 +113,34 @@ gimp_cairo_checkerboard_create (cairo_t *cr,
context = cairo_create (surface);
if (light)
gimp_cairo_set_source_rgb (context, light);
{
gdouble rgb[3];
gegl_color_get_pixel (GEGL_COLOR (light), babl_format ("R'G'B' double"), rgb);
cairo_set_source_rgb (context, rgb[0], rgb[1], rgb[2]);
}
else
{
cairo_set_source_rgb (context,
GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT, GIMP_CHECK_LIGHT);
}
cairo_rectangle (context, 0, 0, size, size);
cairo_rectangle (context, size, size, size, size);
cairo_fill (context);
if (dark)
gimp_cairo_set_source_rgb (context, dark);
{
gdouble rgb[3];
gegl_color_get_pixel (GEGL_COLOR (dark), babl_format ("R'G'B' double"), rgb);
cairo_set_source_rgb (context, rgb[0], rgb[1], rgb[2]);
}
else
{
cairo_set_source_rgb (context,
GIMP_CHECK_DARK, GIMP_CHECK_DARK, GIMP_CHECK_DARK);
}
cairo_rectangle (context, 0, size, size, size);
cairo_rectangle (context, size, 0, size, size);

View File

@ -31,8 +31,8 @@ void gimp_cairo_set_source_rgba (cairo_t *cr,
cairo_pattern_t * gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark);
const GeglColor *light,
const GeglColor *dark);
const Babl * gimp_cairo_surface_get_format (cairo_surface_t *surface);
GeglBuffer * gimp_cairo_surface_create_buffer (cairo_surface_t *surface,

View File

@ -641,14 +641,10 @@ repaint_da (GtkWidget *darea,
cairo_pattern_t *check;
GeglColor *color1 = (GeglColor *) gimp_check_custom_color1 ();
GeglColor *color2 = (GeglColor *) gimp_check_custom_color2 ();
GimpRGB rgb1;
GimpRGB rgb2;
gimp_checks_get_colors (gimp_check_type (), &color1, &color2);
gegl_color_get_pixel (color1, babl_format ("R'G'B'A double"), &rgb1);
gegl_color_get_pixel (color2, babl_format ("R'G'B'A double"), &rgb2);
check = gimp_cairo_checkerboard_create (cr, 32, &rgb1, &rgb2);
check = gimp_cairo_checkerboard_create (cr, 32, color1, color2);
cairo_set_source (cr, check);
cairo_paint (cr);