~ubuntu-branches/ubuntu/oneiric/ghostscript/oneiric

« back to all changes in this revision

Viewing changes to contrib/lips4/gdevlprn.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2011-07-15 16:49:55 UTC
  • mfrom: (1.1.23 upstream)
  • Revision ID: james.westby@ubuntu.com-20110715164955-uga6qibao6kez05c
Tags: 9.04~dfsg~20110715-0ubuntu1
* New upstream release
   - GIT snapshot from Jult, 12 2011.
* debian/patches/020110406~a54df2d.patch,
  debian/patches/020110408~0791cc8.patch,
  debian/patches/020110408~507cbee.patch,
  debian/patches/020110411~4509a49.patch,
  debian/patches/020110412~78bb9a6.patch,
  debian/patches/020110418~a05ab8a.patch,
  debian/patches/020110420~20b6c78.patch,
  debian/patches/020110420~4ddefa2.patch: Removed upstream patches.
* debian/rules: Generate ABI version number (variable "abi") correctly,
  cutting off repackaging and pre-release parts.
* debian/rules: Added ./lcms2/ directory to DEB_UPSTREAM_REPACKAGE_EXCLUDES.
* debian/copyright: Added lcms2/* to the list of excluded files.
* debian/symbols.common: Updated for new upstream source. Applied patch
  which dpkg-gensymbols generated for debian/libgs9.symbols to this file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
/*
30
30
   ************************
31
 
   * This Library Options * 
 
31
   * This Library Options *
32
32
   ************************
33
33
 
34
34
   -dTumble         : for Duplex
54
54
    int ncode;
55
55
 
56
56
    if (code < 0)
57
 
        return code;
 
57
        return code;
58
58
 
59
59
    if ((ncode = param_write_bool(plist, "ManualFeed", &lprn->ManualFeed)) < 0)
60
 
        code = ncode;
 
60
        code = ncode;
61
61
 
62
62
    if ((ncode = param_write_bool(plist, "NegativePrint", &lprn->NegativePrint)) < 0)
63
 
        code = ncode;
 
63
        code = ncode;
64
64
 
65
65
    if ((ncode = param_write_bool(plist, "Tumble", &lprn->Tumble)) < 0)
66
 
        code = ncode;
 
66
        code = ncode;
67
67
 
68
68
    if ((ncode = param_write_bool(plist, "RITOff", &lprn->RITOff)) < 0)
69
 
        code = ncode;
 
69
        code = ncode;
70
70
 
71
71
    if ((ncode = param_write_int(plist, "BlockLine", &lprn->BlockLine)) < 0)
72
 
        code = ncode;
 
72
        code = ncode;
73
73
 
74
74
    if ((ncode = param_write_int(plist, "BlockWidth", &lprn->nBw)) < 0)
75
 
        code = ncode;
 
75
        code = ncode;
76
76
 
77
77
    if ((ncode = param_write_int(plist, "BlockHeight", &lprn->nBh)) < 0)
78
 
        code = ncode;
 
78
        code = ncode;
79
79
 
80
80
    if ((ncode = param_write_bool(plist, "ShowBubble", &lprn->ShowBubble)) < 0)
81
 
        code = ncode;
 
81
        code = ncode;
82
82
 
83
83
    return code;
84
84
}
101
101
    bool ShowBubble = lprn->ShowBubble;
102
102
 
103
103
    if ((code = param_read_bool(plist,
104
 
                                (param_name = "ManualFeed"),
105
 
                                &ManualFeed)) < 0) {
106
 
        param_signal_error(plist, param_name, ecode = code);
107
 
    }
108
 
 
109
 
    if ((code = param_read_bool(plist,
110
 
                                (param_name = "NegativePrint"),
111
 
                                &NegativePrint)) < 0) {
112
 
        param_signal_error(plist, param_name, ecode = code);
113
 
    }
114
 
    if ((code = param_read_bool(plist,
115
 
                                (param_name = "Tumble"),
116
 
                                &Tumble)) < 0) {
117
 
        param_signal_error(plist, param_name, ecode = code);
118
 
    }
119
 
    if ((code = param_read_bool(plist,
120
 
                                (param_name = "RITOff"),
121
 
                                &RITOff)) < 0) {
122
 
        param_signal_error(plist, param_name, ecode = code);
123
 
    }
124
 
    switch (code = param_read_int(plist,
125
 
                                  (param_name = "BlockWidth"),
126
 
                                  &BlockWidth)) {
127
 
        case 0:
128
 
            if (BlockWidth < 0)
129
 
                ecode = gs_error_rangecheck;
130
 
            else
131
 
                break;
132
 
            goto bwidthe;
133
 
        default:
134
 
            ecode = code;
135
 
          bwidthe:param_signal_error(plist, param_name, ecode = code);
136
 
        case 1:
137
 
            break;
138
 
    }
139
 
 
140
 
    switch (code = param_read_int(plist,
141
 
                                  (param_name = "BlockLine"),
142
 
                                  &BlockLine)) {
143
 
        case 0:
144
 
            if (BlockLine < 0)
145
 
                ecode = gs_error_rangecheck;
146
 
            else
147
 
                break;
148
 
            goto crowe;
149
 
        default:
150
 
            ecode = code;
151
 
          crowe:param_signal_error(plist, param_name, ecode = code);
152
 
        case 1:
153
 
            break;
154
 
    }
155
 
 
156
 
    switch (code = param_read_int(plist,
157
 
                                  (param_name = "BlockHeight"),
158
 
                                  &BlockHeight)) {
159
 
        case 0:
160
 
            if (BlockHeight < 0)
161
 
                ecode = gs_error_rangecheck;
162
 
            else
163
 
                break;
164
 
            goto bheighte;
165
 
        default:
166
 
            ecode = code;
167
 
          bheighte:param_signal_error(plist, param_name, ecode = code);
168
 
        case 1:
169
 
            break;
170
 
    }
171
 
 
172
 
    if ((code = param_read_bool(plist,
173
 
                                (param_name = "ShowBubble"),
174
 
                                &ShowBubble)) < 0) {
175
 
        param_signal_error(plist, param_name, ecode = code);
 
104
                                (param_name = "ManualFeed"),
 
105
                                &ManualFeed)) < 0) {
 
106
        param_signal_error(plist, param_name, ecode = code);
 
107
    }
 
108
 
 
109
    if ((code = param_read_bool(plist,
 
110
                                (param_name = "NegativePrint"),
 
111
                                &NegativePrint)) < 0) {
 
112
        param_signal_error(plist, param_name, ecode = code);
 
113
    }
 
114
    if ((code = param_read_bool(plist,
 
115
                                (param_name = "Tumble"),
 
116
                                &Tumble)) < 0) {
 
117
        param_signal_error(plist, param_name, ecode = code);
 
118
    }
 
119
    if ((code = param_read_bool(plist,
 
120
                                (param_name = "RITOff"),
 
121
                                &RITOff)) < 0) {
 
122
        param_signal_error(plist, param_name, ecode = code);
 
123
    }
 
124
    switch (code = param_read_int(plist,
 
125
                                  (param_name = "BlockWidth"),
 
126
                                  &BlockWidth)) {
 
127
        case 0:
 
128
            if (BlockWidth < 0)
 
129
                ecode = gs_error_rangecheck;
 
130
            else
 
131
                break;
 
132
            goto bwidthe;
 
133
        default:
 
134
            ecode = code;
 
135
          bwidthe:param_signal_error(plist, param_name, ecode = code);
 
136
        case 1:
 
137
            break;
 
138
    }
 
139
 
 
140
    switch (code = param_read_int(plist,
 
141
                                  (param_name = "BlockLine"),
 
142
                                  &BlockLine)) {
 
143
        case 0:
 
144
            if (BlockLine < 0)
 
145
                ecode = gs_error_rangecheck;
 
146
            else
 
147
                break;
 
148
            goto crowe;
 
149
        default:
 
150
            ecode = code;
 
151
          crowe:param_signal_error(plist, param_name, ecode = code);
 
152
        case 1:
 
153
            break;
 
154
    }
 
155
 
 
156
    switch (code = param_read_int(plist,
 
157
                                  (param_name = "BlockHeight"),
 
158
                                  &BlockHeight)) {
 
159
        case 0:
 
160
            if (BlockHeight < 0)
 
161
                ecode = gs_error_rangecheck;
 
162
            else
 
163
                break;
 
164
            goto bheighte;
 
165
        default:
 
166
            ecode = code;
 
167
          bheighte:param_signal_error(plist, param_name, ecode = code);
 
168
        case 1:
 
169
            break;
 
170
    }
 
171
 
 
172
    if ((code = param_read_bool(plist,
 
173
                                (param_name = "ShowBubble"),
 
174
                                &ShowBubble)) < 0) {
 
175
        param_signal_error(plist, param_name, ecode = code);
176
176
    }
177
177
    if (ecode < 0)
178
 
        return ecode;
 
178
        return ecode;
179
179
    code = gdev_prn_put_params(dev, plist);
180
180
    if (code < 0)
181
 
        return code;
 
181
        return code;
182
182
 
183
183
    lprn->ManualFeed = ManualFeed;
184
184
    lprn->NegativePrint = NegativePrint;
220
220
    maxY = lprn->BlockLine / lprn->nBh * lprn->nBh;
221
221
 
222
222
    if (!(lprn->ImageBuf = gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), bpl, maxY, "lprn_print_image(ImageBuf)")))
223
 
        return_error(gs_error_VMerror);
 
223
        return_error(gs_error_VMerror);
224
224
    if (!(lprn->TmpBuf = gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), bpl, maxY, "lprn_print_iamge(TmpBuf)")))
225
 
        return_error(gs_error_VMerror);
 
225
        return_error(gs_error_VMerror);
226
226
    if (!(lprn->bubbleTbl = gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), sizeof(Bubble *), maxBx, "lprn_print_image(bubbleTbl)")))
227
 
        return_error(gs_error_VMerror);
 
227
        return_error(gs_error_VMerror);
228
228
    if (!(bubbleBuffer = gs_malloc(gs_lib_ctx_get_non_gc_memory_t(), sizeof(Bubble), maxBx, "lprn_print_image(bubbleBuffer)")))
229
 
        return_error(gs_error_VMerror);
 
229
        return_error(gs_error_VMerror);
230
230
 
231
231
    for (i = 0; i < maxBx; i++)
232
 
        lprn->bubbleTbl[i] = NULL;
 
232
        lprn->bubbleTbl[i] = NULL;
233
233
    bbtbl = bubbleBuffer;
234
234
 
235
235
    for (i = 0; i < maxBx - 1; i++)
236
 
        bbtbl[i].next = &bbtbl[i + 1];
 
236
        bbtbl[i].next = &bbtbl[i + 1];
237
237
    bbtbl[i].next = NULL;
238
238
    lprn->freeBubbleList = &bbtbl[0];
239
239
 
240
240
    for (y = 0; y < maxBy; y++) {
241
 
        if (num_y_blocks + lprn->nBh > maxY) {  /* bubble flush for next data */
242
 
            rmin = start_y_block + lprn->nBh;   /* process the data under rmin */
243
 
            for (i = 0; i < maxBx; i++) {
244
 
                bbl = lprn->bubbleTbl[i];
245
 
                if (bbl != NULL && bbl->brect.p.y < rmin)
246
 
                    lprn_bubble_flush(pdev, fp, bbl);
247
 
            }
248
 
            num_y_blocks -= lprn->nBh;  /* data if keeps in [r:r+h] */
249
 
            start_y_block += lprn->nBh;
250
 
 
251
 
        }
252
 
        ri = start_y_block + num_y_blocks;      /* read position */
253
 
        read_y = ri % maxY;     /* end of read position */
254
 
        code = gdev_prn_copy_scan_lines(pdev, ri, lprn->ImageBuf + bpl * read_y, bpl * lprn->nBh);
255
 
        if (code < 0)
256
 
            return code;
257
 
 
258
 
        num_y_blocks += lprn->nBh;
259
 
 
260
 
        lprn_process_line(pdev, fp, start_y_block, num_y_blocks);
 
241
        if (num_y_blocks + lprn->nBh > maxY) {  /* bubble flush for next data */
 
242
            rmin = start_y_block + lprn->nBh;   /* process the data under rmin */
 
243
            for (i = 0; i < maxBx; i++) {
 
244
                bbl = lprn->bubbleTbl[i];
 
245
                if (bbl != NULL && bbl->brect.p.y < rmin)
 
246
                    lprn_bubble_flush(pdev, fp, bbl);
 
247
            }
 
248
            num_y_blocks -= lprn->nBh;  /* data if keeps in [r:r+h] */
 
249
            start_y_block += lprn->nBh;
 
250
 
 
251
        }
 
252
        ri = start_y_block + num_y_blocks;      /* read position */
 
253
        read_y = ri % maxY;     /* end of read position */
 
254
        code = gdev_prn_copy_scan_lines(pdev, ri, lprn->ImageBuf + bpl * read_y, bpl * lprn->nBh);
 
255
        if (code < 0)
 
256
            return code;
 
257
 
 
258
        num_y_blocks += lprn->nBh;
 
259
 
 
260
        lprn_process_line(pdev, fp, start_y_block, num_y_blocks);
261
261
    }
262
262
    lprn_bubble_flush_all(pdev, fp);    /* flush the rest of bubble */
263
263
 
269
269
    return code;
270
270
}
271
271
 
272
 
 
273
272
/*
274
273
 * epag_bubble_flush_all: Output the rect of bubble.
275
274
 */
282
281
    int maxBx = (bpl + lprn->nBw - 1) / lprn->nBw;
283
282
 
284
283
    for (i = 0; i < maxBx; i++) {
285
 
        if (lprn->bubbleTbl[i] != NULL) {
286
 
            lprn_bubble_flush(pdev, fp, lprn->bubbleTbl[i]);
287
 
        } else
288
 
            break;
 
284
        if (lprn->bubbleTbl[i] != NULL) {
 
285
            lprn_bubble_flush(pdev, fp, lprn->bubbleTbl[i]);
 
286
        } else
 
287
            break;
289
288
    }
290
289
}
291
290
 
303
302
 
304
303
    bInBlack = 0;
305
304
    for (bx = 0; bx < maxBx; bx++) {
306
 
        bBlack = lprn_is_black(pdev, r, h, bx);
307
 
        if (!bInBlack) {
308
 
            if (bBlack) {
309
 
                start = bx;
310
 
                bInBlack = 1;
311
 
            }
312
 
        } else {
313
 
            if (!bBlack) {
314
 
                bInBlack = 0;
315
 
                lprn_rect_add(pdev, fp, r, h, start, bx);
316
 
            }
317
 
        }
 
305
        bBlack = lprn_is_black(pdev, r, h, bx);
 
306
        if (!bInBlack) {
 
307
            if (bBlack) {
 
308
                start = bx;
 
309
                bInBlack = 1;
 
310
            }
 
311
        } else {
 
312
            if (!bBlack) {
 
313
                bInBlack = 0;
 
314
                lprn_rect_add(pdev, fp, r, h, start, bx);
 
315
            }
 
316
        }
318
317
    }
319
318
    if (bInBlack)
320
 
        lprn_rect_add(pdev, fp, r, h, start, bx - 1);
 
319
        lprn_rect_add(pdev, fp, r, h, start, bx - 1);
321
320
}
322
321
 
323
322
/*   Search the bx line to make output */
334
333
 
335
334
    y0 = (r + h - bh) % maxY;
336
335
    for (y = 0; y < bh; y++) {
337
 
        p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];
338
 
        for (x = 0; x < lprn->nBw; x++)
339
 
            if (p[x] != 0)
340
 
                return 1;
 
336
        p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw];
 
337
        for (x = 0; x < lprn->nBw; x++)
 
338
            if (p[x] != 0)
 
339
                return 1;
341
340
    }
342
341
    return 0;
343
342
}
355
354
    Bubble *bbl;
356
355
 
357
356
    if ((bbl = lprn->bubbleTbl[start]) != NULL &&
358
 
        bbl->brect.q.y == y0 - 1 &&
359
 
        bbl->brect.p.x == x0 &&
360
 
        bbl->brect.q.x == x1) {
361
 
        bbl->brect.q.y = y1;
 
357
        bbl->brect.q.y == y0 - 1 &&
 
358
        bbl->brect.p.x == x0 &&
 
359
        bbl->brect.q.x == x1) {
 
360
        bbl->brect.q.y = y1;
362
361
    } else {
363
 
        for (i = start; i <= end; i++)
364
 
            if (lprn->bubbleTbl[i] != NULL)
365
 
                lprn_bubble_flush(pdev, fp, lprn->bubbleTbl[i]);
366
 
        lprn_bubble_gen(pdev, x0, x1, y0, y1);
 
362
        for (i = start; i <= end; i++)
 
363
            if (lprn->bubbleTbl[i] != NULL)
 
364
                lprn_bubble_flush(pdev, fp, lprn->bubbleTbl[i]);
 
365
        lprn_bubble_gen(pdev, x0, x1, y0, y1);
367
366
    }
368
367
}
369
368
 
389
388
    bx1 = (x1 + lprn->nBw - 1) / lprn->nBw;
390
389
 
391
390
    for (bx = bx0; bx <= bx1; bx++) {
392
 
        assert(lprn->bubbleTbl[bx] == NULL);
393
 
        lprn->bubbleTbl[bx] = bbl;
 
391
        assert(lprn->bubbleTbl[bx] == NULL);
 
392
        lprn->bubbleTbl[bx] = bbl;
394
393
    }
395
394
}
396
395
 
411
410
    int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh;
412
411
 
413
412
    for (i = 0; i < height; i++) {
414
 
        p = lprn->ImageBuf + ((i + y) % maxY) * bpl;
415
 
        for (j = 0; j < width / 8; j++) {
416
 
            if (lprn->NegativePrint)
417
 
                *(lprn->TmpBuf + i * width / 8 + j) = ~*(p + j + bbl->brect.p.x);
418
 
            else
419
 
                *(lprn->TmpBuf + i * width / 8 + j) = *(p + j + bbl->brect.p.x);
420
 
        }
 
413
        p = lprn->ImageBuf + ((i + y) % maxY) * bpl;
 
414
        for (j = 0; j < width / 8; j++) {
 
415
            if (lprn->NegativePrint)
 
416
                *(lprn->TmpBuf + i * width / 8 + j) = ~*(p + j + bbl->brect.p.x);
 
417
            else
 
418
                *(lprn->TmpBuf + i * width / 8 + j) = *(p + j + bbl->brect.p.x);
 
419
        }
421
420
    }
422
421
 
423
422
    (*lprn->image_out) (pdev, fp, x, y, width, height);
424
423
 
425
424
    /* Initialize bubbleTbl */
426
425
    for (bx = bx0; bx <= bx1; bx++) {
427
 
        assert(lprn->bubbleTbl[bx] == bbl);
428
 
        lprn->bubbleTbl[bx] = NULL;
 
426
        assert(lprn->bubbleTbl[bx] == bbl);
 
427
        lprn->bubbleTbl[bx] = NULL;
429
428
    }
430
429
 
431
430
    bbl->next = lprn->freeBubbleList;