diff options
author | Till Kamppeter <till.kamppeter@gmail.com> | 2010-01-22 17:46:02 +0000 |
---|---|---|
committer | Till Kamppeter <till.kamppeter@gmail.com> | 2010-01-22 17:46:02 +0000 |
commit | 9edea5f8898d73e955181d7dc99dd0bd04905f96 (patch) | |
tree | d2db09248b159d563d8e6fa79019366b66169e6b | |
parent | 9f1ac1c590ed0b620d3b5742e792bbcd19555b7b (diff) |
"cups" output device: Reallocate memory for raster data only if the size of the bitmap has changed, to avoid data getting messed up by unneeded reallocation. This should finally fix bug #691029.
git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@10631 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r-- | gs/cups/gdevcups.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/gs/cups/gdevcups.c b/gs/cups/gdevcups.c index 51a831f10..551b80607 100644 --- a/gs/cups/gdevcups.c +++ b/gs/cups/gdevcups.c @@ -2703,7 +2703,9 @@ cups_put_params(gx_device *pdev, /* I - Device info */ int color_set; /* Were the color attrs set? */ gdev_prn_space_params sp; /* Space parameter data */ int width, /* New width of page */ - height; /* New height of page */ + height; /* New height of page */ + static int width_old = 0, /* Previous width */ + height_old = 0; /* Previous height */ ppd_attr_t *backside = NULL, *backsiderequiresflippedmargins = NULL; float swap; @@ -2807,17 +2809,16 @@ cups_put_params(gx_device *pdev, /* I - Device info */ size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 || param_read_float_array(plist, "PageSize", &arrayval) == 0; margins_set = param_read_float_array(plist, "Margins", &arrayval) == 0; + color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || + param_read_int(plist, "cupsBitsPerColor", &intval) == 0; /* We also recompute page size and margins if we simply get onto a new page without necessarily having a page size change in the PostScript code, as for some printers margins have to flipped on the back sides of the sheets (even pages) when printing duplex */ if (cups->page != lastpage) { size_set = 1; - margins_set = 1; lastpage = cups->page; } - color_set = param_read_int(plist, "cupsColorSpace", &intval) == 0 || - param_read_int(plist, "cupsBitsPerColor", &intval) == 0; stringoption(MediaClass, "MediaClass") stringoption(MediaColor, "MediaColor") @@ -2916,7 +2917,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */ * Update margins/sizes as needed... */ - if (size_set || margins_set) + if (size_set) { /* * Compute the page margins... @@ -3212,7 +3213,7 @@ cups_put_params(gx_device *pdev, /* I - Device info */ * Reallocate memory if the size or color depth was changed... */ - if (color_set || size_set || margins_set) + if (color_set || size_set) { /* * Make sure the page image is the correct size - current Ghostscript @@ -3244,12 +3245,17 @@ cups_put_params(gx_device *pdev, /* I - Device info */ /* * Don't reallocate memory unless the device has been opened... + * Also reallocate only if the size has actually changed... */ - if (pdev->is_open) + if (pdev->is_open && (width != width_old || height != height_old)) { + + width_old = width; + height_old = height; + /* - * Device is open, so reallocate... + * Device is open and size has changed, so reallocate... */ dprintf4("DEBUG2: Reallocating memory, [%.0f %.0f] = %dx%d pixels...\n", |