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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 EXPECT_TRUE(this->RunPixelTest( | 396 EXPECT_TRUE(this->RunPixelTest( |
| 397 &pass_list, | 397 &pass_list, |
| 398 PixelTest::NoOffscreenContext, | 398 PixelTest::NoOffscreenContext, |
| 399 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 399 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 400 FuzzyPixelOffByOneComparator(true))); | 400 FuzzyPixelOffByOneComparator(true))); |
| 401 } | 401 } |
| 402 | 402 |
| 403 class VideoGLRendererPixelTest : public GLRendererPixelTest { | 403 class VideoGLRendererPixelTest : public GLRendererPixelTest { |
| 404 protected: | 404 protected: |
| 405 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( | 405 scoped_ptr<YUVVideoDrawQuad> CreateTestYUVVideoDrawQuad( |
| 406 SharedQuadState* shared_state, bool with_alpha, bool is_transparent) { | 406 SharedQuadState* shared_state, |
| 407 gfx::Rect rect(this->device_viewport_size_); | 407 bool with_alpha, |
| 408 gfx::Rect opaque_rect(0, 0, 0, 0); | 408 bool is_transparent, |
| 409 const gfx::RectF& tex_coord_rect) { | |
| 410 const gfx::Rect rect(this->device_viewport_size_); | |
| 411 const gfx::Rect uv_rect( | |
| 412 0, 0, (rect.width() + 1) / 2, (rect.height() + 1) / 2); | |
| 413 const gfx::Rect opaque_rect(0, 0, 0, 0); | |
| 409 | 414 |
| 410 ResourceProvider::ResourceId y_resource = | 415 ResourceProvider::ResourceId y_resource = |
| 411 resource_provider_->CreateResource( | 416 resource_provider_->CreateResource( |
| 412 this->device_viewport_size_, | 417 rect.size(), |
| 413 GL_CLAMP_TO_EDGE, | 418 GL_CLAMP_TO_EDGE, |
| 414 ResourceProvider::TextureUsageAny, | 419 ResourceProvider::TextureUsageAny, |
| 415 LUMINANCE_8); | 420 LUMINANCE_8); |
| 416 ResourceProvider::ResourceId u_resource = | 421 ResourceProvider::ResourceId u_resource = |
| 417 resource_provider_->CreateResource( | 422 resource_provider_->CreateResource( |
| 418 this->device_viewport_size_, | 423 uv_rect.size(), |
| 419 GL_CLAMP_TO_EDGE, | 424 GL_CLAMP_TO_EDGE, |
| 420 ResourceProvider::TextureUsageAny, | 425 ResourceProvider::TextureUsageAny, |
| 421 LUMINANCE_8); | 426 LUMINANCE_8); |
| 422 ResourceProvider::ResourceId v_resource = | 427 ResourceProvider::ResourceId v_resource = |
| 423 resource_provider_->CreateResource( | 428 resource_provider_->CreateResource( |
| 424 this->device_viewport_size_, | 429 uv_rect.size(), |
| 425 GL_CLAMP_TO_EDGE, | 430 GL_CLAMP_TO_EDGE, |
| 426 ResourceProvider::TextureUsageAny, | 431 ResourceProvider::TextureUsageAny, |
| 427 LUMINANCE_8); | 432 LUMINANCE_8); |
| 428 ResourceProvider::ResourceId a_resource = 0; | 433 ResourceProvider::ResourceId a_resource = 0; |
| 429 if (with_alpha) { | 434 if (with_alpha) { |
| 430 a_resource = resource_provider_->CreateResource( | 435 a_resource = resource_provider_->CreateResource( |
| 431 this->device_viewport_size_, | 436 this->device_viewport_size_, |
| 432 GL_CLAMP_TO_EDGE, | 437 GL_CLAMP_TO_EDGE, |
| 433 ResourceProvider::TextureUsageAny, | 438 ResourceProvider::TextureUsageAny, |
| 434 LUMINANCE_8); | 439 LUMINANCE_8); |
| 435 } | 440 } |
| 436 | 441 |
| 437 int w = this->device_viewport_size_.width(); | 442 const int y_plane_size = rect.size().GetArea(); |
| 438 int h = this->device_viewport_size_.height(); | |
| 439 const int y_plane_size = w * h; | |
| 440 gfx::Rect uv_rect((w + 1) / 2, (h + 1) / 2); | |
| 441 const int uv_plane_size = uv_rect.size().GetArea(); | 443 const int uv_plane_size = uv_rect.size().GetArea(); |
| 442 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); | 444 scoped_ptr<uint8_t[]> y_plane(new uint8_t[y_plane_size]); |
| 443 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); | 445 scoped_ptr<uint8_t[]> u_plane(new uint8_t[uv_plane_size]); |
| 444 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); | 446 scoped_ptr<uint8_t[]> v_plane(new uint8_t[uv_plane_size]); |
| 445 scoped_ptr<uint8_t[]> a_plane; | 447 scoped_ptr<uint8_t[]> a_plane; |
| 446 if (with_alpha) | 448 if (with_alpha) |
| 447 a_plane.reset(new uint8_t[y_plane_size]); | 449 a_plane.reset(new uint8_t[y_plane_size]); |
| 448 // YUV values representing Green. | 450 // YUV values representing a striped pattern of green. |
|
danakj
2014/03/21 21:44:55
Update this comment please
| |
| 449 memset(y_plane.get(), 149, y_plane_size); | 451 uint8_t y_value = 0; |
| 450 memset(u_plane.get(), 43, uv_plane_size); | 452 uint8_t u_value = 0; |
| 451 memset(v_plane.get(), 21, uv_plane_size); | 453 uint8_t v_value = 0; |
| 454 for (int i = 0; i < y_plane_size; ++i) | |
| 455 y_plane.get()[i] = (y_value += 1); | |
| 456 for (int i = 0; i < uv_plane_size; ++i) { | |
| 457 u_plane.get()[i] = (u_value += 3); | |
| 458 v_plane.get()[i] = (v_value += 5); | |
| 459 } | |
| 452 if (with_alpha) | 460 if (with_alpha) |
| 453 memset(a_plane.get(), is_transparent ? 0 : 128, y_plane_size); | 461 memset(a_plane.get(), is_transparent ? 0 : 128, y_plane_size); |
| 454 | 462 |
| 455 resource_provider_->SetPixels(y_resource, y_plane.get(), rect, rect, | 463 resource_provider_->SetPixels( |
| 456 gfx::Vector2d()); | 464 y_resource, y_plane.get(), rect, rect, gfx::Vector2d()); |
| 457 resource_provider_->SetPixels(u_resource, u_plane.get(), uv_rect, uv_rect, | 465 resource_provider_->SetPixels( |
| 458 gfx::Vector2d()); | 466 u_resource, u_plane.get(), uv_rect, uv_rect, gfx::Vector2d()); |
| 459 resource_provider_->SetPixels(v_resource, v_plane.get(), uv_rect, uv_rect, | 467 resource_provider_->SetPixels( |
| 460 gfx::Vector2d()); | 468 v_resource, v_plane.get(), uv_rect, uv_rect, gfx::Vector2d()); |
| 461 if (with_alpha) { | 469 if (with_alpha) { |
| 462 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, | 470 resource_provider_->SetPixels(a_resource, a_plane.get(), rect, rect, |
| 463 gfx::Vector2d()); | 471 gfx::Vector2d()); |
| 464 } | 472 } |
| 465 | 473 |
| 466 scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create(); | 474 scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create(); |
| 467 yuv_quad->SetNew(shared_state, | 475 yuv_quad->SetNew(shared_state, |
| 468 rect, | 476 rect, |
| 469 opaque_rect, | 477 opaque_rect, |
| 470 rect, | 478 rect, |
| 471 gfx::Size(), | 479 tex_coord_rect, |
| 472 y_resource, | 480 y_resource, |
| 473 u_resource, | 481 u_resource, |
| 474 v_resource, | 482 v_resource, |
| 475 a_resource); | 483 a_resource); |
| 476 return yuv_quad.Pass(); | 484 return yuv_quad.Pass(); |
| 477 } | 485 } |
| 478 }; | 486 }; |
| 479 | 487 |
| 480 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { | 488 TEST_F(VideoGLRendererPixelTest, SimpleYUVRect) { |
| 481 gfx::Rect rect(this->device_viewport_size_); | 489 gfx::Rect rect(this->device_viewport_size_); |
| 482 | 490 |
| 483 RenderPass::Id id(1, 1); | 491 RenderPass::Id id(1, 1); |
| 484 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 492 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 485 | 493 |
| 486 scoped_ptr<SharedQuadState> shared_state = | 494 scoped_ptr<SharedQuadState> shared_state = |
| 487 CreateTestSharedQuadState(gfx::Transform(), rect); | 495 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 488 | 496 |
| 489 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 497 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 490 CreateTestYUVVideoDrawQuad(shared_state.get(), false, false); | 498 shared_state.get(), false, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| 491 | 499 |
| 492 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 500 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 493 | 501 |
| 502 RenderPassList pass_list; | |
| 503 pass_list.push_back(pass.Pass()); | |
| 504 | |
| 505 EXPECT_TRUE( | |
| 506 this->RunPixelTest(&pass_list, | |
| 507 PixelTest::NoOffscreenContext, | |
| 508 base::FilePath(FILE_PATH_LITERAL("yuv_stripes.png")), | |
| 509 ExactPixelComparator(true))); | |
| 510 } | |
| 511 | |
| 512 TEST_F(VideoGLRendererPixelTest, OffsetYUVRect) { | |
| 513 gfx::Rect rect(this->device_viewport_size_); | |
| 514 | |
| 515 RenderPass::Id id(1, 1); | |
| 516 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | |
| 517 | |
| 518 scoped_ptr<SharedQuadState> shared_state = | |
| 519 CreateTestSharedQuadState(gfx::Transform(), rect); | |
| 520 | |
| 521 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( | |
| 522 shared_state.get(), false, false, gfx::RectF(0.125f, 0.25f, 0.75f, 0.5f)); | |
| 523 | |
| 524 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | |
| 525 | |
| 494 RenderPassList pass_list; | 526 RenderPassList pass_list; |
| 495 pass_list.push_back(pass.Pass()); | 527 pass_list.push_back(pass.Pass()); |
| 496 | 528 |
| 497 EXPECT_TRUE(this->RunPixelTest( | 529 EXPECT_TRUE(this->RunPixelTest( |
| 498 &pass_list, | 530 &pass_list, |
| 499 PixelTest::NoOffscreenContext, | 531 PixelTest::NoOffscreenContext, |
| 500 base::FilePath(FILE_PATH_LITERAL("green.png")), | 532 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_offset.png")), |
| 501 ExactPixelComparator(true))); | 533 ExactPixelComparator(true))); |
| 502 } | 534 } |
| 503 | 535 |
| 504 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { | 536 TEST_F(VideoGLRendererPixelTest, SimpleYUVARect) { |
| 505 gfx::Rect rect(this->device_viewport_size_); | 537 gfx::Rect rect(this->device_viewport_size_); |
| 506 | 538 |
| 507 RenderPass::Id id(1, 1); | 539 RenderPass::Id id(1, 1); |
| 508 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 540 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 509 | 541 |
| 510 scoped_ptr<SharedQuadState> shared_state = | 542 scoped_ptr<SharedQuadState> shared_state = |
| 511 CreateTestSharedQuadState(gfx::Transform(), rect); | 543 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 512 | 544 |
| 513 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 545 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 514 CreateTestYUVVideoDrawQuad(shared_state.get(), true, false); | 546 shared_state.get(), true, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| 515 | 547 |
| 516 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 548 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 517 | 549 |
| 518 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 550 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 519 color_quad->SetNew(shared_state.get(), rect, rect, SK_ColorWHITE, false); | 551 color_quad->SetNew(shared_state.get(), rect, rect, SK_ColorWHITE, false); |
| 520 | 552 |
| 521 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 553 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 522 | 554 |
| 523 RenderPassList pass_list; | 555 RenderPassList pass_list; |
| 524 pass_list.push_back(pass.Pass()); | 556 pass_list.push_back(pass.Pass()); |
| 525 | 557 |
| 526 EXPECT_TRUE(this->RunPixelTest( | 558 EXPECT_TRUE(this->RunPixelTest( |
| 527 &pass_list, | 559 &pass_list, |
| 528 PixelTest::NoOffscreenContext, | 560 PixelTest::NoOffscreenContext, |
| 529 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 561 base::FilePath(FILE_PATH_LITERAL("yuv_stripes_alpha.png")), |
| 530 ExactPixelComparator(true))); | 562 ExactPixelComparator(true))); |
| 531 } | 563 } |
| 532 | 564 |
| 533 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { | 565 TEST_F(VideoGLRendererPixelTest, FullyTransparentYUVARect) { |
| 534 gfx::Rect rect(this->device_viewport_size_); | 566 gfx::Rect rect(this->device_viewport_size_); |
| 535 | 567 |
| 536 RenderPass::Id id(1, 1); | 568 RenderPass::Id id(1, 1); |
| 537 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 569 scoped_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 538 | 570 |
| 539 scoped_ptr<SharedQuadState> shared_state = | 571 scoped_ptr<SharedQuadState> shared_state = |
| 540 CreateTestSharedQuadState(gfx::Transform(), rect); | 572 CreateTestSharedQuadState(gfx::Transform(), rect); |
| 541 | 573 |
| 542 scoped_ptr<YUVVideoDrawQuad> yuv_quad = | 574 scoped_ptr<YUVVideoDrawQuad> yuv_quad = CreateTestYUVVideoDrawQuad( |
| 543 CreateTestYUVVideoDrawQuad(shared_state.get(), true, true); | 575 shared_state.get(), true, true, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f)); |
| 544 | 576 |
| 545 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); | 577 pass->quad_list.push_back(yuv_quad.PassAs<DrawQuad>()); |
| 546 | 578 |
| 547 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); | 579 scoped_ptr<SolidColorDrawQuad> color_quad = SolidColorDrawQuad::Create(); |
| 548 color_quad->SetNew(shared_state.get(), rect, rect, SK_ColorBLACK, false); | 580 color_quad->SetNew(shared_state.get(), rect, rect, SK_ColorBLACK, false); |
| 549 | 581 |
| 550 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); | 582 pass->quad_list.push_back(color_quad.PassAs<DrawQuad>()); |
| 551 | 583 |
| 552 RenderPassList pass_list; | 584 RenderPassList pass_list; |
| 553 pass_list.push_back(pass.Pass()); | 585 pass_list.push_back(pass.Pass()); |
| (...skipping 1515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2069 &pass_list, | 2101 &pass_list, |
| 2070 PixelTest::NoOffscreenContext, | 2102 PixelTest::NoOffscreenContext, |
| 2071 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), | 2103 base::FilePath(FILE_PATH_LITERAL("wrap_mode_repeat.png")), |
| 2072 FuzzyPixelOffByOneComparator(true))); | 2104 FuzzyPixelOffByOneComparator(true))); |
| 2073 } | 2105 } |
| 2074 | 2106 |
| 2075 #endif // !defined(OS_ANDROID) | 2107 #endif // !defined(OS_ANDROID) |
| 2076 | 2108 |
| 2077 } // namespace | 2109 } // namespace |
| 2078 } // namespace cc | 2110 } // namespace cc |
| OLD | NEW |