OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/layers/delegated_renderer_layer_impl.h" | 5 #include "cc/layers/delegated_renderer_layer_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
127 #if defined(COMPILER_MSVC) | 127 #if defined(COMPILER_MSVC) |
128 resources_in_frame.reserve(reserve_size); | 128 resources_in_frame.reserve(reserve_size); |
129 #elif defined(COMPILER_GCC) | 129 #elif defined(COMPILER_GCC) |
130 // Pre-standard hash-tables only implement resize, which behaves similarly | 130 // Pre-standard hash-tables only implement resize, which behaves similarly |
131 // to reserve for these keys. Resizing to 0 may also be broken (particularly | 131 // to reserve for these keys. Resizing to 0 may also be broken (particularly |
132 // on stlport). | 132 // on stlport). |
133 // TODO(jbauman): Replace with reserve when C++11 is supported everywhere. | 133 // TODO(jbauman): Replace with reserve when C++11 is supported everywhere. |
134 if (reserve_size) | 134 if (reserve_size) |
135 resources_in_frame.resize(reserve_size); | 135 resources_in_frame.resize(reserve_size); |
136 #endif | 136 #endif |
137 DrawQuad::ResourceIteratorCallback remap_resources_to_parent_callback = | |
138 base::Bind(&ResourceRemapHelper, | |
139 &invalid_frame, | |
140 resource_map, | |
141 &resources_in_frame); | |
142 for (const auto& pass : render_pass_list) { | 137 for (const auto& pass : render_pass_list) { |
143 for (const auto& quad : pass->quad_list) | 138 for (const auto& quad : pass->quad_list) |
danakj
2015/05/28 17:10:05
{}
vmpstr
2015/05/28 18:38:45
Done.
| |
144 quad->IterateResources(remap_resources_to_parent_callback); | 139 quad->IterateResources( |
danakj
2015/05/28 17:10:05
Does this look nicer/worse with just walking thru
piman
2015/05/28 18:37:59
Actually... I think we may be able to do something
vmpstr
2015/05/28 18:38:45
Yep, that does look better. In the current version
| |
140 [&invalid_frame, &resource_map, &resources_in_frame]( | |
141 ResourceId resource_id) { | |
142 return ResourceRemapHelper(&invalid_frame, resource_map, | |
danakj
2015/05/28 17:10:05
I *think* I'd just put the body of this helper her
vmpstr
2015/05/28 18:38:45
Yeah, I could, but I prefer keeping lambdas very s
| |
143 &resources_in_frame, resource_id); | |
144 }); | |
145 } | 145 } |
146 | 146 |
147 if (invalid_frame) { | 147 if (invalid_frame) { |
148 // Declare we are still using the last frame's resources. Drops ownership of | 148 // Declare we are still using the last frame's resources. Drops ownership of |
149 // any invalid resources, keeping only those in use by the active tree. | 149 // any invalid resources, keeping only those in use by the active tree. |
150 resource_provider->DeclareUsedResourcesFromChild(child_id_, resources_); | 150 resource_provider->DeclareUsedResourcesFromChild(child_id_, resources_); |
151 return; | 151 return; |
152 } | 152 } |
153 | 153 |
154 // Save the new frame's resources, but don't give them to the ResourceProvider | 154 // Save the new frame's resources, but don't give them to the ResourceProvider |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 if (own_child_id_) { | 526 if (own_child_id_) { |
527 ResourceProvider* provider = layer_tree_impl()->resource_provider(); | 527 ResourceProvider* provider = layer_tree_impl()->resource_provider(); |
528 provider->DestroyChild(child_id_); | 528 provider->DestroyChild(child_id_); |
529 } | 529 } |
530 | 530 |
531 resources_.clear(); | 531 resources_.clear(); |
532 child_id_ = 0; | 532 child_id_ = 0; |
533 } | 533 } |
534 | 534 |
535 } // namespace cc | 535 } // namespace cc |
OLD | NEW |