OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 SurfaceManager manager; | 28 SurfaceManager manager; |
29 std::unique_ptr<CompositorFrameSinkSupport> support = | 29 std::unique_ptr<CompositorFrameSinkSupport> support = |
30 CompositorFrameSinkSupport::Create( | 30 CompositorFrameSinkSupport::Create( |
31 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot, | 31 nullptr, &manager, kArbitraryFrameSinkId, kIsRoot, |
32 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); | 32 kHandlesFrameSinkIdInvalidation, kNeedsSyncPoints); |
33 | 33 |
34 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); | 34 LocalSurfaceId local_surface_id(6, base::UnguessableToken::Create()); |
35 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); | 35 SurfaceId surface_id(kArbitraryFrameSinkId, local_surface_id); |
36 support->SubmitCompositorFrame(local_surface_id, test::MakeCompositorFrame()); | 36 support->SubmitCompositorFrame(local_surface_id, test::MakeCompositorFrame()); |
37 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); | 37 EXPECT_TRUE(manager.GetSurfaceForId(surface_id)); |
38 support->EvictFrame(); | 38 support->EvictCurrentSurface(); |
39 | 39 |
40 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); | 40 EXPECT_EQ(NULL, manager.GetSurfaceForId(surface_id)); |
41 } | 41 } |
42 | 42 |
43 TEST(SurfaceTest, SurfaceIds) { | 43 TEST(SurfaceTest, SurfaceIds) { |
44 for (size_t i = 0; i < 3; ++i) { | 44 for (size_t i = 0; i < 3; ++i) { |
45 LocalSurfaceIdAllocator allocator; | 45 LocalSurfaceIdAllocator allocator; |
46 LocalSurfaceId id1 = allocator.GenerateId(); | 46 LocalSurfaceId id1 = allocator.GenerateId(); |
47 LocalSurfaceId id2 = allocator.GenerateId(); | 47 LocalSurfaceId id2 = allocator.GenerateId(); |
48 EXPECT_NE(id1, id2); | 48 EXPECT_NE(id1, id2); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; | 100 std::multimap<int, std::unique_ptr<CopyOutputRequest>> copy_requests; |
101 surface->TakeCopyOutputRequests(©_requests); | 101 surface->TakeCopyOutputRequests(©_requests); |
102 EXPECT_EQ(1u, copy_requests.size()); | 102 EXPECT_EQ(1u, copy_requests.size()); |
103 // Last (root) pass should receive copy request. | 103 // Last (root) pass should receive copy request. |
104 ASSERT_EQ(1u, copy_requests.count(last_pass_id)); | 104 ASSERT_EQ(1u, copy_requests.count(last_pass_id)); |
105 EXPECT_FALSE(copy_called); | 105 EXPECT_FALSE(copy_called); |
106 copy_requests.find(last_pass_id)->second->SendEmptyResult(); | 106 copy_requests.find(last_pass_id)->second->SendEmptyResult(); |
107 EXPECT_TRUE(copy_called); | 107 EXPECT_TRUE(copy_called); |
108 | 108 |
109 support->EvictFrame(); | 109 support->EvictCurrentSurface(); |
110 } | 110 } |
111 | 111 |
112 } // namespace | 112 } // namespace |
113 } // namespace cc | 113 } // namespace cc |
OLD | NEW |