summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2016-11-17 16:45:04 +0000
committerMichael Vrhel <michael.vrhel@artifex.com>2016-11-21 08:29:23 -0800
commitc9d8618934ebf682f72dd9b3ebef48b2be535a8d (patch)
tree89ef2c7bd7f34b6240022d5b344287ad70ac7446
parentb33ffc0e958b613cd6ba114d42720694b11219ff (diff)
downloadghostpdl-c9d8618934ebf682f72dd9b3ebef48b2be535a8d.tar.gz
Change API for put_image
-rw-r--r--base/gdevflp.c6
-rw-r--r--base/gdevmpla.c48
-rw-r--r--base/gdevoflt.c6
-rw-r--r--base/gdevp14.c17
-rw-r--r--base/gdevsclass.c6
-rw-r--r--base/gxblend1.c15
-rw-r--r--base/gxdevcli.h4
-rw-r--r--devices/gdevbit.c11
-rw-r--r--devices/gdevpng.c15
9 files changed, 82 insertions, 46 deletions
diff --git a/base/gdevflp.c b/base/gdevflp.c
index 5a2afc2d0..c0d616f30 100644
--- a/base/gdevflp.c
+++ b/base/gdevflp.c
@@ -1101,8 +1101,8 @@ int flp_pop_transparency_state(gx_device *dev, gs_gstate *pgs)
return 0;
}
-int flp_put_image(gx_device *dev, const byte *buffer, int num_chan, int x, int y,
- int width, int height, int row_stride, int plane_stride,
+int flp_put_image(gx_device *dev, const byte **buffers, int num_chan, int x, int y,
+ int width, int height, int row_stride,
int alpha_plane_index, int tag_plane_index)
{
int code = SkipPage(dev);
@@ -1110,7 +1110,7 @@ int flp_put_image(gx_device *dev, const byte *buffer, int num_chan, int x, int y
if (code < 0)
return code;
if (!code)
- return default_subclass_put_image(dev, buffer, num_chan, x, y, width, height, row_stride, plane_stride, alpha_plane_index, tag_plane_index);
+ return default_subclass_put_image(dev, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
return 0;
}
diff --git a/base/gdevmpla.c b/base/gdevmpla.c
index 9800e8719..414b488fc 100644
--- a/base/gdevmpla.c
+++ b/base/gdevmpla.c
@@ -211,25 +211,61 @@ typedef struct mem_save_params_s {
mdev->base = msp.base,\
mdev->line_ptrs = msp.line_ptrs)
+static int
+put_image_copy_planes(gx_device * dev, const byte **base_ptr, int sourcex,
+ int sraster, gx_bitmap_id id,
+ int x, int y, int w, int h)
+{
+ 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++)
+ {
+ const byte *base = base_ptr[plane];
+ plane_depth = mdev->planes[plane].depth;
+ mdproto = gdev_mem_device_for_bits(plane_depth);
+ if (base == NULL) {
+ /* Blank the plane */
+ code = dev_proc(mdproto, 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);
+ else
+ code = dev_proc(mdproto, copy_color)(dev, base, sourcex, sraster,
+ id, x, y, w, h);
+ mdev->line_ptrs += mdev->height;
+ }
+ MEM_RESTORE_PARAMS(mdev, save);
+ return code;
+}
+
/* Put image command for copying the planar image buffers with or without
alpha directly to the device buffer */
static int
-mem_planar_put_image(gx_device *pdev, const byte *buffer, int num_chan, int xstart,
+mem_planar_put_image(gx_device *pdev, const byte **buffers, int num_chan, int xstart,
int ystart, int width, int height, int row_stride,
- int plane_stride, int alpha_plane_index, int tag_plane_index)
+ int alpha_plane_index, int tag_plane_index)
{
gx_device_memory * const mdev = (gx_device_memory *)pdev;
/* We don't want alpha, return 0 to ask for the pdf14 device to do the
alpha composition. We also do not want chunky data coming in or to deal
with planar devices that are not 8 bit per colorant */
- if (alpha_plane_index != 0 || plane_stride == 0 ||
+ if (alpha_plane_index != 0 ||
mdev->planes[0].depth != 8)
return 0;
- (*dev_proc(pdev, copy_planes)) (pdev, buffer, 0, row_stride,
- gx_no_bitmap_id, xstart, ystart,
- width, height, plane_stride/row_stride);
+ put_image_copy_planes(pdev, buffers, 0, row_stride,
+ gx_no_bitmap_id, xstart, ystart,
+ width, height);
/* we used all of the data */
return height;
}
diff --git a/base/gdevoflt.c b/base/gdevoflt.c
index c7e4f449b..5e1b5cf60 100644
--- a/base/gdevoflt.c
+++ b/base/gdevoflt.c
@@ -518,12 +518,12 @@ int obj_filter_fill_linear_color_triangle(gx_device *dev, const gs_fill_attribut
return 0;
}
-int obj_filter_put_image(gx_device *dev, const byte *buffer, int num_chan, int x, int y,
- int width, int height, int row_stride, int plane_stride,
+int obj_filter_put_image(gx_device *dev, const byte **buffers, int num_chan, int x, int y,
+ int width, int height, int row_stride,
int alpha_plane_index, int tag_plane_index)
{
if ((dev->ObjectFilter & FILTERIMAGE) == 0)
- return default_subclass_put_image(dev, buffer, num_chan, x, y, width, height, row_stride, plane_stride, alpha_plane_index, tag_plane_index);
+ return default_subclass_put_image(dev, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
return 0;
}
diff --git a/base/gdevp14.c b/base/gdevp14.c
index 8c077cef1..7b140567c 100644
--- a/base/gdevp14.c
+++ b/base/gdevp14.c
@@ -1777,10 +1777,14 @@ pdf14_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
form with the alpha component */
int alpha_offset = num_comp;
int tag_offset = buf->has_tags ? num_comp+1 : 0;
- code = dev_proc(target, put_image) (target, buf_ptr, num_comp,
+ const byte *buf_ptrs[GS_CLIENT_COLOR_MAX_COMPONENTS];
+ int i;
+ for (i = 0; i < num_comp; i++)
+ buf_ptrs[i] = buf_ptr + i * buf->planestride;
+ code = dev_proc(target, put_image) (target, buf_ptrs, num_comp,
rect.p.x, rect.p.y, width, height,
- buf->rowstride, buf->planestride,
- num_comp,tag_offset);
+ buf->rowstride,
+ num_comp, tag_offset);
if (code == 0) {
/* Device could not handle the alpha data. Go ahead and
preblend now. Note that if we do this, and we end up in the
@@ -1805,19 +1809,18 @@ pdf14_put_image(gx_device * dev, gs_gstate * pgs, gx_device * target)
data_blended = true;
/* Try again now */
alpha_offset = 0;
- code = dev_proc(target, put_image) (target, buf_ptr, num_comp,
+ code = dev_proc(target, put_image) (target, buf_ptrs, num_comp,
rect.p.x, rect.p.y, width, height,
- buf->rowstride, buf->planestride,
+ buf->rowstride,
alpha_offset, tag_offset);
}
if (code > 0) {
/* We processed some or all of the rows. Continue until we are done */
num_rows_left = height - code;
while (num_rows_left > 0) {
- code = dev_proc(target, put_image) (target, buf_ptr, buf->n_planes,
+ code = dev_proc(target, put_image) (target, buf_ptrs, buf->n_planes,
rect.p.x, rect.p.y+code, width,
num_rows_left, buf->rowstride,
- buf->planestride,
alpha_offset, tag_offset);
num_rows_left = num_rows_left - code;
}
diff --git a/base/gdevsclass.c b/base/gdevsclass.c
index 2b51281f5..d8ec79e33 100644
--- a/base/gdevsclass.c
+++ b/base/gdevsclass.c
@@ -852,12 +852,12 @@ int default_subclass_pop_transparency_state(gx_device *dev, gs_gstate *pgs)
return 0;
}
-int default_subclass_put_image(gx_device *dev, const byte *buffer, int num_chan, int x, int y,
- int width, int height, int row_stride, int plane_stride,
+int default_subclass_put_image(gx_device *dev, const byte **buffers, int num_chan, int x, int y,
+ int width, int height, int row_stride,
int alpha_plane_index, int tag_plane_index)
{
if (dev->child && dev->child->procs.put_image)
- return dev->child->procs.put_image(dev->child, buffer, num_chan, x, y, width, height, row_stride, plane_stride, alpha_plane_index, tag_plane_index);
+ return dev->child->procs.put_image(dev->child, buffers, num_chan, x, y, width, height, row_stride, alpha_plane_index, tag_plane_index);
return 0;
}
diff --git a/base/gxblend1.c b/base/gxblend1.c
index 4a0a04fa9..774f77ea4 100644
--- a/base/gxblend1.c
+++ b/base/gxblend1.c
@@ -921,9 +921,13 @@ gx_put_blended_image_cmykspot(gx_device *target, byte *buf_ptr,
form with the alpha component */
int alpha_offset = num_comp;
int tag_offset = has_tags ? num_comp+1 : 0;
- code = dev_proc(target, put_image) (target, buf_ptr, num_comp,
+ const byte *buf_ptrs[GS_CLIENT_COLOR_MAX_COMPONENTS];
+ int i;
+ for (i = 0; i < num_comp; i++)
+ buf_ptrs[i] = buf_ptr + i * planestride;
+ code = dev_proc(target, put_image) (target, buf_ptrs, num_comp,
rect.p.x, rect.p.y, width, height,
- rowstride, planestride,
+ rowstride,
num_comp,tag_offset);
if (code == 0) {
/* Device could not handle the alpha data. Go ahead and
@@ -946,19 +950,18 @@ gx_put_blended_image_cmykspot(gx_device *target, byte *buf_ptr,
#endif
/* Try again now */
alpha_offset = 0;
- code = dev_proc(target, put_image) (target, buf_ptr, num_comp,
+ code = dev_proc(target, put_image) (target, buf_ptrs, num_comp,
rect.p.x, rect.p.y, width, height,
- rowstride, planestride,
+ rowstride,
alpha_offset, tag_offset);
}
if (code > 0) {
/* We processed some or all of the rows. Continue until we are done */
num_rows_left = height - code;
while (num_rows_left > 0) {
- code = dev_proc(target, put_image) (target, buf_ptr, num_comp,
+ code = dev_proc(target, put_image) (target, buf_ptrs, num_comp,
rect.p.x, rect.p.y+code, width,
num_rows_left, rowstride,
- planestride,
alpha_offset, tag_offset);
if (code < 0)
return code;
diff --git a/base/gxdevcli.h b/base/gxdevcli.h
index cd0b09c7f..80a4563d5 100644
--- a/base/gxdevcli.h
+++ b/base/gxdevcli.h
@@ -1479,8 +1479,8 @@ typedef struct gs_devn_params_s gs_devn_params;
dev_t_proc_pop_transparency_state(proc, gx_device)
#define dev_t_proc_put_image(proc, dev_t)\
- int proc(gx_device *dev, const byte *buffer, int num_chan, int x, int y,\
- int width, int height, int row_stride, int plane_stride,\
+ int proc(gx_device *dev, const byte **buffers, int num_chan, int x, int y,\
+ int width, int height, int row_stride,\
int alpha_plane_index, int tag_plane_index)
#define dev_proc_put_image(proc)\
dev_t_proc_put_image(proc, gx_device)
diff --git a/devices/gdevbit.c b/devices/gdevbit.c
index 5a4b17546..ecf1a596f 100644
--- a/devices/gdevbit.c
+++ b/devices/gdevbit.c
@@ -777,9 +777,9 @@ bittags_print_page(gx_device_printer * pdev, FILE * prn_stream)
}
static int
-bit_put_image(gx_device *pdev, const byte *buffer, int num_chan, int xstart,
+bit_put_image(gx_device *pdev, const byte **buffers, int num_chan, int xstart,
int ystart, int width, int height, int row_stride,
- int plane_stride, int alpha_plane_index, int tag_plane_index)
+ int alpha_plane_index, int tag_plane_index)
{
gx_device_memory *pmemdev = (gx_device_memory *)pdev;
byte *buffer_prn;
@@ -791,9 +791,6 @@ bit_put_image(gx_device *pdev, const byte *buffer, int num_chan, int xstart,
if (alpha_plane_index != 0)
return 0; /* we don't want alpha, return 0 to ask for the */
/* pdf14 device to do the alpha composition */
- /* Eventually, the pdf14 device might be chunky pixels, punt for now */
- if (plane_stride == 0)
- return 0;
if (num_chan != 3 || tag_plane_index <= 0)
return_error(gs_error_unknownerror); /* can't handle these cases */
/* Drill down to get the appropriate memory buffer pointer */
@@ -805,11 +802,11 @@ bit_put_image(gx_device *pdev, const byte *buffer, int num_chan, int xstart,
for ( x = xstart; x < xend; x++ ) {
/* Tag data first, then RGB */
buffer_prn[des_position] =
- buffer[src_position + tag_plane_index * plane_stride];
+ buffers[tag_plane_index][src_position];
des_position += 1;
for ( k = 0; k < 3; k++) {
buffer_prn[des_position] =
- buffer[src_position + k * plane_stride];
+ buffers[k][src_position];
des_position += 1;
}
src_position += 1;
diff --git a/devices/gdevpng.c b/devices/gdevpng.c
index 45b886c1d..1c203897d 100644
--- a/devices/gdevpng.c
+++ b/devices/gdevpng.c
@@ -845,9 +845,9 @@ pngalpha_fillpage(gx_device *dev, gs_gstate * pgs, gx_device_color *pdevc)
/* Handle the RGBA planes from the PDF 1.4 compositor */
static int
-pngalpha_put_image (gx_device *pdev, const byte *buffer, int num_chan, int xstart,
+pngalpha_put_image (gx_device *pdev, const byte **buffers, int num_chan, int xstart,
int ystart, int width, int height, int row_stride,
- int plane_stride, int alpha_plane_index, int tag_plane_index)
+ int alpha_plane_index, int tag_plane_index)
{
gx_device_memory *pmemdev = (gx_device_memory *)pdev;
byte *buffer_prn;
@@ -856,9 +856,6 @@ pngalpha_put_image (gx_device *pdev, const byte *buffer, int num_chan, int xstar
int x, y;
int src_position, des_position;
- /* Eventually, the pdf14 device might be chunky pixels, punt for now */
- if (plane_stride == 0)
- return 0;
if (num_chan != 3 || alpha_plane_index <= 0)
return_error(gs_error_unknownerror); /* can't handle these cases */
@@ -873,11 +870,11 @@ pngalpha_put_image (gx_device *pdev, const byte *buffer, int num_chan, int xstar
src_position = (y - ystart) * row_stride;
des_position = y * pmemdev->raster + xstart * 4;
for ( x = xstart; x < xend; x++ ) {
- buffer_prn[des_position++] = buffer[src_position];
- buffer_prn[des_position++] = buffer[src_position + plane_stride];
- buffer_prn[des_position++] = buffer[src_position + 2 * plane_stride];
+ buffer_prn[des_position++] = buffers[0][src_position];
+ buffer_prn[des_position++] = buffers[1][src_position];
+ buffer_prn[des_position++] = buffers[2][src_position];
/* Alpha data in low bits. Note that Alpha is inverted. */
- buffer_prn[des_position++] = (255 - buffer[src_position + alpha_plane_index * plane_stride]);
+ buffer_prn[des_position++] = (255 - buffers[alpha_plane_index][src_position]);
src_position += 1;
}
}