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_aggregator.h" | 5 #include "cc/surfaces/surface_aggregator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/containers/hash_tables.h" | |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/macros.h" | 13 #include "base/macros.h" |
15 #include "base/stl_util.h" | 14 #include "base/stl_util.h" |
16 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
17 #include "cc/base/math_util.h" | 16 #include "cc/base/math_util.h" |
18 #include "cc/output/compositor_frame.h" | 17 #include "cc/output/compositor_frame.h" |
19 #include "cc/output/delegated_frame_data.h" | 18 #include "cc/output/delegated_frame_data.h" |
20 #include "cc/quads/draw_quad.h" | 19 #include "cc/quads/draw_quad.h" |
21 #include "cc/quads/render_pass_draw_quad.h" | 20 #include "cc/quads/render_pass_draw_quad.h" |
22 #include "cc/quads/shared_quad_state.h" | 21 #include "cc/quads/shared_quad_state.h" |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 return; | 99 return; |
101 id_to_index_map_[id] = (*next_index_)++; | 100 id_to_index_map_[id] = (*next_index_)++; |
102 } | 101 } |
103 | 102 |
104 RenderPassId Remap(RenderPassId id) { | 103 RenderPassId Remap(RenderPassId id) { |
105 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end()); | 104 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end()); |
106 return RenderPassId(1, id_to_index_map_[id]); | 105 return RenderPassId(1, id_to_index_map_[id]); |
107 } | 106 } |
108 | 107 |
109 private: | 108 private: |
110 base::hash_map<RenderPassId, int> id_to_index_map_; | 109 std::unordered_map<RenderPassId, int, RenderPassIdHash> id_to_index_map_; |
111 int* next_index_; | 110 int* next_index_; |
112 | 111 |
113 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); | 112 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); |
114 }; | 113 }; |
115 | 114 |
116 static void UnrefHelper(base::WeakPtr<SurfaceFactory> surface_factory, | 115 static void UnrefHelper(base::WeakPtr<SurfaceFactory> surface_factory, |
117 const ReturnedResourceArray& resources, | 116 const ReturnedResourceArray& resources, |
118 BlockingTaskRunner* main_thread_task_runner) { | 117 BlockingTaskRunner* main_thread_task_runner) { |
119 if (surface_factory) | 118 if (surface_factory) |
120 surface_factory->UnrefResources(resources); | 119 surface_factory->UnrefResources(resources); |
121 } | 120 } |
122 | 121 |
123 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id, | 122 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id, |
124 SurfaceId surface_id) { | 123 SurfaceId surface_id) { |
125 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id); | 124 RenderPassIdAllocator* allocator; |
126 if (!allocator) { | 125 auto iter = render_pass_allocator_map_.find(surface_id); |
| 126 if (iter == render_pass_allocator_map_.end()) { |
127 allocator = new RenderPassIdAllocator(&next_render_pass_id_); | 127 allocator = new RenderPassIdAllocator(&next_render_pass_id_); |
128 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); | 128 render_pass_allocator_map_[surface_id] = make_scoped_ptr(allocator); |
| 129 } else { |
| 130 allocator = iter->second.get(); |
129 } | 131 } |
130 allocator->AddKnownPass(surface_local_pass_id); | 132 allocator->AddKnownPass(surface_local_pass_id); |
131 return allocator->Remap(surface_local_pass_id); | 133 return allocator->Remap(surface_local_pass_id); |
132 } | 134 } |
133 | 135 |
134 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { | 136 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { |
135 SurfaceToResourceChildIdMap::iterator it = | 137 SurfaceToResourceChildIdMap::iterator it = |
136 surface_id_to_resource_child_id_.find(surface->surface_id()); | 138 surface_id_to_resource_child_id_.find(surface->surface_id()); |
137 if (it == surface_id_to_resource_child_id_.end()) { | 139 if (it == surface_id_to_resource_child_id_.end()) { |
138 int child_id = | 140 int child_id = |
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
707 | 709 |
708 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { | 710 void SurfaceAggregator::SetFullDamageForSurface(SurfaceId surface_id) { |
709 auto it = previous_contained_surfaces_.find(surface_id); | 711 auto it = previous_contained_surfaces_.find(surface_id); |
710 if (it == previous_contained_surfaces_.end()) | 712 if (it == previous_contained_surfaces_.end()) |
711 return; | 713 return; |
712 // Set the last drawn index as 0 to ensure full damage next time it's drawn. | 714 // Set the last drawn index as 0 to ensure full damage next time it's drawn. |
713 it->second = 0; | 715 it->second = 0; |
714 } | 716 } |
715 | 717 |
716 } // namespace cc | 718 } // namespace cc |
OLD | NEW |