| 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_factory_client.h" | 7 #include "cc/surfaces/surface_factory_client.h" |
| 8 | 8 |
| 9 namespace cc { | 9 namespace cc { |
| 10 | 10 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 void SurfaceResourceHolder::UnrefResources( | 45 void SurfaceResourceHolder::UnrefResources( |
| 46 const ReturnedResourceArray& resources) { | 46 const ReturnedResourceArray& resources) { |
| 47 ReturnedResourceArray resources_available_to_return; | 47 ReturnedResourceArray resources_available_to_return; |
| 48 | 48 |
| 49 for (ReturnedResourceArray::const_iterator it = resources.begin(); | 49 for (ReturnedResourceArray::const_iterator it = resources.begin(); |
| 50 it != resources.end(); | 50 it != resources.end(); |
| 51 ++it) { | 51 ++it) { |
| 52 ResourceProvider::ResourceId id = it->id; | 52 ResourceProvider::ResourceId id = it->id; |
| 53 ResourceIdCountMap::iterator count_it = resource_id_use_count_map_.find(id); | 53 ResourceIdCountMap::iterator count_it = resource_id_use_count_map_.find(id); |
| 54 DCHECK(count_it != resource_id_use_count_map_.end()); | 54 if (count_it == resource_id_use_count_map_.end()) |
| 55 continue; |
| 55 ResourceRefs& ref = count_it->second; | 56 ResourceRefs& ref = count_it->second; |
| 56 ref.refs_holding_resource_alive -= it->count; | 57 ref.refs_holding_resource_alive -= it->count; |
| 57 if (ref.refs_holding_resource_alive == 0) { | 58 if (ref.refs_holding_resource_alive == 0) { |
| 58 ReturnedResource returned = *it; | 59 ReturnedResource returned = *it; |
| 59 returned.count = ref.refs_received_from_child; | 60 returned.count = ref.refs_received_from_child; |
| 60 resources_available_to_return.push_back(returned); | 61 resources_available_to_return.push_back(returned); |
| 61 resource_id_use_count_map_.erase(count_it); | 62 resource_id_use_count_map_.erase(count_it); |
| 62 } | 63 } |
| 63 } | 64 } |
| 64 | 65 |
| 65 client_->ReturnResources(resources_available_to_return); | 66 client_->ReturnResources(resources_available_to_return); |
| 66 } | 67 } |
| 67 | 68 |
| 68 } // namespace cc | 69 } // namespace cc |
| OLD | NEW |