OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 | 6 |
7 #include <unordered_map> | 7 #include <unordered_map> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/flat_set.h" | 10 #include "base/containers/flat_set.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 SurfaceId CreateSurface(const FrameSinkId& frame_sink_id, uint32_t local_id) { | 41 SurfaceId CreateSurface(const FrameSinkId& frame_sink_id, uint32_t local_id) { |
42 LocalSurfaceId local_surface_id(local_id, | 42 LocalSurfaceId local_surface_id(local_id, |
43 base::UnguessableToken::Deserialize(0, 1u)); | 43 base::UnguessableToken::Deserialize(0, 1u)); |
44 GetCompositorFrameSinkSupport(frame_sink_id) | 44 GetCompositorFrameSinkSupport(frame_sink_id) |
45 .SubmitCompositorFrame(local_surface_id, test::MakeCompositorFrame()); | 45 .SubmitCompositorFrame(local_surface_id, test::MakeCompositorFrame()); |
46 return SurfaceId(frame_sink_id, local_surface_id); | 46 return SurfaceId(frame_sink_id, local_surface_id); |
47 } | 47 } |
48 | 48 |
49 // Destroy Surface with |surface_id|. | 49 // Destroy Surface with |surface_id|. |
50 void DestroySurface(const SurfaceId& surface_id) { | 50 void DestroySurface(const SurfaceId& surface_id) { |
51 GetCompositorFrameSinkSupport(surface_id.frame_sink_id()).EvictFrame(); | 51 GetCompositorFrameSinkSupport(surface_id.frame_sink_id()) |
| 52 .EvictCurrentSurface(); |
52 } | 53 } |
53 | 54 |
54 CompositorFrameSinkSupport& GetCompositorFrameSinkSupport( | 55 CompositorFrameSinkSupport& GetCompositorFrameSinkSupport( |
55 const FrameSinkId& frame_sink_id) { | 56 const FrameSinkId& frame_sink_id) { |
56 auto& support_ptr = supports_[frame_sink_id]; | 57 auto& support_ptr = supports_[frame_sink_id]; |
57 if (!support_ptr) { | 58 if (!support_ptr) { |
58 constexpr bool is_root = false; | 59 constexpr bool is_root = false; |
59 constexpr bool handles_frame_sink_id_invalidation = true; | 60 constexpr bool handles_frame_sink_id_invalidation = true; |
60 constexpr bool needs_sync_points = true; | 61 constexpr bool needs_sync_points = true; |
61 support_ptr = CompositorFrameSinkSupport::Create( | 62 support_ptr = CompositorFrameSinkSupport::Create( |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 105 |
105 protected: | 106 protected: |
106 // testing::Test: | 107 // testing::Test: |
107 void SetUp() override { | 108 void SetUp() override { |
108 // Start each test with a fresh SurfaceManager instance. | 109 // Start each test with a fresh SurfaceManager instance. |
109 manager_ = base::MakeUnique<SurfaceManager>( | 110 manager_ = base::MakeUnique<SurfaceManager>( |
110 SurfaceManager::LifetimeType::REFERENCES); | 111 SurfaceManager::LifetimeType::REFERENCES); |
111 } | 112 } |
112 void TearDown() override { | 113 void TearDown() override { |
113 for (auto& support : supports_) | 114 for (auto& support : supports_) |
114 support.second->EvictFrame(); | 115 support.second->EvictCurrentSurface(); |
115 supports_.clear(); | 116 supports_.clear(); |
116 manager_.reset(); | 117 manager_.reset(); |
117 } | 118 } |
118 | 119 |
119 std::unordered_map<FrameSinkId, | 120 std::unordered_map<FrameSinkId, |
120 std::unique_ptr<CompositorFrameSinkSupport>, | 121 std::unique_ptr<CompositorFrameSinkSupport>, |
121 FrameSinkIdHash> | 122 FrameSinkIdHash> |
122 supports_; | 123 supports_; |
123 std::unique_ptr<SurfaceManager> manager_; | 124 std::unique_ptr<SurfaceManager> manager_; |
124 }; | 125 }; |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 ASSERT_THAT(GetAllTempReferences(), UnorderedElementsAre(id1b)); | 508 ASSERT_THAT(GetAllTempReferences(), UnorderedElementsAre(id1b)); |
508 | 509 |
509 // If the parent has crashed then the window server will have already removed | 510 // If the parent has crashed then the window server will have already removed |
510 // it from the ServerWindow hierarchy and won't have an owner for |id2b|. The | 511 // it from the ServerWindow hierarchy and won't have an owner for |id2b|. The |
511 // window server will ask to drop the reference instead. | 512 // window server will ask to drop the reference instead. |
512 manager().DropTemporaryReference(id1b); | 513 manager().DropTemporaryReference(id1b); |
513 ASSERT_THAT(GetAllTempReferences(), IsEmpty()); | 514 ASSERT_THAT(GetAllTempReferences(), IsEmpty()); |
514 } | 515 } |
515 | 516 |
516 } // namespace cc | 517 } // namespace cc |
OLD | NEW |