Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "cc/layers/append_quads_data.h" | 6 #include "cc/layers/append_quads_data.h" |
| 7 #include "cc/output/gl_renderer.h" | 7 #include "cc/output/gl_renderer.h" |
| 8 #include "cc/quads/draw_quad.h" | 8 #include "cc/quads/draw_quad.h" |
| 9 #include "cc/quads/picture_draw_quad.h" | 9 #include "cc/quads/picture_draw_quad.h" |
| 10 #include "cc/quads/texture_draw_quad.h" | 10 #include "cc/quads/texture_draw_quad.h" |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 EXPECT_TRUE(this->RunPixelTest( | 398 EXPECT_TRUE(this->RunPixelTest( |
| 399 &pass_list, | 399 &pass_list, |
| 400 PixelTest::NoOffscreenContext, | 400 PixelTest::NoOffscreenContext, |
| 401 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 401 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 402 FuzzyPixelOffByOneComparator(true))); | 402 FuzzyPixelOffByOneComparator(true))); |
| 403 } | 403 } |
| 404 | 404 |
| 405 class VideoGLRendererPixelTest : public GLRendererPixelTest { | 405 class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| 406 protected: | 406 protected: |
| 407 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( | 407 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( |
| 408 SharedQuadState* shared_state, bool with_alpha, bool is_transparent) { | 408 SharedQuadState* shared_state, |
| 409 bool with_alpha, | |
| 410 bool is_transparent, | |
| 411 bool has_jpeg_color_range) { | |
| 409 gfx::Rect rect(this->device_viewport_size_); | 412 gfx::Rect rect(this->device_viewport_size_); |
| 410 gfx::Rect opaque_rect(0, 0, 0, 0); | 413 gfx::Rect opaque_rect(0, 0, 0, 0); |
| 411 | 414 |
| 412 ResourceProvider::ResourceId y_resource = | 415 ResourceProvider::ResourceId y_resource = |
| 413 resource_provider_->CreateResource( | 416 resource_provider_->CreateResource( |
| 414 this->device_viewport_size_, | 417 this->device_viewport_size_, |
| 415 GL_CLAMP_TO_EDGE, | 418 GL_CLAMP_TO_EDGE, |
| 416 ResourceProvider::TextureUsageAny, | 419 ResourceProvider::TextureUsageAny, |
| 417 LUMINANCE_8); | 420 LUMINANCE_8); |
| 418 ResourceProvider::ResourceId u_resource = | 421 ResourceProvider::ResourceId u_resource = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 459 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, | 462 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, |
| 460 gfx::Vector2d()); | 463 gfx::Vector2d()); |
| 461 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, | 464 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, |
| 462 gfx::Vector2d()); | 465 gfx::Vector2d()); |
| 463 if (with_alpha) { | 466 if (with_alpha) { |
| 464 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, | 467 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, |
| 465 gfx::Vector2d()); | 468 gfx::Vector2d()); |
| 466 } | 469 } |
| 467 | 470 |
| 468 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); | 471 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); |
| 469 yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(), | 472 yuv_quad->SetNew(shared_state, |
| 470 y_resource, u_resource, v_resource, a_resource); | 473 rect, |
| 474 opaque_rect, | |
| 475 gfx::Size(), | |
| 476 y_resource, | |
| 477 u_resource, | |
| 478 v_resource, | |
| 479 a_resource, | |
| 480 has_jpeg_color_range); | |
| 471 return yuv_quad.Pass(); | 481 return yuv_quad.Pass(); |
| 472 } | 482 } |
| 473 }; | 483 }; |
| 474 | 484 |
| 475 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { | 485 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
| 476 gfx::Rect rect(this->device_viewport_size_); | 486 gfx::Rect rect(this->device_viewport_size_); |
| 477 | 487 |
| 478 RenderPass::Id id(1, 1); | 488 RenderPass::Id id(1, 1); |
| 479 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 489 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 480 | 490 |
| 481 scoped_ptr<SharedQuadState> shared_state = | 491 scoped_ptr<SharedQuadState> shared_state = |
| 482 CreateTestSharedQuadState(gfx::Transform(), rect); | 492 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 483 | 493 |
| 484 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 494 scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| 485 CreateTestYUVVideoDrawQuad(shared_state.get(), false, false); | 495 CreateTestYUVVideoDrawQuad(shared_state.get(), false, false, false); |
| 486 | 496 |
| 487 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 497 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 488 | 498 |
| 499 RenderPassList pass_list; | |
| 500 pass_list.push_back(pass.Pass()); | |
| 501 | |
| 502 EXPECT_TRUE(this->RunPixelTest( | |
| 503 &pass_list, | |
| 504 PixelTest::NoOffscreenContext, | |
| 505 base::FilePath(FILE_PATH_LITERAL("green.png")), | |
| 506 ExactPixelComparator(true))); | |
| 507 } | |
| 508 | |
| 509 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) { | |
| 510 gfx::Rect rect(this->device_viewport_size_); | |
| 511 | |
| 512 RenderPass::Id id(1, 1); | |
| 513 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
| 514 | |
| 515 scoped_ptr<SharedQuadState> shared_state = | |
| 516 CreateTestSharedQuadState(gfx::Transform(), rect); | |
| 517 | |
| 518 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | |
| 519 CreateTestYUVVideoDrawQuad(shared_state.get(), false, false, true); | |
| 520 | |
| 521 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
| 522 | |
| 489 RenderPassList pass_list; | 523 RenderPassList pass_list; |
| 490 pass_list.push_back(pass.Pass()); | 524 pass_list.push_back(pass.Pass()); |
| 491 | 525 |
| 492 EXPECT_TRUE(this->RunPixelTest( | 526 EXPECT_TRUE(this->RunPixelTest( |
| 493 &pass_list, | 527 &pass_list, |
| 494 PixelTest::NoOffscreenContext, | 528 PixelTest::NoOffscreenContext, |
| 495 base::FilePath(FILE_PATH_LITERAL("green.png")), | 529 base::FilePath(FILE_PATH_LITERAL("green.png")), |
|
rileya (GONE FROM CHROMIUM)
2013/12/03 23:33:41
Conveniently the test YUV values evaluate to the s
danakj
2013/12/03 23:39:04
Oh.. that's unfortunate as it means the test would
| |
| 496 ExactPixelComparator(true))); | 530 ExactPixelComparator(true))); |
| 497 } | 531 } |
| 498 | 532 |
| 499 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { | 533 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
| 500 gfx::Rect rect(this->device_viewport_size_); | 534 gfx::Rect rect(this->device_viewport_size_); |
| 501 | 535 |
| 502 RenderPass::Id id(1, 1); | 536 RenderPass::Id id(1, 1); |
| 503 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 537 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 504 | 538 |
| 505 scoped_ptr<SharedQuadState> shared_state = | 539 scoped_ptr<SharedQuadState> shared_state = |
| 506 CreateTestSharedQuadState(gfx::Transform(), rect); | 540 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 507 | 541 |
| 508 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 542 scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| 509 CreateTestYUVVideoDrawQuad(shared_state.get(), true, false); | 543 CreateTestYUVVideoDrawQuad(shared_state.get(), true, false, false); |
| 510 | 544 |
| 511 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 545 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 512 | 546 |
| 513 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 547 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 514 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); | 548 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); |
| 515 | 549 |
| 516 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 550 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 517 | 551 |
| 518 RenderPassList pass_list; | 552 RenderPassList pass_list; |
| 519 pass_list.push_back(pass.Pass()); | 553 pass_list.push_back(pass.Pass()); |
| 520 | 554 |
| 521 EXPECT_TRUE(this->RunPixelTest( | 555 EXPECT_TRUE(this->RunPixelTest( |
| 522 &pass_list, | 556 &pass_list, |
| 523 PixelTest::NoOffscreenContext, | 557 PixelTest::NoOffscreenContext, |
| 524 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 558 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 525 ExactPixelComparator(true))); | 559 ExactPixelComparator(true))); |
| 526 } | 560 } |
| 527 | 561 |
| 528 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { | 562 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { |
| 529 gfx::Rect rect(this->device_viewport_size_); | 563 gfx::Rect rect(this->device_viewport_size_); |
| 530 | 564 |
| 531 RenderPass::Id id(1, 1); | 565 RenderPass::Id id(1, 1); |
| 532 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 566 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 533 | 567 |
| 534 scoped_ptr<SharedQuadState> shared_state = | 568 scoped_ptr<SharedQuadState> shared_state = |
| 535 CreateTestSharedQuadState(gfx::Transform(), rect); | 569 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 536 | 570 |
| 537 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 571 scoped_ptr<YUVVideoDrawQuad> yuv_quad = |
| 538 CreateTestYUVVideoDrawQuad(shared_state.get(), true, true); | 572 CreateTestYUVVideoDrawQuad(shared_state.get(), true, true, false); |
| 539 | 573 |
| 540 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 574 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 541 | 575 |
| 542 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 576 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 543 color_quad->SetNew(shared_state.get(), rect, SK_ColorBLACK, false); | 577 color_quad->SetNew(shared_state.get(), rect, SK_ColorBLACK, false); |
| 544 | 578 |
| 545 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 579 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 546 | 580 |
| 547 RenderPassList pass_list; | 581 RenderPassList pass_list; |
| 548 pass_list.push_back(pass.Pass()); | 582 pass_list.push_back(pass.Pass()); |
| (...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2075 &pass_list, | 2109 &pass_list, |
| 2076 PixelTest::NoOffscreenContext, | 2110 PixelTest::NoOffscreenContext, |
| 2077 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), | 2111 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), |
| 2078 FuzzyPixelOffByOneComparator(true))); | 2112 FuzzyPixelOffByOneComparator(true))); |
| 2079 } | 2113 } |
| 2080 | 2114 |
| 2081 #endif // !defined(OS_ANDROID) | 2115 #endif // !defined(OS_ANDROID) |
| 2082 | 2116 |
| 2083 } // namespace | 2117 } // namespace |
| 2084 } // namespace cc | 2118 } // namespace cc |
| OLD | NEW |