@@ -243,11 +243,18 @@ generateRandomFile (
243
243
}
244
244
}
245
245
246
+ enum ReadType
247
+ {
248
+ eReadBulk = 1 ,
249
+ eReadScanline,
250
+ eReadScanlinelFrameBuffer
251
+ };
252
+
246
253
void
247
254
readFile (
248
255
const std::string& filename,
249
256
int channelCount,
250
- bool bulkRead ,
257
+ ReadType readType ,
251
258
bool randomChannels)
252
259
{
253
260
if (randomChannels) { cout << " reading random channels " << flush; }
@@ -352,9 +359,12 @@ readFile (
352
359
pointerSize * width, // yStride// 10
353
360
sampleSize)); // sampleStride
354
361
}
355
- file.setFrameBuffer (frameBuffer);
362
+ if (readType != eReadScanlinelFrameBuffer)
363
+ {
364
+ file.setFrameBuffer (frameBuffer);
365
+ }
356
366
357
- if (bulkRead )
367
+ if (readType == eReadBulk )
358
368
{
359
369
cout << " bulk " << flush;
360
370
file.readPixelSampleCounts (dataWindow.min .y , dataWindow.max .y );
@@ -397,10 +407,24 @@ readFile (
397
407
else
398
408
{
399
409
cout << " per-line " << flush;
410
+ if (readType == eReadScanlinelFrameBuffer) cout << " framebuffer " << flush;
400
411
for (int i = 0 ; i < dataWindow.max .y - dataWindow.min .y + 1 ; i++)
401
412
{
402
413
int y = i + dataWindow.min .y ;
403
- file.readPixelSampleCounts (y);
414
+ vector<char > buffer;
415
+ if (readType == eReadScanlinelFrameBuffer)
416
+ {
417
+ uint64_t pixSize = 0 ;
418
+ file.rawPixelData (y, nullptr , pixSize);
419
+ buffer.resize (pixSize);
420
+ file.rawPixelData (y, buffer.data (), pixSize);
421
+ file.readPixelSampleCounts (buffer.data (), frameBuffer, y, y);
422
+ }
423
+ else // readType == eReadScanline
424
+ {
425
+ file.readPixelSampleCounts (y);
426
+ }
427
+
404
428
405
429
for (int j = 0 ; j < width; j++)
406
430
assert (localSampleCount[i][j] == sampleCount[i][j]);
@@ -431,7 +455,14 @@ readFile (
431
455
}
432
456
}
433
457
434
- file.readPixels (y);
458
+ if (readType == eReadScanlinelFrameBuffer)
459
+ {
460
+ file.readPixels (buffer.data (), frameBuffer, y, y);
461
+ }
462
+ else // readType == eReadScanline
463
+ {
464
+ file.readPixels (y);
465
+ }
435
466
}
436
467
}
437
468
@@ -539,8 +570,10 @@ readWriteTest (
539
570
false ,
540
571
dataWindow,
541
572
displayWindow);
542
- readFile (filename, channelCount, false , false );
543
- if (channelCount > 1 ) readFile (filename, channelCount, false , true );
573
+ readFile (filename, channelCount, eReadScanline, false );
574
+ if (channelCount > 1 ) readFile (filename, channelCount, eReadScanline, true );
575
+ readFile (filename, channelCount, eReadScanlinelFrameBuffer, false );
576
+ if (channelCount > 1 ) readFile (filename, channelCount, eReadScanlinelFrameBuffer, true );
544
577
remove (filename.c_str ());
545
578
cout << endl << flush;
546
579
@@ -551,8 +584,8 @@ readWriteTest (
551
584
true ,
552
585
dataWindow,
553
586
displayWindow);
554
- readFile (filename, channelCount, true , false );
555
- if (channelCount > 1 ) readFile (filename, channelCount, true , true );
587
+ readFile (filename, channelCount, eReadBulk , false );
588
+ if (channelCount > 1 ) readFile (filename, channelCount, eReadBulk , true );
556
589
remove (filename.c_str ());
557
590
cout << endl << flush;
558
591
}
0 commit comments