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

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

Issue 670183003: Update from chromium 62675d9fb31fb8cedc40f68e78e8445a74f362e7 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 2 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
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_test_helpers.h » ('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 "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 22 matching lines...) Expand all
33 output_requests->push_back(scoped_ptr<CopyOutputRequest>(it->second)); 33 output_requests->push_back(scoped_ptr<CopyOutputRequest>(it->second));
34 it->second = nullptr; 34 it->second = nullptr;
35 } 35 }
36 copy_requests->erase(request_range.first, request_range.second); 36 copy_requests->erase(request_range.first, request_range.second);
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager, 41 SurfaceAggregator::SurfaceAggregator(SurfaceManager* manager,
42 ResourceProvider* provider) 42 ResourceProvider* provider)
43 : manager_(manager), provider_(provider) { 43 : manager_(manager), provider_(provider), next_render_pass_id_(1) {
44 DCHECK(manager_); 44 DCHECK(manager_);
45 } 45 }
46 46
47 SurfaceAggregator::~SurfaceAggregator() {} 47 SurfaceAggregator::~SurfaceAggregator() {}
48 48
49 class SurfaceAggregator::RenderPassIdAllocator { 49 class SurfaceAggregator::RenderPassIdAllocator {
50 public: 50 public:
51 explicit RenderPassIdAllocator(SurfaceId surface_id) 51 explicit RenderPassIdAllocator(int* next_index) : next_index_(next_index) {}
52 : surface_id_(surface_id), next_index_(1) {}
53 ~RenderPassIdAllocator() {} 52 ~RenderPassIdAllocator() {}
54 53
55 void AddKnownPass(RenderPassId id) { 54 void AddKnownPass(RenderPassId id) {
56 if (id_to_index_map_.find(id) != id_to_index_map_.end()) 55 if (id_to_index_map_.find(id) != id_to_index_map_.end())
57 return; 56 return;
58 id_to_index_map_[id] = next_index_++; 57 id_to_index_map_[id] = (*next_index_)++;
59 } 58 }
60 59
61 RenderPassId Remap(RenderPassId id) { 60 RenderPassId Remap(RenderPassId id) {
62 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end()); 61 DCHECK(id_to_index_map_.find(id) != id_to_index_map_.end());
63 return RenderPassId(surface_id_.id, id_to_index_map_[id]); 62 return RenderPassId(1, id_to_index_map_[id]);
64 } 63 }
65 64
66 private: 65 private:
67 base::hash_map<RenderPassId, int> id_to_index_map_; 66 base::hash_map<RenderPassId, int> id_to_index_map_;
68 SurfaceId surface_id_; 67 int* next_index_;
69 int next_index_;
70 68
71 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator); 69 DISALLOW_COPY_AND_ASSIGN(RenderPassIdAllocator);
72 }; 70 };
73 71
74 static void UnrefHelper(base::WeakPtr<SurfaceFactory> surface_factory, 72 static void UnrefHelper(base::WeakPtr<SurfaceFactory> surface_factory,
75 const ReturnedResourceArray& resources, 73 const ReturnedResourceArray& resources,
76 BlockingTaskRunner* main_thread_task_runner) { 74 BlockingTaskRunner* main_thread_task_runner) {
77 if (surface_factory) 75 if (surface_factory)
78 surface_factory->UnrefResources(resources); 76 surface_factory->UnrefResources(resources);
79 } 77 }
80 78
81 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id, 79 RenderPassId SurfaceAggregator::RemapPassId(RenderPassId surface_local_pass_id,
82 SurfaceId surface_id) { 80 SurfaceId surface_id) {
83 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id); 81 RenderPassIdAllocator* allocator = render_pass_allocator_map_.get(surface_id);
84 if (!allocator) { 82 if (!allocator) {
85 allocator = new RenderPassIdAllocator(surface_id); 83 allocator = new RenderPassIdAllocator(&next_render_pass_id_);
86 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator)); 84 render_pass_allocator_map_.set(surface_id, make_scoped_ptr(allocator));
87 } 85 }
88 allocator->AddKnownPass(surface_local_pass_id); 86 allocator->AddKnownPass(surface_local_pass_id);
89 return allocator->Remap(surface_local_pass_id); 87 return allocator->Remap(surface_local_pass_id);
90 } 88 }
91 89
92 int SurfaceAggregator::ChildIdForSurface(Surface* surface) { 90 int SurfaceAggregator::ChildIdForSurface(Surface* surface) {
93 SurfaceToResourceChildIdMap::iterator it = 91 SurfaceToResourceChildIdMap::iterator it =
94 surface_id_to_resource_child_id_.find(surface->surface_id()); 92 surface_id_to_resource_child_id_.find(surface->surface_id());
95 if (it == surface_id_to_resource_child_id_.end()) { 93 if (it == surface_id_to_resource_child_id_.end()) {
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 surface->TakeLatencyInfo(&frame->metadata.latency_info); 415 surface->TakeLatencyInfo(&frame->metadata.latency_info);
418 } 416 }
419 417
420 // TODO(jamesr): Aggregate all resource references into the returned frame's 418 // TODO(jamesr): Aggregate all resource references into the returned frame's
421 // resource list. 419 // resource list.
422 420
423 return frame.Pass(); 421 return frame.Pass();
424 } 422 }
425 423
426 } // namespace cc 424 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_aggregator.h ('k') | cc/surfaces/surface_aggregator_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698