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

Side by Side Diff: cc/surfaces/surface_unittest.cc

Issue 2848223003: Enforce constant size and device scale factor for surfaces (Closed)
Patch Set: Address comments Created 3 years, 7 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
« no previous file with comments | « cc/surfaces/surface_manager.cc ('k') | cc/test/compositor_frame_helpers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/surfaces/surface.h" 5 #include "cc/surfaces/surface.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "cc/output/copy_output_result.h" 7 #include "cc/output/copy_output_result.h"
8 #include "cc/surfaces/compositor_frame_sink_support.h" 8 #include "cc/surfaces/compositor_frame_sink_support.h"
9 #include "cc/surfaces/local_surface_id_allocator.h" 9 #include "cc/surfaces/local_surface_id_allocator.h"
10 #include "cc/surfaces/surface_dependency_tracker.h" 10 #include "cc/surfaces/surface_dependency_tracker.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 TEST(SurfaceTest, CopyRequestLifetime) { 59 TEST(SurfaceTest, CopyRequestLifetime) {
60 SurfaceManager manager; 60 SurfaceManager manager;
61 std::unique_ptr<CompositorFrameSinkSupport> support = 61 std::unique_ptr<CompositorFrameSinkSupport> support =
62 CompositorFrameSinkSupport::Create( 62 CompositorFrameSinkSupport::Create(
63 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot, 63 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot,
64 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); 64 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints);
65 65
66 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); 66 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create());
67 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); 67 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id);
68 CompositorFrame frame = test::MakeCompositorFrame(); 68 CompositorFrame frame = test::MakeCompositorFrame();
69 frame.render_pass_list.push_back(RenderPass::Create());
70 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); 69 support->SubmitCompositorFrame(local_surface_id, std::move(frame));
71 Surface* surface = manager.GetSurfaceForId(surface_id); 70 Surface* surface = manager.GetSurfaceForId(surface_id);
72 ASSERT_TRUE(!!surface); 71 ASSERT_TRUE(!!surface);
73 72
74 bool copy_called = false; 73 bool copy_called = false;
75 support->RequestCopyOfSurface(CopyOutputRequest::CreateRequest( 74 support->RequestCopyOfSurface(CopyOutputRequest::CreateRequest(
76 base::Bind(&TestCopyResultCallback, &copy_called))); 75 base::Bind(&TestCopyResultCallback, &copy_called)));
77 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); 76 EXPECT_TRUE(manager.GetSurfaceForId(surface_id));
78 EXPECT_FALSE(copy_called); 77 EXPECT_FALSE(copy_called);
79 78
80 int max_frame = 3, start_id = 200; 79 int max_frame = 3, start_id = 200;
81 for (int i = 0; i < max_frame; ++i) { 80 for (int i = 0; i < max_frame; ++i) {
82 CompositorFrame frame = test::MakeCompositorFrame(); 81 CompositorFrame frame = test::MakeEmptyCompositorFrame();
83 frame.render_pass_list.push_back(RenderPass::Create()); 82 frame.render_pass_list.push_back(RenderPass::Create());
84 frame.render_pass_list.back()->id = i * 3 + start_id; 83 frame.render_pass_list.back()->id = i * 3 + start_id;
85 frame.render_pass_list.push_back(RenderPass::Create()); 84 frame.render_pass_list.push_back(RenderPass::Create());
86 frame.render_pass_list.back()->id = i * 3 + start_id + 1; 85 frame.render_pass_list.back()->id = i * 3 + start_id + 1;
87 frame.render_pass_list.push_back(RenderPass::Create()); 86 frame.render_pass_list.push_back(RenderPass::Create());
88 frame.render_pass_list.back()->id = i * 3 + start_id + 2; 87 frame.render_pass_list.back()->SetNew(i * 3 + start_id + 2,
88 gfx::Rect(0, 0, 20, 20), gfx::Rect(),
89 gfx::Transform());
89 support->SubmitCompositorFrame(local_surface_id, std::move(frame)); 90 support->SubmitCompositorFrame(local_surface_id, std::move(frame));
90 } 91 }
91 92
92 int last_pass_id = (max_frame - 1) * 3 + start_id + 2; 93 int last_pass_id = (max_frame - 1) * 3 + start_id + 2;
93 // The copy request should stay on the Surface until TakeCopyOutputRequests 94 // The copy request should stay on the Surface until TakeCopyOutputRequests
94 // is called. 95 // is called.
95 EXPECT_FALSE(copy_called); 96 EXPECT_FALSE(copy_called);
96 EXPECT_EQ( 97 EXPECT_EQ(
97 1u, 98 1u,
98 surface->GetActiveFrame().render_pass_list.back()->copy_requests.size()); 99 surface->GetActiveFrame().render_pass_list.back()->copy_requests.size());
99 100
100 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; 101 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests;
101 surface->TakeCopyOutputRequests(&copy_requests); 102 surface->TakeCopyOutputRequests(&copy_requests);
102 EXPECT_EQ(1u, copy_requests.size()); 103 EXPECT_EQ(1u, copy_requests.size());
103 // Last (root) pass should receive copy request. 104 // Last (root) pass should receive copy request.
104 ASSERT_EQ(1u, copy_requests.count(last_pass_id)); 105 ASSERT_EQ(1u, copy_requests.count(last_pass_id));
105 EXPECT_FALSE(copy_called); 106 EXPECT_FALSE(copy_called);
106 copy_requests.find(last_pass_id)->second->SendEmptyResult(); 107 copy_requests.find(last_pass_id)->second->SendEmptyResult();
107 EXPECT_TRUE(copy_called); 108 EXPECT_TRUE(copy_called);
108 109
109 support->EvictCurrentSurface(); 110 support->EvictCurrentSurface();
110 } 111 }
111 112
112 } // namespace 113 } // namespace
113 } // namespace cc 114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_manager.cc ('k') | cc/test/compositor_frame_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698