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

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

Issue 485043003: cc: Use correct message loop proxy in BlockingTaskRunner (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Help gn deal with it. Created 6 years, 3 months 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 | Annotate | Revision Log
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 "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"
11 #include "cc/base/math_util.h" 11 #include "cc/base/math_util.h"
12 #include "cc/output/compositor_frame.h" 12 #include "cc/output/compositor_frame.h"
13 #include "cc/output/delegated_frame_data.h" 13 #include "cc/output/delegated_frame_data.h"
14 #include "cc/quads/draw_quad.h" 14 #include "cc/quads/draw_quad.h"
15 #include "cc/quads/render_pass_draw_quad.h" 15 #include "cc/quads/render_pass_draw_quad.h"
16 #include "cc/quads/shared_quad_state.h" 16 #include "cc/quads/shared_quad_state.h"
17 #include "cc/quads/surface_draw_quad.h" 17 #include "cc/quads/surface_draw_quad.h"
18 #include "cc/surfaces/surface.h" 18 #include "cc/surfaces/surface.h"
19 #include "cc/surfaces/surface_factory.h" 19 #include "cc/surfaces/surface_factory.h"
20 #include "cc/surfaces/surface_manager.h" 20 #include "cc/surfaces/surface_manager.h"
21 #include "cc/trees/blocking_task_runner.h"
21 22
22 namespace cc { 23 namespace cc {
23 24
24 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager, 25 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager,
25 ResourceProvider* provider) 26 ResourceProvider* provider)
26 : manager_(manager), provider_(provider) { 27 : manager_(manager), provider_(provider) {
27 DCHECK(manager_); 28 DCHECK(manager_);
28 } 29 }
29 30
30 SurfaceAggregator::~SurfaceAggregator() {} 31 SurfaceAggregator::~SurfaceAggregator() {}
(...skipping 16 matching lines...) Expand all
47 } 48 }
48 49
49 private: 50 private:
50 base::hash_map<RenderPassId, int> id_to_index_map_; 51 base::hash_map<RenderPassId, int> id_to_index_map_;
51 SurfaceId surface_id_; 52 SurfaceId surface_id_;
52 int next_index_; 53 int next_index_;
53 54
54 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); 55 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator);
55 }; 56 };
56 57
58 static void UnrefHelper(
59 base::WeakPtr<SurfaceFactory> surface_factory,
60 const ReturnedResourceArray& resources,
61 scoped_refptr<BlockingTaskRunner> main_thread_task_runner) {
62 surface_factory->UnrefResources(resources);
63 }
64
57 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id, 65 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id,
58 SurfaceId surface_id) { 66 SurfaceId surface_id) {
59 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id); 67 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id);
60 if (!allocator) { 68 if (!allocator) {
61 allocator = new RenderPassIdAllocator(surface_id); 69 allocator = new RenderPassIdAllocator(surface_id);
62 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); 70 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator));
63 } 71 }
64 allocator->AddKnownPass(surface_local_pass_id); 72 allocator->AddKnownPass(surface_local_pass_id);
65 return allocator->Remap(surface_local_pass_id); 73 return allocator->Remap(surface_local_pass_id);
66 } 74 }
67 75
68 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { 76 int SurfaceAggregator::ChildIdForSurface(Surface* surface) {
69 SurfaceToResourceChildIdMap::iterator it = 77 SurfaceToResourceChildIdMap::iterator it =
70 surface_id_to_resource_child_id_.find(surface->surface_id()); 78 surface_id_to_resource_child_id_.find(surface->surface_id());
71 if (it == surface_id_to_resource_child_id_.end()) { 79 if (it == surface_id_to_resource_child_id_.end()) {
72 int child_id = provider_->CreateChild(base::Bind( 80 int child_id = provider_->CreateChild(
73 &SurfaceFactory::UnrefResources, surface->factory()->AsWeakPtr())); 81 base::Bind(&UnrefHelper, surface->factory()->AsWeakPtr()));
74 surface_id_to_resource_child_id_[surface->surface_id()] = child_id; 82 surface_id_to_resource_child_id_[surface->surface_id()] = child_id;
75 return child_id; 83 return child_id;
76 } else { 84 } else {
77 return it->second; 85 return it->second;
78 } 86 }
79 } 87 }
80 88
81 static ResourceProvider::ResourceId ResourceRemapHelper( 89 static ResourceProvider::ResourceId ResourceRemapHelper(
82 bool* invalid_frame, 90 bool* invalid_frame,
83 const ResourceProvider::ResourceIdMap& child_to_parent_map, 91 const ResourceProvider::ResourceIdMap& child_to_parent_map,
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 contained_surfaces_.swap(previous_contained_surfaces_); 354 contained_surfaces_.swap(previous_contained_surfaces_);
347 contained_surfaces_.clear(); 355 contained_surfaces_.clear();
348 356
349 // TODO(jamesr): Aggregate all resource references into the returned frame's 357 // TODO(jamesr): Aggregate all resource references into the returned frame's
350 // resource list. 358 // resource list.
351 359
352 return frame.Pass(); 360 return frame.Pass();
353 } 361 }
354 362
355 } // namespace cc 363 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698