OLD | NEW |
1 // Copyright (c) 2013 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 "content/browser/renderer_host/compositing_iosurface_transformer_mac.h" | 5 #include "content/browser/renderer_host/compositing_iosurface_transformer_mac.h" |
6 | 6 |
7 #include <OpenGL/CGLCurrent.h> | 7 #include <OpenGL/CGLCurrent.h> |
8 #include <OpenGL/CGLRenderers.h> | 8 #include <OpenGL/CGLRenderers.h> |
9 #include <OpenGL/CGLTypes.h> | 9 #include <OpenGL/CGLTypes.h> |
10 #include <OpenGL/OpenGL.h> | 10 #include <OpenGL/OpenGL.h> |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 private: | 403 private: |
404 CGLContextObj context_; | 404 CGLContextObj context_; |
405 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache_; | 405 scoped_ptr<CompositingIOSurfaceShaderPrograms> shader_program_cache_; |
406 scoped_ptr<CompositingIOSurfaceTransformer> transformer_; | 406 scoped_ptr<CompositingIOSurfaceTransformer> transformer_; |
407 | 407 |
408 private: | 408 private: |
409 DISALLOW_COPY_AND_ASSIGN(CompositingIOSurfaceTransformerTest); | 409 DISALLOW_COPY_AND_ASSIGN(CompositingIOSurfaceTransformerTest); |
410 }; | 410 }; |
411 | 411 |
412 // TODO(miu): Enable ALL the tests after the initial change lands. These were | 412 TEST_F(CompositingIOSurfaceTransformerTest, ShaderProgramsCompileAndLink) { |
413 // started out DISABLED since unit tests executing on GPUs have been known to | |
414 // sometimes cause messy flakiness problems. | |
415 TEST_F(CompositingIOSurfaceTransformerTest, | |
416 DISABLED_ShaderProgramsCompileAndLink) { | |
417 // Attempt to use each program, binding its required uniform variables. | 413 // Attempt to use each program, binding its required uniform variables. |
418 EXPECT_NO_GL_ERROR(shader_program_cache()->UseBlitProgram()); | 414 EXPECT_NO_GL_ERROR(shader_program_cache()->UseBlitProgram()); |
419 EXPECT_NO_GL_ERROR(shader_program_cache()->UseSolidWhiteProgram()); | 415 EXPECT_NO_GL_ERROR(shader_program_cache()->UseSolidWhiteProgram()); |
420 EXPECT_NO_GL_ERROR(shader_program_cache()->UseRGBToYV12Program(1, 1.0f)); | 416 EXPECT_NO_GL_ERROR(shader_program_cache()->UseRGBToYV12Program(1, 1.0f)); |
421 EXPECT_NO_GL_ERROR(shader_program_cache()->UseRGBToYV12Program(2, 1.0f)); | 417 EXPECT_NO_GL_ERROR(shader_program_cache()->UseRGBToYV12Program(2, 1.0f)); |
422 | 418 |
423 EXPECT_NO_GL_ERROR(glUseProgram(0)); | 419 EXPECT_NO_GL_ERROR(glUseProgram(0)); |
424 } | 420 } |
425 | 421 |
426 namespace { | 422 namespace { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
460 // Odd-size, one or both dimensions downscaled by 1 pixel. | 456 // Odd-size, one or both dimensions downscaled by 1 pixel. |
461 { 33, 33, 32, 33 }, { 33, 33, 33, 32 }, { 33, 33, 32, 32 }, | 457 { 33, 33, 32, 33 }, { 33, 33, 33, 32 }, { 33, 33, 32, 32 }, |
462 // Odd-size, one or both dimensions downscaled by 2 pixels. | 458 // Odd-size, one or both dimensions downscaled by 2 pixels. |
463 { 33, 33, 31, 33 }, { 33, 33, 33, 31 }, { 33, 33, 31, 31 }, | 459 { 33, 33, 31, 33 }, { 33, 33, 33, 31 }, { 33, 33, 31, 31 }, |
464 // Odd-size, one or both dimensions downscaled by 3 pixels. | 460 // Odd-size, one or both dimensions downscaled by 3 pixels. |
465 { 33, 33, 30, 33 }, { 33, 33, 33, 30 }, { 33, 33, 30, 30 }, | 461 { 33, 33, 30, 33 }, { 33, 33, 33, 30 }, { 33, 33, 30, 30 }, |
466 }; | 462 }; |
467 | 463 |
468 } // namespace | 464 } // namespace |
469 | 465 |
470 TEST_F(CompositingIOSurfaceTransformerTest, DISABLED_ResizesTexturesCorrectly) { | 466 TEST_F(CompositingIOSurfaceTransformerTest, ResizesTexturesCorrectly) { |
471 for (size_t i = 0; i < arraysize(kTestParameters); ++i) { | 467 for (size_t i = 0; i < arraysize(kTestParameters); ++i) { |
472 SCOPED_TRACE(::testing::Message() << "kTestParameters[" << i << ']'); | 468 SCOPED_TRACE(::testing::Message() << "kTestParameters[" << i << ']'); |
473 | 469 |
474 const TestParameters& params = kTestParameters[i]; | 470 const TestParameters& params = kTestParameters[i]; |
475 const gfx::Size src_size(params.src_width, params.src_height); | 471 const gfx::Size src_size(params.src_width, params.src_height); |
476 const gfx::Size dst_size(params.scaled_width, params.scaled_height); | 472 const gfx::Size dst_size(params.scaled_width, params.scaled_height); |
477 const SkBitmap src_bitmap = GenerateTestPatternBitmap(src_size); | 473 const SkBitmap src_bitmap = GenerateTestPatternBitmap(src_size); |
478 | 474 |
479 // Full texture resize test. | 475 // Full texture resize test. |
480 RunResizeTest(src_bitmap, gfx::Rect(src_size), dst_size); | 476 RunResizeTest(src_bitmap, gfx::Rect(src_size), dst_size); |
481 // Subrect resize test: missing top row in source. | 477 // Subrect resize test: missing top row in source. |
482 RunResizeTest(src_bitmap, | 478 RunResizeTest(src_bitmap, |
483 gfx::Rect(0, 1, params.src_width, params.src_height - 1), | 479 gfx::Rect(0, 1, params.src_width, params.src_height - 1), |
484 dst_size); | 480 dst_size); |
485 // Subrect resize test: missing left column in source. | 481 // Subrect resize test: missing left column in source. |
486 RunResizeTest(src_bitmap, | 482 RunResizeTest(src_bitmap, |
487 gfx::Rect(1, 0, params.src_width - 1, params.src_height), | 483 gfx::Rect(1, 0, params.src_width - 1, params.src_height), |
488 dst_size); | 484 dst_size); |
489 // Subrect resize test: missing top+bottom rows, and left column in source. | 485 // Subrect resize test: missing top+bottom rows, and left column in source. |
490 RunResizeTest(src_bitmap, | 486 RunResizeTest(src_bitmap, |
491 gfx::Rect(1, 1, params.src_width - 1, params.src_height - 2), | 487 gfx::Rect(1, 1, params.src_width - 1, params.src_height - 2), |
492 dst_size); | 488 dst_size); |
493 // Subrect resize test: missing top row, and left+right columns in source. | 489 // Subrect resize test: missing top row, and left+right columns in source. |
494 RunResizeTest(src_bitmap, | 490 RunResizeTest(src_bitmap, |
495 gfx::Rect(1, 1, params.src_width - 2, params.src_height - 1), | 491 gfx::Rect(1, 1, params.src_width - 2, params.src_height - 1), |
496 dst_size); | 492 dst_size); |
497 } | 493 } |
498 } | 494 } |
499 | 495 |
500 TEST_F(CompositingIOSurfaceTransformerTest, DISABLED_TransformsRGBToYV12) { | 496 TEST_F(CompositingIOSurfaceTransformerTest, TransformsRGBToYV12) { |
501 for (size_t i = 0; i < arraysize(kTestParameters); ++i) { | 497 for (size_t i = 0; i < arraysize(kTestParameters); ++i) { |
502 SCOPED_TRACE(::testing::Message() << "kTestParameters[" << i << ']'); | 498 SCOPED_TRACE(::testing::Message() << "kTestParameters[" << i << ']'); |
503 | 499 |
504 const TestParameters& params = kTestParameters[i]; | 500 const TestParameters& params = kTestParameters[i]; |
505 const gfx::Size src_size(params.src_width, params.src_height); | 501 const gfx::Size src_size(params.src_width, params.src_height); |
506 const gfx::Size dst_size(params.scaled_width, params.scaled_height); | 502 const gfx::Size dst_size(params.scaled_width, params.scaled_height); |
507 const SkBitmap src_bitmap = GenerateTestPatternBitmap(src_size); | 503 const SkBitmap src_bitmap = GenerateTestPatternBitmap(src_size); |
508 | 504 |
509 // Full texture resize test. | 505 // Full texture resize test. |
510 RunTransformRGBToYV12Test(src_bitmap, gfx::Rect(src_size), dst_size); | 506 RunTransformRGBToYV12Test(src_bitmap, gfx::Rect(src_size), dst_size); |
(...skipping 13 matching lines...) Expand all Loading... |
524 dst_size); | 520 dst_size); |
525 // Subrect resize test: missing top row, and left+right columns in source. | 521 // Subrect resize test: missing top row, and left+right columns in source. |
526 RunTransformRGBToYV12Test( | 522 RunTransformRGBToYV12Test( |
527 src_bitmap, | 523 src_bitmap, |
528 gfx::Rect(1, 1, params.src_width - 2, params.src_height - 1), | 524 gfx::Rect(1, 1, params.src_width - 2, params.src_height - 1), |
529 dst_size); | 525 dst_size); |
530 } | 526 } |
531 } | 527 } |
532 | 528 |
533 } // namespace content | 529 } // namespace content |
OLD | NEW |