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

Side by Side Diff: blimp/common/compositor/blimp_picture_cache_registry.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_BLIMP_PICTURE_CACHE_REGISTRY_H_
6 #define BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_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 // BlimpPictureCacheRegistry provides functionality to count the number of
19 // references to a given item, and a way of retrieving the delta in the number
20 // of items with a positive reference count since last call to Commit().
Kevin M 2016/06/06 23:33:58 ...of uncommitted items
nyquist 2016/06/10 22:02:24 But it also provides the delta for items that were
21 // Commit() functions provides the deltas since last call to Commit(), as sets
22 // of added and removed entries.
23 // It is not necessary to increment the ref count for an item if it has already
24 // been committed. Only changes to the reference count need to be informed.
Kevin M 2016/06/06 23:33:58 It's not the ref count change that matters, it's t
nyquist 2016/06/10 22:02:24 Tried to clarify.
25 // It is illegal to have a negative reference count.
26 class BLIMP_COMMON_EXPORT BlimpPictureCacheRegistry {
27 public:
28 BlimpPictureCacheRegistry();
29 ~BlimpPictureCacheRegistry();
30
31 // Increment the reference count for an |item|. Must be called before
32 // DecrementRefCount for that item.
33 void IncrementRefCount(uint32_t item);
34
35 // Decrement the reference count for an |item|.
36 void DecrementRefCount(uint32_t item);
37
38 // Calculates the delta of items that have a positive reference count since
39 // since last call to Commit() and provides the result in the output params
40 // |added_items| and |removed_items|.
41 void Commit(std::vector<uint32_t>* added_items,
Kevin M 2016/06/06 23:33:58 "Commit"() seems like it's mixing in concepts from
nyquist 2016/06/10 22:02:24 You're right, it's technically calculating the del
42 std::vector<uint32_t>* removed_items);
43
44 private:
45 // A reference count for all the given items. The key is the item, and the
46 // value is the count for that item.
47 std::unordered_map<uint32_t, uint32_t> used_item_ref_counts_;
48
49 // The full set of all committed items.
50 std::unordered_set<uint32_t> committed_;
51
52 DISALLOW_COPY_AND_ASSIGN(BlimpPictureCacheRegistry);
53 };
54
55 } // namespace blimp
56
57 #endif // BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698