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_resource_holder.h" | 5 #include "cc/surfaces/surface_resource_holder.h" |
6 | 6 |
7 #include "cc/surfaces/surface_resource_holder_client.h" | 7 #include "cc/surfaces/surface_resource_holder_client.h" |
8 namespace cc { | 8 namespace cc { |
9 | 9 |
10 SurfaceResourceHolder::SurfaceResourceHolder( | 10 SurfaceResourceHolder::SurfaceResourceHolder( |
11 SurfaceResourceHolderClient* client) | 11 SurfaceResourceHolderClient* client) |
12 : client_(client) {} | 12 : client_(client) {} |
13 | 13 |
14 SurfaceResourceHolder::~SurfaceResourceHolder() { | 14 SurfaceResourceHolder::~SurfaceResourceHolder() = default; |
15 } | |
16 | 15 |
17 SurfaceResourceHolder::ResourceRefs::ResourceRefs() | 16 SurfaceResourceHolder::ResourceRefs::ResourceRefs() |
18 : refs_received_from_child(0), refs_holding_resource_alive(0) { | 17 : refs_received_from_child(0), refs_holding_resource_alive(0) {} |
19 } | |
20 | 18 |
21 void SurfaceResourceHolder::Reset() { | 19 void SurfaceResourceHolder::Reset() { |
22 resource_id_info_map_.clear(); | 20 resource_id_info_map_.clear(); |
23 } | 21 } |
24 | 22 |
25 void SurfaceResourceHolder::ReceiveFromChild( | 23 void SurfaceResourceHolder::ReceiveFromChild( |
26 const TransferableResourceArray& resources) { | 24 const TransferableResourceArray& resources) { |
27 for (TransferableResourceArray::const_iterator it = resources.begin(); | 25 for (const auto& resource : resources) { |
28 it != resources.end(); | 26 ResourceRefs& ref = resource_id_info_map_[resource.id]; |
29 ++it) { | |
30 ResourceRefs& ref = resource_id_info_map_[it->id]; | |
31 ref.refs_holding_resource_alive++; | 27 ref.refs_holding_resource_alive++; |
32 ref.refs_received_from_child++; | 28 ref.refs_received_from_child++; |
33 } | 29 } |
34 } | 30 } |
35 | 31 |
36 void SurfaceResourceHolder::RefResources( | 32 void SurfaceResourceHolder::RefResources( |
37 const TransferableResourceArray& resources) { | 33 const TransferableResourceArray& resources) { |
38 for (TransferableResourceArray::const_iterator it = resources.begin(); | 34 for (TransferableResourceArray::const_iterator it = resources.begin(); |
39 it != resources.end(); | 35 it != resources.end(); |
40 ++it) { | 36 ++it) { |
(...skipping 26 matching lines...) Expand all Loading... |
67 returned.count = ref.refs_received_from_child; | 63 returned.count = ref.refs_received_from_child; |
68 resources_available_to_return.push_back(returned); | 64 resources_available_to_return.push_back(returned); |
69 resource_id_info_map_.erase(count_it); | 65 resource_id_info_map_.erase(count_it); |
70 } | 66 } |
71 } | 67 } |
72 | 68 |
73 client_->ReturnResources(resources_available_to_return); | 69 client_->ReturnResources(resources_available_to_return); |
74 } | 70 } |
75 | 71 |
76 } // namespace cc | 72 } // namespace cc |
OLD | NEW |