Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "blimp/common/compositor/blimp_picture_cache_registry.h" | |
| 6 | |
| 7 #include <stdint.h> | |
| 8 #include <map> | |
| 9 #include <set> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/logging.h" | |
| 13 | |
| 14 namespace blimp { | |
| 15 | |
| 16 BlimpPictureCacheRegistry::BlimpPictureCacheRegistry() {} | |
| 17 | |
| 18 BlimpPictureCacheRegistry::~BlimpPictureCacheRegistry() {} | |
| 19 | |
| 20 void BlimpPictureCacheRegistry::IncrementRefCount(uint32_t item) { | |
| 21 ++used_item_ref_counts_[item]; | |
| 22 } | |
| 23 | |
| 24 void BlimpPictureCacheRegistry::DecrementRefCount(uint32_t item) { | |
| 25 DCHECK_GT(used_item_ref_counts_[item], 0U); | |
|
vmpstr
2016/06/01 00:10:56
nit: lowercase u
nyquist
2016/06/04 00:24:57
Done.
| |
| 26 --used_item_ref_counts_[item]; | |
| 27 } | |
| 28 | |
| 29 void BlimpPictureCacheRegistry::Commit(std::vector<uint32_t>* added_entries, | |
| 30 std::vector<uint32_t>* removed_entries) { | |
| 31 for (auto it = used_item_ref_counts_.begin(); | |
| 32 it != used_item_ref_counts_.end();) { | |
| 33 uint32_t key = it->first; | |
| 34 uint32_t ref_count = it->second; | |
| 35 bool is_committed = committed_.find(key) != committed_.end(); | |
|
vmpstr
2016/06/01 00:10:56
committed_.count(key) > 0;
nyquist
2016/06/04 00:24:57
Done.
| |
| 36 if (ref_count > 0U) { | |
|
vmpstr
2016/06/01 00:10:56
nit: same here.
nyquist
2016/06/04 00:24:57
Done.
| |
| 37 if (!is_committed) { | |
| 38 committed_.insert(key); | |
| 39 added_entries->push_back(key); | |
| 40 } | |
| 41 ++it; | |
| 42 } else { | |
| 43 if (is_committed) { | |
| 44 committed_.erase(key); | |
| 45 removed_entries->push_back(key); | |
| 46 } | |
| 47 // The entry has no references, so should not be staged anymore. | |
| 48 it = used_item_ref_counts_.erase(it); | |
| 49 } | |
| 50 } | |
| 51 } | |
| 52 | |
| 53 } // namespace blimp | |
| OLD | NEW |