| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 bits_per_channel = 10; | 278 bits_per_channel = 10; |
| 279 } | 279 } |
| 280 | 280 |
| 281 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, | 281 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, |
| 282 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 282 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 283 uv_tex_size, y_resource, u_resource, v_resource, a_resource, | 283 uv_tex_size, y_resource, u_resource, v_resource, a_resource, |
| 284 color_space, video_color_space, 0.0f, 1.0f, | 284 color_space, video_color_space, 0.0f, 1.0f, |
| 285 bits_per_channel); | 285 bits_per_channel); |
| 286 } | 286 } |
| 287 | 287 |
| 288 void CreateTestY16TextureDrawQuad_FromVideoFrame( |
| 289 const SharedQuadState* shared_state, |
| 290 scoped_refptr<media::VideoFrame> video_frame, |
| 291 const gfx::RectF& tex_coord_rect, |
| 292 RenderPass* render_pass, |
| 293 VideoResourceUpdater* video_resource_updater, |
| 294 const gfx::Rect& rect, |
| 295 const gfx::Rect& visible_rect, |
| 296 ResourceProvider* resource_provider) { |
| 297 VideoFrameExternalResources resources = |
| 298 video_resource_updater->CreateExternalResourcesFromVideoFrame( |
| 299 video_frame); |
| 300 |
| 301 EXPECT_EQ(VideoFrameExternalResources::RGBA_RESOURCE, resources.type); |
| 302 EXPECT_EQ(1u, resources.mailboxes.size()); |
| 303 EXPECT_EQ(1u, resources.release_callbacks.size()); |
| 304 |
| 305 ResourceId y_resource = resource_provider->CreateResourceFromTextureMailbox( |
| 306 resources.mailboxes[0], |
| 307 SingleReleaseCallbackImpl::Create(resources.release_callbacks[0])); |
| 308 |
| 309 TextureDrawQuad* quad = |
| 310 render_pass->CreateAndAppendDrawQuad<TextureDrawQuad>(); |
| 311 float vertex_opacity[4] = {1.0f, 1.0f, 1.0f, 1.0f}; |
| 312 quad->SetNew(shared_state, rect, gfx::Rect(), rect, y_resource, false, |
| 313 tex_coord_rect.origin(), tex_coord_rect.bottom_right(), |
| 314 SK_ColorBLACK, vertex_opacity, false, false, false); |
| 315 } |
| 316 |
| 288 // Upshift video frame to 10 bit. | 317 // Upshift video frame to 10 bit. |
| 289 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame( | 318 scoped_refptr<media::VideoFrame> CreateHighbitVideoFrame( |
| 290 media::VideoFrame* video_frame) { | 319 media::VideoFrame* video_frame) { |
| 291 media::VideoPixelFormat format; | 320 media::VideoPixelFormat format; |
| 292 switch (video_frame->format()) { | 321 switch (video_frame->format()) { |
| 293 case media::PIXEL_FORMAT_I420: | 322 case media::PIXEL_FORMAT_I420: |
| 294 case media::PIXEL_FORMAT_YV12: | 323 case media::PIXEL_FORMAT_YV12: |
| 295 format = media::PIXEL_FORMAT_YUV420P10; | 324 format = media::PIXEL_FORMAT_YUV420P10; |
| 296 break; | 325 break; |
| 297 case media::PIXEL_FORMAT_YV16: | 326 case media::PIXEL_FORMAT_YV16: |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 532 tex_coord_rect.height() * uv_tex_size.height()); | 561 tex_coord_rect.height() * uv_tex_size.height()); |
| 533 | 562 |
| 534 YUVVideoDrawQuad* yuv_quad = | 563 YUVVideoDrawQuad* yuv_quad = |
| 535 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); | 564 render_pass->CreateAndAppendDrawQuad<YUVVideoDrawQuad>(); |
| 536 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, | 565 yuv_quad->SetNew(shared_state, rect, opaque_rect, visible_rect, |
| 537 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, | 566 ya_tex_coord_rect, uv_tex_coord_rect, ya_tex_size, |
| 538 uv_tex_size, y_resource, u_resource, v_resource, a_resource, | 567 uv_tex_size, y_resource, u_resource, v_resource, a_resource, |
| 539 color_space, video_color_space, 0.0f, 1.0f, 8); | 568 color_space, video_color_space, 0.0f, 1.0f, 8); |
| 540 } | 569 } |
| 541 | 570 |
| 571 void CreateTestY16TextureDrawQuad_TwoColor( |
| 572 const SharedQuadState* shared_state, |
| 573 const gfx::RectF& tex_coord_rect, |
| 574 uint8_t g_foreground, |
| 575 uint8_t g_background, |
| 576 RenderPass* render_pass, |
| 577 VideoResourceUpdater* video_resource_updater, |
| 578 const gfx::Rect& rect, |
| 579 const gfx::Rect& visible_rect, |
| 580 const gfx::Rect& foreground_rect, |
| 581 ResourceProvider* resource_provider) { |
| 582 std::unique_ptr<unsigned char, base::AlignedFreeDeleter> memory( |
| 583 static_cast<unsigned char*>( |
| 584 base::AlignedAlloc(rect.size().GetArea() * 2, |
| 585 media::VideoFrame::kFrameAddressAlignment))); |
| 586 scoped_refptr<media::VideoFrame> video_frame = |
| 587 media::VideoFrame::WrapExternalData( |
| 588 media::PIXEL_FORMAT_Y16, rect.size(), visible_rect, |
| 589 visible_rect.size(), memory.get(), rect.size().GetArea() * 2, |
| 590 base::TimeDelta()); |
| 591 DCHECK_EQ(video_frame->rows(0) % 2, 0); |
| 592 DCHECK_EQ(video_frame->stride(0) % 2, 0); |
| 593 |
| 594 for (int j = 0; j < video_frame->rows(0); ++j) { |
| 595 uint8_t* row = video_frame->data(0) + j * video_frame->stride(0); |
| 596 if (j < foreground_rect.y() || j >= foreground_rect.bottom()) { |
| 597 for (int i = 0; i < video_frame->stride(0) / 2; ++i) { |
| 598 *row++ = i & 0xFF; // Fill R with anything. It is not rendered. |
| 599 *row++ = g_background; |
| 600 } |
| 601 } else { |
| 602 for (int i = 0; |
| 603 i < std::min(video_frame->stride(0) / 2, foreground_rect.x()); ++i) { |
| 604 *row++ = i & 0xFF; |
| 605 *row++ = g_background; |
| 606 } |
| 607 for (int i = foreground_rect.x(); |
| 608 i < std::min(video_frame->stride(0) / 2, foreground_rect.right()); |
| 609 ++i) { |
| 610 *row++ = i & 0xFF; |
| 611 *row++ = g_foreground; |
| 612 } |
| 613 for (int i = foreground_rect.right(); i < video_frame->stride(0) / 2; |
| 614 ++i) { |
| 615 *row++ = i & 0xFF; |
| 616 *row++ = g_background; |
| 617 } |
| 618 } |
| 619 } |
| 620 |
| 621 CreateTestY16TextureDrawQuad_FromVideoFrame( |
| 622 shared_state, video_frame, tex_coord_rect, render_pass, |
| 623 video_resource_updater, rect, visible_rect, resource_provider); |
| 624 } |
| 625 |
| 542 typedef ::testing::Types<GLRenderer, | 626 typedef ::testing::Types<GLRenderer, |
| 543 SoftwareRenderer, | 627 SoftwareRenderer, |
| 544 GLRendererWithExpandedViewport, | 628 GLRendererWithExpandedViewport, |
| 545 SoftwareRendererWithExpandedViewport> RendererTypes; | 629 SoftwareRendererWithExpandedViewport> RendererTypes; |
| 546 TYPED_TEST_CASE(RendererPixelTest, RendererTypes); | 630 TYPED_TEST_CASE(RendererPixelTest, RendererTypes); |
| 547 | 631 |
| 548 template <typename RendererType> | 632 template <typename RendererType> |
| 549 class SoftwareRendererPixelTest : public RendererPixelTest<RendererType> {}; | 633 class SoftwareRendererPixelTest : public RendererPixelTest<RendererType> {}; |
| 550 | 634 |
| 551 typedef ::testing::Types<SoftwareRenderer, SoftwareRendererWithExpandedViewport> | 635 typedef ::testing::Types<SoftwareRenderer, SoftwareRendererWithExpandedViewport> |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 | 788 |
| 705 RenderPassList pass_list; | 789 RenderPassList pass_list; |
| 706 pass_list.push_back(std::move(pass)); | 790 pass_list.push_back(std::move(pass)); |
| 707 | 791 |
| 708 EXPECT_TRUE(this->RunPixelTest( | 792 EXPECT_TRUE(this->RunPixelTest( |
| 709 &pass_list, | 793 &pass_list, |
| 710 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), | 794 base::FilePath(FILE_PATH_LITERAL("green_alpha.png")), |
| 711 FuzzyPixelOffByOneComparator(true))); | 795 FuzzyPixelOffByOneComparator(true))); |
| 712 } | 796 } |
| 713 | 797 |
| 714 template <typename QuadType> | |
| 715 static const base::FilePath::CharType* IntersectingQuadImage() { | |
| 716 return FILE_PATH_LITERAL("intersecting_blue_green_squares.png"); | |
| 717 } | |
| 718 template <> | |
| 719 const base::FilePath::CharType* IntersectingQuadImage<SolidColorDrawQuad>() { | |
| 720 return FILE_PATH_LITERAL("intersecting_blue_green.png"); | |
| 721 } | |
| 722 template <> | |
| 723 const base::FilePath::CharType* IntersectingQuadImage<YUVVideoDrawQuad>() { | |
| 724 return FILE_PATH_LITERAL("intersecting_blue_green_squares_video.png"); | |
| 725 } | |
| 726 | |
| 727 template <typename TypeParam> | 798 template <typename TypeParam> |
| 728 class IntersectingQuadPixelTest : public RendererPixelTest<TypeParam> { | 799 class IntersectingQuadPixelTest : public RendererPixelTest<TypeParam> { |
| 729 protected: | 800 protected: |
| 730 void SetupQuadStateAndRenderPass() { | 801 void SetupQuadStateAndRenderPass() { |
| 731 // This sets up a pair of draw quads. They are both rotated | 802 // This sets up a pair of draw quads. They are both rotated |
| 732 // relative to the root plane, they are also rotated relative to each other. | 803 // relative to the root plane, they are also rotated relative to each other. |
| 733 // The intersect in the middle at a non-perpendicular angle so that any | 804 // The intersect in the middle at a non-perpendicular angle so that any |
| 734 // errors are hopefully magnified. | 805 // errors are hopefully magnified. |
| 735 // The quads should intersect correctly, as in the front quad should only | 806 // The quads should intersect correctly, as in the front quad should only |
| 736 // be partially in front of the back quad, and partially behind. | 807 // be partially in front of the back quad, and partially behind. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 756 // Create the back quad, and rotate on just the y axis. This will intersect | 827 // Create the back quad, and rotate on just the y axis. This will intersect |
| 757 // the first quad partially. | 828 // the first quad partially. |
| 758 trans = gfx::Transform(); | 829 trans = gfx::Transform(); |
| 759 trans.Translate3d(0, 0, -0.707 * this->device_viewport_size_.width() / 2.0); | 830 trans.Translate3d(0, 0, -0.707 * this->device_viewport_size_.width() / 2.0); |
| 760 trans.RotateAboutYAxis(-45.0); | 831 trans.RotateAboutYAxis(-45.0); |
| 761 back_quad_state_ = | 832 back_quad_state_ = |
| 762 CreateTestSharedQuadState(trans, viewport_rect_, render_pass_.get()); | 833 CreateTestSharedQuadState(trans, viewport_rect_, render_pass_.get()); |
| 763 back_quad_state_->sorting_context_id = 1; | 834 back_quad_state_->sorting_context_id = 1; |
| 764 back_quad_state_->clip_rect = quad_rect_; | 835 back_quad_state_->clip_rect = quad_rect_; |
| 765 } | 836 } |
| 766 template <typename T> | 837 void AppendBackgroundAndRunTest(const PixelComparator& comparator, |
| 767 void AppendBackgroundAndRunTest(const PixelComparator& comparator) { | 838 const base::FilePath::CharType* ref_file) { |
| 768 SharedQuadState* background_quad_state = CreateTestSharedQuadState( | 839 SharedQuadState* background_quad_state = CreateTestSharedQuadState( |
| 769 gfx::Transform(), viewport_rect_, render_pass_.get()); | 840 gfx::Transform(), viewport_rect_, render_pass_.get()); |
| 770 SolidColorDrawQuad* background_quad = | 841 SolidColorDrawQuad* background_quad = |
| 771 render_pass_->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 842 render_pass_->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 772 background_quad->SetNew(background_quad_state, viewport_rect_, | 843 background_quad->SetNew(background_quad_state, viewport_rect_, |
| 773 viewport_rect_, SK_ColorWHITE, false); | 844 viewport_rect_, SK_ColorWHITE, false); |
| 774 pass_list_.push_back(std::move(render_pass_)); | 845 pass_list_.push_back(std::move(render_pass_)); |
| 775 const base::FilePath::CharType* fileName = IntersectingQuadImage<T>(); | |
| 776 EXPECT_TRUE( | 846 EXPECT_TRUE( |
| 777 this->RunPixelTest(&pass_list_, base::FilePath(fileName), comparator)); | 847 this->RunPixelTest(&pass_list_, base::FilePath(ref_file), comparator)); |
| 778 } | 848 } |
| 779 template <typename T> | 849 template <typename T> |
| 780 T* CreateAndAppendDrawQuad() { | 850 T* CreateAndAppendDrawQuad() { |
| 781 return render_pass_->CreateAndAppendDrawQuad<T>(); | 851 return render_pass_->CreateAndAppendDrawQuad<T>(); |
| 782 } | 852 } |
| 783 | 853 |
| 784 std::unique_ptr<RenderPass> render_pass_; | 854 std::unique_ptr<RenderPass> render_pass_; |
| 785 gfx::Rect viewport_rect_; | 855 gfx::Rect viewport_rect_; |
| 786 SharedQuadState* front_quad_state_; | 856 SharedQuadState* front_quad_state_; |
| 787 SharedQuadState* back_quad_state_; | 857 SharedQuadState* back_quad_state_; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 SolidColorDrawQuad* quad = | 897 SolidColorDrawQuad* quad = |
| 828 this->template CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 898 this->template CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 829 SolidColorDrawQuad* quad2 = | 899 SolidColorDrawQuad* quad2 = |
| 830 this->template CreateAndAppendDrawQuad<SolidColorDrawQuad>(); | 900 this->template CreateAndAppendDrawQuad<SolidColorDrawQuad>(); |
| 831 | 901 |
| 832 quad->SetNew(this->front_quad_state_, this->quad_rect_, this->quad_rect_, | 902 quad->SetNew(this->front_quad_state_, this->quad_rect_, this->quad_rect_, |
| 833 SK_ColorBLUE, false); | 903 SK_ColorBLUE, false); |
| 834 quad2->SetNew(this->back_quad_state_, this->quad_rect_, this->quad_rect_, | 904 quad2->SetNew(this->back_quad_state_, this->quad_rect_, this->quad_rect_, |
| 835 SK_ColorGREEN, false); | 905 SK_ColorGREEN, false); |
| 836 SCOPED_TRACE("IntersectingSolidColorQuads"); | 906 SCOPED_TRACE("IntersectingSolidColorQuads"); |
| 837 this->template AppendBackgroundAndRunTest<SolidColorDrawQuad>( | 907 this->AppendBackgroundAndRunTest( |
| 838 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f)); | 908 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f), |
| 909 FILE_PATH_LITERAL("intersecting_blue_green.png")); |
| 839 } | 910 } |
| 840 | 911 |
| 841 template <typename TypeParam> | 912 template <typename TypeParam> |
| 842 SkColor GetColor(const SkColor& color) { | 913 SkColor GetColor(const SkColor& color) { |
| 843 return color; | 914 return color; |
| 844 } | 915 } |
| 845 | 916 |
| 846 template <> | 917 template <> |
| 847 SkColor GetColor<GLRenderer>(const SkColor& color) { | 918 SkColor GetColor<GLRenderer>(const SkColor& color) { |
| 848 return SkColorSetARGB(SkColorGetA(color), SkColorGetB(color), | 919 return SkColorSetARGB(SkColorGetA(color), SkColorGetB(color), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 860 GetColor<TypeParam>(SkColorSetARGB(255, 0, 0, 255)), SK_ColorTRANSPARENT, | 931 GetColor<TypeParam>(SkColorSetARGB(255, 0, 0, 255)), SK_ColorTRANSPARENT, |
| 861 true, this->front_quad_state_, this->resource_provider_.get(), | 932 true, this->front_quad_state_, this->resource_provider_.get(), |
| 862 this->render_pass_.get()); | 933 this->render_pass_.get()); |
| 863 CreateTestTwoColoredTextureDrawQuad( | 934 CreateTestTwoColoredTextureDrawQuad( |
| 864 this->quad_rect_, GetColor<TypeParam>(SkColorSetARGB(255, 0, 255, 0)), | 935 this->quad_rect_, GetColor<TypeParam>(SkColorSetARGB(255, 0, 255, 0)), |
| 865 GetColor<TypeParam>(SkColorSetARGB(255, 0, 0, 0)), SK_ColorTRANSPARENT, | 936 GetColor<TypeParam>(SkColorSetARGB(255, 0, 0, 0)), SK_ColorTRANSPARENT, |
| 866 true, this->back_quad_state_, this->resource_provider_.get(), | 937 true, this->back_quad_state_, this->resource_provider_.get(), |
| 867 this->render_pass_.get()); | 938 this->render_pass_.get()); |
| 868 | 939 |
| 869 SCOPED_TRACE("IntersectingTexturedQuads"); | 940 SCOPED_TRACE("IntersectingTexturedQuads"); |
| 870 this->template AppendBackgroundAndRunTest<TextureDrawQuad>( | 941 this->AppendBackgroundAndRunTest( |
| 871 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f)); | 942 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f), |
| 943 FILE_PATH_LITERAL("intersecting_blue_green_squares.png")); |
| 872 } | 944 } |
| 873 | 945 |
| 874 TYPED_TEST(IntersectingQuadSoftwareTest, PictureQuads) { | 946 TYPED_TEST(IntersectingQuadSoftwareTest, PictureQuads) { |
| 875 this->SetupQuadStateAndRenderPass(); | 947 this->SetupQuadStateAndRenderPass(); |
| 876 gfx::Rect outer_rect(this->quad_rect_); | 948 gfx::Rect outer_rect(this->quad_rect_); |
| 877 gfx::Rect inner_rect(this->quad_rect_.x() + (this->quad_rect_.width() / 4), | 949 gfx::Rect inner_rect(this->quad_rect_.x() + (this->quad_rect_.width() / 4), |
| 878 this->quad_rect_.y() + (this->quad_rect_.height() / 4), | 950 this->quad_rect_.y() + (this->quad_rect_.height() / 4), |
| 879 this->quad_rect_.width() / 2, | 951 this->quad_rect_.width() / 2, |
| 880 this->quad_rect_.height() / 2); | 952 this->quad_rect_.height() / 2); |
| 881 | 953 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 910 scoped_refptr<FakeRasterSource> green_raster_source = | 982 scoped_refptr<FakeRasterSource> green_raster_source = |
| 911 FakeRasterSource::CreateFromRecordingSource(green_recording.get(), false); | 983 FakeRasterSource::CreateFromRecordingSource(green_recording.get(), false); |
| 912 | 984 |
| 913 PictureDrawQuad* green_quad = | 985 PictureDrawQuad* green_quad = |
| 914 this->render_pass_->template CreateAndAppendDrawQuad<PictureDrawQuad>(); | 986 this->render_pass_->template CreateAndAppendDrawQuad<PictureDrawQuad>(); |
| 915 green_quad->SetNew(this->back_quad_state_, this->quad_rect_, gfx::Rect(), | 987 green_quad->SetNew(this->back_quad_state_, this->quad_rect_, gfx::Rect(), |
| 916 this->quad_rect_, gfx::RectF(this->quad_rect_), | 988 this->quad_rect_, gfx::RectF(this->quad_rect_), |
| 917 this->quad_rect_.size(), false, RGBA_8888, | 989 this->quad_rect_.size(), false, RGBA_8888, |
| 918 this->quad_rect_, 1.f, green_raster_source); | 990 this->quad_rect_, 1.f, green_raster_source); |
| 919 SCOPED_TRACE("IntersectingPictureQuadsPass"); | 991 SCOPED_TRACE("IntersectingPictureQuadsPass"); |
| 920 this->template AppendBackgroundAndRunTest<PictureDrawQuad>( | 992 this->AppendBackgroundAndRunTest( |
| 921 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f)); | 993 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f), |
| 994 FILE_PATH_LITERAL("intersecting_blue_green_squares.png")); |
| 922 } | 995 } |
| 923 | 996 |
| 924 TYPED_TEST(IntersectingQuadPixelTest, RenderPassQuads) { | 997 TYPED_TEST(IntersectingQuadPixelTest, RenderPassQuads) { |
| 925 this->SetupQuadStateAndRenderPass(); | 998 this->SetupQuadStateAndRenderPass(); |
| 926 RenderPassId child_pass_id1(2, 2); | 999 RenderPassId child_pass_id1(2, 2); |
| 927 RenderPassId child_pass_id2(2, 3); | 1000 RenderPassId child_pass_id2(2, 3); |
| 928 std::unique_ptr<RenderPass> child_pass1 = | 1001 std::unique_ptr<RenderPass> child_pass1 = |
| 929 CreateTestRenderPass(child_pass_id1, this->quad_rect_, gfx::Transform()); | 1002 CreateTestRenderPass(child_pass_id1, this->quad_rect_, gfx::Transform()); |
| 930 SharedQuadState* child1_quad_state = CreateTestSharedQuadState( | 1003 SharedQuadState* child1_quad_state = CreateTestSharedQuadState( |
| 931 gfx::Transform(), this->quad_rect_, child_pass1.get()); | 1004 gfx::Transform(), this->quad_rect_, child_pass1.get()); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 946 child_pass2.get()); | 1019 child_pass2.get()); |
| 947 | 1020 |
| 948 CreateTestRenderPassDrawQuad(this->front_quad_state_, this->quad_rect_, | 1021 CreateTestRenderPassDrawQuad(this->front_quad_state_, this->quad_rect_, |
| 949 child_pass_id1, this->render_pass_.get()); | 1022 child_pass_id1, this->render_pass_.get()); |
| 950 CreateTestRenderPassDrawQuad(this->back_quad_state_, this->quad_rect_, | 1023 CreateTestRenderPassDrawQuad(this->back_quad_state_, this->quad_rect_, |
| 951 child_pass_id2, this->render_pass_.get()); | 1024 child_pass_id2, this->render_pass_.get()); |
| 952 | 1025 |
| 953 this->pass_list_.push_back(std::move(child_pass1)); | 1026 this->pass_list_.push_back(std::move(child_pass1)); |
| 954 this->pass_list_.push_back(std::move(child_pass2)); | 1027 this->pass_list_.push_back(std::move(child_pass2)); |
| 955 SCOPED_TRACE("IntersectingRenderQuadsPass"); | 1028 SCOPED_TRACE("IntersectingRenderQuadsPass"); |
| 956 this->template AppendBackgroundAndRunTest<RenderPassDrawQuad>( | 1029 this->AppendBackgroundAndRunTest( |
| 957 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f)); | 1030 FuzzyPixelComparator(false, 2.f, 0.f, 256.f, 256, 0.f), |
| 1031 FILE_PATH_LITERAL("intersecting_blue_green_squares.png")); |
| 958 } | 1032 } |
| 959 | 1033 |
| 960 TYPED_TEST(IntersectingQuadGLPixelTest, YUVVideoQuads) { | 1034 TYPED_TEST(IntersectingQuadGLPixelTest, YUVVideoQuads) { |
| 961 this->SetupQuadStateAndRenderPass(); | 1035 this->SetupQuadStateAndRenderPass(); |
| 962 gfx::Rect inner_rect( | 1036 gfx::Rect inner_rect( |
| 963 ((this->quad_rect_.x() + (this->quad_rect_.width() / 4)) & ~0xF), | 1037 ((this->quad_rect_.x() + (this->quad_rect_.width() / 4)) & ~0xF), |
| 964 ((this->quad_rect_.y() + (this->quad_rect_.height() / 4)) & ~0xF), | 1038 ((this->quad_rect_.y() + (this->quad_rect_.height() / 4)) & ~0xF), |
| 965 (this->quad_rect_.width() / 2) & ~0xF, | 1039 (this->quad_rect_.width() / 2) & ~0xF, |
| 966 (this->quad_rect_.height() / 2) & ~0xF); | 1040 (this->quad_rect_.height() / 2) & ~0xF); |
| 967 | 1041 |
| 968 CreateTestYUVVideoDrawQuad_TwoColor( | 1042 CreateTestYUVVideoDrawQuad_TwoColor( |
| 969 this->front_quad_state_, media::PIXEL_FORMAT_YV12, | 1043 this->front_quad_state_, media::PIXEL_FORMAT_YV12, |
| 970 media::COLOR_SPACE_JPEG, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), | 1044 media::COLOR_SPACE_JPEG, false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), |
| 971 this->quad_rect_.size(), this->quad_rect_, 0, 128, 128, inner_rect, 29, | 1045 this->quad_rect_.size(), this->quad_rect_, 0, 128, 128, inner_rect, 29, |
| 972 255, 107, this->render_pass_.get(), this->video_resource_updater_.get(), | 1046 255, 107, this->render_pass_.get(), this->video_resource_updater_.get(), |
| 973 this->resource_provider_.get()); | 1047 this->resource_provider_.get()); |
| 974 | 1048 |
| 975 CreateTestYUVVideoDrawQuad_TwoColor( | 1049 CreateTestYUVVideoDrawQuad_TwoColor( |
| 976 this->back_quad_state_, media::PIXEL_FORMAT_YV12, media::COLOR_SPACE_JPEG, | 1050 this->back_quad_state_, media::PIXEL_FORMAT_YV12, media::COLOR_SPACE_JPEG, |
| 977 false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), this->quad_rect_.size(), | 1051 false, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), this->quad_rect_.size(), |
| 978 this->quad_rect_, 149, 43, 21, inner_rect, 0, 128, 128, | 1052 this->quad_rect_, 149, 43, 21, inner_rect, 0, 128, 128, |
| 979 this->render_pass_.get(), this->video_resource_updater2_.get(), | 1053 this->render_pass_.get(), this->video_resource_updater2_.get(), |
| 980 this->resource_provider_.get()); | 1054 this->resource_provider_.get()); |
| 981 | 1055 |
| 982 SCOPED_TRACE("IntersectingVideoQuads"); | 1056 SCOPED_TRACE("IntersectingVideoQuads"); |
| 983 this->template AppendBackgroundAndRunTest<YUVVideoDrawQuad>( | 1057 this->AppendBackgroundAndRunTest( |
| 984 FuzzyPixelOffByOneComparator(false)); | 1058 FuzzyPixelOffByOneComparator(false), |
| 1059 FILE_PATH_LITERAL("intersecting_blue_green_squares_video.png")); |
| 1060 } |
| 1061 |
| 1062 TYPED_TEST(IntersectingQuadGLPixelTest, Y16VideoQuads) { |
| 1063 this->SetupQuadStateAndRenderPass(); |
| 1064 gfx::Rect inner_rect( |
| 1065 ((this->quad_rect_.x() + (this->quad_rect_.width() / 4)) & ~0xF), |
| 1066 ((this->quad_rect_.y() + (this->quad_rect_.height() / 4)) & ~0xF), |
| 1067 (this->quad_rect_.width() / 2) & ~0xF, |
| 1068 (this->quad_rect_.height() / 2) & ~0xF); |
| 1069 |
| 1070 CreateTestY16TextureDrawQuad_TwoColor( |
| 1071 this->front_quad_state_, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 18, 0, |
| 1072 this->render_pass_.get(), this->video_resource_updater_.get(), |
| 1073 this->quad_rect_, this->quad_rect_, inner_rect, |
| 1074 this->resource_provider_.get()); |
| 1075 |
| 1076 CreateTestY16TextureDrawQuad_TwoColor( |
| 1077 this->back_quad_state_, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 0, 182, |
| 1078 this->render_pass_.get(), this->video_resource_updater2_.get(), |
| 1079 this->quad_rect_, this->quad_rect_, inner_rect, |
| 1080 this->resource_provider_.get()); |
| 1081 |
| 1082 SCOPED_TRACE("IntersectingVideoQuads"); |
| 1083 this->AppendBackgroundAndRunTest( |
| 1084 FuzzyPixelOffByOneComparator(false), |
| 1085 FILE_PATH_LITERAL("intersecting_light_dark_squares_video.png")); |
| 985 } | 1086 } |
| 986 | 1087 |
| 987 // TODO(skaslev): The software renderer does not support non-premultplied alpha. | 1088 // TODO(skaslev): The software renderer does not support non-premultplied alpha. |
| 988 TEST_F(GLRendererPixelTest, NonPremultipliedTextureWithoutBackground) { | 1089 TEST_F(GLRendererPixelTest, NonPremultipliedTextureWithoutBackground) { |
| 989 gfx::Rect rect(this->device_viewport_size_); | 1090 gfx::Rect rect(this->device_viewport_size_); |
| 990 | 1091 |
| 991 RenderPassId id(1, 1); | 1092 RenderPassId id(1, 1); |
| 992 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); | 1093 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 993 | 1094 |
| 994 SharedQuadState* shared_state = | 1095 SharedQuadState* shared_state = |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1338 | 1439 |
| 1339 RenderPassList pass_list; | 1440 RenderPassList pass_list; |
| 1340 pass_list.push_back(std::move(pass)); | 1441 pass_list.push_back(std::move(pass)); |
| 1341 | 1442 |
| 1342 EXPECT_TRUE(this->RunPixelTest( | 1443 EXPECT_TRUE(this->RunPixelTest( |
| 1343 &pass_list, | 1444 &pass_list, |
| 1344 base::FilePath(FILE_PATH_LITERAL("black.png")), | 1445 base::FilePath(FILE_PATH_LITERAL("black.png")), |
| 1345 ExactPixelComparator(true))); | 1446 ExactPixelComparator(true))); |
| 1346 } | 1447 } |
| 1347 | 1448 |
| 1449 TEST_F(VideoGLRendererPixelTest, TwoColorY16Rect) { |
| 1450 gfx::Rect rect(this->device_viewport_size_); |
| 1451 |
| 1452 RenderPassId id(1, 1); |
| 1453 std::unique_ptr<RenderPass> pass = CreateTestRootRenderPass(id, rect); |
| 1454 |
| 1455 SharedQuadState* shared_state = |
| 1456 CreateTestSharedQuadState(gfx::Transform(), rect, pass.get()); |
| 1457 |
| 1458 gfx::Rect upper_rect(rect.x(), rect.y(), rect.width(), rect.height() / 2); |
| 1459 CreateTestY16TextureDrawQuad_TwoColor( |
| 1460 shared_state, gfx::RectF(0.0f, 0.0f, 1.0f, 1.0f), 68, 123, pass.get(), |
| 1461 video_resource_updater_.get(), rect, rect, upper_rect, |
| 1462 resource_provider_.get()); |
| 1463 |
| 1464 RenderPassList pass_list; |
| 1465 pass_list.push_back(std::move(pass)); |
| 1466 |
| 1467 EXPECT_TRUE(this->RunPixelTest( |
| 1468 &pass_list, |
| 1469 base::FilePath(FILE_PATH_LITERAL("blue_yellow_filter_chain.png")), |
| 1470 FuzzyPixelOffByOneComparator(true))); |
| 1471 } |
| 1472 |
| 1348 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { | 1473 TYPED_TEST(RendererPixelTest, FastPassColorFilterAlpha) { |
| 1349 gfx::Rect viewport_rect(this->device_viewport_size_); | 1474 gfx::Rect viewport_rect(this->device_viewport_size_); |
| 1350 | 1475 |
| 1351 RenderPassId root_pass_id(1, 1); | 1476 RenderPassId root_pass_id(1, 1); |
| 1352 std::unique_ptr<RenderPass> root_pass = | 1477 std::unique_ptr<RenderPass> root_pass = |
| 1353 CreateTestRootRenderPass(root_pass_id, viewport_rect); | 1478 CreateTestRootRenderPass(root_pass_id, viewport_rect); |
| 1354 | 1479 |
| 1355 RenderPassId child_pass_id(2, 2); | 1480 RenderPassId child_pass_id(2, 2); |
| 1356 gfx::Rect pass_rect(this->device_viewport_size_); | 1481 gfx::Rect pass_rect(this->device_viewport_size_); |
| 1357 gfx::Transform transform_to_root; | 1482 gfx::Transform transform_to_root; |
| (...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3147 | 3272 |
| 3148 EXPECT_TRUE(this->RunPixelTest( | 3273 EXPECT_TRUE(this->RunPixelTest( |
| 3149 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), | 3274 &pass_list, base::FilePath(FILE_PATH_LITERAL("spiral.png")), |
| 3150 FuzzyPixelOffByOneComparator(true))); | 3275 FuzzyPixelOffByOneComparator(true))); |
| 3151 } | 3276 } |
| 3152 | 3277 |
| 3153 #endif // !defined(OS_ANDROID) | 3278 #endif // !defined(OS_ANDROID) |
| 3154 | 3279 |
| 3155 } // namespace | 3280 } // namespace |
| 3156 } // namespace cc | 3281 } // namespace cc |
| OLD | NEW |