libgimpwidgets/color: move the cairo color utility functions to libgimpcolor

Add CAIRO_CFLAGS to a lot of Makefiles to make this possible, and
because they pull in cairo via the libgimp headers.
This commit is contained in:
Michael Natterer 2011-04-28 15:50:39 +02:00
parent 268930f489
commit cc47b2a600
106 changed files with 428 additions and 257 deletions

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -23,6 +23,7 @@
#include <sys/types.h>
#include <unistd.h>
#include <cairo.h>
#include <glib-object.h>
#include <glib/gstdio.h>

View File

@ -11,6 +11,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)

View File

@ -26,6 +26,7 @@
#include <string.h>
#include <stdio.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -16,6 +16,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -27,6 +27,7 @@
#include <unistd.h>
#endif
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -26,6 +26,7 @@
#include <langinfo.h>
#endif
#include <cairo.h>
#include <glib-object.h>
#include <gobject/gvaluecollector.h>

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -18,6 +18,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gegl-plugin.h>

View File

@ -21,6 +21,7 @@
#include <string.h>
#include <errno.h>
#include <cairo.h>
#include <glib-object.h>
#include <glib/gstdio.h>

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,8 +20,9 @@
#include "config.h"
#include <string.h> /* strcmp */
#include <string.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -19,6 +19,7 @@
#include <stdlib.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -132,6 +132,7 @@
#include <stdio.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include <string.h>
#include <time.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -31,6 +31,7 @@
#define _O_BINARY 0
#endif
#include <cairo.h>
#include <glib-object.h>
#include <glib/gstdio.h>

View File

@ -25,6 +25,7 @@
#include <unistd.h>
#endif
#include <cairo.h>
#include <glib-object.h>
#include <glib/gstdio.h>

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gegl-paramspecs.h>

View File

@ -26,6 +26,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -25,6 +25,7 @@
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display/display-types.h"

View File

@ -20,6 +20,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "display-types.h"

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GEGL_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -22,6 +22,7 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include <glib/gstdio.h>

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpconfig/gimpconfig.h"

View File

@ -23,6 +23,7 @@
#include <errno.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include <glib/gstdio.h>

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include <gegl-buffer-iterator.h>

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl-plugin.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -20,6 +20,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -13,6 +13,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GEGL_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -19,8 +19,6 @@
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
#include "paint-types.h"
#include "base/temp-buf.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GEGL_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -25,7 +25,6 @@
#include <gobject/gvaluecollector.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "pdb-types.h"

View File

@ -23,7 +23,6 @@
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "pdb-types.h"

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <cairo.h>
#include <string.h>
#include <gegl.h>

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbaseenums.h"

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <cairo.h>
#include <string.h>
#include <gegl.h>

View File

@ -19,6 +19,7 @@
#include "config.h"
#include <cairo.h>
#include <string.h>
#include <gegl.h>

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -19,6 +19,8 @@
#include "config.h"
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GEGL_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -17,6 +17,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -23,6 +23,7 @@
#include <string.h>
#include <stdlib.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -22,7 +22,7 @@
#include <string.h>
#include <glib-object.h>
#include <cairo.h>
#include <pango/pango.h>
#include "libgimpbase/gimpbase.h"

View File

@ -22,17 +22,15 @@
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <pango/pangocairo.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#define GIMP_WIDGETS_COMPILATION
#include "libgimpwidgets/gimpcairo-utils.h" /* eek */
#undef GIMP_WIDGETS_COMPILATION
#include "text-types.h"
#include "base/pixel-region.h"

View File

@ -22,8 +22,9 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "widgets-types.h"

View File

@ -8,6 +8,7 @@ INCLUDES = \
-I$(top_srcdir) \
-I$(top_builddir)/app \
-I$(top_srcdir)/app \
$(CAIRO_CFLAGS) \
$(GEGL_CFLAGS) \
$(GDK_PIXBUF_CFLAGS) \
-I$(includedir)

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
#include <stdio.h>
#include <string.h>
#include <cairo.h>
#include <gegl.h>
#include "libgimpbase/gimpbase.h"

View File

@ -20,6 +20,7 @@
<xi:include href="xml/gimpcolormanaged.xml" />
<xi:include href="xml/gimpadaptivesupersample.xml" />
<xi:include href="xml/gimpbilinear.xml" />
<xi:include href="xml/gimpcairocolor.xml" />
</part>
<index id="libgimpcolor-index">

View File

@ -141,3 +141,15 @@ gimp_bilinear_rgb
gimp_bilinear_rgba
gimp_bilinear_pixels_8
</SECTION>
<SECTION>
<FILE>gimpcairocolor</FILE>
<TITLE>GimpCairoColor</TITLE>
gimp_cairo_set_source_rgb
gimp_cairo_set_source_rgba
gimp_cairo_checkerboard_create
GIMP_CAIRO_RGB24_SET_PIXEL
GIMP_CAIRO_RGB24_GET_PIXEL
GIMP_CAIRO_ARGB32_SET_PIXEL
GIMP_CAIRO_ARGB32_GET_PIXEL
</SECTION>

View File

@ -37,15 +37,8 @@ GIMP_BUTTON_GET_CLASS
<SECTION>
<FILE>gimpcairo-utils</FILE>
<TITLE>GimpCairoUtils</TITLE>
gimp_cairo_set_source_rgb
gimp_cairo_set_source_rgba
gimp_cairo_set_focus_line_pattern
gimp_cairo_checkerboard_create
gimp_cairo_surface_create_from_pixbuf
GIMP_CAIRO_RGB24_SET_PIXEL
GIMP_CAIRO_RGB24_GET_PIXEL
GIMP_CAIRO_ARGB32_SET_PIXEL
GIMP_CAIRO_ARGB32_GET_PIXEL
</SECTION>
<SECTION>

View File

@ -27,10 +27,6 @@
#undef __GIMP_LAYER_H__
#include "gimplayer.h"
#define GIMP_WIDGETS_COMPILATION
#include "libgimpwidgets/gimpcairo-utils.h" /* eek */
#undef GIMP_WIDGETS_COMPILATION
/**
* gimp_layer_new:

View File

@ -52,6 +52,7 @@ AM_CPPFLAGS = \
INCLUDES = \
-I$(top_srcdir) \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)
@ -68,6 +69,8 @@ libgimpcolor_2_0_la_SOURCES = \
gimpadaptivesupersample.h \
gimpbilinear.c \
gimpbilinear.h \
gimpcairocolor.c \
gimpcairocolor.h \
gimpcmyk.c \
gimpcmyk.h \
gimpcolormanaged.c \
@ -87,6 +90,7 @@ libgimpcolorinclude_HEADERS = \
gimpcolortypes.h \
gimpadaptivesupersample.h \
gimpbilinear.h \
gimpcairocolor.h \
gimpcmyk.h \
gimpcolormanaged.h \
gimpcolorspace.h \
@ -99,9 +103,14 @@ libgimpcolor_2_0_la_LDFLAGS = \
$(no_undefined) \
$(libgimpcolor_export_symbols)
libgimpcolor_2_0_la_DEPENDENCIES = $(gimpcolor_def) $(libgimpbase)
libgimpcolor_2_0_la_DEPENDENCIES = \
$(gimpcolor_def) \
$(libgimpbase)
libgimpcolor_2_0_la_LIBADD = $(GLIB_LIBS) $(libm)
libgimpcolor_2_0_la_LIBADD = \
$(CAIRO_LIBS) \
$(GLIB_LIBS) \
$(libm)
#
@ -116,6 +125,7 @@ test_color_parser_DEPENDENCIES = \
$(top_builddir)/libgimpcolor/libgimpcolor-$(GIMP_API_VERSION).la
test_color_parser_LDADD = \
$(CAIRO_LIBS) \
$(GLIB_LIBS) \
$(test_color_parser_DEPENDENCIES)

View File

@ -0,0 +1,142 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcairocolor.c
* Copyright (C) 2007 Sven Neumann <sven@gimp.org>
* 2010 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib-object.h>
#include <cairo.h>
#include "libgimpbase/gimpbase.h"
#include "gimpcolortypes.h"
#include "gimpcairocolor.h"
/**
* SECTION: gimpcairocolor
* @title: GimpCairoColor
* @short_description: Color utility functions for cairo
*
* Utility functions that make cairo easier to use with GIMP color
* data types.
**/
/**
* gimp_cairo_set_source_rgb:
* @cr: Cairo context
* @color: GimpRGB color
*
* Sets the source pattern within @cr to the solid opaque color
* described by @color.
*
* This function calls cairo_set_source_rgb() for you.
*
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgb (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgb (cr, color->r, color->g, color->b);
}
/**
* gimp_cairo_set_source_rgba:
* @cr: Cairo context
* @color: GimpRGB color
*
* Sets the source pattern within @cr to the solid translucent color
* described by @color.
*
* This function calls cairo_set_source_rgba() for you.
*
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgba (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgba (cr, color->r, color->g, color->b, color->a);
}
/**
* gimp_cairo_checkerboard_create:
* @cr: Cairo context
* @size: check size
* @light: light check color or %NULL to use the default light gray
* @dark: dark check color or %NULL to use the default dark gray
*
* Create a repeating checkerboard pattern.
*
* Return value: a new Cairo pattern that can be used as a source on @cr.
*
* Since: GIMP 2.6
**/
cairo_pattern_t *
gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark)
{
cairo_t *context;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
g_return_val_if_fail (cr != NULL, NULL);
g_return_val_if_fail (size > 0, NULL);
surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR,
2 * size, 2 * size);
context = cairo_create (surface);
if (light)
gimp_cairo_set_source_rgb (context, light);
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);
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);
cairo_fill (context);
cairo_destroy (context);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_surface_destroy (surface);
return pattern;
}

View File

@ -0,0 +1,156 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* gimpcairocolor.h
* Copyright (C) 2007 Sven Neumann <sven@gimp.org>
* 2010 Michael Natterer <mitch@gimp.org>
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CAIRO_COLOR_H__
#define __GIMP_CAIRO_COLOR_H__
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,
const GimpRGB *light,
const GimpRGB *dark);
/* some useful macros for writing directly to a Cairo surface */
/**
* GIMP_CAIRO_RGB24_SET_PIXEL:
* @d: pointer to the destination buffer
* @r: red component
* @g: green component
* @b: blue component
*
* Sets a single pixel in an Cairo image surface in %CAIRO_FORMAT_RGB24.
*
* Since: GIMP 2.6
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_RGB24_SET_PIXEL(d, r, g, b) \
G_STMT_START { d[0] = (b); d[1] = (g); d[2] = (r); } G_STMT_END
#else
#define GIMP_CAIRO_RGB24_SET_PIXEL(d, r, g, b) \
G_STMT_START { d[1] = (r); d[2] = (g); d[3] = (b); } G_STMT_END
#endif
/**
* GIMP_CAIRO_RGB24_GET_PIXEL:
* @s: pointer to the source buffer
* @r: red component
* @g: green component
* @b: blue component
*
* Gets a single pixel from a Cairo image surface in %CAIRO_FORMAT_RGB24.
*
* Since: GIMP 2.8
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_RGB24_GET_PIXEL(s, r, g, b) \
G_STMT_START { (b) = s[0]; (g) = s[1]; (r) = s[2]; } G_STMT_END
#else
#define GIMP_CAIRO_RGB24_GET_PIXEL(s, r, g, b) \
G_STMT_START { (r) = s[1]; (g) = s[2]; (b) = s[3]; } G_STMT_END
#endif
/**
* GIMP_CAIRO_ARGB32_SET_PIXEL:
* @d: pointer to the destination buffer
* @r: red component, not pre-multiplied
* @g: green component, not pre-multiplied
* @b: blue component, not pre-multiplied
* @a: alpha component
*
* Sets a single pixel in an Cairo image surface in %CAIRO_FORMAT_ARGB32.
*
* Since: GIMP 2.6
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (((tb) >> 8) + (tb)) >> 8; \
(d)[1] = (((tg) >> 8) + (tg)) >> 8; \
(d)[2] = (((tr) >> 8) + (tr)) >> 8; \
(d)[3] = (a); \
} G_STMT_END
#else
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (a); \
(d)[1] = (((tr) >> 8) + (tr)) >> 8; \
(d)[2] = (((tg) >> 8) + (tg)) >> 8; \
(d)[3] = (((tb) >> 8) + (tb)) >> 8; \
} G_STMT_END
#endif
/**
* GIMP_CAIRO_ARGB32_GET_PIXEL:
* @s: pointer to the source buffer
* @r: red component, not pre-multiplied
* @g: green component, not pre-multiplied
* @b: blue component, not pre-multiplied
* @a: alpha component
*
* Gets a single pixel from a Cairo image surface in %CAIRO_FORMAT_ARGB32.
*
* Since: GIMP 2.8
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_ARGB32_GET_PIXEL(s, r, g, b, a) \
G_STMT_START { \
const guint tb = (s)[0]; \
const guint tg = (s)[1]; \
const guint tr = (s)[2]; \
const guint ta = (s)[3]; \
(r) = (tr << 8) / (ta + 1); \
(g) = (tg << 8) / (ta + 1); \
(b) = (tb << 8) / (ta + 1); \
(a) = ta; \
} G_STMT_END
#else
#define GIMP_CAIRO_ARGB32_GET_PIXEL(s, r, g, b, a) \
G_STMT_START { \
const guint ta = (s)[0]; \
const guint tr = (s)[1]; \
const guint tg = (s)[2]; \
const guint tb = (s)[3]; \
(r) = (tr << 8) / (ta + 1); \
(g) = (tg << 8) / (ta + 1); \
(b) = (tb << 8) / (ta + 1); \
(a) = ta; \
} G_STMT_END
#endif
#endif /* __GIMP_CAIRO_COLOR_H__ */

View File

@ -25,6 +25,7 @@
#include <libgimpcolor/gimpadaptivesupersample.h>
#include <libgimpcolor/gimpbilinear.h>
#include <libgimpcolor/gimpcairocolor.h>
#include <libgimpcolor/gimpcolormanaged.h>
#include <libgimpcolor/gimpcolorspace.h>
#include <libgimpcolor/gimpcmyk.h>

View File

@ -49,6 +49,7 @@ AM_CPPFLAGS = \
INCLUDES = \
-I$(top_srcdir) \
$(CAIRO_CFLAGS) \
$(GLIB_CFLAGS) \
-I$(includedir)
@ -116,6 +117,7 @@ libgimpconfig_2_0_la_LIBADD = \
$(libgimpbase) \
$(libgimpcolor) \
$(libgimpmath) \
$(CAIRO_LIBS) \
$(GLIB_LIBS)

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -21,6 +21,7 @@
#include "config.h"
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -25,6 +25,7 @@
#include <string.h>
#include <errno.h>
#include <cairo.h>
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"

View File

@ -41,44 +41,6 @@
**/
/**
* gimp_cairo_set_source_rgb:
* @cr: Cairo context
* @color: GimpRGB color
*
* Sets the source pattern within @cr to the solid opaque color
* described by @color.
*
* This function calls cairo_set_source_rgb() for you.
*
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgb (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgb (cr, color->r, color->g, color->b);
}
/**
* gimp_cairo_set_source_rgba:
* @cr: Cairo context
* @color: GimpRGB color
*
* Sets the source pattern within @cr to the solid translucent color
* described by @color.
*
* This function calls cairo_set_source_rgba() for you.
*
* Since: GIMP 2.6
**/
void
gimp_cairo_set_source_rgba (cairo_t *cr,
const GimpRGB *color)
{
cairo_set_source_rgba (cr, color->r, color->g, color->b, color->a);
}
/**
* gimp_cairo_set_focus_line_pattern:
* @cr: Cairo context
@ -133,67 +95,6 @@ gimp_cairo_set_focus_line_pattern (cairo_t *cr,
return retval;
}
/**
* gimp_cairo_checkerboard_create:
* @cr: Cairo context
* @size: check size
* @light: light check color or %NULL to use the default light gray
* @dark: dark check color or %NULL to use the default dark gray
*
* Create a repeating checkerboard pattern.
*
* Return value: a new Cairo pattern that can be used as a source on @cr.
*
* Since: GIMP 2.6
**/
cairo_pattern_t *
gimp_cairo_checkerboard_create (cairo_t *cr,
gint size,
const GimpRGB *light,
const GimpRGB *dark)
{
cairo_t *context;
cairo_surface_t *surface;
cairo_pattern_t *pattern;
g_return_val_if_fail (cr != NULL, NULL);
g_return_val_if_fail (size > 0, NULL);
surface = cairo_surface_create_similar (cairo_get_target (cr),
CAIRO_CONTENT_COLOR,
2 * size, 2 * size);
context = cairo_create (surface);
if (light)
gimp_cairo_set_source_rgb (context, light);
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);
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);
cairo_fill (context);
cairo_destroy (context);
pattern = cairo_pattern_create_for_surface (surface);
cairo_pattern_set_extend (pattern, CAIRO_EXTEND_REPEAT);
cairo_surface_destroy (surface);
return pattern;
}
/**
* gimp_cairo_surface_create_from_pixbuf:
* @pixbuf: a #GdkPixbuf

View File

@ -27,143 +27,10 @@
#define __GIMP_CAIRO_UTILS_H__
void gimp_cairo_set_source_rgb (cairo_t *cr,
const GimpRGB *color);
void gimp_cairo_set_source_rgba (cairo_t *cr,
const GimpRGB *color);
/* This is a bad hack that allows to include this file from the app's
* non-gui files. I haven't decided yet how to split this header and
* where to move the non-GTK+ part. --Mitch
*/
#ifdef __GTK_H__
gboolean gimp_cairo_set_focus_line_pattern (cairo_t *cr,
GtkWidget *widget);
#endif
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 */
/**
* GIMP_CAIRO_RGB24_SET_PIXEL:
* @d: pointer to the destination buffer
* @r: red component
* @g: green component
* @b: blue component
*
* Sets a single pixel in an Cairo image surface in %CAIRO_FORMAT_RGB24.
*
* Since: GIMP 2.6
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_RGB24_SET_PIXEL(d, r, g, b) \
G_STMT_START { d[0] = (b); d[1] = (g); d[2] = (r); } G_STMT_END
#else
#define GIMP_CAIRO_RGB24_SET_PIXEL(d, r, g, b) \
G_STMT_START { d[1] = (r); d[2] = (g); d[3] = (b); } G_STMT_END
#endif
/**
* GIMP_CAIRO_RGB24_GET_PIXEL:
* @s: pointer to the source buffer
* @r: red component
* @g: green component
* @b: blue component
*
* Gets a single pixel from a Cairo image surface in %CAIRO_FORMAT_RGB24.
*
* Since: GIMP 2.8
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_RGB24_GET_PIXEL(s, r, g, b) \
G_STMT_START { (b) = s[0]; (g) = s[1]; (r) = s[2]; } G_STMT_END
#else
#define GIMP_CAIRO_RGB24_GET_PIXEL(s, r, g, b) \
G_STMT_START { (r) = s[1]; (g) = s[2]; (b) = s[3]; } G_STMT_END
#endif
/**
* GIMP_CAIRO_ARGB32_SET_PIXEL:
* @d: pointer to the destination buffer
* @r: red component, not pre-multiplied
* @g: green component, not pre-multiplied
* @b: blue component, not pre-multiplied
* @a: alpha component
*
* Sets a single pixel in an Cairo image surface in %CAIRO_FORMAT_ARGB32.
*
* Since: GIMP 2.6
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (((tb) >> 8) + (tb)) >> 8; \
(d)[1] = (((tg) >> 8) + (tg)) >> 8; \
(d)[2] = (((tr) >> 8) + (tr)) >> 8; \
(d)[3] = (a); \
} G_STMT_END
#else
#define GIMP_CAIRO_ARGB32_SET_PIXEL(d, r, g, b, a) \
G_STMT_START { \
const guint tr = (a) * (r) + 0x80; \
const guint tg = (a) * (g) + 0x80; \
const guint tb = (a) * (b) + 0x80; \
(d)[0] = (a); \
(d)[1] = (((tr) >> 8) + (tr)) >> 8; \
(d)[2] = (((tg) >> 8) + (tg)) >> 8; \
(d)[3] = (((tb) >> 8) + (tb)) >> 8; \
} G_STMT_END
#endif
/**
* GIMP_CAIRO_ARGB32_GET_PIXEL:
* @s: pointer to the source buffer
* @r: red component, not pre-multiplied
* @g: green component, not pre-multiplied
* @b: blue component, not pre-multiplied
* @a: alpha component
*
* Gets a single pixel from a Cairo image surface in %CAIRO_FORMAT_ARGB32.
*
* Since: GIMP 2.8
**/
#if G_BYTE_ORDER == G_LITTLE_ENDIAN
#define GIMP_CAIRO_ARGB32_GET_PIXEL(s, r, g, b, a) \
G_STMT_START { \
const guint tb = (s)[0]; \
const guint tg = (s)[1]; \
const guint tr = (s)[2]; \
const guint ta = (s)[3]; \
(r) = (tr << 8) / (ta + 1); \
(g) = (tg << 8) / (ta + 1); \
(b) = (tb << 8) / (ta + 1); \
(a) = ta; \
} G_STMT_END
#else
#define GIMP_CAIRO_ARGB32_GET_PIXEL(s, r, g, b, a) \
G_STMT_START { \
const guint ta = (s)[0]; \
const guint tr = (s)[1]; \
const guint tg = (s)[2]; \
const guint tb = (s)[3]; \
(r) = (tr << 8) / (ta + 1); \
(g) = (tg << 8) / (ta + 1); \
(b) = (tb << 8) / (ta + 1); \
(a) = ta; \
} G_STMT_END
#endif
#endif /* __GIMP_CAIRO_UTILS_H__ */

Some files were not shown because too many files have changed in this diff Show More