|
28 | 28 | * - support rsvg_handle_get_intrinsic_size_in_pixels()
|
29 | 29 | * 5/6/22
|
30 | 30 | * - allow random access
|
| 31 | + * 20/5/25 |
| 32 | + * - support high bit depth rendering (128-bit) |
31 | 33 | */
|
32 | 34 |
|
33 | 35 | /*
|
@@ -119,9 +121,9 @@ typedef struct _VipsForeignLoadSvg {
|
119 | 121 | */
|
120 | 122 | gboolean unlimited;
|
121 | 123 |
|
122 |
| - /* Enables 128-bit SVG rendering. |
| 124 | + /* Enables scRGB 128-bit output (32-bit per channel). |
123 | 125 | */
|
124 |
| - gboolean rgb128; |
| 126 | + gboolean high_bitdepth; |
125 | 127 |
|
126 | 128 | /* Custom CSS.
|
127 | 129 | */
|
@@ -343,9 +345,9 @@ vips_foreign_load_svg_build(VipsObject *object)
|
343 | 345 | #endif /*DEBUG*/
|
344 | 346 |
|
345 | 347 | #ifndef HAVE_128BIT_SVG_RENDERING
|
346 |
| - if (svg->rgb128) { |
347 |
| - g_warning("setting rgb128 unsupported"); |
348 |
| - svg->rgb128 = FALSE; |
| 348 | + if (svg->high_bitdepth) { |
| 349 | + g_warning("setting high_bitdepth unsupported"); |
| 350 | + svg->high_bitdepth = FALSE; |
349 | 351 | }
|
350 | 352 | #endif /*HAVE_128BIT_SVG_RENDERING*/
|
351 | 353 |
|
@@ -579,9 +581,9 @@ vips_foreign_load_svg_parse(VipsForeignLoadSvg *svg, VipsImage *out)
|
579 | 581 |
|
580 | 582 | vips_image_init_fields(out,
|
581 | 583 | width, height, 4,
|
582 |
| - svg->rgb128 ? VIPS_FORMAT_FLOAT : VIPS_FORMAT_UCHAR, |
| 584 | + svg->high_bitdepth ? VIPS_FORMAT_FLOAT : VIPS_FORMAT_UCHAR, |
583 | 585 | VIPS_CODING_NONE,
|
584 |
| - svg->rgb128 ? VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB, |
| 586 | + svg->high_bitdepth ? VIPS_INTERPRETATION_scRGB : VIPS_INTERPRETATION_sRGB, |
585 | 587 | res, res);
|
586 | 588 |
|
587 | 589 | /* We use a tilecache, so it's smalltile.
|
@@ -624,7 +626,7 @@ vips_foreign_load_svg_generate(VipsRegion *out_region,
|
624 | 626 | vips_region_black(out_region);
|
625 | 627 |
|
626 | 628 | #ifdef HAVE_128BIT_SVG_RENDERING
|
627 |
| - cairo_format_t format = svg->rgb128 ? CAIRO_FORMAT_RGBA128F : CAIRO_FORMAT_ARGB32; |
| 629 | + cairo_format_t format = svg->high_bitdepth ? CAIRO_FORMAT_RGBA128F : CAIRO_FORMAT_ARGB32; |
628 | 630 | #else
|
629 | 631 | cairo_format_t format = CAIRO_FORMAT_ARGB32;
|
630 | 632 | #endif /*HAVE_128BIT_SVG_RENDERING*/
|
@@ -699,12 +701,12 @@ vips_foreign_load_svg_generate(VipsRegion *out_region,
|
699 | 701 | cairo_destroy(cr);
|
700 | 702 |
|
701 | 703 | #endif /*LIBRSVG_CHECK_VERSION(2, 46, 0)*/
|
702 |
| - if (svg->rgb128) { |
| 704 | + if (svg->high_bitdepth) { |
703 | 705 | /* Assuming the surface is RGBA128F and the data is premultiplied.
|
704 | 706 | Loop through each row and unpremultiply the float data.
|
705 | 707 | */
|
706 | 708 | for (int y = 0; y < r->height; y++)
|
707 |
| - vips__rgba128f_unpremultiplied( |
| 709 | + vips__premultiplied_rgb1282scrgba( |
708 | 710 | (float *) VIPS_REGION_ADDR(out_region, r->left, r->top + y),
|
709 | 711 | r->width);
|
710 | 712 | }
|
@@ -741,7 +743,7 @@ vips_foreign_load_svg_load(VipsForeignLoad *load)
|
741 | 743 | return -1;
|
742 | 744 |
|
743 | 745 | VipsImage *in = t[1];
|
744 |
| - if (svg->rgb128) { |
| 746 | + if (svg->high_bitdepth) { |
745 | 747 | if (vips_gamma(in, &t[2], NULL))
|
746 | 748 | return -1;
|
747 | 749 | in = t[2];
|
@@ -811,11 +813,11 @@ vips_foreign_load_svg_class_init(VipsForeignLoadSvgClass *class)
|
811 | 813 | G_STRUCT_OFFSET(VipsForeignLoadSvg, stylesheet),
|
812 | 814 | NULL);
|
813 | 815 |
|
814 |
| - VIPS_ARG_BOOL(class, "rgb128", 25, |
815 |
| - _("RGB128"), |
816 |
| - _("Enable 128-bit SVG rendering"), |
| 816 | + VIPS_ARG_BOOL(class, "high_bitdepth", 25, |
| 817 | + _("HIGH_BITDEPTH"), |
| 818 | + _("Enable scRGB 128-bit output (32-bit per channel)"), |
817 | 819 | VIPS_ARGUMENT_OPTIONAL_INPUT,
|
818 |
| - G_STRUCT_OFFSET(VipsForeignLoadSvg, rgb128), |
| 820 | + G_STRUCT_OFFSET(VipsForeignLoadSvg, high_bitdepth), |
819 | 821 | FALSE);
|
820 | 822 | }
|
821 | 823 |
|
@@ -1113,11 +1115,14 @@ vips_foreign_load_svg_buffer_init(VipsForeignLoadSvgBuffer *buffer)
|
1113 | 1115 | * During the CSS cascade, the specified stylesheet will be applied with a
|
1114 | 1116 | * User Origin. This feature requires librsvg 2.48.0 or later.
|
1115 | 1117 | *
|
| 1118 | + * Setting @high_bitdepth TRUE enables 128-bit scRGB output." |
| 1119 | + * |
1116 | 1120 | * ::: tip "Optional arguments"
|
1117 | 1121 | * * @dpi: `gdouble`, render at this DPI
|
1118 | 1122 | * * @scale: `gdouble`, scale render by this factor
|
1119 | 1123 | * * @unlimited: `gboolean`, allow SVGs of any size
|
1120 | 1124 | * * @stylesheet: `gchararray`, custom CSS
|
| 1125 | + * * @high_bitdepth: `gboolean`, enable scRGB 128-bit output |
1121 | 1126 | *
|
1122 | 1127 | * ::: seealso
|
1123 | 1128 | * [ctor@Image.new_from_file].
|
@@ -1155,6 +1160,7 @@ vips_svgload(const char *filename, VipsImage **out, ...)
|
1155 | 1160 | * * @scale: `gdouble`, scale render by this factor
|
1156 | 1161 | * * @unlimited: `gboolean`, allow SVGs of any size
|
1157 | 1162 | * * @stylesheet: `gchararray`, custom CSS
|
| 1163 | + * * @high_bitdepth: `gboolean`, enable scRGB 128-bit output |
1158 | 1164 | *
|
1159 | 1165 | * ::: seealso
|
1160 | 1166 | * [ctor@Image.svgload].
|
@@ -1195,6 +1201,7 @@ vips_svgload_buffer(void *buf, size_t len, VipsImage **out, ...)
|
1195 | 1201 | * * @scale: `gdouble`, scale render by this factor
|
1196 | 1202 | * * @unlimited: `gboolean`, allow SVGs of any size
|
1197 | 1203 | * * @stylesheet: `gchararray`, custom CSS
|
| 1204 | + * * @high_bitdepth: `gboolean`, enable scRGB 128-bit output |
1198 | 1205 | *
|
1199 | 1206 | * ::: seealso
|
1200 | 1207 | * [ctor@Image.svgload].
|
|
0 commit comments