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

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: Fix non-existing SkPicture::uniqueID() when dealing with display items without SkPictures Created 4 years, 7 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 <map>
10 #include <set>
11
12 #include "base/macros.h"
13 #include "blimp/common/blimp_common_export.h"
14
15 namespace blimp {
16
17 // BlimpPictureCacheRegistry provides functionality to count the number of
18 // references to a given item. Items can be staged an unstaged which in practice
19 // increments and decrements their reference count, respectively.
20 // When all items have been staged, the Commit() functions provides the deltas
21 // since last call to Commit(), as sets of added and removed entries.
22 // It is not necessary to stage an item if it has already been committed. Only
23 // changes to the reference count need to be informed.
24 // It is illegal to have a negative reference count.
25 class BLIMP_COMMON_EXPORT BlimpPictureCacheRegistry {
26 public:
27 BlimpPictureCacheRegistry();
28 ~BlimpPictureCacheRegistry();
29
30 // Stage an item for commit. This increments the reference count for the
31 // given |item|. Must be called before Unstage of that item.
32 void Stage(uint32_t item);
33
34 // Unstage an item for commit. This decrements the reference count for the
35 // given |item|.
36 void Unstage(uint32_t item);
37
38 // Calculates the delta since last call to Commit() and provides the result
39 // in the output params |added_items| and |removed_items|.
40 void Commit(std::set<uint32_t>* added_items,
41 std::set<uint32_t>* removed_items);
42
43 private:
44 // A reference count for all the given items. The key is the item, and the
45 // value is the count for that item.
46 std::map<uint32_t, uint32_t> staging_;
47
48 // The full set of all committed items.
49 std::set<uint32_t> committed_;
50
51 DISALLOW_COPY_AND_ASSIGN(BlimpPictureCacheRegistry);
52 };
53
54 } // namespace blimp
55
56 #endif // BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698