Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(69)

Side by Side Diff: cc/output/overlay_unittest.cc

Issue 1311013002: [Ozone] Fix SingleOnTop issue by checking if the quad is clipped. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and add unit test Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "cc/base/scoped_ptr_vector.h" 5 #include "cc/base/scoped_ptr_vector.h"
6 #include "cc/output/compositor_frame_metadata.h" 6 #include "cc/output/compositor_frame_metadata.h"
7 #include "cc/output/gl_renderer.h" 7 #include "cc/output/gl_renderer.h"
8 #include "cc/output/output_surface.h" 8 #include "cc/output/output_surface.h"
9 #include "cc/output/output_surface_client.h" 9 #include "cc/output/output_surface_client.h"
10 #include "cc/output/overlay_candidate_validator.h" 10 #include "cc/output/overlay_candidate_validator.h"
(...skipping 18 matching lines...) Expand all
29 using testing::_; 29 using testing::_;
30 using testing::Mock; 30 using testing::Mock;
31 31
32 namespace cc { 32 namespace cc {
33 namespace { 33 namespace {
34 34
35 const gfx::Size kDisplaySize(256, 256); 35 const gfx::Size kDisplaySize(256, 256);
36 const gfx::Rect kOverlayRect(0, 0, 128, 128); 36 const gfx::Rect kOverlayRect(0, 0, 128, 128);
37 const gfx::Rect kOverlayTopLeftRect(0, 0, 64, 64); 37 const gfx::Rect kOverlayTopLeftRect(0, 0, 64, 64);
38 const gfx::Rect kOverlayBottomRightRect(64, 64, 64, 64); 38 const gfx::Rect kOverlayBottomRightRect(64, 64, 64, 64);
39 const gfx::Rect kOverlayClipRect(10, 20, 64, 64);
39 const gfx::PointF kUVTopLeft(0.1f, 0.2f); 40 const gfx::PointF kUVTopLeft(0.1f, 0.2f);
40 const gfx::PointF kUVBottomRight(1.0f, 1.0f); 41 const gfx::PointF kUVBottomRight(1.0f, 1.0f);
41 const gfx::Transform kNormalTransform = 42 const gfx::Transform kNormalTransform =
42 gfx::Transform(0.9f, 0, 0, 0.8f, 0.1f, 0.2f); // x,y -> x,y. 43 gfx::Transform(0.9f, 0, 0, 0.8f, 0.1f, 0.2f); // x,y -> x,y.
43 const gfx::Transform kXMirrorTransform = 44 const gfx::Transform kXMirrorTransform =
44 gfx::Transform(-0.9f, 0, 0, 0.8f, 1.0f, 0.2f); // x,y -> 1-x,y. 45 gfx::Transform(-0.9f, 0, 0, 0.8f, 1.0f, 0.2f); // x,y -> 1-x,y.
45 const gfx::Transform kYMirrorTransform = 46 const gfx::Transform kYMirrorTransform =
46 gfx::Transform(0.9f, 0, 0, -0.8f, 0.1f, 1.0f); // x,y -> x,1-y. 47 gfx::Transform(0.9f, 0, 0, -0.8f, 0.1f, 1.0f); // x,y -> x,1-y.
47 const gfx::Transform kBothMirrorTransform = 48 const gfx::Transform kBothMirrorTransform =
48 gfx::Transform(-0.9f, 0, 0, -0.8f, 1.0f, 1.0f); // x,y -> 1-x,1-y. 49 gfx::Transform(-0.9f, 0, 0, -0.8f, 1.0f, 1.0f); // x,y -> 1-x,1-y.
(...skipping 10 matching lines...) Expand all
59 void GetStrategies(OverlayProcessor::StrategyList* strategies) override { 60 void GetStrategies(OverlayProcessor::StrategyList* strategies) override {
60 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>( 61 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>(
61 new OverlayStrategyCommon(this, new OverlayStrategySingleOnTop))); 62 new OverlayStrategyCommon(this, new OverlayStrategySingleOnTop)));
62 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>( 63 strategies->push_back(scoped_ptr<OverlayProcessor::Strategy>(
63 new OverlayStrategyCommon(this, new OverlayStrategyUnderlay))); 64 new OverlayStrategyCommon(this, new OverlayStrategyUnderlay)));
64 } 65 }
65 void CheckOverlaySupport(OverlayCandidateList* surfaces) override { 66 void CheckOverlaySupport(OverlayCandidateList* surfaces) override {
66 ASSERT_EQ(2U, surfaces->size()); 67 ASSERT_EQ(2U, surfaces->size());
67 68
68 OverlayCandidate& candidate = surfaces->back(); 69 OverlayCandidate& candidate = surfaces->back();
70 if (candidate.is_clipped &&
danakj 2015/09/02 21:50:21 How come this is added here?
william.xie1 2015/09/02 22:04:49 Hi Dana, cc_unittest uses its own OverlayCandidat
danakj 2015/09/03 22:18:42 How come all the other logic from there isn't repl
71 !candidate.clip_rect.Contains(candidate.quad_rect_in_target_space))
72 return;
69 if (candidate.display_rect.width() == 64) { 73 if (candidate.display_rect.width() == 64) {
70 EXPECT_EQ(kOverlayBottomRightRect, candidate.display_rect); 74 EXPECT_EQ(kOverlayBottomRightRect, candidate.display_rect);
71 } else { 75 } else {
72 EXPECT_NEAR(kOverlayRect.x(), candidate.display_rect.x(), 0.01f); 76 EXPECT_NEAR(kOverlayRect.x(), candidate.display_rect.x(), 0.01f);
73 EXPECT_NEAR(kOverlayRect.y(), candidate.display_rect.y(), 0.01f); 77 EXPECT_NEAR(kOverlayRect.y(), candidate.display_rect.y(), 0.01f);
74 EXPECT_NEAR(kOverlayRect.width(), candidate.display_rect.width(), 0.01f); 78 EXPECT_NEAR(kOverlayRect.width(), candidate.display_rect.width(), 0.01f);
75 EXPECT_NEAR(kOverlayRect.height(), candidate.display_rect.height(), 79 EXPECT_NEAR(kOverlayRect.height(), candidate.display_rect.height(),
76 0.01f); 80 0.01f);
77 } 81 }
78 EXPECT_EQ(BoundingRect(kUVTopLeft, kUVBottomRight).ToString(), 82 EXPECT_EQ(BoundingRect(kUVTopLeft, kUVBottomRight).ToString(),
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 ->quad_to_target_transform.RotateAboutXAxis(45.f); 745 ->quad_to_target_transform.RotateAboutXAxis(45.f);
742 746
743 RenderPassList pass_list; 747 RenderPassList pass_list;
744 pass_list.push_back(pass.Pass()); 748 pass_list.push_back(pass.Pass());
745 OverlayCandidateList candidate_list; 749 OverlayCandidateList candidate_list;
746 overlay_processor_->ProcessForOverlays(&pass_list, &candidate_list); 750 overlay_processor_->ProcessForOverlays(&pass_list, &candidate_list);
747 ASSERT_EQ(1U, pass_list.size()); 751 ASSERT_EQ(1U, pass_list.size());
748 EXPECT_EQ(0U, candidate_list.size()); 752 EXPECT_EQ(0U, candidate_list.size());
749 } 753 }
750 754
755 TEST_F(SingleOverlayOnTopTest, RejectClipped) {
danakj 2015/09/02 21:50:21 Is this testing OverlayStrategyCommon or is it jus
william.xie1 2015/09/02 22:04:49 It will test OverlayStrategyCommon because Process
danakj 2015/09/03 22:21:17 OK I think I see.. there is no point in writing a
756 scoped_ptr<RenderPass> pass = CreateRenderPass();
757 CreateFullscreenCandidateQuad(resource_provider_.get(),
758 pass->shared_quad_state_list.back(),
759 pass.get());
760 pass->shared_quad_state_list.back()->is_clipped = true;
761 pass->shared_quad_state_list.back()->clip_rect = kOverlayClipRect;
danakj 2015/09/02 21:50:21 can you test the case where the clip rect exists b
william.xie1 2015/09/02 22:04:49 Done.
762
763 RenderPassList pass_list;
764 pass_list.push_back(pass.Pass());
765 OverlayCandidateList candidate_list;
766 overlay_processor_->ProcessForOverlays(&pass_list, &candidate_list);
767 ASSERT_EQ(1U, pass_list.size());
768 EXPECT_EQ(0U, candidate_list.size());
769 }
770
751 TEST_F(SingleOverlayOnTopTest, AllowVerticalFlip) { 771 TEST_F(SingleOverlayOnTopTest, AllowVerticalFlip) {
752 gfx::Rect rect = kOverlayRect; 772 gfx::Rect rect = kOverlayRect;
753 rect.set_width(rect.width() / 2); 773 rect.set_width(rect.width() / 2);
754 rect.Offset(0, -rect.height()); 774 rect.Offset(0, -rect.height());
755 scoped_ptr<RenderPass> pass = CreateRenderPass(); 775 scoped_ptr<RenderPass> pass = CreateRenderPass();
756 CreateCandidateQuadAt(resource_provider_.get(), 776 CreateCandidateQuadAt(resource_provider_.get(),
757 pass->shared_quad_state_list.back(), pass.get(), rect); 777 pass->shared_quad_state_list.back(), pass.get(), rect);
758 pass->shared_quad_state_list.back()->quad_to_target_transform.Scale(2.0f, 778 pass->shared_quad_state_list.back()->quad_to_target_transform.Scale(2.0f,
759 -1.0f); 779 -1.0f);
760 780
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
1482 renderer_->BeginDrawingFrame(&frame_no_overlays); 1502 renderer_->BeginDrawingFrame(&frame_no_overlays);
1483 renderer_->FinishDrawingFrame(&frame_no_overlays); 1503 renderer_->FinishDrawingFrame(&frame_no_overlays);
1484 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1)); 1504 EXPECT_TRUE(resource_provider_->InUseByConsumer(resource1));
1485 SwapBuffers(); 1505 SwapBuffers();
1486 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1)); 1506 EXPECT_FALSE(resource_provider_->InUseByConsumer(resource1));
1487 Mock::VerifyAndClearExpectations(&scheduler_); 1507 Mock::VerifyAndClearExpectations(&scheduler_);
1488 } 1508 }
1489 1509
1490 } // namespace 1510 } // namespace
1491 } // namespace cc 1511 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698