aboutsummaryrefslogtreecommitdiff
path: root/fiv-io-profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'fiv-io-profile.c')
-rw-r--r--fiv-io-profile.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/fiv-io-profile.c b/fiv-io-profile.c
index 2c6f345..4e51848 100644
--- a/fiv-io-profile.c
+++ b/fiv-io-profile.c
@@ -34,7 +34,7 @@
static bool g_broken_cms_premul;
void
-fiv_io_profile_init(void)
+fiv_io_cmm_init(void)
{
// TODO(p): Use Little CMS with contexts instead.
#ifdef HAVE_LCMS2_FAST_FLOAT
@@ -43,6 +43,13 @@ fiv_io_profile_init(void)
#endif // HAVE_LCMS2_FAST_FLOAT
}
+FivIoCmm *
+fiv_io_cmm_get_default()
+{
+ // TODO: Maintain a singleton for the NULL cmsContext.
+ return NULL;
+}
+
FivIoProfile *
fiv_io_profile_new(const void *data, size_t len)
{
@@ -180,7 +187,7 @@ trivial_cmyk_to_host_byte_order_argb(unsigned char *p, int len)
}
void
-fiv_io_profile_cmyk(
+fiv_io_cmm_cmyk(FivIoCmm *self,
FivIoImage *image, FivIoProfile *source, FivIoProfile *target)
{
#ifndef HAVE_LCMS2
@@ -204,7 +211,7 @@ fiv_io_profile_cmyk(
}
static bool
-fiv_io_profile_rgb_direct(unsigned char *data, int w, int h,
+fiv_io_cmm_rgb_direct(FivIoCmm *self, unsigned char *data, int w, int h,
FivIoProfile *source, FivIoProfile *target,
uint32_t source_format, uint32_t target_format)
{
@@ -239,26 +246,26 @@ fiv_io_profile_rgb_direct(unsigned char *data, int w, int h,
}
static void
-fiv_io_profile_xrgb32(
+fiv_io_cmm_xrgb32(FivIoCmm *self,
FivIoImage *image, FivIoProfile *source, FivIoProfile *target)
{
- fiv_io_profile_rgb_direct(image->data, image->width, image->height,
+ fiv_io_cmm_rgb_direct(self, image->data, image->width, image->height,
source, target, FIV_IO_PROFILE_ARGB32, FIV_IO_PROFILE_ARGB32);
}
void
-fiv_io_profile_4x16le_direct(unsigned char *data,
+fiv_io_cmm_4x16le_direct(FivIoCmm *self, unsigned char *data,
int w, int h, FivIoProfile *source, FivIoProfile *target)
{
- fiv_io_profile_rgb_direct(data, w, h, source, target,
+ fiv_io_cmm_rgb_direct(self, data, w, h, source, target,
FIV_IO_PROFILE_4X16LE, FIV_IO_PROFILE_4X16LE);
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void
-fiv_io_profile_page(FivIoImage *page, FivIoProfile *target,
- void (*frame_cb) (FivIoImage *, FivIoProfile *, FivIoProfile *))
+fiv_io_cmm_page(FivIoCmm *self, FivIoImage *page, FivIoProfile *target,
+ void (*frame_cb) (FivIoCmm *, FivIoImage *, FivIoProfile *, FivIoProfile *))
{
FivIoProfile *source = NULL;
if (page->icc)
@@ -266,7 +273,7 @@ fiv_io_profile_page(FivIoImage *page, FivIoProfile *target,
// TODO(p): All animations need to be composited in a linear colour space.
for (FivIoImage *frame = page; frame != NULL; frame = frame->frame_next)
- frame_cb(frame, source, target);
+ frame_cb(self, frame, source, target);
if (source)
fiv_io_profile_free(source);
@@ -299,28 +306,28 @@ fiv_io_premultiply_argb32(FivIoImage *image)
(G_BYTE_ORDER == G_LITTLE_ENDIAN ? TYPE_BGRA_8_PREMUL : TYPE_ARGB_8_PREMUL)
static void
-fiv_io_profile_argb32(FivIoImage *image,
+fiv_io_cmm_argb32(FivIoCmm *self, FivIoImage *image,
FivIoProfile *source, FivIoProfile *target)
{
g_return_if_fail(image->format == CAIRO_FORMAT_ARGB32);
// TODO: With g_no_cms_premultiplication,
// this probably also needs to be wrapped in un-premultiplication.
- fiv_io_profile_rgb_direct(image->data, image->width, image->height,
+ fiv_io_cmm_rgb_direct(self, image->data, image->width, image->height,
source, target,
FIV_IO_PROFILE_ARGB32_PREMUL, FIV_IO_PROFILE_ARGB32_PREMUL);
}
void
-fiv_io_profile_argb32_premultiply(
+fiv_io_cmm_argb32_premultiply(FivIoCmm *self,
FivIoImage *image, FivIoProfile *source, FivIoProfile *target)
{
if (image->format != CAIRO_FORMAT_ARGB32) {
- fiv_io_profile_xrgb32(image, source, target);
+ fiv_io_cmm_xrgb32(self, image, source, target);
} else if (g_broken_cms_premul) {
- fiv_io_profile_xrgb32(image, source, target);
+ fiv_io_cmm_xrgb32(self, image, source, target);
fiv_io_premultiply_argb32(image);
- } else if (!fiv_io_profile_rgb_direct(image->data,
+ } else if (!fiv_io_cmm_rgb_direct(self, image->data,
image->width, image->height, source, target,
FIV_IO_PROFILE_ARGB32, FIV_IO_PROFILE_ARGB32_PREMUL)) {
g_debug("failed to create a premultiplying transform");
@@ -333,11 +340,11 @@ fiv_io_profile_argb32_premultiply(
// TODO(p): Unpremultiply, transform, repremultiply. Or require lcms2>=2.13.
#define fiv_io_profile_argb32(surface, source, target)
-static void
-fiv_io_profile_argb32_premultiply(
+void
+fiv_io_cmm_argb32_premultiply(FivIoCmm *self,
FivIoImage *image, FivIoProfile *source, FivIoProfile *target)
{
- fiv_io_profile_xrgb32(image, source, target);
+ fiv_io_cmm_xrgb32(self, image, source, target);
fiv_io_premultiply_argb32(image);
}
@@ -346,7 +353,7 @@ fiv_io_profile_argb32_premultiply(
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void
-fiv_io_profile_any(
+fiv_io_cmm_any(FivIoCmm *self,
FivIoImage *image, FivIoProfile *source, FivIoProfile *target)
{
// TODO(p): Ensure we do colour management early enough, so that
@@ -354,9 +361,9 @@ fiv_io_profile_any(
// and also for correct alpha compositing.
switch (image->format) {
break; case CAIRO_FORMAT_RGB24:
- fiv_io_profile_xrgb32(image, source, target);
+ fiv_io_cmm_xrgb32(self, image, source, target);
break; case CAIRO_FORMAT_ARGB32:
- fiv_io_profile_argb32(image, source, target);
+ fiv_io_cmm_argb32(self, image, source, target);
break; default:
g_debug("CM attempted on an unsupported surface format");
}
@@ -364,12 +371,12 @@ fiv_io_profile_any(
// TODO(p): Offer better integration, upgrade the bit depth if appropriate.
FivIoImage *
-fiv_io_profile_finalize(FivIoImage *image, FivIoProfile *target)
+fiv_io_cmm_finalize(FivIoCmm *self, FivIoImage *image, FivIoProfile *target)
{
if (!target)
return image;
for (FivIoImage *page = image; page != NULL; page = page->page_next)
- fiv_io_profile_page(page, target, fiv_io_profile_any);
+ fiv_io_cmm_page(self, page, target, fiv_io_cmm_any);
return image;
}