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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: blimp/common/compositor/blimp_picture_cache_registry.h
diff --git a/blimp/common/compositor/blimp_picture_cache_registry.h b/blimp/common/compositor/blimp_picture_cache_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..64eaaa1cd05c1fa8885a74f0e6fdebfd9c22e11a
--- /dev/null
+++ b/blimp/common/compositor/blimp_picture_cache_registry.h
@@ -0,0 +1,56 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_H_
+#define BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_H_
+
+#include <stdint.h>
+#include <map>
+#include <set>
+
+#include "base/macros.h"
+#include "blimp/common/blimp_common_export.h"
+
+namespace blimp {
+
+// BlimpPictureCacheRegistry provides functionality to count the number of
+// references to a given item. Items can be staged an unstaged which in practice
+// increments and decrements their reference count, respectively.
+// When all items have been staged, the Commit() functions provides the deltas
+// since last call to Commit(), as sets of added and removed entries.
+// It is not necessary to stage an item if it has already been committed. Only
+// changes to the reference count need to be informed.
+// It is illegal to have a negative reference count.
+class BLIMP_COMMON_EXPORT BlimpPictureCacheRegistry {
+ public:
+ BlimpPictureCacheRegistry();
+ ~BlimpPictureCacheRegistry();
+
+ // Stage an item for commit. This increments the reference count for the
+ // given |item|. Must be called before Unstage of that item.
+ void Stage(uint32_t item);
+
+ // Unstage an item for commit. This decrements the reference count for the
+ // given |item|.
+ void Unstage(uint32_t item);
+
+ // Calculates the delta since last call to Commit() and provides the result
+ // in the output params |added_items| and |removed_items|.
+ void Commit(std::set<uint32_t>* added_items,
+ std::set<uint32_t>* removed_items);
+
+ private:
+ // A reference count for all the given items. The key is the item, and the
+ // value is the count for that item.
+ std::map<uint32_t, uint32_t> staging_;
+
+ // The full set of all committed items.
+ std::set<uint32_t> committed_;
+
+ DISALLOW_COPY_AND_ASSIGN(BlimpPictureCacheRegistry);
+};
+
+} // namespace blimp
+
+#endif // BLIMP_COMMON_COMPOSITOR_BLIMP_PICTURE_CACHE_REGISTRY_H_

Powered by Google App Engine
This is Rietveld 408576698