OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <GLES2/gl2.h> | 5 #include <GLES2/gl2.h> |
6 #include <GLES2/gl2chromium.h> | 6 #include <GLES2/gl2chromium.h> |
7 #include <GLES2/gl2ext.h> | 7 #include <GLES2/gl2ext.h> |
8 #include <GLES2/gl2extchromium.h> | 8 #include <GLES2/gl2extchromium.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <memory> | 11 #include <memory> |
12 | 12 |
13 #include "base/bind.h" | 13 #include "base/bind.h" |
14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
15 #include "base/process/process_handle.h" | 15 #include "base/process/process_handle.h" |
16 #include "gpu/command_buffer/client/gles2_implementation.h" | 16 #include "gpu/command_buffer/client/gles2_implementation.h" |
17 #include "gpu/command_buffer/service/command_buffer_service.h" | 17 #include "gpu/command_buffer/service/command_buffer_service.h" |
18 #include "gpu/command_buffer/service/image_manager.h" | 18 #include "gpu/command_buffer/service/image_manager.h" |
19 #include "gpu/command_buffer/tests/gl_manager.h" | 19 #include "gpu/command_buffer/tests/gl_manager.h" |
20 #include "gpu/command_buffer/tests/gl_test_utils.h" | 20 #include "gpu/command_buffer/tests/gl_test_utils.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
23 #include "ui/gfx/gpu_memory_buffer.h" | 23 #include "ui/gfx/gpu_memory_buffer.h" |
| 24 #include "ui/gfx/half_float.h" |
24 #include "ui/gl/gl_image.h" | 25 #include "ui/gl/gl_image.h" |
25 | 26 |
26 using testing::_; | 27 using testing::_; |
27 using testing::IgnoreResult; | 28 using testing::IgnoreResult; |
28 using testing::InvokeWithoutArgs; | 29 using testing::InvokeWithoutArgs; |
29 using testing::Invoke; | 30 using testing::Invoke; |
30 using testing::Return; | 31 using testing::Return; |
31 using testing::SetArgPointee; | 32 using testing::SetArgPointee; |
32 using testing::StrictMock; | 33 using testing::StrictMock; |
33 | 34 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 } | 110 } |
110 return; | 111 return; |
111 case gfx::BufferFormat::BGRA_8888: | 112 case gfx::BufferFormat::BGRA_8888: |
112 for (int i = 0; i < width * 4; i += 4) { | 113 for (int i = 0; i < width * 4; i += 4) { |
113 buffer[i + 0] = pixel[2]; | 114 buffer[i + 0] = pixel[2]; |
114 buffer[i + 1] = pixel[1]; | 115 buffer[i + 1] = pixel[1]; |
115 buffer[i + 2] = pixel[0]; | 116 buffer[i + 2] = pixel[0]; |
116 buffer[i + 3] = pixel[3]; | 117 buffer[i + 3] = pixel[3]; |
117 } | 118 } |
118 return; | 119 return; |
| 120 case gfx::BufferFormat::RGBA_F16: { |
| 121 float float_pixel[4] = { |
| 122 pixel[0] / 255.f, pixel[1] / 255.f, pixel[2] / 255.f, |
| 123 pixel[3] / 255.f, |
| 124 }; |
| 125 uint16_t half_float_pixel[4]; |
| 126 gfx::FloatToHalfFloat(float_pixel, half_float_pixel, 4); |
| 127 uint16_t* half_float_buffer = reinterpret_cast<uint16_t*>(buffer); |
| 128 for (int i = 0; i < width * 4; i += 4) { |
| 129 half_float_buffer[i + 0] = half_float_pixel[0]; |
| 130 half_float_buffer[i + 1] = half_float_pixel[1]; |
| 131 half_float_buffer[i + 2] = half_float_pixel[2]; |
| 132 half_float_buffer[i + 3] = half_float_pixel[3]; |
| 133 } |
| 134 return; |
| 135 } |
119 case gfx::BufferFormat::ATC: | 136 case gfx::BufferFormat::ATC: |
120 case gfx::BufferFormat::ATCIA: | 137 case gfx::BufferFormat::ATCIA: |
121 case gfx::BufferFormat::BGRX_8888: | 138 case gfx::BufferFormat::BGRX_8888: |
122 case gfx::BufferFormat::DXT1: | 139 case gfx::BufferFormat::DXT1: |
123 case gfx::BufferFormat::DXT5: | 140 case gfx::BufferFormat::DXT5: |
124 case gfx::BufferFormat::ETC1: | 141 case gfx::BufferFormat::ETC1: |
125 case gfx::BufferFormat::RG_88: | 142 case gfx::BufferFormat::RG_88: |
126 case gfx::BufferFormat::RGBX_8888: | 143 case gfx::BufferFormat::RGBX_8888: |
127 case gfx::BufferFormat::UYVY_422: | 144 case gfx::BufferFormat::UYVY_422: |
128 case gfx::BufferFormat::YVU_420: | 145 case gfx::BufferFormat::YVU_420: |
(...skipping 11 matching lines...) Expand all Loading... |
140 return GL_RED; | 157 return GL_RED; |
141 case gfx::BufferFormat::RG_88: | 158 case gfx::BufferFormat::RG_88: |
142 return GL_RG; | 159 return GL_RG; |
143 case gfx::BufferFormat::BGR_565: | 160 case gfx::BufferFormat::BGR_565: |
144 return GL_RGB; | 161 return GL_RGB; |
145 case gfx::BufferFormat::RGBA_4444: | 162 case gfx::BufferFormat::RGBA_4444: |
146 case gfx::BufferFormat::RGBA_8888: | 163 case gfx::BufferFormat::RGBA_8888: |
147 return GL_RGBA; | 164 return GL_RGBA; |
148 case gfx::BufferFormat::BGRA_8888: | 165 case gfx::BufferFormat::BGRA_8888: |
149 return GL_BGRA_EXT; | 166 return GL_BGRA_EXT; |
| 167 case gfx::BufferFormat::RGBA_F16: |
| 168 return GL_RGBA; |
150 case gfx::BufferFormat::ATC: | 169 case gfx::BufferFormat::ATC: |
151 case gfx::BufferFormat::ATCIA: | 170 case gfx::BufferFormat::ATCIA: |
152 case gfx::BufferFormat::BGRX_8888: | 171 case gfx::BufferFormat::BGRX_8888: |
153 case gfx::BufferFormat::DXT1: | 172 case gfx::BufferFormat::DXT1: |
154 case gfx::BufferFormat::DXT5: | 173 case gfx::BufferFormat::DXT5: |
155 case gfx::BufferFormat::ETC1: | 174 case gfx::BufferFormat::ETC1: |
156 case gfx::BufferFormat::RGBX_8888: | 175 case gfx::BufferFormat::RGBX_8888: |
157 case gfx::BufferFormat::UYVY_422: | 176 case gfx::BufferFormat::UYVY_422: |
158 case gfx::BufferFormat::YVU_420: | 177 case gfx::BufferFormat::YVU_420: |
159 case gfx::BufferFormat::YUV_420_BIPLANAR: | 178 case gfx::BufferFormat::YUV_420_BIPLANAR: |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 glDestroyImageCHROMIUM(image_id); | 267 glDestroyImageCHROMIUM(image_id); |
249 glDeleteTextures(1, &texture_id); | 268 glDeleteTextures(1, &texture_id); |
250 } | 269 } |
251 | 270 |
252 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, | 271 INSTANTIATE_TEST_CASE_P(GpuMemoryBufferTests, |
253 GpuMemoryBufferTest, | 272 GpuMemoryBufferTest, |
254 ::testing::Values(gfx::BufferFormat::R_8, | 273 ::testing::Values(gfx::BufferFormat::R_8, |
255 gfx::BufferFormat::BGR_565, | 274 gfx::BufferFormat::BGR_565, |
256 gfx::BufferFormat::RGBA_4444, | 275 gfx::BufferFormat::RGBA_4444, |
257 gfx::BufferFormat::RGBA_8888, | 276 gfx::BufferFormat::RGBA_8888, |
258 gfx::BufferFormat::BGRA_8888)); | 277 gfx::BufferFormat::BGRA_8888, |
| 278 gfx::BufferFormat::RGBA_F16)); |
259 | 279 |
260 } // namespace gles2 | 280 } // namespace gles2 |
261 } // namespace gpu | 281 } // namespace gpu |
OLD | NEW |