<div dir="ltr">unsubscribe</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 6, 2018 at 7:59 AM, Maarten Lankhorst <span dir="ltr"><<a href="mailto:maarten.lankhorst@linux.intel.com" target="_blank">maarten.lankhorst@linux.intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">IGT wants to add support for planes with a bit depth >10, which<br>
requires a higher precision format than we have currently.<br>
<br>
I'm using RGBA as format, because of its existence in OpenGL.<br>
With the new formats we can directly convert our bytes to half float,<br>
</span>or multiply a colro vector with a matrix to go to the Y'CbCr colorspace.<br>
<br>
Signed-off-by: Maarten Lankhorst <<a href="mailto:maarten.lankhorst@linux.intel.com">maarten.lankhorst@linux.<wbr>intel.com</a>><br>
---<br>
perf/micro/fill-clip.c | 2 ++<br>
perf/micro/pixel.c | 2 ++<br>
src/cairo-debug.c | 6 +++++<br>
src/cairo-image-compositor.c | 4 ++++<br>
src/cairo-image-source.c | 27 ++++++++++++++++++++++<br>
src/cairo-image-surface.c | 16 +++++++++++++<br>
src/cairo-png.c | 2 ++<br>
src/cairo-script-surface.c | 20 ++++++++++++++++<br>
src/cairo-xlib-display.c | 12 ++++++++++<br>
src/cairo.h | 6 ++++-<br>
src/cairoint.h | 2 +-<br>
test/any2ppm.c | 2 ++<br>
test/map-to-image.c | 2 ++<br>
test/png.c | 2 ++<br>
util/cairo-script/cairo-<wbr>script-operators.c | 12 ++++++++++<br>
util/cairo-trace/trace.c | 10 ++++++++<br>
16 files changed, 125 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/perf/micro/fill-clip.c b/perf/micro/fill-clip.c<br>
index 2d014aca832c..f9802705f4d0 100644<br>
--- a/perf/micro/fill-clip.c<br>
+++ b/perf/micro/fill-clip.c<br>
@@ -92,6 +92,8 @@ direct (cairo_t *cr, int width, int height, int loops)<br>
case CAIRO_FORMAT_RGB24:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_ARGB32: bpp = 32; break;<br>
+ case CAIRO_FORMAT_RGB96F: bpp = 96; break;<br>
+ case CAIRO_FORMAT_RGBA128F: bpp = 128; break;<br>
}<br>
<br>
cairo_perf_timer_start ();<br>
diff --git a/perf/micro/pixel.c b/perf/micro/pixel.c<br>
index b600b5170d86..85a42e4427bc 100644<br>
--- a/perf/micro/pixel.c<br>
+++ b/perf/micro/pixel.c<br>
@@ -51,6 +51,8 @@ pixel_direct (cairo_t *cr, int width, int height, int loops)<br>
case CAIRO_FORMAT_RGB24:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_ARGB32: bpp = 32; break;<br>
+ case CAIRO_FORMAT_RGB96F: bpp = 96; break;<br>
+ case CAIRO_FORMAT_RGBA128F: bpp = 128; break;<br>
}<br>
<br>
cairo_perf_timer_start ();<br>
diff --git a/src/cairo-debug.c b/src/cairo-debug.c<br>
index 6005060d4a0c..760f092e3a8b 100644<br>
--- a/src/cairo-debug.c<br>
+++ b/src/cairo-debug.c<br>
@@ -131,6 +131,12 @@ _cairo_debug_check_image_<wbr>surface_is_defined (const cairo_surface_t *surface)<br>
case CAIRO_FORMAT_ARGB32:<br>
width = image->width*4;<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ width = image->width*12;<br>
+ break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ width = image->width*16;<br>
+ break;<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
/* XXX compute width from pixman bpp */<br>
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c<br>
index bbf4cf2281da..434f67e59b74 100644<br>
--- a/src/cairo-image-compositor.c<br>
+++ b/src/cairo-image-compositor.c<br>
@@ -2845,6 +2845,8 @@ inplace_renderer_init (cairo_image_span_renderer_t *r,<br>
case CAIRO_FORMAT_A1:<br>
case CAIRO_FORMAT_RGB16_565:<br>
case CAIRO_FORMAT_RGB30:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_INVALID:<br>
default: break;<br>
}<br>
@@ -2860,6 +2862,8 @@ inplace_renderer_init (cairo_image_span_renderer_t *r,<br>
case CAIRO_FORMAT_A1:<br>
case CAIRO_FORMAT_RGB16_565:<br>
case CAIRO_FORMAT_RGB30:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_INVALID:<br>
default: break;<br>
}<br>
diff --git a/src/cairo-image-source.c b/src/cairo-image-source.c<br>
index 0b50afcad327..c56845ab2d91 100644<br>
--- a/src/cairo-image-source.c<br>
+++ b/src/cairo-image-source.c<br>
@@ -455,6 +455,7 @@ static pixman_image_t *<br>
_pixel_to_solid (cairo_image_surface_t *image, int x, int y)<br>
{<br>
uint32_t pixel;<br>
+ float *rgba;<br>
pixman_color_t color;<br>
<br>
TRACE ((stderr, "%s\n", __FUNCTION__));<br>
@@ -523,6 +524,32 @@ _pixel_to_solid (cairo_image_surface_t *image, int x, int y)<br>
color.green = (pixel >> 8 & 0xff) | (pixel & 0xff00);<br>
color.blue = (pixel & 0xff) | (pixel << 8 & 0xff00);<br>
return pixman_image_create_solid_fill (&color);<br>
+<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ if (image->format == CAIRO_FORMAT_RGBA128F)<br>
+ {<br>
+ rgba = (float *)&image->data[y * image->stride + 16 * x];<br>
+ color.alpha = 65535.f * rgba[3];<br>
+<br>
+ if (color.alpha == 0)<br>
+ return _pixman_transparent_image ();<br>
+ }<br>
+ else<br>
+ {<br>
+ rgba = (float *)&image->data[y * image->stride + 12 * x];<br>
+ color.alpha = 0xffff;<br>
+ }<br>
+<br>
+ if (color.alpha == 0xffff && rgba[0] == 0.f && rgba[1] == 0.f && rgba[2] == 0.f)<br>
+ return _pixman_black_image ();<br>
+ if (color.alpha == 0xffff && rgba[0] == 1.f && rgba[1] == 1.f && rgba[2] == 1.f)<br>
+ return _pixman_white_image ();<br>
+<br>
+ color.red = rgba[0] * 65535.f;<br>
+ color.green = rgba[1] * 65535.f;<br>
+ color.blue = rgba[2] * 65535.f;<br>
+ return pixman_image_create_solid_fill (&color);<br>
}<br>
}<br>
<br>
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c<br>
index 2ee1cad42cf7..0e17f3a1619c 100644<br>
--- a/src/cairo-image-surface.c<br>
+++ b/src/cairo-image-surface.c<br>
@@ -93,6 +93,10 @@ cairo_format_t<br>
_cairo_format_from_pixman_<wbr>format (pixman_format_code_t pixman_format)<br>
{<br>
switch (pixman_format) {<br>
+ case PIXMAN_rgba_float:<br>
+ return CAIRO_FORMAT_RGBA128F;<br>
+ case PIXMAN_rgb_float:<br>
+ return CAIRO_FORMAT_RGB96F;<br>
case PIXMAN_a8r8g8b8:<br>
return CAIRO_FORMAT_ARGB32;<br>
case PIXMAN_x2r10g10b10:<br>
@@ -322,6 +326,12 @@ _cairo_format_to_pixman_<wbr>format_code (cairo_format_t format)<br>
case CAIRO_FORMAT_RGB16_565:<br>
ret = PIXMAN_r5g6b5;<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ ret = PIXMAN_rgb_float;<br>
+ break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ ret = PIXMAN_rgba_float;<br>
+ break;<br>
case CAIRO_FORMAT_ARGB32:<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
@@ -693,8 +703,10 @@ _cairo_format_from_content (cairo_content_t content)<br>
_cairo_content_from_format (cairo_format_t format)<br>
{<br>
switch (format) {<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_ARGB32:<br>
return CAIRO_CONTENT_COLOR_ALPHA;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
case CAIRO_FORMAT_RGB30:<br>
return CAIRO_CONTENT_COLOR;<br>
case CAIRO_FORMAT_RGB24:<br>
@@ -716,6 +728,10 @@ _cairo_content_from_format (cairo_format_t format)<br>
_cairo_format_bits_per_pixel (cairo_format_t format)<br>
{<br>
switch (format) {<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ return 128;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ return 96;<br>
case CAIRO_FORMAT_ARGB32:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_RGB24:<br>
diff --git a/src/cairo-png.c b/src/cairo-png.c<br>
index ab0b9d0c51ea..b9fc9160a8ab 100644<br>
--- a/src/cairo-png.c<br>
+++ b/src/cairo-png.c<br>
@@ -265,6 +265,8 @@ write_png (cairo_surface_t *surface,<br>
break;<br>
case CAIRO_FORMAT_INVALID:<br>
case CAIRO_FORMAT_RGB16_565:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
default:<br>
status = _cairo_error (CAIRO_STATUS_INVALID_FORMAT);<br>
goto BAIL4;<br>
diff --git a/src/cairo-script-surface.c b/src/cairo-script-surface.c<br>
index 7db7dc5b0dfb..0e6bc5e893e1 100644<br>
--- a/src/cairo-script-surface.c<br>
+++ b/src/cairo-script-surface.c<br>
@@ -871,6 +871,8 @@ static const char *<br>
_format_to_string (cairo_format_t format)<br>
{<br>
switch (format) {<br>
+ case CAIRO_FORMAT_RGBA128F: return "RGBA128F";<br>
+ case CAIRO_FORMAT_RGB96F: return "RGB96F";<br>
case CAIRO_FORMAT_ARGB32: return "ARGB32";<br>
case CAIRO_FORMAT_RGB30: return "RGB30";<br>
case CAIRO_FORMAT_RGB24: return "RGB24";<br>
@@ -1315,6 +1317,18 @@ _write_image_surface (cairo_output_stream_t *output,<br>
data += stride;<br>
}<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ for (row = image->height; row--; ) {<br>
+ _cairo_output_stream_write (output, data, 12*width);<br>
+ data += stride;<br>
+ }<br>
+ break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ for (row = image->height; row--; ) {<br>
+ _cairo_output_stream_write (output, data, 16*width);<br>
+ data += stride;<br>
+ }<br>
+ break;<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
ASSERT_NOT_REACHED;<br>
@@ -1421,6 +1435,12 @@ _emit_image_surface (cairo_script_surface_t *surface,<br>
case CAIRO_FORMAT_ARGB32:<br>
len = clone->width * 4;<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ len = clone->width * 12;<br>
+ break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ len = clone->width * 16;<br>
+ break;<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
ASSERT_NOT_REACHED;<br>
diff --git a/src/cairo-xlib-display.c b/src/cairo-xlib-display.c<br>
index add42299b4cd..108897e92a2e 100644<br>
--- a/src/cairo-xlib-display.c<br>
+++ b/src/cairo-xlib-display.c<br>
@@ -383,6 +383,10 @@ _cairo_xlib_display_get_<wbr>xrender_format_for_pixman(<wbr>cairo_xlib_display_t *display,<br>
XRenderPictFormat tmpl;<br>
int mask;<br>
<br>
+ /* No equivalent in X11 yet. */<br>
+ if (format == PIXMAN_rgba_float || format == PIXMAN_rgb_float)<br>
+ return NULL;<br>
+<br>
#define MASK(x) ((1<<(x))-1)<br>
<br>
tmpl.depth = PIXMAN_FORMAT_DEPTH(format);<br>
@@ -510,6 +514,14 @@ _cairo_xlib_display_get_<wbr>xrender_format (cairo_xlib_display_t *display,<br>
xrender_format = _cairo_xlib_display_get_<wbr>xrender_format_for_pixman(<wbr>display,<br>
PIXMAN_x2r10g10b10);<br>
break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ xrender_format = _cairo_xlib_display_get_<wbr>xrender_format_for_pixman(<wbr>display,<br>
+ PIXMAN_rgba_float);<br>
+ break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ xrender_format = _cairo_xlib_display_get_<wbr>xrender_format_for_pixman(<wbr>display,<br>
+ PIXMAN_rgb_float);<br>
+ break;<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
ASSERT_NOT_REACHED;<br>
diff --git a/src/cairo.h b/src/cairo.h<br>
index b2386af5d920..29be5ef7e57e 100644<br>
--- a/src/cairo.h<br>
+++ b/src/cairo.h<br>
@@ -405,6 +405,8 @@ typedef enum _cairo_content {<br>
* with red in the upper 5 bits, then green in the middle<br>
* 6 bits, and blue in the lower 5 bits. (Since 1.2)<br>
* @CAIRO_FORMAT_RGB30: like RGB24 but with 10bpc. (Since 1.12)<br>
+ * @CAIRO_FORMAT_RGB96F: 3 floats, R, G, B. (Since 1.16)<br>
+ * @CAIRO_FORMAT_RGBA128F: 4 floats, R, G, B, A. (Since 1.16)<br>
*<br>
* #cairo_format_t is used to identify the memory format of<br>
* image data.<br>
@@ -420,7 +422,9 @@ typedef enum _cairo_format {<br>
CAIRO_FORMAT_A8 = 2,<br>
CAIRO_FORMAT_A1 = 3,<br>
CAIRO_FORMAT_RGB16_565 = 4,<br>
- CAIRO_FORMAT_RGB30 = 5<br>
+ CAIRO_FORMAT_RGB30 = 5,<br>
+ CAIRO_FORMAT_RGB96F = 6,<br>
+ CAIRO_FORMAT_RGBA128F = 7<br>
} cairo_format_t;<br>
<br>
<br>
diff --git a/src/cairoint.h b/src/cairoint.h<br>
index cfae18cf93bd..331ab5357ac4 100644<br>
--- a/src/cairoint.h<br>
+++ b/src/cairoint.h<br>
@@ -1536,7 +1536,7 @@ _cairo_surface_release_device_<wbr>reference (cairo_surface_t *surface);<br>
* in cairo-xlib-surface.c--again see -Wswitch-enum).<br>
*/<br>
#define CAIRO_FORMAT_VALID(format) ((format) >= CAIRO_FORMAT_ARGB32 && \<br>
- (format) <= CAIRO_FORMAT_RGB30)<br>
+ (format) <= CAIRO_FORMAT_RGBA128F)<br>
<br>
/* pixman-required stride alignment in bytes. */<br>
#define CAIRO_STRIDE_ALIGNMENT (sizeof (uint32_t))<br>
diff --git a/test/any2ppm.c b/test/any2ppm.c<br>
index a92412d084f1..7eb582c04d22 100644<br>
--- a/test/any2ppm.c<br>
+++ b/test/any2ppm.c<br>
@@ -201,6 +201,8 @@ write_ppm (cairo_surface_t *surface, int fd)<br>
case CAIRO_FORMAT_A1:<br>
case CAIRO_FORMAT_RGB16_565:<br>
case CAIRO_FORMAT_RGB30:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_INVALID:<br>
default:<br>
return "unhandled image format";<br>
diff --git a/test/map-to-image.c b/test/map-to-image.c<br>
index 0262245a88e1..2b1799f71107 100644<br>
--- a/test/map-to-image.c<br>
+++ b/test/map-to-image.c<br>
@@ -45,6 +45,8 @@ set_pixel_black(uint8_t *data, int stride,<br>
case CAIRO_FORMAT_RGB16_565:<br>
*(uint16_t *)(data + y * stride + 2*x) = black_pixel;<br>
break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_A8:<br>
case CAIRO_FORMAT_A1:<br>
diff --git a/test/png.c b/test/png.c<br>
index cd11fd0d1825..a199d4867d3f 100644<br>
--- a/test/png.c<br>
+++ b/test/png.c<br>
@@ -60,6 +60,8 @@ format_to_string (cairo_format_t format)<br>
case CAIRO_FORMAT_RGB24: return "rgb24";<br>
case CAIRO_FORMAT_RGB30: return "rgb30";<br>
case CAIRO_FORMAT_ARGB32: return "argb32";<br>
+ case CAIRO_FORMAT_RGB96F: return "rgb96f";<br>
+ case CAIRO_FORMAT_RGBA128F: return "rgba128f";<br>
case CAIRO_FORMAT_INVALID:<br>
default: return "???";<br>
}<br>
diff --git a/util/cairo-script/cairo-<wbr>script-operators.c b/util/cairo-script/cairo-<wbr>script-operators.c<br>
index e493311e74a0..7cdb5afb66a2 100644<br>
--- a/util/cairo-script/cairo-<wbr>script-operators.c<br>
+++ b/util/cairo-script/cairo-<wbr>script-operators.c<br>
@@ -2967,6 +2967,12 @@ _image_read_raw (csi_t *ctx,<br>
case CAIRO_FORMAT_ARGB32:<br>
instride = rowlen = 4 * width;<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ instride = rowlen = 12 * width;<br>
+ break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ instride = rowlen = 16 * width;<br>
+ break;<br>
}<br>
len = rowlen * height;<br>
<br>
@@ -3066,6 +3072,8 @@ err_decompress:<br>
#endif<br>
}<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_INVALID:<br>
case CAIRO_FORMAT_ARGB32:<br>
@@ -3155,6 +3163,8 @@ err_decompress:<br>
#endif<br>
}<br>
break;<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_INVALID:<br>
case CAIRO_FORMAT_ARGB32:<br>
@@ -3191,6 +3201,8 @@ err_decompress:<br>
case CAIRO_FORMAT_A8:<br>
break;<br>
<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_RGB24:<br>
case CAIRO_FORMAT_INVALID:<br>
diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c<br>
index 7a43b0f2c341..0f271d8a2671 100644<br>
--- a/util/cairo-trace/trace.c<br>
+++ b/util/cairo-trace/trace.c<br>
@@ -1510,6 +1510,8 @@ _format_to_string (cairo_format_t format)<br>
#define f(name) case CAIRO_FORMAT_ ## name: return #name<br>
switch (format) {<br>
f(INVALID);<br>
+ f(RGBA128F);<br>
+ f(RGB96F);<br>
f(ARGB32);<br>
f(RGB30);<br>
f(RGB24);<br>
@@ -1527,8 +1529,10 @@ _format_to_content_string (cairo_format_t format)<br>
switch (format) {<br>
case CAIRO_FORMAT_INVALID:<br>
return "INVALID";<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_ARGB32:<br>
return "COLOR_ALPHA";<br>
+ case CAIRO_FORMAT_RGB96F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_RGB24:<br>
case CAIRO_FORMAT_RGB16_565:<br>
@@ -1673,6 +1677,8 @@ _emit_image (cairo_surface_t *image,<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_INVALID:<br>
case CAIRO_FORMAT_ARGB32: len = 4*width; break;<br>
+ case CAIRO_FORMAT_RGB96F: len = 12*width; break;<br>
+ case CAIRO_FORMAT_RGBA128F: len = 16*width; break;<br>
}<br>
<br>
_trace_printf (" /source ");<br>
@@ -1696,6 +1702,8 @@ _emit_image (cairo_surface_t *image,<br>
case CAIRO_FORMAT_RGB16_565:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_ARGB32:<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
for (row = height; row--; ) {<br>
_write_data (&stream, data, len);<br>
data += stride;<br>
@@ -1754,6 +1762,8 @@ _emit_image (cairo_surface_t *image,<br>
data += stride;<br>
}<br>
break;<br>
+ case CAIRO_FORMAT_RGB96F:<br>
+ case CAIRO_FORMAT_RGBA128F:<br>
case CAIRO_FORMAT_RGB30:<br>
case CAIRO_FORMAT_ARGB32:<br>
for (row = height; row--; ) {<br>
<div class="HOEnZb"><div class="h5">-- <br>
2.18.0<br>
<br>
-- <br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="https://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">https://lists.cairographics.<wbr>org/mailman/listinfo/cairo</a></div></div></blockquote></div><br></div>