| Index: ui/gl/test/gl_image_test_support.cc
|
| diff --git a/ui/gl/test/gl_image_test_support.cc b/ui/gl/test/gl_image_test_support.cc
|
| index 587d13952388c8c89f6b4cfd869d89dd012d348f..48d6a40612e4465e320080c6cfea358932465e6e 100644
|
| --- a/ui/gl/test/gl_image_test_support.cc
|
| +++ b/ui/gl/test/gl_image_test_support.cc
|
| @@ -38,50 +38,89 @@ void GLImageTestSupport::CleanupGL() {
|
| // static
|
| void GLImageTestSupport::SetBufferDataToColor(int width,
|
| int height,
|
| - int stride,
|
| + int strides[],
|
| BufferFormat format,
|
| const uint8_t color[4],
|
| - uint8_t* data) {
|
| + uint8_t* data[]) {
|
| switch (format) {
|
| - case BufferFormat::RGBX_8888:
|
| + case BufferFormat::RGBX_8888: {
|
| + uint8_t* rgbx_data = data[0];
|
| + int stride = strides[0];
|
| for (int y = 0; y < height; ++y) {
|
| for (int x = 0; x < width; ++x) {
|
| - data[y * stride + x * 4 + 0] = color[0];
|
| - data[y * stride + x * 4 + 1] = color[1];
|
| - data[y * stride + x * 4 + 2] = color[2];
|
| - data[y * stride + x * 4 + 3] = 0xaa; // unused
|
| + rgbx_data[y * stride + x * 4 + 0] = color[0];
|
| + rgbx_data[y * stride + x * 4 + 1] = color[1];
|
| + rgbx_data[y * stride + x * 4 + 2] = color[2];
|
| + rgbx_data[y * stride + x * 4 + 3] = 0xaa; // unused
|
| }
|
| }
|
| + }
|
| return;
|
| - case BufferFormat::RGBA_8888:
|
| + case BufferFormat::RGBA_8888: {
|
| + uint8_t* rgba_data = data[0];
|
| + int stride = strides[0];
|
| for (int y = 0; y < height; ++y) {
|
| for (int x = 0; x < width; ++x) {
|
| - data[y * stride + x * 4 + 0] = color[0];
|
| - data[y * stride + x * 4 + 1] = color[1];
|
| - data[y * stride + x * 4 + 2] = color[2];
|
| - data[y * stride + x * 4 + 3] = color[3];
|
| + rgba_data[y * stride + x * 4 + 0] = color[0];
|
| + rgba_data[y * stride + x * 4 + 1] = color[1];
|
| + rgba_data[y * stride + x * 4 + 2] = color[2];
|
| + rgba_data[y * stride + x * 4 + 3] = color[3];
|
| }
|
| }
|
| + }
|
| return;
|
| - case BufferFormat::BGRX_8888:
|
| + case BufferFormat::BGRX_8888: {
|
| + uint8_t* bgrx_data = data[0];
|
| + int stride = strides[0];
|
| for (int y = 0; y < height; ++y) {
|
| for (int x = 0; x < width; ++x) {
|
| - data[y * stride + x * 4 + 0] = color[2];
|
| - data[y * stride + x * 4 + 1] = color[1];
|
| - data[y * stride + x * 4 + 2] = color[0];
|
| - data[y * stride + x * 4 + 3] = 0xaa; // unused
|
| + bgrx_data[y * stride + x * 4 + 0] = color[2];
|
| + bgrx_data[y * stride + x * 4 + 1] = color[1];
|
| + bgrx_data[y * stride + x * 4 + 2] = color[0];
|
| + bgrx_data[y * stride + x * 4 + 3] = 0xaa; // unused
|
| }
|
| }
|
| + }
|
| return;
|
| - case BufferFormat::BGRA_8888:
|
| + case BufferFormat::BGRA_8888: {
|
| + uint8_t* bgra_data = data[0];
|
| + int stride = strides[0];
|
| for (int y = 0; y < height; ++y) {
|
| for (int x = 0; x < width; ++x) {
|
| - data[y * stride + x * 4 + 0] = color[2];
|
| - data[y * stride + x * 4 + 1] = color[1];
|
| - data[y * stride + x * 4 + 2] = color[0];
|
| - data[y * stride + x * 4 + 3] = color[3];
|
| + bgra_data[y * stride + x * 4 + 0] = color[2];
|
| + bgra_data[y * stride + x * 4 + 1] = color[1];
|
| + bgra_data[y * stride + x * 4 + 2] = color[0];
|
| + bgra_data[y * stride + x * 4 + 3] = color[3];
|
| + }
|
| + }
|
| + }
|
| + return;
|
| + case BufferFormat::YUV_420_BIPLANAR: {
|
| + // These values are used in the transformation from YUV to RGB color
|
| + // values. They are taken from the following webpage:
|
| + // http://www.fourcc.org/fccyvrgb.php
|
| + uint8_t yuv[] = {
|
| + (0.257 * color[0]) + (0.504 * color[1]) + (0.098 * color[2]) + 16,
|
| + -(0.148 * color[0]) - (0.291 * color[1]) + (0.439 * color[2]) + 128,
|
| + (0.439 * color[0]) - (0.368 * color[1]) - (0.071 * color[2]) + 128};
|
| + uint8_t* y_data = data[0];
|
| + uint8_t* uv_data = data[1];
|
| + int y_stride = strides[0];
|
| + int uv_stride = strides[1];
|
| + for (int y = 0; y < height; ++y) {
|
| + for (int x = 0; x < width; ++x) {
|
| + y_data[y_stride * y + x] = yuv[0];
|
| + }
|
| + }
|
| + DCHECK(height % 2 == 0);
|
| + DCHECK(width % 2 == 0);
|
| + for (int y = 0; y < height / 2; ++y) {
|
| + for (int x = 0; x < width / 2; ++x) {
|
| + uv_data[uv_stride * y + x * 2] = yuv[1];
|
| + uv_data[uv_stride * y + x * 2 + 1] = yuv[2];
|
| }
|
| }
|
| + }
|
| return;
|
| case BufferFormat::ATC:
|
| case BufferFormat::ATCIA:
|
| @@ -91,7 +130,6 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
|
| case BufferFormat::R_8:
|
| case BufferFormat::RGBA_4444:
|
| case BufferFormat::UYVY_422:
|
| - case BufferFormat::YUV_420_BIPLANAR:
|
| case BufferFormat::YUV_420:
|
| NOTREACHED();
|
| return;
|
| @@ -99,4 +137,16 @@ void GLImageTestSupport::SetBufferDataToColor(int width,
|
| NOTREACHED();
|
| }
|
|
|
| +// static
|
| +void GLImageTestSupport::SetBufferDataToColor(int width,
|
| + int height,
|
| + int stride,
|
| + BufferFormat format,
|
| + const uint8_t color[4],
|
| + uint8_t* data) {
|
| + uint8_t* planes_data[] = {data};
|
| + int strides[] = {stride};
|
| + SetBufferDataToColor(width, height, strides, format, color, planes_data);
|
| +}
|
| +
|
| } // namespace gfx
|
|
|