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, |
| 412 uint8 y, |
| 413 uint8 u, |
| 414 uint8 v) { |
409 gfx::Rect rect(this->device_viewport_size_); | 415 gfx::Rect rect(this->device_viewport_size_); |
410 gfx::Rect opaque_rect(0, 0, 0, 0); | 416 gfx::Rect opaque_rect(0, 0, 0, 0); |
411 | 417 |
412 ResourceProvider::ResourceId y_resource = | 418 ResourceProvider::ResourceId y_resource = |
413 resource_provider_->CreateResource( | 419 resource_provider_->CreateResource( |
414 this->device_viewport_size_, | 420 this->device_viewport_size_, |
415 GL_CLAMP_TO_EDGE, | 421 GL_CLAMP_TO_EDGE, |
416 ResourceProvider::TextureUsageAny, | 422 ResourceProvider::TextureUsageAny, |
417 LUMINANCE_8); | 423 LUMINANCE_8); |
418 ResourceProvider::ResourceId u_resource = | 424 ResourceProvider::ResourceId u_resource = |
(...skipping 21 matching lines...) Expand all Loading... |
440 int h = this->device_viewport_size_.height(); | 446 int h = this->device_viewport_size_.height(); |
441 const int y_plane_size = w * h; | 447 const int y_plane_size = w * h; |
442 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); | 448 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); |
443 const int uv_plane_size = uv_rect.size().GetArea(); | 449 const int uv_plane_size = uv_rect.size().GetArea(); |
444 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); | 450 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); |
445 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); | 451 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); |
446 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); | 452 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); |
447 scoped_ptr<uint8_t[]> a_plane; | 453 scoped_ptr<uint8_t[]> a_plane; |
448 if (with_alpha) | 454 if (with_alpha) |
449 a_plane.reset(new uint8_t[y_plane_size]); | 455 a_plane.reset(new uint8_t[y_plane_size]); |
450 // YUV values representing Green. | 456 // YUV values from params. |
451 memset(y_plane.get(), 149, y_plane_size); | 457 memset(y_plane.get(), y, y_plane_size); |
452 memset(u_plane.get(), 43, uv_plane_size); | 458 memset(u_plane.get(), u, uv_plane_size); |
453 memset(v_plane.get(), 21, uv_plane_size); | 459 memset(v_plane.get(), v, uv_plane_size); |
454 if (with_alpha) | 460 if (with_alpha) |
455 memset(a_plane.get(), is_transparent ? 0 : 128, y_plane_size); | 461 memset(a_plane.get(), is_transparent ? 0 : 128, y_plane_size); |
456 | 462 |
457 resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect, | 463 resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect, |
458 gfx::Vector2d()); | 464 gfx::Vector2d()); |
459 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, | 465 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, |
460 gfx::Vector2d()); | 466 gfx::Vector2d()); |
461 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, | 467 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, |
462 gfx::Vector2d()); | 468 gfx::Vector2d()); |
463 if (with_alpha) { | 469 if (with_alpha) { |
464 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, | 470 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, |
465 gfx::Vector2d()); | 471 gfx::Vector2d()); |
466 } | 472 } |
467 | 473 |
468 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); | 474 scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); |
469 yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(), | 475 yuv_quad->SetNew(shared_state, |
470 y_resource, u_resource, v_resource, a_resource); | 476 rect, |
| 477 opaque_rect, |
| 478 gfx::Size(), |
| 479 y_resource, |
| 480 u_resource, |
| 481 v_resource, |
| 482 a_resource, |
| 483 has_jpeg_color_range); |
471 return yuv_quad.Pass(); | 484 return yuv_quad.Pass(); |
472 } | 485 } |
473 }; | 486 }; |
474 | 487 |
475 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { | 488 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
476 gfx::Rect rect(this->device_viewport_size_); | 489 gfx::Rect rect(this->device_viewport_size_); |
477 | 490 |
478 RenderPass::Id id(1, 1); | 491 RenderPass::Id id(1, 1); |
479 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 492 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
480 | 493 |
481 scoped_ptr<SharedQuadState> shared_state = | 494 scoped_ptr<SharedQuadState> shared_state = |
482 CreateTestSharedQuadState(gfx::Transform(), rect); | 495 CreateTestSharedQuadState(gfx::Transform(), rect); |
483 | 496 |
484 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 497 // YUV of (149,43,21) should be green (0,255,0) in RGB. |
485 CreateTestYUVVideoDrawQuad(shared_state.get(), false, false); | 498 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 499 shared_state.get(), false, false, false, 149, 43, 21); |
486 | 500 |
487 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 501 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
488 | 502 |
489 RenderPassList pass_list; | 503 RenderPassList pass_list; |
490 pass_list.push_back(pass.Pass()); | 504 pass_list.push_back(pass.Pass()); |
491 | 505 |
492 EXPECT_TRUE(this->RunPixelTest( | 506 EXPECT_TRUE(this->RunPixelTest( |
493 &pass_list, | 507 &pass_list, |
494 PixelTest::NoOffscreenContext, | 508 PixelTest::NoOffscreenContext, |
495 base::FilePath(FILE_PATH_LITERAL("green.png")), | 509 base::FilePath(FILE_PATH_LITERAL("green.png")), |
496 ExactPixelComparator(true))); | 510 ExactPixelComparator(true))); |
497 } | 511 } |
498 | 512 |
| 513 TEST_F(VideoGLRendererPixelTest, SimpleYUVRectBlack) { |
| 514 gfx::Rect rect(this->device_viewport_size_); |
| 515 |
| 516 RenderPass::Id id(1, 1); |
| 517 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 518 |
| 519 scoped_ptr<SharedQuadState> shared_state = |
| 520 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 521 |
| 522 // In MPEG color range YUV values of (15,128,128) should produce black. |
| 523 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 524 shared_state.get(), false, false, false, 15, 128, 128); |
| 525 |
| 526 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 527 |
| 528 RenderPassList pass_list; |
| 529 pass_list.push_back(pass.Pass()); |
| 530 |
| 531 // If we didn't get black out of the YUV values above, then we probably have a |
| 532 // color range issue. |
| 533 EXPECT_TRUE(this->RunPixelTest( |
| 534 &pass_list, |
| 535 PixelTest::NoOffscreenContext, |
| 536 base::FilePath(FILE_PATH_LITERAL("black.png")), |
| 537 ExactPixelComparator(true))); |
| 538 } |
| 539 |
| 540 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRect) { |
| 541 gfx::Rect rect(this->device_viewport_size_); |
| 542 |
| 543 RenderPass::Id id(1, 1); |
| 544 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 545 |
| 546 scoped_ptr<SharedQuadState> shared_state = |
| 547 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 548 |
| 549 // YUV of (149,43,21) should be green (0,255,0) in RGB. |
| 550 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 551 shared_state.get(), false, false, true, 149, 43, 21); |
| 552 |
| 553 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 554 |
| 555 RenderPassList pass_list; |
| 556 pass_list.push_back(pass.Pass()); |
| 557 |
| 558 EXPECT_TRUE(this->RunPixelTest( |
| 559 &pass_list, |
| 560 PixelTest::NoOffscreenContext, |
| 561 base::FilePath(FILE_PATH_LITERAL("green.png")), |
| 562 ExactPixelComparator(true))); |
| 563 } |
| 564 |
| 565 TEST_F(VideoGLRendererPixelTest, SimpleYUVJRectGrey) { |
| 566 gfx::Rect rect(this->device_viewport_size_); |
| 567 |
| 568 RenderPass::Id id(1, 1); |
| 569 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 570 |
| 571 scoped_ptr<SharedQuadState> shared_state = |
| 572 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 573 |
| 574 // Dark grey in JPEG color range (in MPEG, this is black). |
| 575 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 576 shared_state.get(), false, false, true, 15, 128, 128); |
| 577 |
| 578 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 579 |
| 580 RenderPassList pass_list; |
| 581 pass_list.push_back(pass.Pass()); |
| 582 |
| 583 EXPECT_TRUE(this->RunPixelTest( |
| 584 &pass_list, |
| 585 PixelTest::NoOffscreenContext, |
| 586 base::FilePath(FILE_PATH_LITERAL("dark_grey.png")), |
| 587 ExactPixelComparator(true))); |
| 588 } |
| 589 |
499 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { | 590 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
500 gfx::Rect rect(this->device_viewport_size_); | 591 gfx::Rect rect(this->device_viewport_size_); |
501 | 592 |
502 RenderPass::Id id(1, 1); | 593 RenderPass::Id id(1, 1); |
503 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 594 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
504 | 595 |
505 scoped_ptr<SharedQuadState> shared_state = | 596 scoped_ptr<SharedQuadState> shared_state = |
506 CreateTestSharedQuadState(gfx::Transform(), rect); | 597 CreateTestSharedQuadState(gfx::Transform(), rect); |
507 | 598 |
508 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 599 // YUV of (149,43,21) should be green (0,255,0) in RGB. |
509 CreateTestYUVVideoDrawQuad(shared_state.get(), true, false); | 600 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 601 shared_state.get(), true, false, false, 149, 43, 21); |
510 | 602 |
511 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 603 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
512 | 604 |
513 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 605 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
514 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); | 606 color_quad->SetNew(shared_state.get(), rect, SK_ColorWHITE, false); |
515 | 607 |
516 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 608 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
517 | 609 |
518 RenderPassList pass_list; | 610 RenderPassList pass_list; |
519 pass_list.push_back(pass.Pass()); | 611 pass_list.push_back(pass.Pass()); |
520 | 612 |
521 EXPECT_TRUE(this->RunPixelTest( | 613 EXPECT_TRUE(this->RunPixelTest( |
522 &pass_list, | 614 &pass_list, |
523 PixelTest::NoOffscreenContext, | 615 PixelTest::NoOffscreenContext, |
524 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 616 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
525 ExactPixelComparator(true))); | 617 ExactPixelComparator(true))); |
526 } | 618 } |
527 | 619 |
528 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { | 620 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { |
529 gfx::Rect rect(this->device_viewport_size_); | 621 gfx::Rect rect(this->device_viewport_size_); |
530 | 622 |
531 RenderPass::Id id(1, 1); | 623 RenderPass::Id id(1, 1); |
532 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 624 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
533 | 625 |
534 scoped_ptr<SharedQuadState> shared_state = | 626 scoped_ptr<SharedQuadState> shared_state = |
535 CreateTestSharedQuadState(gfx::Transform(), rect); | 627 CreateTestSharedQuadState(gfx::Transform(), rect); |
536 | 628 |
537 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 629 // YUV of (149,43,21) should be green (0,255,0) in RGB. |
538 CreateTestYUVVideoDrawQuad(shared_state.get(), true, true); | 630 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 631 shared_state.get(), true, true, false, 149, 43, 21); |
539 | 632 |
540 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 633 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
541 | 634 |
542 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 635 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
543 color_quad->SetNew(shared_state.get(), rect, SK_ColorBLACK, false); | 636 color_quad->SetNew(shared_state.get(), rect, SK_ColorBLACK, false); |
544 | 637 |
545 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 638 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
546 | 639 |
547 RenderPassList pass_list; | 640 RenderPassList pass_list; |
548 pass_list.push_back(pass.Pass()); | 641 pass_list.push_back(pass.Pass()); |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2075 &pass_list, | 2168 &pass_list, |
2076 PixelTest::NoOffscreenContext, | 2169 PixelTest::NoOffscreenContext, |
2077 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), | 2170 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), |
2078 FuzzyPixelOffByOneComparator(true))); | 2171 FuzzyPixelOffByOneComparator(true))); |
2079 } | 2172 } |
2080 | 2173 |
2081 #endif // !defined(OS_ANDROID) | 2174 #endif // !defined(OS_ANDROID) |
2082 | 2175 |
2083 } // namespace | 2176 } // namespace |
2084 } // namespace cc | 2177 } // namespace cc |
OLD | NEW |