summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <Robin.Watts@artifex.com>2021-03-31 17:56:26 +0100
committerRobin Watts <Robin.Watts@artifex.com>2021-04-20 15:03:02 +0100
commit6f332dd0baee0135ebff0bf25c56e9adff0f944a (patch)
tree68dcafd518a5fe8094fd47bab2db9cf6101ee5ca
parente1a3956f252404f07d93be47f7845b23e4a2c4de (diff)
downloadghostpdl-6f332dd0baee0135ebff0bf25c56e9adff0f944a.tar.gz
Move memory devices away from static init of proc tables.
This is slightly more involved than the other devices, as internally some memory devices rely on being able to get the prototype for other ones, and to reference their functions. Accordingly, we change to a much more restricted list of procs (just for the ones that actually differ between memory devices) and have an internal mechanism for getting those. attempt to simplify init of memory devices.
-rw-r--r--base/gdevabuf.c49
-rw-r--r--base/gdevdgbr.c13
-rw-r--r--base/gdevm1.c50
-rw-r--r--base/gdevm16.c19
-rw-r--r--base/gdevm2.c48
-rw-r--r--base/gdevm24.c41
-rw-r--r--base/gdevm32.c40
-rw-r--r--base/gdevm4.c47
-rw-r--r--base/gdevm40.c41
-rw-r--r--base/gdevm48.c41
-rw-r--r--base/gdevm56.c41
-rw-r--r--base/gdevm64.c41
-rw-r--r--base/gdevm8.c39
-rw-r--r--base/gdevmem.c138
-rw-r--r--base/gdevmem.h111
-rw-r--r--base/gdevmpla.c183
-rw-r--r--base/gdevmx.c2
-rw-r--r--base/gdevplnx.c8
-rw-r--r--base/gdevprn.c2
-rw-r--r--base/gxdevmem.h51
-rw-r--r--base/gxifast.c2
21 files changed, 648 insertions, 359 deletions
diff --git a/base/gdevabuf.c b/base/gdevabuf.c
index 1f7c39029..b9d8ede34 100644
--- a/base/gdevabuf.c
+++ b/base/gdevabuf.c
@@ -170,11 +170,24 @@ static dev_proc_get_clipping_box(mem_abuf_get_clipping_box);
static dev_proc_fill_rectangle_hl_color(mem_abuf_fill_rectangle_hl_color);
/* The device descriptor. */
+static int
+mem_alpha_initialize(gx_device *dev)
+{
+ mem_initialize(dev);
+
+ set_dev_proc(dev, map_rgb_color, gx_forward_map_rgb_color);
+ set_dev_proc(dev, map_color_rgb, gx_forward_map_color_rgb);
+ set_dev_proc(dev, fill_rectangle, mem_abuf_fill_rectangle);
+ set_dev_proc(dev, copy_mono, mem_abuf_copy_mono);
+ set_dev_proc(dev, copy_color, gx_default_copy_color);
+ set_dev_proc(dev, strip_copy_rop, gx_no_strip_copy_rop);
+ set_dev_proc(dev, fill_rectangle_hl_color, mem_abuf_fill_rectangle_hl_color);
+
+ return 0;
+}
+
static const gx_device_memory mem_alpha_buffer_device =
-mem_device_hl("image(alpha buffer)", 0, 1,
- gx_forward_map_rgb_color, gx_forward_map_color_rgb,
- mem_abuf_copy_mono, gx_default_copy_color, mem_abuf_fill_rectangle,
- gx_no_strip_copy_rop, mem_abuf_fill_rectangle_hl_color);
+ mem_device("image(alpha buffer)", 0, 1, mem_alpha_initialize);
/* Make an alpha-buffer memory device. */
/* We use abuf instead of alpha_buffer because */
@@ -406,11 +419,13 @@ mem_abuf_copy_mono(gx_device * dev,
code = y_transfer_next(&yt, dev);
if (code < 0)
return code;
- (*dev_proc(&mem_mono_device, copy_mono)) (dev,
- base + (yt.y_next - y) * sraster,
- sourcex, sraster, gx_no_bitmap_id,
- x, yt.transfer_y, w, yt.transfer_height,
- gx_no_color_index, (gx_color_index) 1);
+ code = mem_mono_copy_mono(dev,
+ base + (yt.y_next - y) * sraster,
+ sourcex, sraster, gx_no_bitmap_id,
+ x, yt.transfer_y, w, yt.transfer_height,
+ gx_no_color_index, (gx_color_index) 1);
+ if (code < 0)
+ return code;
}
return 0;
}
@@ -442,9 +457,11 @@ mem_abuf_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
code = y_transfer_next(&yt, dev);
if (code < 0)
return code;
- (*dev_proc(&mem_mono_device, fill_rectangle)) (dev,
- x, yt.transfer_y, w, yt.transfer_height,
- (gx_color_index) 1);
+ code = mem_mono_fill_rectangle(dev, x, yt.transfer_y,
+ w, yt.transfer_height,
+ (gx_color_index) 1);
+ if (code < 0)
+ return code;
}
return 0;
}
@@ -484,9 +501,11 @@ mem_abuf_fill_rectangle_hl_color(gx_device * dev, const gs_fixed_rect *rect,
code = y_transfer_next(&yt, dev);
if (code < 0)
return code;
- (*dev_proc(&mem_mono_device, fill_rectangle)) (dev,
- x, yt.transfer_y, w, yt.transfer_height,
- (gx_color_index) 1);
+ code = mem_mono_fill_rectangle(dev, x, yt.transfer_y,
+ w, yt.transfer_height,
+ (gx_color_index) 1);
+ if (code < 0)
+ return code;
}
return 0;
}
diff --git a/base/gdevdgbr.c b/base/gdevdgbr.c
index d7b34b77f..ec2414fd2 100644
--- a/base/gdevdgbr.c
+++ b/base/gdevdgbr.c
@@ -330,10 +330,12 @@ gx_get_bits_copy(gx_device * dev, int x, int w, int h,
/* set up parameters required by copy_mono's fit_copy */
tdev.width = dest_bit_x + (align << 3) + bit_w;
tdev.height = 1;
- (*dev_proc(&mem_mono_device, copy_mono))
- ((gx_device *) & tdev, src, bit_x, dev_raster, gx_no_bitmap_id,
- dest_bit_x + (align << 3), 0, bit_w, 1,
- (gx_color_index) 0, (gx_color_index) 1);
+ code = mem_mono_copy_mono((gx_device *) & tdev, src, bit_x,
+ dev_raster, gx_no_bitmap_id,
+ dest_bit_x + (align << 3), 0, bit_w, 1,
+ (gx_color_index) 0, (gx_color_index) 1);
+ if (code < 0)
+ break;
}
} else if (options & ~stored_options & GB_COLORS_NATIVE) {
/* Convert standard colors to native. */
@@ -714,8 +716,7 @@ gx_default_get_bits_rectangle(gx_device * dev, const gs_int_rect * prect,
tdev.line_ptrs = &tdev.base;
tdev.base = data;
tdev.raster = bitmap_raster(width_bits);
- code = (*dev_proc(&mem_mono_device, copy_mono))
- ((gx_device *) & tdev,
+ code = mem_mono_copy_mono((gx_device *) & tdev,
(params->options & GB_RETURN_POINTER) ? params->data[0] : row,
prect->p.x * depth,
min_raster, gx_no_bitmap_id, 0, 0, width_bits, 1,
diff --git a/base/gdevm1.c b/base/gdevm1.c
index 7801c3a64..b5de10eff 100644
--- a/base/gdevm1.c
+++ b/base/gdevm1.c
@@ -426,19 +426,26 @@ mem_mono_strip_copy_rop_dev(gx_device * dev, const byte * sdata,
/* Procedures */
static dev_proc_map_rgb_color(mem_mono_map_rgb_color);
static dev_proc_map_color_rgb(mem_mono_map_color_rgb);
-static dev_proc_copy_mono(mem_mono_copy_mono);
-static dev_proc_fill_rectangle(mem_mono_fill_rectangle);
static dev_proc_strip_tile_rectangle(mem_mono_strip_tile_rectangle);
/* The device descriptor. */
/* The instance is public. */
const gx_device_memory mem_mono_device =
-mem_full_alpha_device("image1", 0, 1, mem_open,
- mem_mono_map_rgb_color, mem_mono_map_color_rgb,
- mem_mono_copy_mono, gx_default_copy_color, mem_mono_fill_rectangle,
- gx_default_map_cmyk_color, gx_no_copy_alpha,
- mem_mono_strip_tile_rectangle, mem_mono_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image1", 0, 1, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_1 =
+{
+ mem_mono_map_rgb_color,
+ mem_mono_map_color_rgb,
+ mem_mono_fill_rectangle,
+ mem_mono_copy_mono,
+ gx_default_copy_color,
+ gx_default_copy_alpha,
+ mem_mono_strip_tile_rectangle,
+ mem_mono_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Map color to/from RGB. This may be inverted. */
static gx_color_index
@@ -458,7 +465,7 @@ mem_mono_map_color_rgb(gx_device * dev, gx_color_index color,
}
/* Fill a rectangle with a color. */
-static int
+int
mem_mono_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
gx_color_index color)
{
@@ -582,7 +589,7 @@ static const copy_mode copy_modes[16] = {
(invert ? gs_note_error(-1) :\
mem_mono_fill_rectangle(dev, x, y, w, h, color0))
-static int
+int
mem_mono_copy_mono(gx_device * dev,
const byte * source_data, int source_x, int source_raster, gx_bitmap_id id,
int x, int y, int w, int h, gx_color_index color0, gx_color_index color1)
@@ -1074,6 +1081,8 @@ int tx, int y, int tw, int th, gx_color_index color0, gx_color_index color1,
#endif /* !USE_COPY_ROP */
}
+
+
/* ================ "Word"-oriented device ================ */
/* Note that on a big-endian machine, this is the same as the */
@@ -1089,12 +1098,21 @@ static dev_proc_fill_rectangle(mem1_word_fill_rectangle);
/* Here is the device descriptor. */
const gx_device_memory mem_mono_word_device =
-mem_full_alpha_device("image1w", 0, 1, mem_open,
- mem_mono_map_rgb_color, mem_mono_map_color_rgb,
- mem1_word_copy_mono, gx_default_copy_color, mem1_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_no_copy_alpha,
- mem1_word_strip_tile_rectangle, gx_no_strip_copy_rop,
- mem_word_get_bits_rectangle);
+ mem_device("image1w", 0, 1, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_1w =
+{
+ mem_mono_map_rgb_color,
+ mem_mono_map_color_rgb,
+ mem1_word_fill_rectangle,
+ mem1_word_copy_mono,
+ gx_default_copy_color,
+ gx_default_copy_alpha,
+ mem1_word_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm16.c b/base/gdevm16.c
index f4d662ebd..9e6db7cda 100644
--- a/base/gdevm16.c
+++ b/base/gdevm16.c
@@ -32,10 +32,21 @@ declare_mem_procs(mem_true16_copy_mono, mem_true16_copy_color, mem_true16_fill_r
/* The device descriptor. */
const gx_device_memory mem_true16_device =
- mem_device("image16", 16, 0,
- mem_true16_map_rgb_color, mem_true16_map_color_rgb,
- mem_true16_copy_mono, mem_true16_copy_color,
- mem_true16_fill_rectangle, mem_default_strip_copy_rop);
+ mem_device("image16", 16, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_16 =
+{
+ mem_true16_map_rgb_color,
+ mem_true16_map_color_rgb,
+ mem_true16_fill_rectangle,
+ mem_true16_copy_mono,
+ mem_true16_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Map a r-g-b color to a color index. */
static gx_color_index
diff --git a/base/gdevm2.c b/base/gdevm2.c
index 863811b8e..e483bd721 100644
--- a/base/gdevm2.c
+++ b/base/gdevm2.c
@@ -31,10 +31,21 @@ declare_mem_procs(mem_mapped2_copy_mono, mem_mapped2_copy_color, mem_mapped2_fil
/* The device descriptor. */
const gx_device_memory mem_mapped2_device =
-mem_device("image2", 2, 0,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem_mapped2_copy_mono, mem_mapped2_copy_color,
- mem_mapped2_fill_rectangle, mem_gray_strip_copy_rop);
+ mem_device("image2", 2, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_2 =
+{
+ mem_mapped_map_rgb_color,
+ mem_mapped_map_color_rgb,
+ mem_mapped2_fill_rectangle,
+ mem_mapped2_copy_mono,
+ mem_mapped2_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_gray_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -157,9 +168,9 @@ mem_mapped2_copy_color(gx_device * dev,
/* Use monobit copy_mono. */
/* Patch the width in the device temporarily. */
dev->width <<= 1;
- code = (*dev_proc(&mem_mono_device, copy_mono))
- (dev, base, sourcex << 1, sraster, id,
- x << 1, y, w << 1, h, (gx_color_index) 0, (gx_color_index) 1);
+ code = mem_mono_copy_mono(dev, base, sourcex << 1, sraster, id,
+ x << 1, y, w << 1, h,
+ (gx_color_index) 0, (gx_color_index) 1);
/* Restore the correct width. */
dev->width >>= 1;
return code;
@@ -177,12 +188,21 @@ declare_mem_procs(mem2_word_copy_mono, mem2_word_copy_color, mem2_word_fill_rect
/* Here is the device descriptor. */
const gx_device_memory mem_mapped2_word_device =
-mem_full_device("image2w", 2, 0, mem_open,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem2_word_copy_mono, mem2_word_copy_color,
- mem2_word_fill_rectangle, gx_default_map_cmyk_color,
- gx_default_strip_tile_rectangle, gx_no_strip_copy_rop,
- mem_word_get_bits_rectangle);
+ mem_device("image2w", 2, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_2w =
+{
+ mem_mapped_map_rgb_color,
+ mem_mapped_map_color_rgb,
+ mem2_word_fill_rectangle,
+ mem2_word_copy_mono,
+ mem2_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
@@ -238,7 +258,7 @@ mem2_word_copy_color(gx_device * dev,
/* Use monobit copy_mono. */
/* Patch the width in the device temporarily. */
dev->width <<= 1;
- code = (*dev_proc(&mem_mono_word_device, copy_mono))
+ code = gdev_mem_word_functions_for_bits(1)->copy_mono
(dev, base, sourcex << 1, sraster, id,
x << 1, y, w << 1, h, (gx_color_index) 0, (gx_color_index) 1);
/* Restore the correct width. */
diff --git a/base/gdevm24.c b/base/gdevm24.c
index 332279b6c..c45e412b1 100644
--- a/base/gdevm24.c
+++ b/base/gdevm24.c
@@ -58,12 +58,21 @@ static dev_proc_copy_alpha(mem_true24_copy_alpha);
/* The device descriptor. */
const gx_device_memory mem_true24_device =
-mem_full_alpha_device("image24", 24, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem_true24_copy_mono, mem_true24_copy_color, mem_true24_fill_rectangle,
- gx_default_map_cmyk_color, mem_true24_copy_alpha,
- gx_default_strip_tile_rectangle, mem_true24_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image24", 24, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_24 =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem_true24_fill_rectangle,
+ mem_true24_copy_mono,
+ mem_true24_copy_color,
+ mem_true24_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_true24_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -551,11 +560,21 @@ declare_mem_procs(mem24_word_copy_mono, mem24_word_copy_color, mem24_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true24_word_device =
-mem_full_device("image24w", 24, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem24_word_copy_mono, mem24_word_copy_color, mem24_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image24w", 24, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_24w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem24_word_fill_rectangle,
+ mem24_word_copy_mono,
+ mem24_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm32.c b/base/gdevm32.c
index 414831c19..725f0831d 100644
--- a/base/gdevm32.c
+++ b/base/gdevm32.c
@@ -30,11 +30,21 @@ declare_mem_procs(mem_true32_copy_mono, mem_true32_copy_color, mem_true32_fill_r
/* The device descriptor. */
const gx_device_memory mem_true32_device =
-mem_full_device("image32", 24, 8, mem_open,
- gx_default_map_rgb_color, gx_default_map_color_rgb,
- mem_true32_copy_mono, mem_true32_copy_color, mem_true32_fill_rectangle,
- gx_default_cmyk_map_cmyk_color, gx_default_strip_tile_rectangle,
- mem_default_strip_copy_rop, mem_get_bits_rectangle);
+ mem_device("image32", 24, 8, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_32 =
+{
+ gx_default_map_rgb_color,
+ gx_default_map_color_rgb,
+ mem_true32_fill_rectangle,
+ mem_true32_copy_mono,
+ mem_true32_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -248,11 +258,21 @@ declare_mem_procs(mem32_word_copy_mono, mem32_word_copy_color, mem32_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true32_word_device =
-mem_full_device("image32w", 24, 8, mem_open,
- gx_default_map_rgb_color, gx_default_map_color_rgb,
- mem32_word_copy_mono, mem32_word_copy_color, mem32_word_fill_rectangle,
- gx_default_cmyk_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image32w", 24, 8, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_32w =
+{
+ gx_default_map_rgb_color,
+ gx_default_map_color_rgb,
+ mem32_word_fill_rectangle,
+ mem32_word_copy_mono,
+ mem32_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm4.c b/base/gdevm4.c
index 51940a5bd..638fd9c16 100644
--- a/base/gdevm4.c
+++ b/base/gdevm4.c
@@ -31,10 +31,21 @@ declare_mem_procs(mem_mapped4_copy_mono, mem_mapped4_copy_color, mem_mapped4_fil
/* The device descriptor. */
const gx_device_memory mem_mapped4_device =
-mem_device("image4", 3, 1,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem_mapped4_copy_mono, mem_mapped4_copy_color, mem_mapped4_fill_rectangle,
- mem_gray_strip_copy_rop);
+ mem_device("image4", 3, 1, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_4 =
+{
+ mem_mapped_map_rgb_color,
+ mem_mapped_map_color_rgb,
+ mem_mapped4_fill_rectangle,
+ mem_mapped4_copy_mono,
+ mem_mapped4_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_gray_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -216,9 +227,9 @@ mem_mapped4_copy_color(gx_device * dev,
/* Patch the width in the device temporarily. */
dev->width <<= 2;
- code = (*dev_proc(&mem_mono_device, copy_mono))
- (dev, base, sourcex << 2, sraster, id,
- x << 2, y, w << 2, h, (gx_color_index) 0, (gx_color_index) 1);
+ code = mem_mono_copy_mono(dev, base, sourcex << 2, sraster, id,
+ x << 2, y, w << 2, h,
+ (gx_color_index) 0, (gx_color_index) 1);
/* Restore the correct width. */
dev->width >>= 2;
return code;
@@ -236,11 +247,21 @@ declare_mem_procs(mem4_word_copy_mono, mem4_word_copy_color, mem4_word_fill_rect
/* Here is the device descriptor. */
const gx_device_memory mem_mapped4_word_device =
-mem_full_device("image4w", 4, 0, mem_open,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem4_word_copy_mono, mem4_word_copy_color, mem4_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image4w", 4, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_4w =
+{
+ mem_mapped_map_rgb_color,
+ mem_mapped_map_color_rgb,
+ mem4_word_fill_rectangle,
+ mem4_word_copy_mono,
+ mem4_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
@@ -295,7 +316,7 @@ mem4_word_copy_color(gx_device * dev,
/* Use monobit copy_mono. */
/* Patch the width in the device temporarily. */
dev->width <<= 2;
- code = (*dev_proc(&mem_mono_word_device, copy_mono))
+ code = gdev_mem_word_functions_for_bits(1)->copy_mono
(dev, base, sourcex << 2, sraster, id,
x << 2, y, w << 2, h, (gx_color_index) 0, (gx_color_index) 1);
/* Restore the correct width. */
diff --git a/base/gdevm40.c b/base/gdevm40.c
index 0946a0334..d244573a8 100644
--- a/base/gdevm40.c
+++ b/base/gdevm40.c
@@ -46,12 +46,21 @@ declare_mem_procs(mem_true40_copy_mono, mem_true40_copy_color, mem_true40_fill_r
/* The device descriptor. */
const gx_device_memory mem_true40_device =
-mem_full_alpha_device("image40", 40, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem_true40_copy_mono, mem_true40_copy_color, mem_true40_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_copy_alpha,
- gx_default_strip_tile_rectangle, mem_default_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image40", 40, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_40 =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem_true40_fill_rectangle,
+ mem_true40_copy_mono,
+ mem_true40_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -416,11 +425,21 @@ declare_mem_procs(mem40_word_copy_mono, mem40_word_copy_color, mem40_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true40_word_device =
-mem_full_device("image40w", 40, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem40_word_copy_mono, mem40_word_copy_color, mem40_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image40w", 40, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_40w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem40_word_fill_rectangle,
+ mem40_word_copy_mono,
+ mem40_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm48.c b/base/gdevm48.c
index d951ccfa5..310883f6f 100644
--- a/base/gdevm48.c
+++ b/base/gdevm48.c
@@ -46,12 +46,21 @@ declare_mem_procs(mem_true48_copy_mono, mem_true48_copy_color, mem_true48_fill_r
/* The device descriptor. */
const gx_device_memory mem_true48_device =
-mem_full_alpha_device("image48", 48, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem_true48_copy_mono, mem_true48_copy_color, mem_true48_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_copy_alpha,
- gx_default_strip_tile_rectangle, mem_default_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image48", 48, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_48 =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem_true48_fill_rectangle,
+ mem_true48_copy_mono,
+ mem_true48_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -385,11 +394,21 @@ declare_mem_procs(mem48_word_copy_mono, mem48_word_copy_color, mem48_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true48_word_device =
-mem_full_device("image48w", 48, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem48_word_copy_mono, mem48_word_copy_color, mem48_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image48w", 48, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_48w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem48_word_fill_rectangle,
+ mem48_word_copy_mono,
+ mem48_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm56.c b/base/gdevm56.c
index 72774fb97..9e490df80 100644
--- a/base/gdevm56.c
+++ b/base/gdevm56.c
@@ -46,12 +46,21 @@ declare_mem_procs(mem_true56_copy_mono, mem_true56_copy_color, mem_true56_fill_r
/* The device descriptor. */
const gx_device_memory mem_true56_device =
-mem_full_alpha_device("image56", 56, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem_true56_copy_mono, mem_true56_copy_color, mem_true56_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_copy_alpha,
- gx_default_strip_tile_rectangle, mem_default_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image56", 56, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_56 =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem_true56_fill_rectangle,
+ mem_true56_copy_mono,
+ mem_true56_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -440,11 +449,21 @@ declare_mem_procs(mem56_word_copy_mono, mem56_word_copy_color, mem56_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true56_word_device =
-mem_full_device("image56w", 56, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem56_word_copy_mono, mem56_word_copy_color, mem56_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image56w", 56, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_56w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem56_word_fill_rectangle,
+ mem56_word_copy_mono,
+ mem56_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm64.c b/base/gdevm64.c
index 899713ef3..f9f923b8e 100644
--- a/base/gdevm64.c
+++ b/base/gdevm64.c
@@ -46,12 +46,21 @@ declare_mem_procs(mem_true64_copy_mono, mem_true64_copy_color, mem_true64_fill_r
/* The device descriptor. */
const gx_device_memory mem_true64_device =
-mem_full_alpha_device("image64", 64, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem_true64_copy_mono, mem_true64_copy_color, mem_true64_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_copy_alpha,
- gx_default_strip_tile_rectangle, mem_default_strip_copy_rop,
- mem_get_bits_rectangle);
+ mem_device("image64", 64, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_64 =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem_true64_fill_rectangle,
+ mem_true64_copy_mono,
+ mem_true64_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_default_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -343,11 +352,21 @@ declare_mem_procs(mem64_word_copy_mono, mem64_word_copy_color, mem64_word_fill_r
/* Here is the device descriptor. */
const gx_device_memory mem_true64_word_device =
-mem_full_device("image64w", 64, 0, mem_open,
- gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb,
- mem64_word_copy_mono, mem64_word_copy_color, mem64_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image64w", 64, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_64w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem64_word_fill_rectangle,
+ mem64_word_copy_mono,
+ mem64_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevm8.c b/base/gdevm8.c
index 650135070..d91202b35 100644
--- a/base/gdevm8.c
+++ b/base/gdevm8.c
@@ -32,10 +32,21 @@ declare_mem_procs(mem_mapped8_copy_mono, mem_mapped8_copy_color, mem_mapped8_fil
/* The device descriptor. */
const gx_device_memory mem_mapped8_device =
-mem_device("image8", 8, 0,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem_mapped8_copy_mono, mem_mapped8_copy_color, mem_mapped8_fill_rectangle,
- mem_gray8_strip_copy_rop);
+ mem_device("image8", 8, 0, mem_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_8 =
+{
+ mem_mapped_map_rgb_color,
+ mem_mapped_map_color_rgb,
+ mem_mapped8_fill_rectangle,
+ mem_mapped8_copy_mono,
+ mem_mapped8_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ mem_gray8_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_get_bits_rectangle
+};
/* Convert x coordinate to byte offset in scan line. */
#undef x_to_byte
@@ -330,11 +341,21 @@ declare_mem_procs(mem8_word_copy_mono, mem8_word_copy_color, mem8_word_fill_rect
/* Here is the device descriptor. */
const gx_device_memory mem_mapped8_word_device =
-mem_full_device("image8w", 8, 0, mem_open,
- mem_mapped_map_rgb_color, mem_mapped_map_color_rgb,
- mem8_word_copy_mono, mem8_word_copy_color, mem8_word_fill_rectangle,
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,
- gx_no_strip_copy_rop, mem_word_get_bits_rectangle);
+ mem_device("image8w", 8, 0, mem_word_dev_initialize);
+
+const gdev_mem_functions gdev_mem_fns_8w =
+{
+ gx_default_rgb_map_rgb_color,
+ gx_default_rgb_map_color_rgb,
+ mem8_word_fill_rectangle,
+ mem8_word_copy_mono,
+ mem8_word_copy_color,
+ gx_default_copy_alpha,
+ gx_default_strip_tile_rectangle,
+ gx_no_strip_copy_rop,
+ gx_default_strip_copy_rop2,
+ mem_word_get_bits_rectangle
+};
/* Fill a rectangle with a color. */
static int
diff --git a/base/gdevmem.c b/base/gdevmem.c
index b8d9f7cd4..b5c5cd222 100644
--- a/base/gdevmem.c
+++ b/base/gdevmem.c
@@ -122,6 +122,44 @@ gdev_mem_word_device_for_bits(int bits_per_pixel)
mem_word_devices[bits_per_pixel]);
}
+static const gdev_mem_functions *mem_fns[65] = {
+ NULL, &gdev_mem_fns_1, &gdev_mem_fns_2, NULL,
+ &gdev_mem_fns_4, NULL, NULL, NULL,
+ &gdev_mem_fns_8, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_16, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_24, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_32, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_40, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_48, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_56, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_64
+};
+
+const gdev_mem_functions *
+gdev_mem_functions_for_bits(int bits_per_pixel)
+{
+ return ((uint)bits_per_pixel > 64 ? NULL : mem_fns[bits_per_pixel]);
+}
+
+static const gdev_mem_functions *mem_word_fns[65] = {
+ NULL, &gdev_mem_fns_1, &gdev_mem_fns_2w, NULL,
+ &gdev_mem_fns_4w, NULL, NULL, NULL,
+ &gdev_mem_fns_8w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_24w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_32w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_40w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_48w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_56w, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
+ &gdev_mem_fns_64w
+};
+
+const gdev_mem_functions *
+gdev_mem_word_functions_for_bits(int bits_per_pixel)
+{
+ return ((uint)bits_per_pixel > 64 ? NULL : mem_word_fns[bits_per_pixel]);
+}
+
/* Test whether a device is a memory device */
bool
gs_device_is_memory(const gx_device * dev)
@@ -130,17 +168,7 @@ gs_device_is_memory(const gx_device * dev)
* We use the draw_thin_line procedure to mark memory devices.
* See gdevmem.h.
*/
- int bits_per_pixel = dev->color_info.depth;
- const gx_device_memory *mdproto;
-
- if (dev->is_planar)
- bits_per_pixel /= dev->color_info.num_components;
-
- mdproto = gdev_mem_device_for_bits(bits_per_pixel);
- if (mdproto != 0 && dev_proc(dev, draw_thin_line) == dev_proc(mdproto, draw_thin_line))
- return true;
- mdproto = gdev_mem_word_device_for_bits(bits_per_pixel);
- return (mdproto != 0 && dev_proc(dev, draw_thin_line) == dev_proc(mdproto, draw_thin_line));
+ return (dev_proc(dev, draw_thin_line) == mem_draw_thin_line);
}
/* Make a memory device. */
@@ -851,3 +879,91 @@ mem_draw_thin_line(gx_device *dev, fixed fx0, fixed fy0, fixed fx1, fixed fy1,
return gx_default_draw_thin_line(dev, fx0, fy0, fx1, fy1, pdcolor, lop,
adjustx, adjusty);
}
+
+void mem_initialize(gx_device *dev)
+{
+ set_dev_proc(dev, get_initial_matrix, mem_get_initial_matrix);
+ set_dev_proc(dev, sync_output, gx_default_sync_output);
+ set_dev_proc(dev, output_page, gx_default_output_page);
+ set_dev_proc(dev, close_device, mem_close);
+ set_dev_proc(dev, tile_rectangle, gx_default_tile_rectangle);
+ set_dev_proc(dev, obsolete_draw_line, gx_default_draw_line);
+ set_dev_proc(dev, get_bits, gx_default_get_bits);
+ set_dev_proc(dev, get_params, gx_default_get_params);
+ set_dev_proc(dev, put_params, gx_default_put_params);
+ set_dev_proc(dev, get_xfont_procs, gx_forward_get_xfont_procs);
+ set_dev_proc(dev, get_xfont_device, gx_forward_get_xfont_device);
+ set_dev_proc(dev, map_rgb_alpha_color, gx_default_map_rgb_alpha_color);
+ set_dev_proc(dev, get_page_device, gx_forward_get_page_device);
+ set_dev_proc(dev, get_alpha_bits, gx_default_get_alpha_bits);
+ set_dev_proc(dev, get_band, gx_default_get_band);
+ set_dev_proc(dev, copy_rop, gx_default_copy_rop);
+ set_dev_proc(dev, fill_path, gx_default_fill_path);
+ set_dev_proc(dev, stroke_path, gx_default_stroke_path);
+ set_dev_proc(dev, fill_mask, gx_default_fill_mask);
+ set_dev_proc(dev, fill_trapezoid, gx_default_fill_trapezoid);
+ set_dev_proc(dev, fill_parallelogram, gx_default_fill_parallelogram);
+ set_dev_proc(dev, fill_triangle, gx_default_fill_triangle);
+ set_dev_proc(dev, draw_thin_line, mem_draw_thin_line);
+ set_dev_proc(dev, begin_image, gx_default_begin_image);
+ set_dev_proc(dev, image_data, gx_default_image_data);
+ set_dev_proc(dev, end_image, gx_default_end_image);
+ set_dev_proc(dev, get_clipping_box, gx_default_get_clipping_box);
+ set_dev_proc(dev, begin_typed_image, gx_default_begin_typed_image);
+ set_dev_proc(dev, map_color_rgb_alpha, gx_default_map_color_rgb_alpha);
+ set_dev_proc(dev, create_compositor, gx_default_create_compositor);
+ set_dev_proc(dev, get_hardware_params, gx_default_get_hardware_params);
+ set_dev_proc(dev, text_begin, gx_default_text_begin);
+ set_dev_proc(dev, transform_pixel_region, mem_transform_pixel_region);
+
+ /* Defaults that may well get overridden. */
+ set_dev_proc(dev, open_device, mem_open);
+ set_dev_proc(dev, copy_alpha, gx_default_copy_alpha);
+ set_dev_proc(dev, map_cmyk_color, gx_default_map_cmyk_color);
+ set_dev_proc(dev, strip_tile_rectangle, gx_default_strip_tile_rectangle);
+ set_dev_proc(dev, get_bits_rectangle, mem_get_bits_rectangle);
+}
+
+int mem_dev_initialize(gx_device *dev)
+{
+ int depth = dev->color_info.depth;
+ const gdev_mem_functions *fns;
+
+ if (dev->is_planar)
+ depth /= dev->color_info.num_components;
+ fns = gdev_mem_functions_for_bits(depth);
+
+ mem_initialize(dev);
+
+ set_dev_proc(dev, map_rgb_color, fns->map_rgb_color);
+ set_dev_proc(dev, map_color_rgb, fns->map_color_rgb);
+ set_dev_proc(dev, fill_rectangle, fns->fill_rectangle);
+ set_dev_proc(dev, copy_mono, fns->copy_mono);
+ set_dev_proc(dev, copy_color, fns->copy_color);
+ set_dev_proc(dev, copy_alpha, fns->copy_alpha);
+ set_dev_proc(dev, strip_copy_rop, fns->strip_copy_rop);
+ set_dev_proc(dev, strip_copy_rop2, fns->strip_copy_rop2);
+ set_dev_proc(dev, strip_tile_rectangle, fns->strip_tile_rectangle);
+
+ return 0;
+}
+
+int mem_word_dev_initialize(gx_device *dev)
+{
+ const gdev_mem_functions *fns =
+ gdev_mem_word_functions_for_bits(dev->color_info.depth);
+
+ mem_initialize(dev);
+
+ set_dev_proc(dev, map_rgb_color, fns->map_rgb_color);
+ set_dev_proc(dev, map_color_rgb, fns->map_color_rgb);
+ set_dev_proc(dev, fill_rectangle, fns->fill_rectangle);
+ set_dev_proc(dev, copy_mono, fns->copy_mono);
+ set_dev_proc(dev, copy_color, fns->copy_color);
+ set_dev_proc(dev, copy_alpha, fns->copy_alpha);
+ set_dev_proc(dev, strip_copy_rop, fns->strip_copy_rop);
+ set_dev_proc(dev, strip_copy_rop2, fns->strip_copy_rop2);
+ set_dev_proc(dev, strip_tile_rectangle, fns->strip_tile_rectangle);
+
+ return 0;
+}
diff --git a/base/gdevmem.h b/base/gdevmem.h
index 7decce315..0cd89f9ab 100644
--- a/base/gdevmem.h
+++ b/base/gdevmem.h
@@ -120,7 +120,12 @@ dev_proc_transform_pixel_region(mem_transform_pixel_region);
#define max_value_rgb(rgb_depth, gray_depth)\
(rgb_depth >= 8 ? 255 : rgb_depth == 4 ? 15 : rgb_depth == 2 ? 3 :\
rgb_depth == 1 ? 1 : (1 << gray_depth) - 1)
-#define mem_full_alpha_device_hl(name, rgb_depth, gray_depth, open, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, map_cmyk_color, copy_alpha, strip_tile_rectangle, strip_copy_rop, get_bits_rectangle, fill_rectangle_hl_color)\
+
+void mem_initialize(gx_device *dev);
+int mem_dev_initialize(gx_device *dev);
+int mem_word_dev_initialize(gx_device *dev);
+
+#define mem_device(name, rgb_depth, gray_depth, initialize)\
{ std_device_dci_body(gx_device_memory, 0, name,\
0, 0, 72, 72,\
(rgb_depth ? 3 : 0) + (gray_depth ? 1 : 0), /* num_components */\
@@ -130,110 +135,10 @@ dev_proc_transform_pixel_region(mem_transform_pixel_region);
max_value_gray(rgb_depth, gray_depth) + 1, /* dither_grays */\
max_value_rgb(rgb_depth, gray_depth) + 1 /* dither_colors */\
),\
- { open, /* differs */\
- mem_get_initial_matrix,\
- gx_default_sync_output,\
- gx_default_output_page,\
- mem_close,\
- map_rgb_color, /* differs */\
- map_color_rgb, /* differs */\
- fill_rectangle, /* differs */\
- gx_default_tile_rectangle,\
- copy_mono, /* differs */\
- copy_color, /* differs */\
- gx_default_draw_line,\
- gx_default_get_bits,\
- gx_default_get_params,\
- gx_default_put_params,\
- map_cmyk_color, /* differs */\
- gx_forward_get_xfont_procs,\
- gx_forward_get_xfont_device,\
- gx_default_map_rgb_alpha_color,\
- gx_forward_get_page_device,\
- gx_default_get_alpha_bits, /* default is no alpha */\
- copy_alpha, /* differs */\
- gx_default_get_band,\
- gx_default_copy_rop,\
- gx_default_fill_path,\
- gx_default_stroke_path,\
- gx_default_fill_mask,\
- gx_default_fill_trapezoid,\
- gx_default_fill_parallelogram,\
- gx_default_fill_triangle,\
- mem_draw_thin_line, /* see above */\
- gx_default_begin_image,\
- gx_default_image_data,\
- gx_default_end_image,\
- strip_tile_rectangle, /* differs */\
- strip_copy_rop, /* differs */\
- gx_default_get_clipping_box,\
- gx_default_begin_typed_image,\
- get_bits_rectangle, /* differs */\
- gx_default_map_color_rgb_alpha,\
- gx_default_create_compositor,\
- gx_default_get_hardware_params,\
- gx_default_text_begin,\
- NULL, /* initialize */\
- NULL, /* begin_transparency_group */\
- NULL, /* end_transparency_group */\
- NULL, /* begin_transparency_mask */\
- NULL, /* end_transparency_mask */\
- NULL, /* discard_transparency_layer */\
- NULL, /* get_color_mapping_procs */\
- NULL, /* get_color_comp_index */\
- NULL, /* encode_color */\
- NULL, /* decode_color */\
- NULL, /* pattern_manage */\
- fill_rectangle_hl_color, /* fill_rectangle_hl_color */\
- NULL, /* include_color_space */\
- NULL, /* fill_linear_color_scanline */\
- NULL, /* fill_linear_color_trapezoid */\
- NULL, /* fill_linear_color_triangle */\
- NULL, /* update_spot_equivalent_colors */\
- NULL, /* ret_devn_params */\
- NULL, /* fillpage */\
- NULL, /* push_transparency_state */\
- NULL, /* pop_transparency_state */\
- NULL, /* put_image */\
- NULL, /* dev_spec_op */\
- NULL, /* copy_planes */\
- NULL, /* get_profile */\
- NULL, /* set_graphics_type_tag */\
- NULL, /* strip_copy_rop2 */\
- NULL, /* strip_tile_rect_devn */\
- NULL, /* copy_alpha_hl_color */\
- NULL, /* process_page */\
- mem_transform_pixel_region,\
- NULL, /* fill_stroke_path */\
- },\
+ devprocs_initialize(initialize),\
0, /* target */\
mem_device_init_private /* see gxdevmem.h */\
}
-#define mem_full_alpha_device(name, rgb_depth, gray_depth, open, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, map_cmyk_color, copy_alpha, strip_tile_rectangle, strip_copy_rop, get_bits_rectangle)\
- mem_full_alpha_device_hl(name, rgb_depth, gray_depth, open, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, map_cmyk_color, copy_alpha, strip_tile_rectangle, strip_copy_rop, get_bits_rectangle, NULL)
-
-#define mem_full_device(name, rgb_depth, gray_depth, open, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, map_cmyk_color, strip_tile_rectangle, strip_copy_rop, get_bits_rectangle)\
- mem_full_alpha_device(name, rgb_depth, gray_depth, open, map_rgb_color,\
- map_color_rgb, copy_mono, copy_color, fill_rectangle,\
- map_cmyk_color, gx_default_copy_alpha,\
- strip_tile_rectangle, strip_copy_rop,\
- get_bits_rectangle)
-#define mem_device(name, rgb_depth, gray_depth, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, strip_copy_rop)\
- mem_full_device(name, rgb_depth, gray_depth, mem_open, map_rgb_color,\
- map_color_rgb, copy_mono, copy_color, fill_rectangle,\
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,\
- strip_copy_rop, mem_get_bits_rectangle)
-#define mem_full_device_hl(name, rgb_depth, gray_depth, open, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, map_cmyk_color, strip_tile_rectangle, strip_copy_rop, get_bits_rectangle, fill_rectangle_hl)\
- mem_full_alpha_device_hl(name, rgb_depth, gray_depth, open, map_rgb_color,\
- map_color_rgb, copy_mono, copy_color, fill_rectangle,\
- map_cmyk_color, gx_default_copy_alpha,\
- strip_tile_rectangle, strip_copy_rop,\
- get_bits_rectangle, fill_rectangle_hl)
-#define mem_device_hl(name, rgb_depth, gray_depth, map_rgb_color, map_color_rgb, copy_mono, copy_color, fill_rectangle, strip_copy_rop, fill_rectangle_hl)\
- mem_full_device_hl(name, rgb_depth, gray_depth, mem_open, map_rgb_color,\
- map_color_rgb, copy_mono, copy_color, fill_rectangle,\
- gx_default_map_cmyk_color, gx_default_strip_tile_rectangle,\
- strip_copy_rop, mem_get_bits_rectangle, fill_rectangle_hl)
/* Swap a rectangle of bytes, for converting between word- and */
/* byte-oriented representation. */
@@ -269,6 +174,8 @@ dev_proc_strip_copy_rop(mem_mono_strip_copy_rop);
dev_proc_strip_copy_rop(mem_mono_strip_copy_rop_dev);
dev_proc_strip_copy_rop(mem_gray_strip_copy_rop);
dev_proc_strip_copy_rop(mem_gray8_rgb24_strip_copy_rop);
+dev_proc_copy_mono(mem_mono_copy_mono);
+dev_proc_fill_rectangle(mem_mono_fill_rectangle);
#if ARCH_IS_BIG_ENDIAN
# define mem_mono_word_device mem_mono_device
diff --git a/base/gdevmpla.c b/base/gdevmpla.c
index d233a1324..81c5bfffd 100644
--- a/base/gdevmpla.c
+++ b/base/gdevmpla.c
@@ -94,7 +94,8 @@ gdev_mem_set_planar_interleaved(gx_device_memory * mdev, int num_planes,
int same_depth = planes[0].depth;
gx_color_index covered = 0;
int pi;
- const gx_device_memory *mdproto = gdev_mem_device_for_bits(mdev->color_info.depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(mdev->color_info.depth);
if (num_planes < 1 || num_planes > GX_DEVICE_COLOR_MAX_COMPONENTS || num_planes != mdev->color_info.num_components)
return_error(gs_error_rangecheck);
@@ -136,14 +137,14 @@ gdev_mem_set_planar_interleaved(gx_device_memory * mdev, int num_planes,
mem_planar_fill_rectangle_hl_color);
if (num_planes == 1) {
/* For 1 plane, just use a normal device */
- set_dev_proc(mdev, fill_rectangle, dev_proc(mdproto, fill_rectangle));
- set_dev_proc(mdev, copy_mono, dev_proc(mdproto, copy_mono));
- set_dev_proc(mdev, copy_color, dev_proc(mdproto, copy_color));
- set_dev_proc(mdev, copy_alpha, dev_proc(mdproto, copy_alpha));
- set_dev_proc(mdev, strip_tile_rectangle, dev_proc(mdproto, strip_tile_rectangle));
- set_dev_proc(mdev, strip_copy_rop, dev_proc(mdproto, strip_copy_rop));
- set_dev_proc(mdev, strip_copy_rop2, dev_proc(mdproto, strip_copy_rop2));
- set_dev_proc(mdev, get_bits_rectangle, dev_proc(mdproto, get_bits_rectangle));
+ set_dev_proc(mdev, fill_rectangle, fns->fill_rectangle);
+ set_dev_proc(mdev, copy_mono, fns->copy_mono);
+ set_dev_proc(mdev, copy_color, fns->copy_color);
+ set_dev_proc(mdev, copy_alpha, fns->copy_alpha);
+ set_dev_proc(mdev, strip_tile_rectangle, fns->strip_tile_rectangle);
+ set_dev_proc(mdev, strip_copy_rop, fns->strip_copy_rop);
+ set_dev_proc(mdev, strip_copy_rop2, fns->strip_copy_rop2);
+ set_dev_proc(mdev, get_bits_rectangle, fns->get_bits_rectangle);
} else {
/* If we are going out to a separation device or one that has more than
four planes then use the high level color filling procedure. Also
@@ -247,7 +248,7 @@ put_image_copy_planes(gx_device * dev, const byte **base_ptr, int sourcex,
gx_device_memory * const mdev = (gx_device_memory *)dev;
int plane_depth;
mem_save_params_t save;
- const gx_device_memory *mdproto;
+ const gdev_mem_functions *fns;
int code = 0;
uchar plane;
@@ -256,19 +257,17 @@ put_image_copy_planes(gx_device * dev, const byte **base_ptr, int sourcex,
{
const byte *base = base_ptr[plane];
plane_depth = mdev->planes[plane].depth;
- mdproto = gdev_mem_device_for_bits(plane_depth);
+ fns = gdev_mem_functions_for_bits(plane_depth);
if (base == NULL) {
/* Blank the plane */
- code = dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h,
+ code = fns->fill_rectangle(dev, x, y, w, h,
(gx_color_index)(dev->color_info.polarity == GX_CINFO_POLARITY_ADDITIVE ? 0 : -1));
} else if (plane_depth == 1)
- code = dev_proc(mdproto, copy_mono)(dev, base, sourcex, sraster, id,
- x, y, w, h,
- (gx_color_index)0,
- (gx_color_index)1);
+ code = fns->copy_mono(dev, base, sourcex, sraster, id,
+ x, y, w, h,
+ (gx_color_index)0, (gx_color_index)1);
else
- code = dev_proc(mdproto, copy_color)(dev, base, sourcex, sraster,
- id, x, y, w, h);
+ fns->copy_color(dev, base, sourcex, sraster, id, x, y, w, h);
mdev->line_ptrs += mdev->height;
}
MEM_RESTORE_PARAMS(mdev, save);
@@ -319,11 +318,12 @@ mem_planar_fill_rectangle_hl_color(gx_device *dev, const gs_fixed_rect *rect,
int plane_depth = mdev->planes[pi].depth;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
int shift = 16 - plane_depth;
- const gx_device_memory *mdproto = gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
MEM_SET_PARAMS(mdev, plane_depth);
- dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h,
- (pdcolor->colors.devn.values[pi]) >> shift & mask);
+ fns->fill_rectangle(dev, x, y, w, h,
+ (pdcolor->colors.devn.values[pi]) >> shift & mask);
mdev->line_ptrs += mdev->height;
}
MEM_RESTORE_PARAMS(mdev, save);
@@ -343,13 +343,12 @@ mem_planar_fill_rectangle(gx_device * dev, int x, int y, int w, int h,
for (pi = 0; pi < mdev->color_info.num_components; ++pi) {
int plane_depth = mdev->planes[pi].depth;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
- const gx_device_memory *mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
MEM_SET_PARAMS(mdev, plane_depth);
- dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h,
- (color >> mdev->planes[pi].shift) &
- mask);
+ fns->fill_rectangle(dev, x, y, w, h,
+ (color >> mdev->planes[pi].shift) & mask);
mdev->line_ptrs += mdev->height;
}
MEM_RESTORE_PARAMS(mdev, save);
@@ -371,8 +370,8 @@ mem_planar_copy_mono(gx_device * dev, const byte * base, int sourcex,
int plane_depth = mdev->planes[pi].depth;
int shift = mdev->planes[pi].shift;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
- const gx_device_memory *mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
gx_color_index c0 =
(color0 == gx_no_color_index ? gx_no_color_index :
(color0 >> shift) & mask);
@@ -382,10 +381,10 @@ mem_planar_copy_mono(gx_device * dev, const byte * base, int sourcex,
MEM_SET_PARAMS(mdev, plane_depth);
if (c0 == c1)
- dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h, c0);
+ fns->fill_rectangle(dev, x, y, w, h, c0);
else
- dev_proc(mdproto, copy_mono)
- (dev, base, sourcex, sraster, id, x, y, w, h, c0, c1);
+ fns->copy_mono(dev, base, sourcex, sraster, id,
+ x, y, w, h, c0, c1);
mdev->line_ptrs += mdev->height;
}
MEM_RESTORE_PARAMS(mdev, save);
@@ -406,7 +405,8 @@ mem_planar_copy_color_24to8(gx_device * dev, const byte * base, int sourcex,
byte b[BUF_BYTES];
} buf, buf1, buf2;
mem_save_params_t save;
- const gx_device_memory *mdproto = gdev_mem_device_for_bits(8);
+ dev_proc_copy_color((*copy_color)) =
+ gdev_mem_functions_for_bits(8)->copy_color;
uint plane_raster = bitmap_raster(w<<3);
int br, bw, bh, cx, cy, cw, ch, ix, iy;
@@ -449,14 +449,11 @@ mem_planar_copy_color_24to8(gx_device * dev, const byte * base, int sourcex,
} while (--ix);
source_base += sraster;
}
- dev_proc(mdproto, copy_color)
- (dev, buf.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
+ copy_color(dev, buf.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_color)
- (dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
+ copy_color(dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_color)
- (dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
+ copy_color(dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
mdev->line_ptrs -= 2*mdev->height;
}
}
@@ -485,7 +482,8 @@ mem_planar_copy_color_4to1(gx_device * dev, const byte * base, int sourcex,
byte b[BUF_BYTES];
} buf0, buf1, buf2, buf3;
mem_save_params_t save;
- const gx_device_memory *mdproto = gdev_mem_device_for_bits(1);
+ dev_proc_copy_mono((*copy_mono)) =
+ gdev_mem_fill_functions_for_bits(1)->copy_mono;
uint plane_raster = bitmap_raster(w);
int br, bw, bh, cx, cy, cw, ch, ix, iy;
@@ -632,21 +630,17 @@ loop_entry:
source_base += sraster;
}
}
- dev_proc(mdproto, copy_mono)
- (dev, buf0.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf0.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf3.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf3.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs -= 3*mdev->height;
}
}
@@ -736,7 +730,8 @@ mem_planar_copy_color_4to1(gx_device * dev, const byte * base, int sourcex,
byte b[BUF_BYTES];
} buf0, buf1, buf2, buf3;
mem_save_params_t save;
- const gx_device_memory *mdproto = gdev_mem_device_for_bits(1);
+ dev_proc_copy_mono((*copy_mono)) =
+ gdev_mem_functions_for_bits(1)->copy_mono;
uint plane_raster = bitmap_raster(w);
int br, bw, bh, cx, cy, cw, ch, ix, iy;
@@ -833,21 +828,17 @@ loop_entry:
source_base += sraster;
}
}
- dev_proc(mdproto, copy_mono)
- (dev, buf0.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf0.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf1.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf2.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs += mdev->height;
- dev_proc(mdproto, copy_mono)
- (dev, buf3.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
- (gx_color_index)0, (gx_color_index)1);
+ copy_mono(dev, buf3.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
+ (gx_color_index)0, (gx_color_index)1);
mdev->line_ptrs -= 3*mdev->height;
}
}
@@ -888,8 +879,8 @@ mem_planar_copy_color(gx_device * dev, const byte * base, int sourcex,
int plane_depth = mdev->planes[pi].depth;
int shift = mdev->planes[pi].shift;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
- const gx_device_memory *mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
/*
* Divide up the transfer into chunks that can be assembled
* within the fixed-size buffer. This code can be simplified
@@ -960,11 +951,11 @@ mem_planar_copy_color(gx_device * dev, const byte * base, int sourcex,
* defined in terms of copy_mono.
*/
if (plane_depth == 1)
- dev_proc(mdproto, copy_mono)
+ fns->copy_mono
(dev, buf.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch,
(gx_color_index)0, (gx_color_index)1);
else
- dev_proc(mdproto, copy_color)
+ fns->copy_color
(dev, buf.b, 0, br, gx_no_bitmap_id, cx, cy, cw, ch);
}
}
@@ -983,25 +974,23 @@ mem_planar_copy_planes(gx_device * dev, const byte * base, int sourcex,
int x, int y, int w, int h, int plane_height)
{
gx_device_memory * const mdev = (gx_device_memory *)dev;
- int plane_depth;
mem_save_params_t save;
- const gx_device_memory *mdproto;
int code = 0;
uchar plane;
MEM_SAVE_PARAMS(mdev, save);
for (plane = 0; plane < mdev->color_info.num_components; plane++)
{
- plane_depth = mdev->planes[plane].depth;
- mdproto = gdev_mem_device_for_bits(plane_depth);
+ int plane_depth = mdev->planes[plane].depth;
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
if (plane_depth == 1)
- code = dev_proc(mdproto, copy_mono)(dev, base, sourcex, sraster, id,
- x, y, w, h,
- (gx_color_index)0,
- (gx_color_index)1);
+ code = fns->copy_mono(dev, base, sourcex, sraster, id,
+ x, y, w, h,
+ (gx_color_index)0, (gx_color_index)1);
else
- code = dev_proc(mdproto, copy_color)(dev, base, sourcex, sraster,
- id, x, y, w, h);
+ code = fns->copy_color(dev, base, sourcex, sraster,
+ id, x, y, w, h);
base += sraster * plane_height;
mdev->line_ptrs += mdev->height;
}
@@ -1024,8 +1013,8 @@ mem_planar_strip_tile_rect_devn(gx_device * dev, const gx_strip_bitmap * tiles,
int plane_depth = mdev->planes[pi].depth;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
int shift = 16 - plane_depth;
- const gx_device_memory *mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
gx_color_index c1, c0;
if (pdcolor0->type == gx_dc_type_devn) {
@@ -1045,15 +1034,14 @@ mem_planar_strip_tile_rect_devn(gx_device * dev, const gx_strip_bitmap * tiles,
#endif
MEM_SET_PARAMS(mdev, plane_depth);
if (c0 == c1)
- dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h, c0);
+ fns->fill_rectangle(dev, x, y, w, h, c0);
else {
/*
* Temporarily replace copy_mono in case strip_tile_rectangle is
* defined in terms of it.
*/
- set_dev_proc(dev, copy_mono, dev_proc(mdproto, copy_mono));
- dev_proc(mdproto, strip_tile_rectangle)
- (dev, tiles, x, y, w, h, c0, c1, px, py);
+ set_dev_proc(dev, copy_mono, fns->copy_mono);
+ fns->strip_tile_rectangle(dev, tiles, x, y, w, h, c0, c1, px, py);
}
mdev->line_ptrs += mdev->height;
}
@@ -1081,8 +1069,8 @@ mem_planar_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
int plane_depth = mdev->planes[pi].depth;
int shift = mdev->planes[pi].shift;
gx_color_index mask = ((gx_color_index)1 << plane_depth) - 1;
- const gx_device_memory *mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
gx_color_index c0 =
(color0 == gx_no_color_index ? gx_no_color_index :
(color0 >> shift) & mask);
@@ -1092,15 +1080,14 @@ mem_planar_strip_tile_rectangle(gx_device * dev, const gx_strip_bitmap * tiles,
MEM_SET_PARAMS(mdev, plane_depth);
if (c0 == c1)
- dev_proc(mdproto, fill_rectangle)(dev, x, y, w, h, c0);
+ fns->fill_rectangle(dev, x, y, w, h, c0);
else {
/*
* Temporarily replace copy_mono in case strip_tile_rectangle is
* defined in terms of it.
*/
- set_dev_proc(dev, copy_mono, dev_proc(mdproto, copy_mono));
- dev_proc(mdproto, strip_tile_rectangle)
- (dev, tiles, x, y, w, h, c0, c1, px, py);
+ set_dev_proc(dev, copy_mono, fns->copy_mono);
+ fns->strip_tile_rectangle(dev, tiles, x, y, w, h, c0, c1, px, py);
}
mdev->line_ptrs += mdev->height;
}
@@ -1733,21 +1720,21 @@ plane_strip_copy_rop(gx_device_memory * mdev,
{
mem_save_params_t save;
int code;
- const gx_device_memory *mdproto;
+ const gdev_mem_functions *fns;
MEM_SAVE_PARAMS(mdev, save);
mdev->line_ptrs += mdev->height * plane;
- mdproto = gdev_mem_device_for_bits(mdev->planes[plane].depth);
+ fns = gdev_mem_functions_for_bits(mdev->planes[plane].depth);
/* strip_copy_rop might end up calling get_bits_rectangle or fill_rectangle,
* so ensure we have the right ones in there. */
- set_dev_proc(mdev, get_bits_rectangle, dev_proc(mdproto, get_bits_rectangle));
- set_dev_proc(mdev, fill_rectangle, dev_proc(mdproto, fill_rectangle));
+ set_dev_proc(mdev, get_bits_rectangle, fns->get_bits_rectangle);
+ set_dev_proc(mdev, fill_rectangle, fns->fill_rectangle);
/* mdev->color_info.depth is restored by MEM_RESTORE_PARAMS below. */
mdev->color_info.depth = mdev->planes[plane].depth;
- code = dev_proc(mdproto, strip_copy_rop)((gx_device *)mdev, sdata, sourcex, sraster,
- id, scolors, textures, tcolors,
- x, y, width, height,
- phase_x, phase_y, lop);
+ code = fns->strip_copy_rop((gx_device *)mdev, sdata, sourcex, sraster,
+ id, scolors, textures, tcolors,
+ x, y, width, height,
+ phase_x, phase_y, lop);
set_dev_proc(mdev, get_bits_rectangle, mem_planar_get_bits_rectangle);
set_dev_proc(mdev, fill_rectangle, mem_planar_fill_rectangle);
/* The following effectively does: mdev->line_ptrs -= mdev->height * plane; */
diff --git a/base/gdevmx.c b/base/gdevmx.c
index fa2287ccf..08b0cbcfe 100644
--- a/base/gdevmx.c
+++ b/base/gdevmx.c
@@ -25,4 +25,4 @@
/* The device descriptor. */
const gx_device_memory mem_x_device =
- mem_device("imagex", 256, 0, NULL, NULL, NULL, NULL, NULL, NULL);
+ mem_device("imagex", 256, 0, NULL);
diff --git a/base/gdevplnx.c b/base/gdevplnx.c
index 4e23b9623..8429ec106 100644
--- a/base/gdevplnx.c
+++ b/base/gdevplnx.c
@@ -426,13 +426,13 @@ plane_open_device(gx_device *dev)
gx_device_plane_extract * const edev = (gx_device_plane_extract *)dev;
gx_device * const plane_dev = edev->plane_dev;
int plane_depth = plane_dev->color_info.depth;
- const gx_device_memory * const mdproto =
- gdev_mem_device_for_bits(plane_depth);
+ const gdev_mem_functions *fns =
+ gdev_mem_functions_for_bits(plane_depth);
edev->plane_white = gx_device_white(plane_dev);
edev->plane_mask = (1 << plane_depth) - 1;
- edev->plane_dev_is_memory = mdproto != 0 &&
- dev_proc(plane_dev, copy_color) == dev_proc(mdproto, copy_color);
+ edev->plane_dev_is_memory = fns != NULL &&
+ dev_proc(plane_dev, copy_color) == fns->copy_color;
/* We don't set or clear any_marks here: see ...init above. */
return 0;
}
diff --git a/base/gdevprn.c b/base/gdevprn.c
index 4e4cea67b..a23380d62 100644
--- a/base/gdevprn.c
+++ b/base/gdevprn.c
@@ -1404,6 +1404,8 @@ gx_default_create_buf_device(gx_device **pbdev, gx_device *target, int y,
dev_t_proc_dev_spec_op((*orig_dso), gx_device) = dev_proc(mdev, dev_spec_op);
/* The following is a special hack for setting up printer devices. */
assign_dev_procs(mdev, mdproto);
+ /* This can never fail */
+ (void)mdev->procs.initialize((gx_device *)mdev);
/* Do not override the dev_spec_op! */
dev_proc(mdev, dev_spec_op) = orig_dso;
check_device_separable((gx_device *)mdev);
diff --git a/base/gxdevmem.h b/base/gxdevmem.h
index bb890a277..721815f45 100644
--- a/base/gxdevmem.h
+++ b/base/gxdevmem.h
@@ -202,6 +202,57 @@ int gdev_mem_max_height(const gx_device_memory * dev, int width, ulong size,
#define gdev_mem_raster(mdev)\
gx_device_raster((const gx_device *)(mdev), true)
+typedef struct
+{
+ dev_proc_map_rgb_color((*map_rgb_color));
+ dev_proc_map_color_rgb((*map_color_rgb));
+ dev_proc_fill_rectangle((*fill_rectangle));
+ dev_proc_copy_mono((*copy_mono));
+ dev_proc_copy_color((*copy_color));
+ dev_proc_copy_alpha((*copy_alpha));
+ dev_proc_strip_tile_rectangle((*strip_tile_rectangle));
+ dev_proc_strip_copy_rop((*strip_copy_rop));
+ dev_proc_strip_copy_rop2((*strip_copy_rop2));
+ dev_proc_get_bits_rectangle((*get_bits_rectangle));
+} gdev_mem_functions;
+
+extern const gdev_mem_functions gdev_mem_fns_1;
+extern const gdev_mem_functions gdev_mem_fns_2;
+extern const gdev_mem_functions gdev_mem_fns_4;
+extern const gdev_mem_functions gdev_mem_fns_8;
+extern const gdev_mem_functions gdev_mem_fns_16;
+extern const gdev_mem_functions gdev_mem_fns_24;
+extern const gdev_mem_functions gdev_mem_fns_32;
+extern const gdev_mem_functions gdev_mem_fns_40;
+extern const gdev_mem_functions gdev_mem_fns_48;
+extern const gdev_mem_functions gdev_mem_fns_56;
+extern const gdev_mem_functions gdev_mem_fns_64;
+#if ARCH_IS_BIG_ENDIAN
+#define gdev_mem_fns_1w gdev_mem_fns_1
+#define gdev_mem_fns_2w gdev_mem_fns_2
+#define gdev_mem_fns_4w gdev_mem_fns_4
+#define gdev_mem_fns_8w gdev_mem_fns_8
+#define gdev_mem_fns_24w gdev_mem_fns_24
+#define gdev_mem_fns_32w gdev_mem_fns_32
+#define gdev_mem_fns_40w gdev_mem_fns_40
+#define gdev_mem_fns_48w gdev_mem_fns_48
+#define gdev_mem_fns_56w gdev_mem_fns_56
+#define gdev_mem_fns_64w gdev_mem_fns_64
+#else
+extern const gdev_mem_functions gdev_mem_fns_1w;
+extern const gdev_mem_functions gdev_mem_fns_2w;
+extern const gdev_mem_functions gdev_mem_fns_4w;
+extern const gdev_mem_functions gdev_mem_fns_8w;
+extern const gdev_mem_functions gdev_mem_fns_24w;
+extern const gdev_mem_functions gdev_mem_fns_32w;
+extern const gdev_mem_functions gdev_mem_fns_40w;
+extern const gdev_mem_functions gdev_mem_fns_48w;
+extern const gdev_mem_functions gdev_mem_fns_56w;
+extern const gdev_mem_functions gdev_mem_fns_64w;
+#endif
+const gdev_mem_functions *gdev_mem_functions_for_bits(int bits);
+const gdev_mem_functions *gdev_mem_word_functions_for_bits(int bits);
+
/* Determine the appropriate memory device for a given */
/* number of bits per pixel (0 if none suitable). */
const gx_device_memory *gdev_mem_device_for_bits(int);
diff --git a/base/gxifast.c b/base/gxifast.c
index b93c58614..7ec7a1de7 100644
--- a/base/gxifast.c
+++ b/base/gxifast.c
@@ -606,7 +606,7 @@ image_render_simple(gx_image_enum * penum, const byte * buffer, int data_x,
line_size = (w + 7) >> 3;
line_width = w;
line_x = 0;
- } else if (copy_mono == dev_proc(&mem_mono_device, copy_mono) &&
+ } else if (copy_mono == mem_mono_copy_mono &&
dxx > 0 && gx_dc_is_pure(pdc1) && gx_dc_is_pure(pdc0) &&
/* We know the colors must be (0,1) or (1,0). */
(pdc0->colors.pure ^ pdc1->colors.pure) == 1 &&