Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: ui/surface/accelerated_surface_transformer_win_unittest.cc

Issue 11280318: YUV conversion on the GPU. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: "Yet more line endings." Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ui/surface/accelerated_surface_transformer_win.hlsl ('k') | ui/surface/d3d9_utils_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <d3d9.h> 5 #include <d3d9.h>
6 #include <random> 6 #include <random>
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/file_util.h"
9 #include "base/hash.h" 10 #include "base/hash.h"
10 #include "base/scoped_native_library.h" 11 #include "base/scoped_native_library.h"
11 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
13 #include "base/time.h"
12 #include "base/win/scoped_comptr.h" 14 #include "base/win/scoped_comptr.h"
13 #include "base/win/windows_version.h" 15 #include "base/win/windows_version.h"
16 #include "media/base/simd/convert_rgb_to_yuv.h"
17 #include "media/base/yuv_convert.h"
18 #include "skia/ext/image_operations.h"
14 #include "testing/gtest/include/gtest/gtest-param-test.h" 19 #include "testing/gtest/include/gtest/gtest-param-test.h"
15 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/skia/include/core/SkBitmap.h"
22 #include "third_party/skia/include/core/SkColor.h"
23 #include "ui/gfx/codec/png_codec.h"
16 #include "ui/gfx/rect.h" 24 #include "ui/gfx/rect.h"
17 #include "ui/surface/accelerated_surface_transformer_win.h" 25 #include "ui/surface/accelerated_surface_transformer_win.h"
18 #include "ui/surface/accelerated_surface_win.h" 26 #include "ui/surface/accelerated_surface_win.h"
19 #include "ui/surface/d3d9_utils_win.h" 27 #include "ui/surface/d3d9_utils_win.h"
20 28
21 namespace d3d_utils = ui_surface_d3d9_utils; 29 namespace d3d_utils = ui_surface_d3d9_utils;
22 30
23 using base::win::ScopedComPtr; 31 using base::win::ScopedComPtr;
24 using std::uniform_int_distribution; 32 using std::uniform_int_distribution;
25 33
26 // Provides a reference rasterizer (all rendering done by software emulation) 34 namespace {
27 // Direct3D device, for use by unit tests. 35
36 // Debug flag, useful when hacking on tests.
37 const bool kDumpImagesOnFailure = false;
38
39 SkBitmap ToSkBitmap(IDirect3DSurface9* surface, bool is_single_channel) {
40 D3DLOCKED_RECT locked_rect;
41 EXPECT_HRESULT_SUCCEEDED(
42 surface->LockRect(&locked_rect, NULL, D3DLOCK_READONLY));
43
44 SkBitmap result;
45 gfx::Size size = d3d_utils::GetSize(surface);
46 if (is_single_channel)
47 size = gfx::Size(size.width() * 4, size.height());
48 result.setConfig(SkBitmap::kARGB_8888_Config, size.width(), size.height());
49 result.setIsOpaque(true);
50 result.allocPixels();
51 result.lockPixels();
52 for (int y = 0; y < size.height(); ++y) {
53 uint8* row8 = reinterpret_cast<uint8*>(locked_rect.pBits) +
54 (y * locked_rect.Pitch);
55 if (is_single_channel) {
56 for (int x = 0; x < size.width(); ++x) {
57 *result.getAddr32(x, y) = SkColorSetRGB(row8[x], row8[x], row8[x]);
58 }
59 } else {
60 uint32* row32 = reinterpret_cast<uint32*>(row8);
61 for (int x = 0; x < size.width(); ++x) {
62 *result.getAddr32(x, y) = row32[x] | 0xFF000000;
63 }
64 }
65 }
66 result.unlockPixels();
67 result.setImmutable();
68 surface->UnlockRect();
69 return result;
70 }
71
72 bool WritePNGFile(const SkBitmap& bitmap, const FilePath& file_path) {
73 std::vector<unsigned char> png_data;
74 const bool discard_transparency = true;
75 if (gfx::PNGCodec::EncodeBGRASkBitmap(bitmap,
76 discard_transparency,
77 &png_data) &&
78 file_util::CreateDirectory(file_path.DirName())) {
79 char* data = reinterpret_cast<char*>(&png_data[0]);
80 int size = static_cast<int>(png_data.size());
81 return file_util::WriteFile(file_path, data, size) == size;
82 }
83 return false;
84 }
85
86 } // namespace
87
88 // Test fixture for AcceleratedSurfaceTransformer.
28 // 89 //
29 // This class is parameterized so that it runs only on Vista+. See 90 // This class is parameterized so that it runs only on Vista+. See
30 // WindowsVersionIfVistaOrBetter() for details on this works. 91 // WindowsVersionIfVistaOrBetter() for details on this works.
31 class AcceleratedSurfaceTransformerTest : public testing::TestWithParam<int> { 92 class AcceleratedSurfaceTransformerTest : public testing::TestWithParam<int> {
32 public: 93 public:
33 AcceleratedSurfaceTransformerTest() {}; 94 AcceleratedSurfaceTransformerTest() : color_error_tolerance_(0) {};
34 95
35 IDirect3DDevice9Ex* device() { return device_.get(); } 96 IDirect3DDevice9Ex* device() { return device_.get(); }
36 97
37 virtual void SetUp() { 98 virtual void SetUp() {
38 if (!d3d_module_.is_valid()) { 99 if (!d3d_module_.is_valid()) {
39 if (!d3d_utils::LoadD3D9(&d3d_module_)) { 100 if (!d3d_utils::LoadD3D9(&d3d_module_)) {
40 GTEST_FAIL() << "Could not load d3d9.dll"; 101 GTEST_FAIL() << "Could not load d3d9.dll";
41 return; 102 return;
42 } 103 }
43 } 104 }
(...skipping 28 matching lines...) Expand all
72 } 133 }
73 134
74 // Driver workaround: on an Intel GPU (Mobile Intel 965 Express), it seems 135 // Driver workaround: on an Intel GPU (Mobile Intel 965 Express), it seems
75 // necessary to flush between drawing and locking, for the synchronization 136 // necessary to flush between drawing and locking, for the synchronization
76 // to behave properly. 137 // to behave properly.
77 void BeforeLockWorkaround() { 138 void BeforeLockWorkaround() {
78 EXPECT_HRESULT_SUCCEEDED( 139 EXPECT_HRESULT_SUCCEEDED(
79 device()->Present(0, 0, 0, 0)); 140 device()->Present(0, 0, 0, 0));
80 } 141 }
81 142
143 void WarnOnMissingFeatures(AcceleratedSurfaceTransformer* gpu_ops) {
144 // Prints a single warning line if some tests are feature-dependent
145 // and the feature is not supported by the current GPU.
146 if (!gpu_ops->device_supports_multiple_render_targets()) {
147 LOG(WARNING) << "MRT not supported, some tests will be skipped. "
148 << GetAdapterInfo();
149 }
150 }
151
82 // Locks and fills a surface with a checkerboard pattern where the colors 152 // Locks and fills a surface with a checkerboard pattern where the colors
83 // are random but the total image pattern is horizontally and vertically 153 // are random but the total image pattern is horizontally and vertically
84 // symmetric. 154 // symmetric.
85 void FillSymmetricRandomCheckerboard( 155 void FillSymmetricRandomCheckerboard(
86 IDirect3DSurface9* lockable_surface, 156 IDirect3DSurface9* lockable_surface,
87 const gfx::Size& size, 157 const gfx::Size& size,
88 int checker_square_size) { 158 int checker_square_size) {
89 159
90 D3DLOCKED_RECT locked_rect; 160 D3DLOCKED_RECT locked_rect;
91 ASSERT_HRESULT_SUCCEEDED( 161 ASSERT_HRESULT_SUCCEEDED(
92 lockable_surface->LockRect(&locked_rect, NULL, D3DLOCK_DISCARD)); 162 lockable_surface->LockRect(&locked_rect, NULL, D3DLOCK_DISCARD));
93 DWORD* surface = reinterpret_cast<DWORD*>(locked_rect.pBits); 163 DWORD* surface = reinterpret_cast<DWORD*>(locked_rect.pBits);
94 ASSERT_EQ(0, locked_rect.Pitch % sizeof(DWORD)); 164 ASSERT_EQ(0, locked_rect.Pitch % sizeof(DWORD));
95 int pitch = locked_rect.Pitch / sizeof(DWORD); 165 int pitch = locked_rect.Pitch / sizeof(DWORD);
96 166
97 for (int y = 0; y <= size.height() / 2; y += checker_square_size) { 167 for (int y = 0; y < (size.height() + 1) / 2; y += checker_square_size) {
98 for (int x = 0; x <= size.width() / 2; x += checker_square_size) { 168 for (int x = 0; x < (size.width() + 1) / 2; x += checker_square_size) {
99 DWORD color = RandomColor(); 169 DWORD color = RandomColor();
100 int y_limit = std::min(size.height() / 2, y + checker_square_size - 1); 170 int y_limit = std::min(size.height() / 2, y + checker_square_size - 1);
101 int x_limit = std::min(size.width() / 2, x + checker_square_size - 1); 171 int x_limit = std::min(size.width() / 2, x + checker_square_size - 1);
102 for (int y_lo = y; y_lo <= y_limit; y_lo++) { 172 for (int y_lo = y; y_lo <= y_limit; y_lo++) {
103 for (int x_lo = x; x_lo <= x_limit; x_lo++) { 173 for (int x_lo = x; x_lo <= x_limit; x_lo++) {
104 int y_hi = size.height() - 1 - y_lo; 174 int y_hi = size.height() - 1 - y_lo;
105 int x_hi = size.width() - 1 - x_lo; 175 int x_hi = size.width() - 1 - x_lo;
106 surface[x_lo + y_lo*pitch] = color; 176 surface[x_lo + y_lo*pitch] = color;
107 surface[x_lo + y_hi*pitch] = color; 177 surface[x_lo + y_hi*pitch] = color;
108 surface[x_hi + y_lo*pitch] = color; 178 surface[x_hi + y_lo*pitch] = color;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool AssertSameColor(DWORD color_a, DWORD color_b) { 217 bool AssertSameColor(DWORD color_a, DWORD color_b) {
148 if (color_a == color_b) 218 if (color_a == color_b)
149 return true; 219 return true;
150 uint8* a = reinterpret_cast<uint8*>(&color_a); 220 uint8* a = reinterpret_cast<uint8*>(&color_a);
151 uint8* b = reinterpret_cast<uint8*>(&color_b); 221 uint8* b = reinterpret_cast<uint8*>(&color_b);
152 int max_error = 0; 222 int max_error = 0;
153 for (int i = 0; i < 4; i++) 223 for (int i = 0; i < 4; i++)
154 max_error = std::max(max_error, 224 max_error = std::max(max_error,
155 std::abs(static_cast<int>(a[i]) - b[i])); 225 std::abs(static_cast<int>(a[i]) - b[i]));
156 226
157 if (max_error <= kAbsoluteColorErrorTolerance) 227 if (max_error <= color_error_tolerance())
158 return true; 228 return true;
159 229
160 std::string expected_color = 230 std::string expected_color =
161 StringPrintf("%3d, %3d, %3d, %3d", a[0], a[1], a[2], a[3]); 231 StringPrintf("%3d, %3d, %3d, %3d", a[0], a[1], a[2], a[3]);
162 std::string actual_color = 232 std::string actual_color =
163 StringPrintf("%3d, %3d, %3d, %3d", b[0], b[1], b[2], b[3]); 233 StringPrintf("%3d, %3d, %3d, %3d", b[0], b[1], b[2], b[3]);
164 EXPECT_EQ(expected_color, actual_color) 234 EXPECT_EQ(expected_color, actual_color)
165 << "Componentwise color difference was " 235 << "Componentwise color difference was "
166 << max_error << "; max allowed is " << kAbsoluteColorErrorTolerance; 236 << max_error << "; max allowed is " << color_error_tolerance();
167 237
168 return false; 238 return false;
169 } 239 }
170 240
241 bool AssertSameColor(uint8 color_a, uint8 color_b) {
242 if (color_a == color_b)
243 return true;
244 int max_error = std::abs((int) color_a - (int) color_b);
245 if (max_error <= color_error_tolerance())
246 return true;
247 ADD_FAILURE() << "Colors not equal: " << StringPrintf("0x%x", color_a)
248 << " vs. " << StringPrintf("0x%x", color_b);
249 return false;
250 }
251
171 // Asserts that an image is symmetric with respect to itself: both 252 // Asserts that an image is symmetric with respect to itself: both
172 // horizontally and vertically, within the tolerance of AssertSameColor. 253 // horizontally and vertically, within the tolerance of AssertSameColor.
173 void AssertSymmetry(IDirect3DSurface9* lockable_surface, 254 void AssertSymmetry(IDirect3DSurface9* lockable_surface,
174 const gfx::Size& size) { 255 const gfx::Size& size) {
175 BeforeLockWorkaround(); 256 BeforeLockWorkaround();
176 257
177 D3DLOCKED_RECT locked_rect; 258 D3DLOCKED_RECT locked_rect;
178 ASSERT_HRESULT_SUCCEEDED( 259 ASSERT_HRESULT_SUCCEEDED(
179 lockable_surface->LockRect(&locked_rect, NULL, D3DLOCK_READONLY)); 260 lockable_surface->LockRect(&locked_rect, NULL, D3DLOCK_READONLY));
180 ASSERT_EQ(0, locked_rect.Pitch % sizeof(DWORD)); 261 ASSERT_EQ(0, locked_rect.Pitch % sizeof(DWORD));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 actual->UnlockRect(); 313 actual->UnlockRect();
233 GTEST_FAIL() << "Pixels (" << x << ", " << y << ") vs. " 314 GTEST_FAIL() << "Pixels (" << x << ", " << y << ") vs. "
234 << "(" << x << ", " << y_actual << ")"; 315 << "(" << x << ", " << y_actual << ")";
235 } 316 }
236 } 317 }
237 expected->UnlockRect(); 318 expected->UnlockRect();
238 actual->UnlockRect(); 319 actual->UnlockRect();
239 } 320 }
240 321
241 protected: 322 protected:
242 static const int kAbsoluteColorErrorTolerance = 5;
243
244 DWORD RandomColor() { 323 DWORD RandomColor() {
245 return random_dword_(rng_); 324 return random_dword_(rng_);
246 } 325 }
247 326
327 void set_color_error_tolerance(int value) {
328 color_error_tolerance_ = value;
329 }
330
331 int color_error_tolerance() {
332 return color_error_tolerance_;
333 }
334
248 void DoResizeBilinearTest(AcceleratedSurfaceTransformer* gpu_ops, 335 void DoResizeBilinearTest(AcceleratedSurfaceTransformer* gpu_ops,
249 const gfx::Size& src_size, 336 const gfx::Size& src_size,
250 const gfx::Size& dst_size, 337 const gfx::Size& dst_size,
251 int checkerboard_size) { 338 int checkerboard_size) {
252 339
253 SCOPED_TRACE( 340 SCOPED_TRACE(
254 StringPrintf("Resizing %dx%d -> %dx%d at checkerboard size of %d", 341 StringPrintf("Resizing %dx%d -> %dx%d at checkerboard size of %d",
255 src_size.width(), src_size.height(), 342 src_size.width(), src_size.height(),
256 dst_size.width(), dst_size.height(), 343 dst_size.width(), dst_size.height(),
257 checkerboard_size)); 344 checkerboard_size));
258 345
346 set_color_error_tolerance(4);
347
259 base::win::ScopedComPtr<IDirect3DSurface9> src, dst; 348 base::win::ScopedComPtr<IDirect3DSurface9> src, dst;
260 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface( 349 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(
261 device(), src_size, src.Receive())) 350 device(), src_size, src.Receive()))
262 << "Could not create src render target"; 351 << "Could not create src render target";
263 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface( 352 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(
264 device(), dst_size, dst.Receive())) 353 device(), dst_size, dst.Receive()))
265 << "Could not create dst render target"; 354 << "Could not create dst render target";
266 355
267 FillSymmetricRandomCheckerboard(src, src_size, checkerboard_size); 356 FillSymmetricRandomCheckerboard(src, src_size, checkerboard_size);
268 357
269 ASSERT_TRUE(gpu_ops->ResizeBilinear(src, gfx::Rect(src_size), dst)); 358 ASSERT_TRUE(gpu_ops->ResizeBilinear(src, gfx::Rect(src_size), dst));
270 359
271 AssertSymmetry(dst, dst_size); 360 AssertSymmetry(dst, dst_size);
272 } 361 }
273 362
363 void CreateRandomCheckerboardTexture(
364 const gfx::Size& size,
365 int checkerboard_size,
366 IDirect3DSurface9** reference_surface,
367 IDirect3DTexture9** result) {
368 base::win::ScopedComPtr<IDirect3DSurface9> dst;
369 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(device(), size,
370 reference_surface));
371 ASSERT_TRUE(d3d_utils::CreateTemporaryRenderTargetTexture(device(), size,
372 result, dst.Receive()));
373 FillRandomCheckerboard(*reference_surface, size, checkerboard_size);
374 ASSERT_HRESULT_SUCCEEDED(
375 device()->StretchRect(
376 *reference_surface, NULL, dst, NULL, D3DTEXF_NONE));
377 }
378
379 void AssertSame(int width_in_bytes, int height, uint8* reference,
380 IDirect3DSurface9* lockable) {
381 BeforeLockWorkaround();
382
383 D3DLOCKED_RECT locked_rect;
384 ASSERT_HRESULT_SUCCEEDED(
385 lockable->LockRect(&locked_rect, NULL, D3DLOCK_READONLY));
386 uint8* actual = reinterpret_cast<uint8*>(locked_rect.pBits);
387 for (int y = 0; y < height; ++y) {
388 for (int x = 0; x < width_in_bytes; ++x) {
389 if (!AssertSameColor(reference[y * width_in_bytes + x],
390 actual[y * locked_rect.Pitch + x])) {
391 lockable->UnlockRect();
392 GTEST_FAIL() << "At pixel (" << x << ", " << y << ")";
393 }
394 }
395 }
396 lockable->UnlockRect();
397 }
398
274 void DoCopyInvertedTest(AcceleratedSurfaceTransformer* gpu_ops, 399 void DoCopyInvertedTest(AcceleratedSurfaceTransformer* gpu_ops,
275 const gfx::Size& size) { 400 const gfx::Size& size) {
276 401
277 SCOPED_TRACE( 402 SCOPED_TRACE(
278 StringPrintf("CopyInverted @ %dx%d", size.width(), size.height())); 403 StringPrintf("CopyInverted @ %dx%d", size.width(), size.height()));
279 404
280 base::win::ScopedComPtr<IDirect3DSurface9> checkerboard, src, dst; 405 set_color_error_tolerance(0);
281 base::win::ScopedComPtr<IDirect3DTexture9> src_texture; 406
282 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(device(), size, 407 base::win::ScopedComPtr<IDirect3DSurface9> dst, reference_pattern;
283 checkerboard.Receive())) << "Could not create src render target";; 408 base::win::ScopedComPtr<IDirect3DTexture9> src;
284 ASSERT_TRUE(d3d_utils::CreateTemporaryRenderTargetTexture(device(), size, 409
285 src_texture.Receive(), src.Receive())) 410 CreateRandomCheckerboardTexture(size, 1, reference_pattern.Receive(),
286 << "Could not create src texture."; 411 src.Receive());
287 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(device(), size, 412
413 // Alloc a slightly larger image 75% of the time, to test that the
414 // viewport is set properly.
415 const int kAlign = 4;
416 gfx::Size alloc_size((size.width() + kAlign - 1) / kAlign * kAlign,
417 (size.height() + kAlign - 1) / kAlign * kAlign);
418
419 ASSERT_TRUE(d3d_utils::CreateTemporaryLockableSurface(device(), alloc_size,
288 dst.Receive())) << "Could not create dst render target."; 420 dst.Receive())) << "Could not create dst render target.";
289 421
290 FillRandomCheckerboard(checkerboard, size, 1); 422 ASSERT_TRUE(gpu_ops->CopyInverted(src, dst, size));
291 ASSERT_HRESULT_SUCCEEDED( 423 AssertIsInvertedCopy(size, reference_pattern, dst);
292 device()->StretchRect(checkerboard, NULL, src, NULL, D3DTEXF_NONE)); 424 }
293 ASSERT_TRUE(gpu_ops->CopyInverted(src_texture, dst, size)); 425
294 AssertIsInvertedCopy(size, checkerboard, dst); 426
295 } 427 void DoYUVConversionTest(AcceleratedSurfaceTransformer* gpu_ops,
296 428 const gfx::Size& src_size,
429 int checkerboard_size) {
430 // Test the non-MRT implementation, and the MRT implementation as well
431 // (if supported by the device).
432 ASSERT_NO_FATAL_FAILURE(
433 DoYUVConversionTest(gpu_ops, src_size, src_size,
434 checkerboard_size, false));
435 if (gpu_ops->device_supports_multiple_render_targets()) {
436 ASSERT_NO_FATAL_FAILURE(
437 DoYUVConversionTest(gpu_ops, src_size, src_size,
438 checkerboard_size, true));
439 }
440 }
441
442 void DoYUVConversionScaleTest(AcceleratedSurfaceTransformer* gpu_ops,
443 const gfx::Size& src_size,
444 const gfx::Size& dst_size) {
445 // Test the non-MRT implementation, and the MRT implementation as well
446 // (if supported by the device).
447 if (gpu_ops->device_supports_multiple_render_targets()) {
448 ASSERT_NO_FATAL_FAILURE(
449 DoYUVConversionTest(gpu_ops, src_size, dst_size, 4, true));
450 }
451 ASSERT_NO_FATAL_FAILURE(
452 DoYUVConversionTest(gpu_ops, src_size, dst_size, 4, false));
453 }
454
455 void DoYUVConversionTest(AcceleratedSurfaceTransformer* gpu_ops,
456 const gfx::Size& src_size,
457 const gfx::Size& dst_size,
458 int checkerboard_size,
459 boolean use_multi_render_targets) {
460 SCOPED_TRACE(
461 StringPrintf("YUV Converting %dx%d at checkerboard size of %d; MRT %s",
462 src_size.width(), src_size.height(),
463 checkerboard_size,
464 use_multi_render_targets ? "enabled" : "disabled"));
465
466
467 base::win::ScopedComPtr<IDirect3DTexture9> src;
468 base::win::ScopedComPtr<IDirect3DSurface9> reference;
469 base::win::ScopedComPtr<IDirect3DSurface9> dst_y, dst_u, dst_v;
470
471 // TODO(ncarter): Use a better error metric that measures aggregate error
472 // rather than simply max error. There seems to be slightly more error at
473 // higher resolutions, maybe due to precision issues during rasterization
474 // (or maybe more pixels = more test trials). Results are usually to an
475 // error of 1, but we must use a tolerance of 3.
476 set_color_error_tolerance(3);
477 CreateRandomCheckerboardTexture(
478 src_size, checkerboard_size, reference.Receive(), src.Receive());
479
480 gfx::Size packed_y_size, packed_uv_size;
481
482 ASSERT_TRUE(gpu_ops->AllocYUVBuffers(dst_size,
483 &packed_y_size,
484 &packed_uv_size,
485 dst_y.Receive(),
486 dst_u.Receive(),
487 dst_v.Receive()));
488
489 // Actually do the conversion.
490 if (use_multi_render_targets) {
491 ASSERT_TRUE(gpu_ops->TransformRGBToYV12_MRT(src,
492 dst_size,
493 packed_y_size,
494 packed_uv_size,
495 dst_y,
496 dst_u,
497 dst_v));
498 } else {
499 ASSERT_TRUE(gpu_ops->TransformRGBToYV12_WithoutMRT(src,
500 dst_size,
501 packed_y_size,
502 packed_uv_size,
503 dst_y,
504 dst_u,
505 dst_v));
506 }
507
508 // UV size (in bytes/samples) is half, rounded up.
509 gfx::Size uv_size((dst_size.width() + 1) / 2,
510 (dst_size.height() + 1) / 2);
511
512 // Generate a reference bitmap by calling a software implementation.
513 SkBitmap reference_rgb = ToSkBitmap(reference, false);
514 SkBitmap reference_rgb_scaled;
515 if (dst_size == src_size) {
516 reference_rgb_scaled = reference_rgb;
517 } else {
518 // We'll call Copy to do the bilinear scaling if needed.
519 base::win::ScopedComPtr<IDirect3DSurface9> reference_scaled;
520 ASSERT_TRUE(
521 d3d_utils::CreateTemporaryLockableSurface(
522 device(), dst_size, reference_scaled.Receive()));
523 ASSERT_TRUE(
524 gpu_ops->Copy(src, reference_scaled, dst_size));
525 BeforeLockWorkaround();
526 reference_rgb_scaled = ToSkBitmap(reference_scaled, false);
527 }
528
529 scoped_ptr<uint8[]> reference_y(new uint8[dst_size.GetArea()]);
530 scoped_ptr<uint8[]> reference_u(new uint8[uv_size.GetArea()]);
531 scoped_ptr<uint8[]> reference_v(new uint8[uv_size.GetArea()]);
532 reference_rgb_scaled.lockPixels();
533 media::ConvertRGB32ToYUV_SSE2_Reference(
534 reinterpret_cast<uint8*>(reference_rgb_scaled.getAddr32(0, 0)),
535 &reference_y[0],
536 &reference_u[0],
537 &reference_v[0],
538 dst_size.width(),
539 dst_size.height(),
540 reference_rgb_scaled.rowBytes(),
541 dst_size.width(),
542 uv_size.width());
543 reference_rgb_scaled.unlockPixels();
544
545 // Check for equality of the reference and the actual.
546 AssertSame(dst_size.width(), dst_size.height(), &reference_y[0], dst_y);
547 AssertSame(uv_size.width(), uv_size.height(), &reference_u[0], dst_u);
548 AssertSame(uv_size.width(), uv_size.height(), &reference_v[0], dst_v);
549
550 if (kDumpImagesOnFailure && HasFatalFailure()) {
551 // Note that this will dump the full u and v buffers, including
552 // extra columns added due to packing. That means up to 7 extra
553 // columns for uv, and up to 3 extra columns for y.
554 WritePNGFile(reference_rgb,
555 FilePath(FILE_PATH_LITERAL("test_fail_src.png")));
556 WritePNGFile(reference_rgb_scaled,
557 FilePath(FILE_PATH_LITERAL("test_fail_src_scaled.png")));
558 WritePNGFile(ToSkBitmap(dst_y, true),
559 FilePath(FILE_PATH_LITERAL("test_fail_y.png")));
560 WritePNGFile(ToSkBitmap(dst_u, true),
561 FilePath(FILE_PATH_LITERAL("test_fail_u.png")));
562 WritePNGFile(ToSkBitmap(dst_v, true),
563 FilePath(FILE_PATH_LITERAL("test_fail_v.png")));
564 }
565 }
566
567 int color_error_tolerance_;
297 uniform_int_distribution<DWORD> random_dword_; 568 uniform_int_distribution<DWORD> random_dword_;
298 std::mt19937 rng_; 569 std::mt19937 rng_;
299 base::ScopedNativeLibrary d3d_module_; 570 base::ScopedNativeLibrary d3d_module_;
300 base::win::ScopedComPtr<IDirect3DDevice9Ex> device_; 571 base::win::ScopedComPtr<IDirect3DDevice9Ex> device_;
301 }; 572 };
302 573
303 // Fails on some bots because Direct3D isn't allowed. 574 // Fails on some bots because Direct3D isn't allowed.
304 TEST_P(AcceleratedSurfaceTransformerTest, Init) { 575 TEST_P(AcceleratedSurfaceTransformerTest, Init) {
305 SCOPED_TRACE(GetAdapterInfo()); 576 SCOPED_TRACE(GetAdapterInfo());
306 AcceleratedSurfaceTransformer gpu_ops; 577 AcceleratedSurfaceTransformer gpu_ops;
307 ASSERT_TRUE(gpu_ops.Init(device())); 578 ASSERT_TRUE(gpu_ops.Init(device()));
579
580 WarnOnMissingFeatures(&gpu_ops);
308 }; 581 };
309 582
310 // Fails on some bots because Direct3D isn't allowed. 583 // Fails on some bots because Direct3D isn't allowed.
311 TEST_P(AcceleratedSurfaceTransformerTest, TestConsistentRandom) { 584 TEST_P(AcceleratedSurfaceTransformerTest, TestConsistentRandom) {
312 // This behavior should be the same for every execution on every machine. 585 // This behavior should be the same for every execution on every machine.
313 // Otherwise tests might be flaky and impossible to debug. 586 // Otherwise tests might be flaky and impossible to debug.
314 SeedRandom("AcceleratedSurfaceTransformerTest.TestConsistentRandom"); 587 SeedRandom("AcceleratedSurfaceTransformerTest.TestConsistentRandom");
315 ASSERT_EQ(2922058934, RandomColor()); 588 ASSERT_EQ(2922058934, RandomColor());
316 589
317 SeedRandom("AcceleratedSurfaceTransformerTest.TestConsistentRandom"); 590 SeedRandom("AcceleratedSurfaceTransformerTest.TestConsistentRandom");
(...skipping 16 matching lines...) Expand all
334 607
335 uniform_int_distribution<int> size(1, 512); 608 uniform_int_distribution<int> size(1, 512);
336 609
337 for (int i = 0; i < 100; ++i) { 610 for (int i = 0; i < 100; ++i) {
338 ASSERT_NO_FATAL_FAILURE( 611 ASSERT_NO_FATAL_FAILURE(
339 DoCopyInvertedTest(&t, gfx::Size(size(rng_), size(rng_)))) 612 DoCopyInvertedTest(&t, gfx::Size(size(rng_), size(rng_))))
340 << "At iteration " << i; 613 << "At iteration " << i;
341 } 614 }
342 } 615 }
343 616
344
345 // Fails on some bots because Direct3D isn't allowed. 617 // Fails on some bots because Direct3D isn't allowed.
346 // Fails on other bots because of ResizeBilinear symmetry failures. 618 // Fails on other bots because of ResizeBilinear symmetry failures.
347 // Should pass, at least, on NVIDIA Quadro 600. 619 // Should pass, at least, on NVIDIA Quadro 600.
348 TEST_P(AcceleratedSurfaceTransformerTest, MixedOperations) { 620 TEST_P(AcceleratedSurfaceTransformerTest, MixedOperations) {
349 SCOPED_TRACE(GetAdapterInfo()); 621 SCOPED_TRACE(GetAdapterInfo());
350 SeedRandom("MixedOperations"); 622 SeedRandom("MixedOperations");
351 623
352 AcceleratedSurfaceTransformer t; 624 AcceleratedSurfaceTransformer t;
353 ASSERT_TRUE(t.Init(device())); 625 ASSERT_TRUE(t.Init(device()));
354 626
355 ASSERT_NO_FATAL_FAILURE( 627 ASSERT_NO_FATAL_FAILURE(
356 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 1)); 628 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 1));
357 ASSERT_NO_FATAL_FAILURE( 629 ASSERT_NO_FATAL_FAILURE(
358 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 2)); 630 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 2));
359 ASSERT_NO_FATAL_FAILURE( 631 ASSERT_NO_FATAL_FAILURE(
360 DoCopyInvertedTest(&t, gfx::Size(20, 107))); 632 DoCopyInvertedTest(&t, gfx::Size(20, 107)));
361 ASSERT_NO_FATAL_FAILURE( 633 ASSERT_NO_FATAL_FAILURE(
362 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 5)); 634 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(255, 255), 5));
363 ASSERT_NO_FATAL_FAILURE( 635 ASSERT_NO_FATAL_FAILURE(
364 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(64, 64), 5)); 636 DoResizeBilinearTest(&t, gfx::Size(256, 256), gfx::Size(64, 64), 5));
365 ASSERT_NO_FATAL_FAILURE( 637 ASSERT_NO_FATAL_FAILURE(
638 DoYUVConversionTest(&t, gfx::Size(128, 128), 1));
639 ASSERT_NO_FATAL_FAILURE(
366 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(3, 3), 1)); 640 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(3, 3), 1));
367 ASSERT_NO_FATAL_FAILURE( 641 ASSERT_NO_FATAL_FAILURE(
368 DoCopyInvertedTest(&t, gfx::Size(1412, 124))); 642 DoCopyInvertedTest(&t, gfx::Size(1412, 124)));
369 ASSERT_NO_FATAL_FAILURE( 643 ASSERT_NO_FATAL_FAILURE(
644 DoYUVConversionTest(&t, gfx::Size(100, 200), 1));
645 ASSERT_NO_FATAL_FAILURE(
370 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 1)); 646 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 1));
371 ASSERT_NO_FATAL_FAILURE( 647 ASSERT_NO_FATAL_FAILURE(
372 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 2)); 648 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 2));
373 649
374 ASSERT_NO_FATAL_FAILURE( 650 ASSERT_NO_FATAL_FAILURE(
375 DoCopyInvertedTest(&t, gfx::Size(1512, 7))); 651 DoCopyInvertedTest(&t, gfx::Size(1512, 7)));
376 ASSERT_NO_FATAL_FAILURE( 652 ASSERT_NO_FATAL_FAILURE(
377 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 5)); 653 DoResizeBilinearTest(&t, gfx::Size(255, 255), gfx::Size(257, 257), 5));
378 ASSERT_NO_FATAL_FAILURE( 654 ASSERT_NO_FATAL_FAILURE(
379 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 256), 8)); 655 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 256), 8));
380 ASSERT_NO_FATAL_FAILURE( 656 ASSERT_NO_FATAL_FAILURE(
381 DoCopyInvertedTest(&t, gfx::Size(1521, 3))); 657 DoCopyInvertedTest(&t, gfx::Size(1521, 3)));
382 ASSERT_NO_FATAL_FAILURE( 658 ASSERT_NO_FATAL_FAILURE(
659 DoYUVConversionTest(&t, gfx::Size(140, 181), 1));
660 ASSERT_NO_FATAL_FAILURE(
383 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 256), 1)); 661 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 256), 1));
384 ASSERT_NO_FATAL_FAILURE( 662 ASSERT_NO_FATAL_FAILURE(
385 DoCopyInvertedTest(&t, gfx::Size(33, 712))); 663 DoCopyInvertedTest(&t, gfx::Size(33, 712)));
386 ASSERT_NO_FATAL_FAILURE( 664 ASSERT_NO_FATAL_FAILURE(
387 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 8), 8)); 665 DoResizeBilinearTest(&t, gfx::Size(150, 256), gfx::Size(126, 8), 8));
388 ASSERT_NO_FATAL_FAILURE( 666 ASSERT_NO_FATAL_FAILURE(
389 DoCopyInvertedTest(&t, gfx::Size(33, 2))); 667 DoCopyInvertedTest(&t, gfx::Size(33, 2)));
390 ASSERT_NO_FATAL_FAILURE( 668 ASSERT_NO_FATAL_FAILURE(
391 DoResizeBilinearTest(&t, gfx::Size(200, 256), gfx::Size(126, 8), 8)); 669 DoResizeBilinearTest(&t, gfx::Size(200, 256), gfx::Size(126, 8), 8));
392 } 670 }
(...skipping 25 matching lines...) Expand all
418 ASSERT_NO_FATAL_FAILURE( 696 ASSERT_NO_FATAL_FAILURE(
419 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, h), gfx::Size(lo, lo), 1)); 697 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, h), gfx::Size(lo, lo), 1));
420 ASSERT_NO_FATAL_FAILURE( 698 ASSERT_NO_FATAL_FAILURE(
421 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, lo), gfx::Size(w, lo), lo)); 699 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, lo), gfx::Size(w, lo), lo));
422 ASSERT_NO_FATAL_FAILURE( 700 ASSERT_NO_FATAL_FAILURE(
423 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, lo), gfx::Size(lo, h), lo)); 701 DoResizeBilinearTest(&gpu_ops, gfx::Size(lo, lo), gfx::Size(lo, h), lo));
424 ASSERT_NO_FATAL_FAILURE( 702 ASSERT_NO_FATAL_FAILURE(
425 DoCopyInvertedTest(&gpu_ops, gfx::Size(w, lo))); 703 DoCopyInvertedTest(&gpu_ops, gfx::Size(w, lo)));
426 ASSERT_NO_FATAL_FAILURE( 704 ASSERT_NO_FATAL_FAILURE(
427 DoCopyInvertedTest(&gpu_ops, gfx::Size(lo, h))); 705 DoCopyInvertedTest(&gpu_ops, gfx::Size(lo, h)));
706
707 ASSERT_NO_FATAL_FAILURE(
708 DoYUVConversionTest(&gpu_ops, gfx::Size(w, lo), 1));
709 ASSERT_NO_FATAL_FAILURE(
710 DoYUVConversionTest(&gpu_ops, gfx::Size(lo, h), 1));
711
428 } 712 }
429 713
430 // Exercises ResizeBilinear with random minification cases where the 714 // Exercises ResizeBilinear with random minification cases where the
431 // aspect ratio does not change. 715 // aspect ratio does not change.
432 // 716 //
433 // Fails on some bots because Direct3D isn't allowed. 717 // Fails on some bots because Direct3D isn't allowed.
434 // Fails on other bots because of StretchRect symmetry failures. 718 // Fails on other bots because of StretchRect symmetry failures.
435 // Should pass, at least, on NVIDIA Quadro 600. 719 // Should pass, at least, on NVIDIA Quadro 600.
436 TEST_P(AcceleratedSurfaceTransformerTest, MinifyUniform) { 720 TEST_P(AcceleratedSurfaceTransformerTest, MinifyUniform) {
437 SCOPED_TRACE(GetAdapterInfo()); 721 SCOPED_TRACE(GetAdapterInfo());
438 SeedRandom("MinifyUniform"); 722 SeedRandom("MinifyUniform");
439 723
440 AcceleratedSurfaceTransformer gpu_ops; 724 AcceleratedSurfaceTransformer gpu_ops;
441 ASSERT_TRUE(gpu_ops.Init(device())); 725 ASSERT_TRUE(gpu_ops.Init(device()));
442 726
443 int dims[] = { 21, 63, 64, 65, 99, 127, 128, 129, 192, 255, 256, 257}; 727 const int dims[] = {21, 63, 64, 65, 99, 127, 128, 129, 192, 255, 256, 257};
444 int checkerboards[] = {1, 2, 3, 9}; 728 const int checkerboards[] = {1, 2, 3, 9};
445 uniform_int_distribution<int> dim(0, arraysize(dims) - 1); 729 uniform_int_distribution<int> dim(0, arraysize(dims) - 1);
446 uniform_int_distribution<int> checkerboard(0, arraysize(checkerboards) - 1); 730 uniform_int_distribution<int> checkerboard(0, arraysize(checkerboards) - 1);
447 731
448 for (int i = 0; i < 300; i++) { 732 for (int i = 0; i < 300; i++) {
449 // Widths are picked so that dst is smaller than src. 733 // Widths are picked so that dst is smaller than src.
450 int dst_width = dims[dim(rng_)]; 734 int dst_width = dims[dim(rng_)];
451 int src_width = dims[dim(rng_)]; 735 int src_width = dims[dim(rng_)];
452 if (src_width < dst_width) 736 if (src_width < dst_width)
453 std::swap(dst_width, src_width); 737 std::swap(dst_width, src_width);
454 738
(...skipping 19 matching lines...) Expand all
474 // image, but for the current implementation of ResizeBilinear, this does not 758 // image, but for the current implementation of ResizeBilinear, this does not
475 // seem to be true (fails on NVIDIA Quadro 600; passes on 759 // seem to be true (fails on NVIDIA Quadro 600; passes on
476 // Intel Mobile 965 Express) 760 // Intel Mobile 965 Express)
477 TEST_P(AcceleratedSurfaceTransformerTest, DISABLED_MagnifyUniform) { 761 TEST_P(AcceleratedSurfaceTransformerTest, DISABLED_MagnifyUniform) {
478 SCOPED_TRACE(GetAdapterInfo()); 762 SCOPED_TRACE(GetAdapterInfo());
479 SeedRandom("MagnifyUniform"); 763 SeedRandom("MagnifyUniform");
480 764
481 AcceleratedSurfaceTransformer gpu_ops; 765 AcceleratedSurfaceTransformer gpu_ops;
482 ASSERT_TRUE(gpu_ops.Init(device())); 766 ASSERT_TRUE(gpu_ops.Init(device()));
483 767
484 int dims[] = {63, 64, 65, 99, 127, 128, 129, 192, 255, 256, 257}; 768 const int dims[] = {63, 64, 65, 99, 127, 128, 129, 192, 255, 256, 257};
485 int checkerboards[] = {1, 2, 3, 9}; 769 const int checkerboards[] = {1, 2, 3, 9};
486 uniform_int_distribution<int> dim(0, arraysize(dims) - 1); 770 uniform_int_distribution<int> dim(0, arraysize(dims) - 1);
487 uniform_int_distribution<int> checkerboard(0, arraysize(checkerboards) - 1); 771 uniform_int_distribution<int> checkerboard(0, arraysize(checkerboards) - 1);
488 772
489 for (int i = 0; i < 50; i++) { 773 for (int i = 0; i < 50; i++) {
490 // Widths are picked so that src is smaller than dst. 774 // Widths are picked so that src is smaller than dst.
491 int dst_width = dims[dim(rng_)]; 775 int dst_width = dims[dim(rng_)];
492 int src_width = dims[dim(rng_)]; 776 int src_width = dims[dim(rng_)];
493 if (dst_width < src_width) 777 if (dst_width < src_width)
494 std::swap(src_width, dst_width); 778 std::swap(src_width, dst_width);
495 779
496 int dst_height = dims[dim(rng_)]; 780 int dst_height = dims[dim(rng_)];
497 int src_height = static_cast<int>( 781 int src_height = static_cast<int>(
498 static_cast<int64>(src_width) * dst_height / dst_width); 782 static_cast<int64>(src_width) * dst_height / dst_width);
499 783
500 int checkerboard_size = checkerboards[checkerboard(rng_)]; 784 int checkerboard_size = checkerboards[checkerboard(rng_)];
501 785
502 ASSERT_NO_FATAL_FAILURE( 786 ASSERT_NO_FATAL_FAILURE(
503 DoResizeBilinearTest(&gpu_ops, 787 DoResizeBilinearTest(&gpu_ops,
504 gfx::Size(src_width, src_height), // Src size (smaller) 788 gfx::Size(src_width, src_height), // Src size (smaller)
505 gfx::Size(dst_width, dst_height), // Dst size (larger) 789 gfx::Size(dst_width, dst_height), // Dst size (larger)
506 checkerboard_size)) << "Failed on iteration " << i; 790 checkerboard_size)) << "Failed on iteration " << i;
507 } 791 }
508 }; 792 };
509 793
794 TEST_P(AcceleratedSurfaceTransformerTest, RGBtoYUV) {
795 SeedRandom("RGBtoYUV");
796
797 AcceleratedSurfaceTransformer gpu_ops;
798 ASSERT_TRUE(gpu_ops.Init(device()));
799
800 // Start with some easy-to-debug cases. A checkerboard size of 1 is the
801 // best test, but larger checkerboard sizes give more insight into where
802 // a bug might be.
803 ASSERT_NO_FATAL_FAILURE(
804 DoYUVConversionTest(&gpu_ops, gfx::Size(32, 32), 4));
805 ASSERT_NO_FATAL_FAILURE(
806 DoYUVConversionTest(&gpu_ops, gfx::Size(32, 32), 2));
807 ASSERT_NO_FATAL_FAILURE(
808 DoYUVConversionTest(&gpu_ops, gfx::Size(32, 32), 3));
809
810 // All cases of width (mod 8) and height (mod 8), using 1x1 checkerboard.
811 for (int w = 32; w < 40; ++w) {
812 for (int h = 32; h < 40; ++h) {
813 ASSERT_NO_FATAL_FAILURE(
814 DoYUVConversionTest(&gpu_ops, gfx::Size(w, h), 1));
815 }
816 }
817
818 // All the very small sizes which require the most shifting in the
819 // texture coordinates when doing alignment.
820 for (int w = 1; w <= 9; ++w) {
821 for (int h = 1; h <= 9; ++h) {
822 ASSERT_NO_FATAL_FAILURE(
823 DoYUVConversionTest(&gpu_ops, gfx::Size(w, h), 1));
824 }
825 }
826
827 // Random medium dimensions.
828 ASSERT_NO_FATAL_FAILURE(
829 DoYUVConversionTest(&gpu_ops, gfx::Size(10, 142), 1));
830 ASSERT_NO_FATAL_FAILURE(
831 DoYUVConversionTest(&gpu_ops, gfx::Size(124, 333), 1));
832 ASSERT_NO_FATAL_FAILURE(
833 DoYUVConversionTest(&gpu_ops, gfx::Size(853, 225), 1));
834 ASSERT_NO_FATAL_FAILURE(
835 DoYUVConversionTest(&gpu_ops, gfx::Size(231, 412), 1));
836 ASSERT_NO_FATAL_FAILURE(
837 DoYUVConversionTest(&gpu_ops, gfx::Size(512, 128), 1));
838 ASSERT_NO_FATAL_FAILURE(
839 DoYUVConversionTest(&gpu_ops, gfx::Size(1024, 768), 1));
840
841 // Common video/monitor resolutions
842 ASSERT_NO_FATAL_FAILURE(
843 DoYUVConversionTest(&gpu_ops, gfx::Size(800, 768), 1));
844 ASSERT_NO_FATAL_FAILURE(
845 DoYUVConversionTest(&gpu_ops, gfx::Size(1024, 768), 1));
846 ASSERT_NO_FATAL_FAILURE(
847 DoYUVConversionTest(&gpu_ops, gfx::Size(1280, 720), 1));
848 ASSERT_NO_FATAL_FAILURE(
849 DoYUVConversionTest(&gpu_ops, gfx::Size(1280, 720), 2));
850 ASSERT_NO_FATAL_FAILURE(
851 DoYUVConversionTest(&gpu_ops, gfx::Size(1920, 1080), 1));
852 ASSERT_NO_FATAL_FAILURE(
853 DoYUVConversionTest(&gpu_ops, gfx::Size(1920, 1080), 2));
854 ASSERT_NO_FATAL_FAILURE(
855 DoYUVConversionTest(&gpu_ops, gfx::Size(2048, 1536), 1));
856 }
857
858 TEST_P(AcceleratedSurfaceTransformerTest, RGBtoYUVScaled) {
859 SeedRandom("RGBtoYUVScaled");
860
861 AcceleratedSurfaceTransformer gpu_ops;
862 ASSERT_TRUE(gpu_ops.Init(device()));
863
864 ASSERT_NO_FATAL_FAILURE(
865 DoYUVConversionScaleTest(&gpu_ops, gfx::Size(32, 32), gfx::Size(64, 64)));
866
867 ASSERT_NO_FATAL_FAILURE(
868 DoYUVConversionScaleTest(&gpu_ops, gfx::Size(32, 32), gfx::Size(16, 16)));
869 ASSERT_NO_FATAL_FAILURE(
870 DoYUVConversionScaleTest(&gpu_ops, gfx::Size(32, 32), gfx::Size(24, 24)));
871 ASSERT_NO_FATAL_FAILURE(
872 DoYUVConversionScaleTest(&gpu_ops, gfx::Size(32, 32), gfx::Size(48, 48)));
873 }
874
510 namespace { 875 namespace {
511 876
512 // Used to suppress test on Windows versions prior to Vista. 877 // Used to suppress test on Windows versions prior to Vista.
513 std::vector<int> WindowsVersionIfVistaOrBetter() { 878 std::vector<int> WindowsVersionIfVistaOrBetter() {
514 std::vector<int> result; 879 std::vector<int> result;
515 if (base::win::GetVersion() >= base::win::VERSION_VISTA) { 880 if (base::win::GetVersion() >= base::win::VERSION_VISTA) {
516 result.push_back(base::win::GetVersion()); 881 result.push_back(base::win::GetVersion());
517 } 882 }
518 return result; 883 return result;
519 } 884 }
520 885
521 } // namespace 886 } // namespace
522 887
523 INSTANTIATE_TEST_CASE_P(VistaAndUp, 888 INSTANTIATE_TEST_CASE_P(VistaAndUp,
524 AcceleratedSurfaceTransformerTest, 889 AcceleratedSurfaceTransformerTest,
525 ::testing::ValuesIn(WindowsVersionIfVistaOrBetter())); 890 ::testing::ValuesIn(WindowsVersionIfVistaOrBetter()));
OLDNEW
« no previous file with comments | « ui/surface/accelerated_surface_transformer_win.hlsl ('k') | ui/surface/d3d9_utils_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698