Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1038)

Side by Side Diff: cc/surfaces/surface_aggregator.cc

Issue 732423002: Update from chromium https://crrev.com/304586 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
374 CopyQuadsToPass(source.quad_list, 374 CopyQuadsToPass(source.quad_list,
375 source.shared_quad_state_list, 375 source.shared_quad_state_list,
376 gfx::Transform(), 376 gfx::Transform(),
377 copy_pass.get(), 377 copy_pass.get(),
378 surface->surface_id()); 378 surface->surface_id());
379 379
380 dest_pass_list_->push_back(copy_pass.Pass()); 380 dest_pass_list_->push_back(copy_pass.Pass());
381 } 381 }
382 } 382 }
383 383
384 void SurfaceAggregator::RemoveUnreferencedChildren() {
385 for (const auto& surface : previous_contained_surfaces_) {
386 if (!contained_surfaces_.count(surface.first)) {
387 SurfaceToResourceChildIdMap::iterator it =
388 surface_id_to_resource_child_id_.find(surface.first);
389 if (it != surface_id_to_resource_child_id_.end()) {
390 provider_->DestroyChild(it->second);
391 surface_id_to_resource_child_id_.erase(it);
392 }
393 }
394 }
395 }
396
384 scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) { 397 scoped_ptr<CompositorFrame> SurfaceAggregator::Aggregate(SurfaceId surface_id) {
385 Surface* surface = manager_->GetSurfaceForId(surface_id); 398 Surface* surface = manager_->GetSurfaceForId(surface_id);
386 DCHECK(surface); 399 DCHECK(surface);
387 contained_surfaces_[surface_id] = surface->frame_index(); 400 contained_surfaces_[surface_id] = surface->frame_index();
388 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame(); 401 const CompositorFrame* root_surface_frame = surface->GetEligibleFrame();
389 if (!root_surface_frame) 402 if (!root_surface_frame)
390 return nullptr; 403 return nullptr;
391 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate"); 404 TRACE_EVENT0("cc", "SurfaceAggregator::Aggregate");
392 405
393 scoped_ptr<CompositorFrame> frame(new CompositorFrame); 406 scoped_ptr<CompositorFrame> frame(new CompositorFrame);
394 frame->delegated_frame_data = make_scoped_ptr(new DelegatedFrameData); 407 frame->delegated_frame_data = make_scoped_ptr(new DelegatedFrameData);
395 408
396 DCHECK(root_surface_frame->delegated_frame_data); 409 DCHECK(root_surface_frame->delegated_frame_data);
397 410
398 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first; 411 SurfaceSet::iterator it = referenced_surfaces_.insert(surface_id).first;
399 412
400 dest_resource_list_ = &frame->delegated_frame_data->resource_list; 413 dest_resource_list_ = &frame->delegated_frame_data->resource_list;
401 dest_pass_list_ = &frame->delegated_frame_data->render_pass_list; 414 dest_pass_list_ = &frame->delegated_frame_data->render_pass_list;
402 415
403 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface); 416 CopyPasses(root_surface_frame->delegated_frame_data.get(), surface);
404 417
405 referenced_surfaces_.erase(it); 418 referenced_surfaces_.erase(it);
406 DCHECK(referenced_surfaces_.empty()); 419 DCHECK(referenced_surfaces_.empty());
407 420
408 dest_pass_list_ = NULL; 421 dest_pass_list_ = NULL;
422 RemoveUnreferencedChildren();
409 contained_surfaces_.swap(previous_contained_surfaces_); 423 contained_surfaces_.swap(previous_contained_surfaces_);
410 contained_surfaces_.clear(); 424 contained_surfaces_.clear();
411 425
412 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin(); 426 for (SurfaceIndexMap::iterator it = previous_contained_surfaces_.begin();
413 it != previous_contained_surfaces_.end(); 427 it != previous_contained_surfaces_.end();
414 ++it) { 428 ++it) {
415 Surface* surface = manager_->GetSurfaceForId(it->first); 429 Surface* surface = manager_->GetSurfaceForId(it->first);
416 if (surface) 430 if (surface)
417 surface->TakeLatencyInfo(&frame->metadata.latency_info); 431 surface->TakeLatencyInfo(&frame->metadata.latency_info);
418 } 432 }
419 433
420 // TODO(jamesr): Aggregate all resource references into the returned frame's 434 // TODO(jamesr): Aggregate all resource references into the returned frame's
421 // resource list. 435 // resource list.
422 436
423 return frame.Pass(); 437 return frame.Pass();
424 } 438 }
425 439
426 } // namespace cc 440 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698