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

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

Issue 1982893002: [blimp] Add SkPicture caching support. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git merge origin/master Created 4 years, 6 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
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 // Calculates the delta of items that still have a positive reference count
40 // since last call to CommitRefCounts() and provides calculated delta in the
41 // output params |added_items| and |removed_items|.
42 void CommitRefCounts(std::vector<uint32_t>* added_items,
43 std::vector<uint32_t>* removed_items);
44
45 private:
46 // A reference count for all the given items. The key is the item, and the
47 // value is the count for that item.
48 std::unordered_map<uint32_t, uint32_t> active_ref_counts_;
vmpstr 2016/06/16 22:09:58 i think the value can just be "int"
nyquist 2016/06/24 11:11:14 Done.
49
50 // The full set of all committed items.
51 std::unordered_set<uint32_t> committed_;
52
53 DISALLOW_COPY_AND_ASSIGN(ReferenceTracker);
54 };
55
56 } // namespace blimp
57
58 #endif // BLIMP_COMMON_COMPOSITOR_REFERENCE_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698