summaryrefslogtreecommitdiff
path: root/base/gxblend1.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2017-10-04 15:48:07 +0100
committerRobin Watts <robin.watts@artifex.com>2017-10-04 20:51:34 +0100
commit3d6168d9bdfe60f77bc60a270945c67e36ac02a3 (patch)
treef3fcfdafdc75cdc99d09f0aa4f32e9d129d95e47 /base/gxblend1.c
parenta2532236a8f85101c3d0377dde163071745c53bf (diff)
downloadghostpdl-3d6168d9bdfe60f77bc60a270945c67e36ac02a3.tar.gz
Tweak pdf14_preserve_backdrop (for speed).
First the current code clears the backdrop, then we copy into it. In many cases we overwrite exactly the area we just cleared. Spot this, and avoid it. We *could* optimise this further in cases where we aren't overwriting exactly the same region. Wait to see if this is justified.
Diffstat (limited to 'base/gxblend1.c')
-rw-r--r--base/gxblend1.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/base/gxblend1.c b/base/gxblend1.c
index e30d1fdcc..23b9ae638 100644
--- a/base/gxblend1.c
+++ b/base/gxblend1.c
@@ -123,6 +123,11 @@ copy_plane_part(byte *des_ptr, int des_rowstride, byte *src_ptr, int src_rowstri
{
int y;
+ if (width == des_rowstride && width == src_rowstride) {
+ width *= height;
+ height = 1;
+ }
+
for (y = 0; y < height; ++y) {
memcpy(des_ptr, src_ptr, width);
des_ptr += des_rowstride;
@@ -267,7 +272,15 @@ pdf14_preserve_backdrop(pdf14_buf *buf, pdf14_buf *tos, bool knockout_buff)
has a region outside the existing tos group. Need to check if this
is getting clipped in which case we need to fix the allocation of
the buffer to be smaller */
- memset(buf_plane, 0, n_planes * buf->planestride);
+ if (x0 > buf->rect.p.x || x1 < buf->rect.q.x ||
+ y0 > buf->rect.p.y || y1 < buf->rect.q.y) {
+ /* FIXME: There is potential for more optimisation here,
+ * but I don't know how often we hit this case. */
+ memset(buf_plane, 0, n_planes * buf->planestride);
+ } else if (n_planes > tos->n_chan) {
+ /* We *could* get away with not blanking any tag plane too... */
+ memset(buf->data + tos->n_chan * buf->planestride, 0, (n_planes - tos->n_chan) * buf->planestride);
+ }
buf_plane += x0 - buf->rect.p.x +
(y0 - buf->rect.p.y) * buf->rowstride;
tos_plane += x0 - tos->rect.p.x +