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

Side by Side Diff: blimp/common/compositor/reference_tracker.h

Issue 2626423004: Remove all //blimp code. (Closed)
Patch Set: One last(?) `git merge` for good measure. Created 3 years, 11 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 | « blimp/common/blob_cache/test_util.cc ('k') | blimp/common/compositor/reference_tracker.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #ifndef BLIMP_COMMON_COMPOSITOR_REFERENCE_TRACKER_H_
6 #define BLIMP_COMMON_COMPOSITOR_REFERENCE_TRACKER_H_
7
8 #include <stdint.h>
9 #include <unordered_map>
10 #include <unordered_set>
11 #include <vector>
12
13 #include "base/macros.h"
14 #include "blimp/common/blimp_common_export.h"
15
16 namespace blimp {
17
18 // ReferenceTracker provides functionality to count the number of references to
19 // a given uint32_t, and a way of retrieving the delta in the number of items
20 // with a positive reference count since last call to CommitRefCounts().
21 // CommitRefCounts() functions provides the deltas since last call to Commit(),
22 // as sets of added and removed entries.
23 // The important thing for any given item is whether it is in a state of having
24 // positive reference count at the time of the call to CommitRefCounts(), not
25 // how the reference count changed overtime in-between two calls to
26 // CommitRefCounts().
27 class BLIMP_COMMON_EXPORT ReferenceTracker {
28 public:
29 ReferenceTracker();
30 ~ReferenceTracker();
31
32 // Increment the reference count for an |item|.
33 void IncrementRefCount(uint32_t item);
34
35 // Decrement the reference count for an |item|. Negative reference counts are
36 // not allowed.
37 void DecrementRefCount(uint32_t item);
38
39 // Clears the reference count for all items.
40 void ClearRefCounts();
41
42 // Calculates the delta of items that still have a positive reference count
43 // since last call to CommitRefCounts() and provides calculated delta in the
44 // output params |added_items| and |removed_items|. This method changes
45 // the internal state of the ReferenceTracker to be able to track what has
46 // in fact been committed to make it possible to find a delta.
47 void CommitRefCounts(std::vector<uint32_t>* added_items,
48 std::vector<uint32_t>* removed_items);
49
50 private:
51 // A reference count for all the given items. The key is the item, and the
52 // value is the count for that item.
53 std::unordered_map<uint32_t, int> active_ref_counts_;
54
55 // The full set of all committed items.
56 std::unordered_set<uint32_t> committed_;
57
58 DISALLOW_COPY_AND_ASSIGN(ReferenceTracker);
59 };
60
61 } // namespace blimp
62
63 #endif // BLIMP_COMMON_COMPOSITOR_REFERENCE_TRACKER_H_
OLDNEW
« no previous file with comments | « blimp/common/blob_cache/test_util.cc ('k') | blimp/common/compositor/reference_tracker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698