Hash :
f11dbdb3
Author :
Date :
2013-10-23T14:37:58
Added a read pixels test. Change-Id: Ia4c5a0290e62e2c312d86fa18ef4e76d782a4a41 Reviewed-on: https://chromium-review.googlesource.com/179357 Reviewed-by: Nicolas Capens <nicolascapens@chromium.org> Commit-Queue: Nicolas Capens <nicolascapens@chromium.org> Tested-by: Nicolas Capens <nicolascapens@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
#include "ANGLETest.h"
class ReadPixelsTest : public ANGLETest
{
protected:
ReadPixelsTest()
{
setWindowWidth(32);
setWindowHeight(32);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
TEST_F(ReadPixelsTest, out_of_bounds)
{
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_GL_NO_ERROR();
GLsizei pixelsWidth = 32;
GLsizei pixelsHeight = 32;
std::vector<GLubyte> pixels(pixelsWidth * pixelsHeight * 4);
glReadPixels(-pixelsWidth / 2, -pixelsHeight / 2, pixelsWidth, pixelsHeight, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data());
EXPECT_GL_NO_ERROR();
for (int y = pixelsHeight / 2; y < pixelsHeight; y++)
{
for (int x = pixelsWidth / 2; x < pixelsWidth; x++)
{
const GLubyte* pixel = pixels.data() + ((y * pixelsWidth + x) * 4);
// Expect that all pixels which fell within the framebuffer are red
EXPECT_EQ(pixel[0], 255);
EXPECT_EQ(pixel[1], 0);
EXPECT_EQ(pixel[2], 0);
EXPECT_EQ(pixel[3], 255);
}
}
}