Skip to content

Commit 7ca2ed0

Browse files
committed
Add a Deep Scanline Input test that uses a framebuffer parameter
After having found a bug with the readPixels() and readPixelSampleCounts() overloads that receive a framebuffer parameter, it was made apparent that there was a hole in our tests to cover these functions. This commits slightly refactors the DeepScanLineBasic tests and adds a third read path to add coverage for this case as well. Signed-off-by: Nikolaos Koutsikos <[email protected]>
1 parent ff83af2 commit 7ca2ed0

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

src/test/OpenEXRTest/testDeepScanLineBasic.cpp

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,18 @@ generateRandomFile (
243243
}
244244
}
245245

246+
enum ReadType
247+
{
248+
eReadBulk = 1,
249+
eReadScanline,
250+
eReadScanlinelFrameBuffer
251+
};
252+
246253
void
247254
readFile (
248255
const std::string& filename,
249256
int channelCount,
250-
bool bulkRead,
257+
ReadType readType,
251258
bool randomChannels)
252259
{
253260
if (randomChannels) { cout << " reading random channels " << flush; }
@@ -352,9 +359,12 @@ readFile (
352359
pointerSize * width, // yStride// 10
353360
sampleSize)); // sampleStride
354361
}
355-
file.setFrameBuffer (frameBuffer);
362+
if (readType != eReadScanlinelFrameBuffer)
363+
{
364+
file.setFrameBuffer (frameBuffer);
365+
}
356366

357-
if (bulkRead)
367+
if (readType == eReadBulk)
358368
{
359369
cout << "bulk " << flush;
360370
file.readPixelSampleCounts (dataWindow.min.y, dataWindow.max.y);
@@ -397,10 +407,24 @@ readFile (
397407
else
398408
{
399409
cout << "per-line " << flush;
410+
if (readType == eReadScanlinelFrameBuffer) cout << "framebuffer " << flush;
400411
for (int i = 0; i < dataWindow.max.y - dataWindow.min.y + 1; i++)
401412
{
402413
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+
404428

405429
for (int j = 0; j < width; j++)
406430
assert (localSampleCount[i][j] == sampleCount[i][j]);
@@ -431,7 +455,14 @@ readFile (
431455
}
432456
}
433457

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+
}
435466
}
436467
}
437468

@@ -539,8 +570,10 @@ readWriteTest (
539570
false,
540571
dataWindow,
541572
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);
544577
remove (filename.c_str ());
545578
cout << endl << flush;
546579

@@ -551,8 +584,8 @@ readWriteTest (
551584
true,
552585
dataWindow,
553586
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);
556589
remove (filename.c_str ());
557590
cout << endl << flush;
558591
}

0 commit comments

Comments
 (0)