Subversion Repositories filter_foundry

Rev

Rev 231 | Rev 233 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 231 Rev 232
Line 134... Line 134...
134
                DoPrepare(pb);
134
                DoPrepare(pb);
135
                init_symtab(predefs); // ready for parser calls
135
                init_symtab(predefs); // ready for parser calls
136
                init_trigtab();
136
                init_trigtab();
137
                break;
137
                break;
138
        case filterSelectorStart:
138
        case filterSelectorStart:
-
 
139
                if (pb->bigDocumentData != NULL) {
-
 
140
                        // The BigDocument structure is required if the document is larger than 30,000 pixels
-
 
141
                        // It deprecates imageSize, filterRect, inRect, outRect, maskRect, floatCoord, and wholeSize.
-
 
142
                        // By setting it to nonzero, we communicate to Photoshop that we support the BigDocument structure.
-
 
143
                        pb->bigDocumentData->PluginUsing32BitCoordinates = true;
-
 
144
                }
-
 
145
 
139
                /* initialise the parameter handle that Photoshop keeps for us */
146
                /* initialise the parameter handle that Photoshop keeps for us */
140
                if(!pb->parameters)
147
                if(!pb->parameters)
141
                        pb->parameters = PINEWHANDLE(1); // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that.
148
                        pb->parameters = PINEWHANDLE(1); // don't set initial size to 0, since some hosts (e.g. GIMP/PSPI) are incompatible with that.
142
 
149
 
143
                wantdialog |= checkandinitparams(pb->parameters);
150
                wantdialog |= checkandinitparams(pb->parameters);
Line 369... Line 376...
369
        /* Request next block of the image */
376
        /* Request next block of the image */
370
 
377
 
371
        pb->inLoPlane = pb->outLoPlane = 0;
378
        pb->inLoPlane = pb->outLoPlane = 0;
372
        pb->inHiPlane = pb->outHiPlane = nplanes-1;
379
        pb->inHiPlane = pb->outHiPlane = nplanes-1;
373
 
380
 
-
 
381
        if (HAS_BIG_DOC(pb)) {
374
        // if any of the formulae involve random access to image pixels,
382
                // if any of the formulae involve random access to image pixels,
375
        // ask for the entire image
383
                // ask for the entire image
376
        if(needall){
384
                if (needall) {
377
                SETRECT(pb->inRect,0,0,pb->imageSize.h,pb->imageSize.v);
385
                        SETRECT(BIGDOC_IN_RECT(pb), 0, 0, BIGDOC_IMAGE_SIZE(pb).h, BIGDOC_IMAGE_SIZE(pb).v);
378
        }else{
386
                } else {
379
                // TODO: This does not work with GIMP. So, if we are using GIMP, we should
387
                        // TODO: This does not work with GIMP. So, if we are using GIMP, we should
380
                //       somehow always use "needall=true", and/or find out why this doesn't work
388
                        //       somehow always use "needall=true", and/or find out why this doesn't work
381
                //       with GIMP.
389
                        //       with GIMP.
382
 
390
 
383
                // otherwise, process the filtered area, by chunksize parts
391
                        // otherwise, process the filtered area, by chunksize parts
384
                pb->inRect.left = pb->filterRect.left;
392
                        BIGDOC_IN_RECT(pb).left = BIGDOC_FILTER_RECT(pb).left;
385
                pb->inRect.right = pb->filterRect.right;
393
                        BIGDOC_IN_RECT(pb).right = BIGDOC_FILTER_RECT(pb).right;
386
                pb->inRect.top = (int16)toprow;
394
                        BIGDOC_IN_RECT(pb).top = (int32)toprow;
387
                pb->inRect.bottom = (int16)MIN(toprow + chunksize,pb->filterRect.bottom);
395
                        BIGDOC_IN_RECT(pb).bottom = (int32)MIN(toprow + chunksize, BIGDOC_FILTER_RECT(pb).bottom);
388
 
396
 
389
                if(cnvused){
397
                        if (cnvused) {
390
                        // cnv() needs one extra pixel in each direction
398
                                // cnv() needs one extra pixel in each direction
391
                        if(pb->inRect.left > 0)
399
                                if (BIGDOC_IN_RECT(pb).left > 0)
392
                                --pb->inRect.left;
400
                                        --BIGDOC_IN_RECT(pb).left;
393
                        if(pb->inRect.right < pb->imageSize.h)
401
                                if (BIGDOC_IN_RECT(pb).right < BIGDOC_IMAGE_SIZE(pb).h)
394
                                ++pb->inRect.right;
402
                                        ++BIGDOC_IN_RECT(pb).right;
395
                        if(pb->inRect.top > 0)
403
                                if (BIGDOC_IN_RECT(pb).top > 0)
396
                                --pb->inRect.top;
404
                                        --BIGDOC_IN_RECT(pb).top;
397
                        if(pb->inRect.bottom < pb->imageSize.v)
405
                                if (BIGDOC_IN_RECT(pb).bottom < BIGDOC_IMAGE_SIZE(pb).v)
398
                                ++pb->inRect.bottom;
406
                                        ++BIGDOC_IN_RECT(pb).bottom;
399
                }
407
                        }
400
        }
408
                }
401
        pb->outRect = pb->filterRect;
409
                BIGDOC_OUT_RECT(pb) = BIGDOC_FILTER_RECT(pb);
402
/*
410
                /*
403
{char s[0x100];sprintf(s,"RequestNext needall=%d inRect=(%d,%d,%d,%d) filterRect=(%d,%d,%d,%d)",
411
                {char s[0x100];sprintf(s,"RequestNext needall=%d inRect=(%d,%d,%d,%d) filterRect=(%d,%d,%d,%d)",
404
        needall,
412
                        needall,
405
        pb->inRect.left,pb->inRect.top,pb->inRect.right,pb->inRect.bottom,
413
                        BIGDOC_IN_RECT(pb).left,BIGDOC_IN_RECT(pb).top,BIGDOC_IN_RECT(pb).right,BIGDOC_IN_RECT(pb).bottom,
406
        pb->filterRect.left,pb->filterRect.top,pb->filterRect.right,pb->filterRect.bottom);dbg(s);}
414
                        BIGDOC_FILTER_RECT(pb).left,BIGDOC_FILTER_RECT(pb).top,BIGDOC_FILTER_RECT(pb).right,BIGDOC_FILTER_RECT(pb).bottom);dbg(s);}
407
*/
415
                */
-
 
416
        } else {
-
 
417
                // if any of the formulae involve random access to image pixels,
-
 
418
                // ask for the entire image
-
 
419
                if (needall) {
-
 
420
                        SETRECT(IN_RECT(pb), 0, 0, IMAGE_SIZE(pb).h, IMAGE_SIZE(pb).v);
-
 
421
                }
-
 
422
                else {
-
 
423
                        // TODO: This does not work with GIMP. So, if we are using GIMP, we should
-
 
424
                        //       somehow always use "needall=true", and/or find out why this doesn't work
-
 
425
                        //       with GIMP.
-
 
426
 
-
 
427
                        // otherwise, process the filtered area, by chunksize parts
-
 
428
                        IN_RECT(pb).left = FILTER_RECT(pb).left;
-
 
429
                        IN_RECT(pb).right = FILTER_RECT(pb).right;
-
 
430
                        IN_RECT(pb).top = (int16)toprow;
-
 
431
                        IN_RECT(pb).bottom = (int16)MIN(toprow + chunksize, FILTER_RECT(pb).bottom);
-
 
432
 
-
 
433
                        if (cnvused) {
-
 
434
                                // cnv() needs one extra pixel in each direction
-
 
435
                                if (IN_RECT(pb).left > 0)
-
 
436
                                        --IN_RECT(pb).left;
-
 
437
                                if (IN_RECT(pb).right < IMAGE_SIZE(pb).h)
-
 
438
                                        ++IN_RECT(pb).right;
-
 
439
                                if (IN_RECT(pb).top > 0)
-
 
440
                                        --IN_RECT(pb).top;
-
 
441
                                if (IN_RECT(pb).bottom < IMAGE_SIZE(pb).v)
-
 
442
                                        ++IN_RECT(pb).bottom;
-
 
443
                        }
-
 
444
                }
-
 
445
                OUT_RECT(pb) = FILTER_RECT(pb);
-
 
446
                /*
-
 
447
                {char s[0x100];sprintf(s,"RequestNext needall=%d inRect=(%d,%d,%d,%d) filterRect=(%d,%d,%d,%d)",
-
 
448
                        needall,
-
 
449
                        IN_RECT(pb).left,IN_RECT(pb).top,IN_RECT(pb).right,IN_RECT(pb).bottom,
-
 
450
                        FILTER_RECT(pb).left,FILTER_RECT(pb).top,FILTER_RECT(pb).right,FILTER_RECT(pb).bottom);dbg(s);}
-
 
451
                */
-
 
452
        }
408
}
453
}
409
 
454
 
410
void DoStart(FilterRecordPtr pb){
455
void DoStart(FilterRecordPtr pb){
411
//dbg("DoStart");
456
//dbg("DoStart");
412
        /* if src() or rad() functions are used, random access to the image data is required,
457
        /* if src() or rad() functions are used, random access to the image data is required,
413
           so we must request the entire image in a single chunk. */
458
           so we must request the entire image in a single chunk. */
-
 
459
        if (HAS_BIG_DOC(pb)) {
-
 
460
                chunksize = needall ? (BIGDOC_FILTER_RECT(pb).bottom - BIGDOC_FILTER_RECT(pb).top) : CHUNK_ROWS;
-
 
461
                toprow = BIGDOC_FILTER_RECT(pb).top;
-
 
462
        } else {
414
        chunksize = needall ? (pb->filterRect.bottom - pb->filterRect.top) : CHUNK_ROWS;
463
                chunksize = needall ? (FILTER_RECT(pb).bottom - FILTER_RECT(pb).top) : CHUNK_ROWS;
415
        toprow = pb->filterRect.top;
464
                toprow = FILTER_RECT(pb).top;
-
 
465
        }
416
        RequestNext(pb,toprow);
466
        RequestNext(pb, toprow);
417
}
467
}
418
 
468
 
419
OSErr DoContinue(FilterRecordPtr pb){
469
OSErr DoContinue(FilterRecordPtr pb){
420
        OSErr e = noErr;
470
        OSErr e = noErr;
421
        Rect fr;
-
 
422
        long outoffset;
471
        long outoffset;
423
 
472
 
-
 
473
        if (HAS_BIG_DOC(pb)) {
-
 
474
                VRect fr;
424
        if(needall)
475
                if (needall) {
425
                fr = pb->filterRect;  // filter whole selection at once
476
                        fr = BIGDOC_FILTER_RECT(pb);  // filter whole selection at once
426
        else if(cnvused){
477
                } else if (cnvused) {
427
                // we've requested one pixel extra all around
478
                        // we've requested one pixel extra all around
428
                // (see RequestNext()), just for access purposes. But filter
479
                        // (see RequestNext()), just for access purposes. But filter
429
                // original selection only.
480
                        // original selection only.
430
                fr.left = pb->filterRect.left;
481
                        fr.left = BIGDOC_FILTER_RECT(pb).left;
431
                fr.right = pb->filterRect.right;
482
                        fr.right = BIGDOC_FILTER_RECT(pb).right;
432
                fr.top = toprow;
483
                        fr.top = toprow;
433
                fr.bottom = MIN(toprow + chunksize,pb->filterRect.bottom);
484
                        fr.bottom = MIN(toprow + chunksize, BIGDOC_FILTER_RECT(pb).bottom);
434
        }else  // filter whatever portion we've been given
485
                } else {  // filter whatever portion we've been given
435
                fr = pb->inRect;
486
                        fr = BIGDOC_IN_RECT(pb);
-
 
487
                }
436
 
488
 
437
        outoffset = (long)pb->outRowBytes*(fr.top - pb->outRect.top)
489
                outoffset = (long)pb->outRowBytes * (fr.top - BIGDOC_OUT_RECT(pb).top)
438
                                + (long)nplanes*(fr.left - pb->outRect.left);
490
                        + (long)nplanes * (fr.left - BIGDOC_OUT_RECT(pb).left);
439
 
491
 
440
        if(!(e = process_scaled(pb, true, &fr, &fr,
492
                if (!(e = process_scaled_bigdoc(pb, true, fr, fr,
441
                                (Ptr)pb->outData+outoffset, pb->outRowBytes, 1.)))
493
                        (Ptr)pb->outData + outoffset, pb->outRowBytes, 1.)))
442
        {
494
                {
443
                toprow += chunksize;
495
                        toprow += chunksize;
444
                if(toprow < pb->filterRect.bottom)
496
                        if (toprow < BIGDOC_FILTER_RECT(pb).bottom)
445
                        RequestNext(pb,toprow);
497
                                RequestNext(pb, toprow);
446
                else{
498
                        else {
-
 
499
                                SETRECT(BIGDOC_IN_RECT(pb), 0, 0, 0, 0);
-
 
500
                                BIGDOC_OUT_RECT(pb) = BIGDOC_MASK_RECT(pb) = BIGDOC_IN_RECT(pb);
-
 
501
                        }
-
 
502
                }
-
 
503
        } else {
-
 
504
                Rect fr;
-
 
505
                if (needall) {
-
 
506
                        fr = FILTER_RECT(pb);  // filter whole selection at once
-
 
507
                } else if (cnvused) {
-
 
508
                        // we've requested one pixel extra all around
-
 
509
                        // (see RequestNext()), just for access purposes. But filter
-
 
510
                        // original selection only.
-
 
511
                        fr.left = FILTER_RECT(pb).left;
-
 
512
                        fr.right = FILTER_RECT(pb).right;
-
 
513
                        fr.top = toprow;
-
 
514
                        fr.bottom = MIN(toprow + chunksize, FILTER_RECT(pb).bottom);
-
 
515
                } else {  // filter whatever portion we've been given
-
 
516
                        fr = IN_RECT(pb);
-
 
517
                }
-
 
518
 
-
 
519
                outoffset = (long)pb->outRowBytes*(fr.top - OUT_RECT(pb).top)
-
 
520
                                        + (long)nplanes*(fr.left - OUT_RECT(pb).left);
-
 
521
 
-
 
522
                if(!(e = process_scaled_olddoc(pb, true, fr, fr,
-
 
523
                                        (Ptr)pb->outData+outoffset, pb->outRowBytes, 1.)))
-
 
524
                {
-
 
525
                        toprow += chunksize;
-
 
526
                        if(toprow < FILTER_RECT(pb).bottom)
-
 
527
                                RequestNext(pb,toprow);
-
 
528
                        else{
447
                        SETRECT(pb->inRect,0,0,0,0);
529
                                SETRECT(IN_RECT(pb),0,0,0,0);
448
                        pb->outRect = pb->maskRect = pb->inRect;
530
                                OUT_RECT(pb) = MASK_RECT(pb) = IN_RECT(pb);
-
 
531
                        }
449
                }
532
                }
450
        }
533
        }
451
        return e;
534
        return e;
452
}
535
}
453
 
536