OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/gl/test/gl_image_test_support.h" | 5 #include "ui/gl/test/gl_image_test_support.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ui/gl/gl_implementation.h" | 9 #include "ui/gl/gl_implementation.h" |
10 #include "ui/gl/test/gl_surface_test_support.h" | 10 #include "ui/gl/test/gl_surface_test_support.h" |
(...skipping 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 // static | 33 // static |
34 void GLImageTestSupport::CleanupGL() { | 34 void GLImageTestSupport::CleanupGL() { |
35 ClearGLBindings(); | 35 ClearGLBindings(); |
36 } | 36 } |
37 | 37 |
38 // static | 38 // static |
39 void GLImageTestSupport::SetBufferDataToColor(int width, | 39 void GLImageTestSupport::SetBufferDataToColor(int width, |
40 int height, | 40 int height, |
41 int stride, | 41 int stride, |
42 int plane, | |
42 BufferFormat format, | 43 BufferFormat format, |
43 const uint8_t color[4], | 44 const uint8_t color[4], |
44 uint8_t* data) { | 45 uint8_t* data) { |
45 switch (format) { | 46 switch (format) { |
46 case BufferFormat::RGBX_8888: | 47 case BufferFormat::RGBX_8888: |
48 DCHECK_EQ(0, plane); | |
47 for (int y = 0; y < height; ++y) { | 49 for (int y = 0; y < height; ++y) { |
48 for (int x = 0; x < width; ++x) { | 50 for (int x = 0; x < width; ++x) { |
49 data[y * stride + x * 4 + 0] = color[0]; | 51 data[y * stride + x * 4 + 0] = color[0]; |
50 data[y * stride + x * 4 + 1] = color[1]; | 52 data[y * stride + x * 4 + 1] = color[1]; |
51 data[y * stride + x * 4 + 2] = color[2]; | 53 data[y * stride + x * 4 + 2] = color[2]; |
52 data[y * stride + x * 4 + 3] = 0xaa; // unused | 54 data[y * stride + x * 4 + 3] = 0xaa; // unused |
53 } | 55 } |
54 } | 56 } |
55 return; | 57 return; |
56 case BufferFormat::RGBA_8888: | 58 case BufferFormat::RGBA_8888: |
59 DCHECK_EQ(0, plane); | |
57 for (int y = 0; y < height; ++y) { | 60 for (int y = 0; y < height; ++y) { |
58 for (int x = 0; x < width; ++x) { | 61 for (int x = 0; x < width; ++x) { |
59 data[y * stride + x * 4 + 0] = color[0]; | 62 data[y * stride + x * 4 + 0] = color[0]; |
60 data[y * stride + x * 4 + 1] = color[1]; | 63 data[y * stride + x * 4 + 1] = color[1]; |
61 data[y * stride + x * 4 + 2] = color[2]; | 64 data[y * stride + x * 4 + 2] = color[2]; |
62 data[y * stride + x * 4 + 3] = color[3]; | 65 data[y * stride + x * 4 + 3] = color[3]; |
63 } | 66 } |
64 } | 67 } |
65 return; | 68 return; |
66 case BufferFormat::BGRX_8888: | 69 case BufferFormat::BGRX_8888: |
70 DCHECK_EQ(0, plane); | |
67 for (int y = 0; y < height; ++y) { | 71 for (int y = 0; y < height; ++y) { |
68 for (int x = 0; x < width; ++x) { | 72 for (int x = 0; x < width; ++x) { |
69 data[y * stride + x * 4 + 0] = color[2]; | 73 data[y * stride + x * 4 + 0] = color[2]; |
70 data[y * stride + x * 4 + 1] = color[1]; | 74 data[y * stride + x * 4 + 1] = color[1]; |
71 data[y * stride + x * 4 + 2] = color[0]; | 75 data[y * stride + x * 4 + 2] = color[0]; |
72 data[y * stride + x * 4 + 3] = 0xaa; // unused | 76 data[y * stride + x * 4 + 3] = 0xaa; // unused |
73 } | 77 } |
74 } | 78 } |
75 return; | 79 return; |
76 case BufferFormat::BGRA_8888: | 80 case BufferFormat::BGRA_8888: |
81 DCHECK_EQ(0, plane); | |
77 for (int y = 0; y < height; ++y) { | 82 for (int y = 0; y < height; ++y) { |
78 for (int x = 0; x < width; ++x) { | 83 for (int x = 0; x < width; ++x) { |
79 data[y * stride + x * 4 + 0] = color[2]; | 84 data[y * stride + x * 4 + 0] = color[2]; |
80 data[y * stride + x * 4 + 1] = color[1]; | 85 data[y * stride + x * 4 + 1] = color[1]; |
81 data[y * stride + x * 4 + 2] = color[0]; | 86 data[y * stride + x * 4 + 2] = color[0]; |
82 data[y * stride + x * 4 + 3] = color[3]; | 87 data[y * stride + x * 4 + 3] = color[3]; |
83 } | 88 } |
84 } | 89 } |
85 return; | 90 return; |
91 case BufferFormat::YUV_420_BIPLANAR: { | |
92 DCHECK_LT(plane, 2); | |
93 DCHECK(height % 2 == 0); | |
reveman
2015/11/01 14:19:05
nit: DCHECK_EQ
Daniele Castagna
2015/11/01 21:55:31
Done.
| |
94 DCHECK(width % 2 == 0); | |
reveman
2015/11/01 14:19:05
nit: DCHECK_EQ
Daniele Castagna
2015/11/01 21:55:31
Done.
| |
95 // These values are used in the transformation from YUV to RGB color | |
96 // values. They are taken from the following webpage: | |
97 // http://www.fourcc.org/fccyvrgb.php | |
98 uint8_t yuv[] = { | |
99 (0.257 * color[0]) + (0.504 * color[1]) + (0.098 * color[2]) + 16, | |
100 -(0.148 * color[0]) - (0.291 * color[1]) + (0.439 * color[2]) + 128, | |
101 (0.439 * color[0]) - (0.368 * color[1]) - (0.071 * color[2]) + 128}; | |
102 if (plane == 0) { | |
103 for (int y = 0; y < height; ++y) { | |
104 for (int x = 0; x < width; ++x) { | |
105 data[stride * y + x] = yuv[0]; | |
106 } | |
107 } | |
108 } else { | |
109 for (int y = 0; y < height / 2; ++y) { | |
110 for (int x = 0; x < width / 2; ++x) { | |
111 data[stride * y + x * 2] = yuv[1]; | |
112 data[stride * y + x * 2 + 1] = yuv[2]; | |
113 } | |
114 } | |
115 } | |
116 } | |
117 return; | |
reveman
2015/11/01 14:19:05
nit: move 'return' into the above scope
Daniele Castagna
2015/11/01 21:55:31
Done.
| |
86 case BufferFormat::ATC: | 118 case BufferFormat::ATC: |
87 case BufferFormat::ATCIA: | 119 case BufferFormat::ATCIA: |
88 case BufferFormat::DXT1: | 120 case BufferFormat::DXT1: |
89 case BufferFormat::DXT5: | 121 case BufferFormat::DXT5: |
90 case BufferFormat::ETC1: | 122 case BufferFormat::ETC1: |
91 case BufferFormat::R_8: | 123 case BufferFormat::R_8: |
92 case BufferFormat::RGBA_4444: | 124 case BufferFormat::RGBA_4444: |
93 case BufferFormat::UYVY_422: | 125 case BufferFormat::UYVY_422: |
94 case BufferFormat::YUV_420_BIPLANAR: | |
95 case BufferFormat::YUV_420: | 126 case BufferFormat::YUV_420: |
96 NOTREACHED(); | 127 NOTREACHED(); |
97 return; | 128 return; |
98 } | 129 } |
99 NOTREACHED(); | 130 NOTREACHED(); |
100 } | 131 } |
101 | 132 |
102 } // namespace gfx | 133 } // namespace gfx |
OLD | NEW |