static int BackgroundCorrectCheckImage(const IceTImage image) { IceTInt rank; icetGetIntegerv(ICET_RANK, &rank); if (rank == 0) { IceTInt num_proc; IceTInt proc; const IceTFloat *pixel; icetGetIntegerv(ICET_NUM_PROCESSES, &num_proc); pixel = icetImageGetColorcf(image); for (proc = 0; proc < num_proc; proc++) { if (!BackgroundCorrectCheckImageRegion(&pixel, g_blended_color)) { printrank("For process %d\n", proc); if (ColorsEqual(pixel, g_foreground_color)) { printrank("Pixel never blended with background.\n"); } return TEST_FAILED; } } /* Also check a final patch on top that should be background. */ if (!BackgroundCorrectCheckImageRegion(&pixel, g_background_color)) { printrank("For background area\n"); return TEST_FAILED; } } return TEST_PASSED; }
static IceTBoolean BackgroundCorrectCheckImageRegion( const IceTFloat **pixel_p, const IceTFloat *expected_color) { IceTInt x, y; const IceTFloat *pixel = *pixel_p; for (y = 0; y < PROC_REGION_HEIGHT; y++) { for (x = 0; x < PROC_REGION_WIDTH; x++) { if (!ColorsEqual(pixel, expected_color)) { *pixel_p = pixel; printrank("**** Found bad pixel!!!! ****\n"); printrank("Region location x = %d, y = %d\n", x, y); printrank("Got color %f %f %f %f\n", pixel[0], pixel[1], pixel[2], pixel[3]); printrank("Expected %f %f %f %f\n", expected_color[0], expected_color[1], expected_color[2], expected_color[3]); return ICET_FALSE; } pixel += 4; } } *pixel_p = pixel; return ICET_TRUE; }
// Read framebuffer and check that region [width x height] is the expected // solid color, except the upper-right quadrant will always be black/zero. // comp: which color channel in src image was set (0 = red, 1 = green, // 2 = blue, 3 = alpha), other channels are zero. // format is the color format we're testing. bool PixelFormatsTest::CheckRendering(int width, int height, int comp, GLenum format, GLint intFormat) const { const int checkAlpha = alphaBits > 0; GLubyte *image = new GLubyte [width * height * 4]; GLboolean ok = 1; GLubyte expected[4]; int i; assert(comp >= 0 && comp < 4); glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, image); for (i = 0; i < width * height; i += 4) { ComputeExpected(format, comp, intFormat, expected); if (IsUpperRight(i/4, width, height)) { expected[0] = expected[1] = expected[2] = expected[3] = 0; } if (!checkAlpha) { expected[3] = 0xff; } // do the color check if (!ColorsEqual(image+i, expected)) { // report failure info char msg[1000]; env->log << name; sprintf(msg, " failed at pixel (%d,%d), color channel %d:\n", i/width, i%width, comp); env->log << msg; sprintf(msg, " Expected: 0x%02x 0x%02x 0x%02x 0x%02x\n", expected[0], expected[1], expected[2], expected[3]); env->log << msg; sprintf(msg, " Found: 0x%02x 0x%02x 0x%02x 0x%02x\n", image[i + 0], image[i + 1], image[i + 2], image[i + 3]); env->log << msg; ok = false; break; } } delete [] image; return ok; }