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

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

Issue 2695243006: Don't delete CopyOutputRequests when queueing a new Surface frame. (Closed)
Patch Set: add test Created 3 years, 10 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
« cc/surfaces/surface.cc ('K') | « cc/surfaces/surface_aggregator.cc ('k') | no next file » | 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/surfaces/surface_dependency_tracker.h" 8 #include "cc/surfaces/surface_dependency_tracker.h"
8 #include "cc/surfaces/surface_factory.h" 9 #include "cc/surfaces/surface_factory.h"
9 #include "cc/surfaces/surface_factory_client.h" 10 #include "cc/surfaces/surface_factory_client.h"
10 #include "cc/surfaces/surface_id_allocator.h" 11 #include "cc/surfaces/surface_id_allocator.h"
11 #include "cc/surfaces/surface_manager.h" 12 #include "cc/surfaces/surface_manager.h"
12 #include "cc/test/begin_frame_args_test.h" 13 #include "cc/test/begin_frame_args_test.h"
13 #include "cc/test/fake_external_begin_frame_source.h" 14 #include "cc/test/fake_external_begin_frame_source.h"
14 #include "cc/test/scheduler_test_common.h" 15 #include "cc/test/scheduler_test_common.h"
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "ui/gfx/geometry/size.h" 17 #include "ui/gfx/geometry/size.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 55
55 TEST(SurfaceTest, SurfaceIds) { 56 TEST(SurfaceTest, SurfaceIds) {
56 for (size_t i = 0; i < 3; ++i) { 57 for (size_t i = 0; i < 3; ++i) {
57 SurfaceIdAllocator allocator; 58 SurfaceIdAllocator allocator;
58 LocalSurfaceId id1 = allocator.GenerateId(); 59 LocalSurfaceId id1 = allocator.GenerateId();
59 LocalSurfaceId id2 = allocator.GenerateId(); 60 LocalSurfaceId id2 = allocator.GenerateId();
60 EXPECT_NE(id1, id2); 61 EXPECT_NE(id1, id2);
61 } 62 }
62 } 63 }
63 64
65 void TestCopyResultCallback(bool* called,
66 std::unique_ptr<CopyOutputResult> result) {
67 *called = true;
68 }
69
70 // Test that CopyOutputRequests can outlive the current frame and be
71 // aggregated on the next frame.
72 TEST(SurfaceTest, CopyRequestLifetime) {
73 SurfaceManager manager;
74 FakeSurfaceFactoryClient surface_factory_client;
75 SurfaceFactory factory(kArbitraryFrameSinkId, &manager,
76 &surface_factory_client);
77
78 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create());
79 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id);
80 CompositorFrame frame;
81 frame.render_pass_list.push_back(RenderPass::Create());
82 factory.SubmitCompositorFrame(local_surface_id, std::move(frame),
83 SurfaceFactory::DrawCallback());
84 Surface* surface = manager.GetSurfaceForId(surface_id);
85 ASSERT_TRUE(!!surface);
86 EXPECT_FALSE(surface->HasRootCopyRequests());
87
88 bool copy_called = false;
89 factory.RequestCopyOfSurface(CopyOutputRequest::CreateRequest(
90 base::Bind(&TestCopyResultCallback, &copy_called)));
91 EXPECT_TRUE(manager.GetSurfaceForId(surface_id));
92 EXPECT_FALSE(copy_called);
93
94 CompositorFrame frame2;
95 frame2.render_pass_list.push_back(RenderPass::Create());
96 frame2.render_pass_list.back()->id = 1;
97 frame2.render_pass_list.push_back(RenderPass::Create());
98 frame2.render_pass_list.back()->id = 2;
99 factory.SubmitCompositorFrame(local_surface_id, std::move(frame2),
100 SurfaceFactory::DrawCallback());
101
102 // The copy request should stay on the Surface after a new frame is created.
103 EXPECT_FALSE(copy_called);
104 EXPECT_TRUE(surface->HasRootCopyRequests());
105
106 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests;
107 surface->TakeCopyOutputRequests(&copy_requests);
108 EXPECT_EQ(1u, copy_requests.size());
109 // Last (root) pass should receive copy request.
110 ASSERT_EQ(1u, copy_requests.count(2));
111 EXPECT_FALSE(copy_called);
112 copy_requests.find(2)->second->SendEmptyResult();
113 EXPECT_TRUE(copy_called);
114
115 factory.EvictSurface();
116 }
117
64 } // namespace 118 } // namespace
65 } // namespace cc 119 } // namespace cc
OLDNEW
« cc/surfaces/surface.cc ('K') | « cc/surfaces/surface_aggregator.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698