~ubuntu-branches/ubuntu/saucy/openexr/saucy

« back to all changes in this revision

Viewing changes to IlmImf/ImfTiledRgbaFile.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adeodato Simó
  • Date: 2008-03-24 23:00:21 UTC
  • mfrom: (3.1.2 lenny)
  • Revision ID: james.westby@ubuntu.com-20080324230021-gnofz9mnvcj1xlv3
Tags: 1.6.1-3
Disable (hopefully temporarily) the test suite on arm and ia64.

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#include <ImfStandardAttributes.h>
49
49
#include <ImfRgbaYca.h>
50
50
#include <ImfArray.h>
51
 
#include <Iex.h>
 
51
#include "IlmThreadMutex.h"
 
52
#include "Iex.h"
 
53
 
52
54
 
53
55
namespace Imf {
54
56
 
55
57
using namespace Imath;
56
58
using namespace RgbaYca;
 
59
using namespace IlmThread;
57
60
 
58
61
namespace {
59
62
 
135
138
} // namespace
136
139
 
137
140
 
138
 
class TiledRgbaOutputFile::ToYa
 
141
class TiledRgbaOutputFile::ToYa: public Mutex
139
142
{
140
143
  public:
141
144
 
245
248
     int tileXSize,
246
249
     int tileYSize,
247
250
     LevelMode mode,
248
 
     LevelRoundingMode rmode)
 
251
     LevelRoundingMode rmode,
 
252
     int numThreads)
249
253
:
250
254
    _outputFile (0),
251
255
    _toYa (0)
253
257
    Header hd (header);
254
258
    insertChannels (hd, rgbaChannels, name);
255
259
    hd.setTileDescription (TileDescription (tileXSize, tileYSize, mode, rmode));
256
 
    _outputFile = new TiledOutputFile (name, hd);
 
260
    _outputFile = new TiledOutputFile (name, hd, numThreads);
257
261
 
258
262
    if (rgbaChannels & WRITE_Y)
259
263
        _toYa = new ToYa (*_outputFile, rgbaChannels);
268
272
     int tileXSize,
269
273
     int tileYSize,
270
274
     LevelMode mode,
271
 
     LevelRoundingMode rmode)
 
275
     LevelRoundingMode rmode,
 
276
     int numThreads)
272
277
:
273
278
    _outputFile (0),
274
279
    _toYa (0)
276
281
    Header hd (header);
277
282
    insertChannels (hd, rgbaChannels, os.fileName());
278
283
    hd.setTileDescription (TileDescription (tileXSize, tileYSize, mode, rmode));
279
 
    _outputFile = new TiledOutputFile (os, hd);
 
284
    _outputFile = new TiledOutputFile (os, hd, numThreads);
280
285
 
281
286
    if (rgbaChannels & WRITE_Y)
282
287
        _toYa = new ToYa (*_outputFile, rgbaChannels);
297
302
     const Imath::V2f screenWindowCenter,
298
303
     float screenWindowWidth,
299
304
     LineOrder lineOrder,
300
 
     Compression compression)
 
305
     Compression compression,
 
306
     int numThreads)
301
307
:
302
308
    _outputFile (0),
303
309
    _toYa (0)
312
318
 
313
319
    insertChannels (hd, rgbaChannels, name);
314
320
    hd.setTileDescription (TileDescription (tileXSize, tileYSize, mode, rmode));
315
 
    _outputFile = new TiledOutputFile (name, hd);
 
321
    _outputFile = new TiledOutputFile (name, hd, numThreads);
316
322
 
317
323
    if (rgbaChannels & WRITE_Y)
318
324
        _toYa = new ToYa (*_outputFile, rgbaChannels);
332
338
     const Imath::V2f screenWindowCenter,
333
339
     float screenWindowWidth,
334
340
     LineOrder lineOrder,
335
 
     Compression compression)
 
341
     Compression compression,
 
342
     int numThreads)
336
343
:
337
344
    _outputFile (0),
338
345
    _toYa (0)
347
354
 
348
355
    insertChannels (hd, rgbaChannels, name);
349
356
    hd.setTileDescription (TileDescription (tileXSize, tileYSize, mode, rmode));
350
 
    _outputFile = new TiledOutputFile (name, hd);
 
357
    _outputFile = new TiledOutputFile (name, hd, numThreads);
351
358
 
352
359
    if (rgbaChannels & WRITE_Y)
353
360
        _toYa = new ToYa (*_outputFile, rgbaChannels);
368
375
{
369
376
    if (_toYa)
370
377
    {
 
378
        Lock lock (*_toYa);
371
379
        _toYa->setFrameBuffer (base, xStride, yStride);
372
380
    }
373
381
    else
573
581
TiledRgbaOutputFile::writeTile (int dx, int dy, int l)
574
582
{
575
583
    if (_toYa)
 
584
    {
 
585
        Lock lock (*_toYa);
576
586
        _toYa->writeTile (dx, dy, l, l);
 
587
    }
577
588
    else
 
589
    {
578
590
         _outputFile->writeTile (dx, dy, l);
 
591
    }
579
592
}
580
593
 
581
594
 
583
596
TiledRgbaOutputFile::writeTile (int dx, int dy, int lx, int ly)
584
597
{
585
598
    if (_toYa)
 
599
    {
 
600
        Lock lock (*_toYa);
586
601
        _toYa->writeTile (dx, dy, lx, ly);
 
602
    }
587
603
    else
 
604
    {
588
605
         _outputFile->writeTile (dx, dy, lx, ly);
589
 
}
590
 
 
591
 
 
592
 
class TiledRgbaInputFile::FromYa
 
606
    }
 
607
}
 
608
 
 
609
 
 
610
void    
 
611
TiledRgbaOutputFile::writeTiles
 
612
    (int dxMin, int dxMax, int dyMin, int dyMax, int lx, int ly)
 
613
{
 
614
    if (_toYa)
 
615
    {
 
616
        Lock lock (*_toYa);
 
617
 
 
618
        for (int dy = dyMin; dy <= dyMax; dy++)
 
619
            for (int dx = dxMin; dx <= dxMax; dx++)
 
620
                _toYa->writeTile (dx, dy, lx, ly);
 
621
    }
 
622
    else
 
623
    {
 
624
        _outputFile->writeTiles (dxMin, dxMax, dyMin, dyMax, lx, ly);
 
625
    }
 
626
}
 
627
 
 
628
void    
 
629
TiledRgbaOutputFile::writeTiles
 
630
    (int dxMin, int dxMax, int dyMin, int dyMax, int l)
 
631
{
 
632
    writeTiles (dxMin, dxMax, dyMin, dyMax, l, l);
 
633
}
 
634
 
 
635
 
 
636
class TiledRgbaInputFile::FromYa: public Mutex
593
637
{
594
638
  public:
595
639
 
698
742
}
699
743
 
700
744
 
701
 
TiledRgbaInputFile::TiledRgbaInputFile (const char name[]):
702
 
    _inputFile (new TiledInputFile (name)),
 
745
TiledRgbaInputFile::TiledRgbaInputFile (const char name[], int numThreads):
 
746
    _inputFile (new TiledInputFile (name, numThreads)),
703
747
    _fromYa (0)
704
748
{
705
749
    if (channels() & WRITE_Y)
707
751
}
708
752
 
709
753
 
710
 
TiledRgbaInputFile::TiledRgbaInputFile (IStream &is):
711
 
    _inputFile (new TiledInputFile (is)),
 
754
TiledRgbaInputFile::TiledRgbaInputFile (IStream &is, int numThreads):
 
755
    _inputFile (new TiledInputFile (is, numThreads)),
712
756
    _fromYa (0)
713
757
{
714
758
    if (channels() & WRITE_Y)
728
772
{
729
773
    if (_fromYa)
730
774
    {
 
775
        Lock lock (*_fromYa);
731
776
        _fromYa->setFrameBuffer (base, xStride, yStride);
732
777
    }
733
778
    else
973
1018
TiledRgbaInputFile::readTile (int dx, int dy, int l)
974
1019
{
975
1020
    if (_fromYa)
 
1021
    {
 
1022
        Lock lock (*_fromYa);
976
1023
        _fromYa->readTile (dx, dy, l, l);
 
1024
    }
977
1025
    else
 
1026
    {
978
1027
         _inputFile->readTile (dx, dy, l);
 
1028
    }
979
1029
}
980
1030
 
981
1031
 
983
1033
TiledRgbaInputFile::readTile (int dx, int dy, int lx, int ly)
984
1034
{
985
1035
    if (_fromYa)
 
1036
    {
 
1037
        Lock lock (*_fromYa);
986
1038
        _fromYa->readTile (dx, dy, lx, ly);
 
1039
    }
987
1040
    else
 
1041
    {
988
1042
         _inputFile->readTile (dx, dy, lx, ly);
 
1043
    }
 
1044
}
 
1045
 
 
1046
 
 
1047
void    
 
1048
TiledRgbaInputFile::readTiles (int dxMin, int dxMax, int dyMin, int dyMax,
 
1049
                               int lx, int ly)
 
1050
{
 
1051
    if (_fromYa)
 
1052
    {
 
1053
        Lock lock (*_fromYa);
 
1054
 
 
1055
        for (int dy = dyMin; dy <= dyMax; dy++)
 
1056
            for (int dx = dxMin; dx <= dxMax; dx++)
 
1057
                _fromYa->readTile (dx, dy, lx, ly);
 
1058
    }
 
1059
    else
 
1060
    {
 
1061
        _inputFile->readTiles (dxMin, dxMax, dyMin, dyMax, lx, ly);
 
1062
    }
 
1063
}
 
1064
 
 
1065
void    
 
1066
TiledRgbaInputFile::readTiles (int dxMin, int dxMax, int dyMin, int dyMax,
 
1067
                               int l)
 
1068
{
 
1069
    readTiles (dxMin, dxMax, dyMin, dyMax, l, l);
989
1070
}
990
1071
 
991
1072
 
996
1077
}
997
1078
 
998
1079
 
 
1080
void    
 
1081
TiledRgbaOutputFile::breakTile  (int dx, int dy, int lx, int ly,
 
1082
                                 int offset, int length, char c)
 
1083
{
 
1084
    _outputFile->breakTile (dx, dy, lx, ly, offset, length, c);
 
1085
}
 
1086
 
 
1087
 
999
1088
} // namespace Imf