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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 SurfaceAggregator::~SurfaceAggregator() {} | 30 SurfaceAggregator::~SurfaceAggregator() {} |
31 | 31 |
32 class SurfaceAggregator::RenderPassIdAllocator { | 32 class SurfaceAggregator::RenderPassIdAllocator { |
33 public: | 33 public: |
34 explicit RenderPassIdAllocator(SurfaceId surface_id) | 34 explicit RenderPassIdAllocator(SurfaceId surface_id) |
35 : surface_id_(surface_id), next_index_(1) {} | 35 : surface_id_(surface_id), next_index_(1) {} |
36 ~RenderPassIdAllocator() {} | 36 ~RenderPassIdAllocator() {} |
37 | 37 |
38 void AddKnownPass(RenderPass::Id id) { | 38 void AddKnownPass(RenderPassId id) { |
39 if (id_to_index_map_.find(id) != id_to_index_map_.end()) | 39 if (id_to_index_map_.find(id) != id_to_index_map_.end()) |
40 return; | 40 return; |
41 id_to_index_map_[id] = next_index_++; | 41 id_to_index_map_[id] = next_index_++; |
42 } | 42 } |
43 | 43 |
44 RenderPass::Id Remap(RenderPass::Id id) { | 44 RenderPassId Remap(RenderPassId id) { |
45 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end()); | 45 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end()); |
46 return RenderPass::Id(surface_id_.id, id_to_index_map_[id]); | 46 return RenderPassId(surface_id_.id, id_to_index_map_[id]); |
47 } | 47 } |
48 | 48 |
49 private: | 49 private: |
50 base::hash_map<RenderPass::Id, int> id_to_index_map_; | 50 base::hash_map<RenderPassId, int> id_to_index_map_; |
51 SurfaceId surface_id_; | 51 SurfaceId surface_id_; |
52 int next_index_; | 52 int next_index_; |
53 | 53 |
54 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); | 54 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); |
55 }; | 55 }; |
56 | 56 |
57 RenderPass::Id SurfaceAggregator::RemapPassId( | 57 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id, |
58 RenderPass::Id surface_local_pass_id, | 58 SurfaceId surface_id) { |
59 SurfaceId surface_id) { | |
60 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id); | 59 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id); |
61 if (!allocator) { | 60 if (!allocator) { |
62 allocator = new RenderPassIdAllocator(surface_id); | 61 allocator = new RenderPassIdAllocator(surface_id); |
63 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); | 62 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); |
64 } | 63 } |
65 allocator->AddKnownPass(surface_local_pass_id); | 64 allocator->AddKnownPass(surface_local_pass_id); |
66 return allocator->Remap(surface_local_pass_id); | 65 return allocator->Remap(surface_local_pass_id); |
67 } | 66 } |
68 | 67 |
69 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { | 68 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 return; | 156 return; |
158 | 157 |
159 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; | 158 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; |
160 | 159 |
161 const RenderPassList& referenced_passes = render_pass_list; | 160 const RenderPassList& referenced_passes = render_pass_list; |
162 for (size_t j = 0; j + 1 < referenced_passes.size(); ++j) { | 161 for (size_t j = 0; j + 1 < referenced_passes.size(); ++j) { |
163 const RenderPass& source = *referenced_passes[j]; | 162 const RenderPass& source = *referenced_passes[j]; |
164 | 163 |
165 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); | 164 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); |
166 | 165 |
167 RenderPass::Id remapped_pass_id = RemapPassId(source.id, surface_id); | 166 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
168 | 167 |
169 copy_pass->SetAll(remapped_pass_id, | 168 copy_pass->SetAll(remapped_pass_id, |
170 source.output_rect, | 169 source.output_rect, |
171 source.damage_rect, | 170 source.damage_rect, |
172 source.transform_to_root_target, | 171 source.transform_to_root_target, |
173 source.has_transparent_background); | 172 source.has_transparent_background); |
174 | 173 |
175 // Contributing passes aggregated in to the pass list need to take the | 174 // Contributing passes aggregated in to the pass list need to take the |
176 // transform of the surface quad into account to update their transform to | 175 // transform of the surface quad into account to update their transform to |
177 // the root surface. | 176 // the root surface. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
245 HandleSurfaceQuad(surface_quad, dest_pass); | 244 HandleSurfaceQuad(surface_quad, dest_pass); |
246 } else { | 245 } else { |
247 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { | 246 if (quad->shared_quad_state != last_copied_source_shared_quad_state) { |
248 CopySharedQuadState( | 247 CopySharedQuadState( |
249 quad->shared_quad_state, content_to_target_transform, dest_pass); | 248 quad->shared_quad_state, content_to_target_transform, dest_pass); |
250 last_copied_source_shared_quad_state = quad->shared_quad_state; | 249 last_copied_source_shared_quad_state = quad->shared_quad_state; |
251 } | 250 } |
252 if (quad->material == DrawQuad::RENDER_PASS) { | 251 if (quad->material == DrawQuad::RENDER_PASS) { |
253 const RenderPassDrawQuad* pass_quad = | 252 const RenderPassDrawQuad* pass_quad = |
254 RenderPassDrawQuad::MaterialCast(quad); | 253 RenderPassDrawQuad::MaterialCast(quad); |
255 RenderPass::Id original_pass_id = pass_quad->render_pass_id; | 254 RenderPassId original_pass_id = pass_quad->render_pass_id; |
256 RenderPass::Id remapped_pass_id = | 255 RenderPassId remapped_pass_id = |
257 RemapPassId(original_pass_id, surface_id); | 256 RemapPassId(original_pass_id, surface_id); |
258 | 257 |
259 dest_pass->CopyFromAndAppendRenderPassDrawQuad( | 258 dest_pass->CopyFromAndAppendRenderPassDrawQuad( |
260 pass_quad, | 259 pass_quad, |
261 dest_pass->shared_quad_state_list.back(), | 260 dest_pass->shared_quad_state_list.back(), |
262 remapped_pass_id); | 261 remapped_pass_id); |
263 } else { | 262 } else { |
264 dest_pass->CopyFromAndAppendDrawQuad( | 263 dest_pass->CopyFromAndAppendDrawQuad( |
265 quad, dest_pass->shared_quad_state_list.back()); | 264 quad, dest_pass->shared_quad_state_list.back()); |
266 } | 265 } |
267 } | 266 } |
268 } | 267 } |
269 } | 268 } |
270 | 269 |
271 void SurfaceAggregator::CopyPasses(const RenderPassList& source_pass_list, | 270 void SurfaceAggregator::CopyPasses(const RenderPassList& source_pass_list, |
272 SurfaceId surface_id) { | 271 SurfaceId surface_id) { |
273 for (size_t i = 0; i < source_pass_list.size(); ++i) { | 272 for (size_t i = 0; i < source_pass_list.size(); ++i) { |
274 const RenderPass& source = *source_pass_list[i]; | 273 const RenderPass& source = *source_pass_list[i]; |
275 | 274 |
276 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); | 275 scoped_ptr<RenderPass> copy_pass(RenderPass::Create()); |
277 | 276 |
278 RenderPass::Id remapped_pass_id = RemapPassId(source.id, surface_id); | 277 RenderPassId remapped_pass_id = RemapPassId(source.id, surface_id); |
279 | 278 |
280 copy_pass->SetAll(remapped_pass_id, | 279 copy_pass->SetAll(remapped_pass_id, |
281 source.output_rect, | 280 source.output_rect, |
282 source.damage_rect, | 281 source.damage_rect, |
283 source.transform_to_root_target, | 282 source.transform_to_root_target, |
284 source.has_transparent_background); | 283 source.has_transparent_background); |
285 | 284 |
286 CopyQuadsToPass(source.quad_list, | 285 CopyQuadsToPass(source.quad_list, |
287 source.shared_quad_state_list, | 286 source.shared_quad_state_list, |
288 gfx::Transform(), | 287 gfx::Transform(), |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 | 329 |
331 dest_pass_list_ = NULL; | 330 dest_pass_list_ = NULL; |
332 | 331 |
333 // TODO(jamesr): Aggregate all resource references into the returned frame's | 332 // TODO(jamesr): Aggregate all resource references into the returned frame's |
334 // resource list. | 333 // resource list. |
335 | 334 |
336 return frame.Pass(); | 335 return frame.Pass(); |
337 } | 336 } |
338 | 337 |
339 } // namespace cc | 338 } // namespace cc |
OLD | NEW |