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