[gs-commits] ghostpdl branch, master, updated. jbig2dec-0.14-1595-gaccc3d1
[email protected] (Robin Watts)
| Newsgroups | gmane.comp.printing.ghostscript.cvs |
|---|---|
| Message-ID | <[email protected]> |
The ghostpdl branch, master has been updated
via accc3d19da5d7a1ad545e78f252eb9c50b39f2aa (commit)
via 4041906852365a602c2f9e011703e4174bdc8040 (commit)
from cd1b1cacadac2479e291efe611979bdc1b3bdb19 (commit)
----------------------------------------------------------------------
commit accc3d19da5d7a1ad545e78f252eb9c50b39f2aa
Author: Robin Watts <[email protected]>
Date: Wed Dec 13 14:17:40 2017 +0000
Optimise gx_default_copy_color
Simple static inline template used to make optimised versions.
This doesn't yield a noticable speedup for me, so I hand coded
8, 24 and 32 bit cores, and do see a speedup.
diff --git a/base/gdevdbit.c b/base/gdevdbit.c
index 8b5fa2f..546966f 100644
--- a/base/gdevdbit.c
+++ b/base/gdevdbit.c
@@ -82,25 +82,16 @@ gx_default_copy_mono(gx_device * dev, const byte * data,
(&devc, data, dx, raster, id, x, y, w, h, dev, rop3_T, invert);
}
-/* Implement copy_color by filling lots of small rectangles. */
-/* This is very inefficient, but it works as a default. */
-int
-gx_default_copy_color(gx_device * dev, const byte * data,
- int dx, int raster, gx_bitmap_id id,
- int x, int y, int w, int h)
+static inline int dcc_template(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h, int depth)
{
- int depth = dev->color_info.depth;
byte mask;
dev_proc_fill_rectangle((*fill));
const byte *row;
int iy;
- if (depth == 1)
- return (*dev_proc(dev, copy_mono)) (dev, data, dx, raster, id,
- x, y, w, h,
- (gx_color_index) 0, (gx_color_index) 1);
- fit_copy(dev, data, dx, raster, id, x, y, w, h);
fill = dev_proc(dev, fill_rectangle);
mask = (byte) ((1 << depth) - 1);
for (row = data, iy = 0; iy < h; row += raster, ++iy) {
@@ -159,6 +150,221 @@ gx_default_copy_color(gx_device * dev, const byte * data,
return 0;
}
+static int dcc_64(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 64);
+}
+
+static int dcc_56(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 56);
+}
+
+static int dcc_48(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 48);
+}
+
+static int dcc_40(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 40);
+}
+
+static int dcc_32(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ dev_proc_fill_rectangle((*fill));
+ const byte *row;
+ int iy;
+
+ fill = dev_proc(dev, fill_rectangle);
+ for (row = data, iy = 0; iy < h; row += raster, ++iy) {
+ int ix;
+ gx_color_index c0 = gx_no_color_index;
+ const byte *ptr = row + dx * 4;
+ int i0;
+
+ for (i0 = ix = 0; ix < w; ++ix) {
+ gx_color_index color;
+
+ color = *ptr++;
+ color = (color << 8) + *ptr++;
+ color = (color << 8) + *ptr++;
+ color = (color << 8) + *ptr++;
+ if (color != c0) {
+ if (ix > i0) {
+ int code = (*fill)
+ (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ c0 = color;
+ i0 = ix;
+ }
+ }
+ if (ix > i0) {
+ int code = (*fill) (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ }
+ return 0;
+}
+
+static int dcc_24(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ dev_proc_fill_rectangle((*fill));
+ const byte *row;
+ int iy;
+
+ fill = dev_proc(dev, fill_rectangle);
+ for (row = data, iy = 0; iy < h; row += raster, ++iy) {
+ int ix;
+ gx_color_index c0 = gx_no_color_index;
+ const byte *ptr = row + dx * 3;
+ int i0;
+
+ for (i0 = ix = 0; ix < w; ++ix) {
+ gx_color_index color;
+
+ color = *ptr++;
+ color = (color << 8) + *ptr++;
+ color = (color << 8) + *ptr++;
+ if (color != c0) {
+ if (ix > i0) {
+ int code = (*fill)
+ (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ c0 = color;
+ i0 = ix;
+ }
+ }
+ if (ix > i0) {
+ int code = (*fill) (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ }
+ return 0;
+}
+
+static int dcc_16(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 16);
+}
+
+static int dcc_8(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ dev_proc_fill_rectangle((*fill));
+ const byte *row;
+ int iy;
+
+ fill = dev_proc(dev, fill_rectangle);
+ for (row = data, iy = 0; iy < h; row += raster, ++iy) {
+ int ix;
+ gx_color_index c0 = gx_no_color_index;
+ const byte *ptr = row + dx;
+ int i0;
+
+ for (i0 = ix = 0; ix < w; ++ix) {
+ gx_color_index color;
+
+ color = *ptr++;
+ if (color != c0) {
+ if (ix > i0) {
+ int code = (*fill)
+ (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ c0 = color;
+ i0 = ix;
+ }
+ }
+ if (ix > i0) {
+ int code = (*fill) (dev, i0 + x, iy + y, ix - i0, 1, c0);
+
+ if (code < 0)
+ return code;
+ }
+ }
+ return 0;
+}
+
+static int dcc_4(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 4);
+}
+
+static int dcc_2(gx_device * dev, const byte * data,
+ int dx, int raster,
+ int x, int y, int w, int h)
+{
+ return dcc_template(dev, data, dx, raster, x, y, w, h, 2);
+}
+
+/* Implement copy_color by filling lots of small rectangles. */
+/* This is very inefficient, but it works as a default. */
+int
+gx_default_copy_color(gx_device * dev, const byte * data,
+ int dx, int raster, gx_bitmap_id id,
+ int x, int y, int w, int h)
+{
+ int depth = dev->color_info.depth;
+ if (depth == 1)
+ return (*dev_proc(dev, copy_mono)) (dev, data, dx, raster, id,
+ x, y, w, h,
+ (gx_color_index) 0, (gx_color_index) 1);
+ fit_copy(dev, data, dx, raster, id, x, y, w, h);
+ switch (depth) {
+ case 64:
+ return dcc_64(dev, data, dx, raster, x, y, w, h);
+ case 56:
+ return dcc_56(dev, data, dx, raster, x, y, w, h);
+ case 48:
+ return dcc_48(dev, data, dx, raster, x, y, w, h);
+ case 40:
+ return dcc_40(dev, data, dx, raster, x, y, w, h);
+ case 32:
+ return dcc_32(dev, data, dx, raster, x, y, w, h);
+ case 24:
+ return dcc_24(dev, data, dx, raster, x, y, w, h);
+ case 16:
+ return dcc_16(dev, data, dx, raster, x, y, w, h);
+ case 8:
+ return dcc_8(dev, data, dx, raster, x, y, w, h);
+ case 4:
+ return dcc_4(dev, data, dx, raster, x, y, w, h);
+ case 2:
+ return dcc_2(dev, data, dx, raster, x, y, w, h);
+ }
+ return gs_error_Fatal;
+}
+
int
gx_no_copy_alpha(gx_device * dev, const byte * data, int data_x,
int raster, gx_bitmap_id id, int x, int y, int width, int height,
----------------------------------------------------------------------
commit 4041906852365a602c2f9e011703e4174bdc8040
Author: Robin Watts <[email protected]>
Date: Wed Aug 21 14:28:20 2019 +0100
Bug 701451: Fix clist color_usage calculations for shadings.
Or rather, don't attempt to calculate them badly, and just
use the safe "all colors" value.
diff --git a/base/gxclrect.c b/base/gxclrect.c
index 07f398f..a4b5982 100644
--- a/base/gxclrect.c
+++ b/base/gxclrect.c
@@ -425,21 +425,6 @@ clist_fill_rectangle_hl_color(gx_device *dev, const gs_fixed_rect *rect,
return 0;
}
-static void update_color_use_frac_array(uchar num_colors, const frac31 *color,
- cmd_rects_enum_t *re)
-{
- uchar k;
-
- if (color == NULL)
- return;
-
- for (k = 0; k < num_colors; k++){
- if (color[k] != 0) {
- re->pcls->color_usage.or |= (1<<k);
- }
- }
-}
-
static inline int
clist_write_fill_trapezoid(gx_device * dev,
const gs_fixed_edge *left, const gs_fixed_edge *right,
@@ -517,14 +502,11 @@ clist_write_fill_trapezoid(gx_device * dev,
} else {
/* Even with pdcolor NULL, we may still have colors packed in
c0, c1, c2 or c3 */
- update_color_use_frac_array(dev->color_info.num_components, c0, &re);
- update_color_use_frac_array(dev->color_info.num_components, c1, &re);
- update_color_use_frac_array(dev->color_info.num_components, c2, &re);
- update_color_use_frac_array(dev->color_info.num_components, c3, &re);
+ re.pcls->color_usage.or |= gx_color_usage_all(cdev);
code = 0;
}
if (code >= 0) {
- /* Dont't want to shorten the trapezoid by the band boundary,
+ /* Don't want to shorten the trapezoid by the band boundary,
keeping in mind a further optimization with writing same data to all bands. */
code = cmd_write_trapezoid_cmd(cdev, re.pcls, cmd_opv_fill_trapezoid, left, right,
ybot, ytop, options, fa, c0, c1, c2, c3);
Summary of changes:
base/gdevdbit.c | 230 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
base/gxclrect.c | 22 +-----
2 files changed, 220 insertions(+), 32 deletions(-)