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

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: git merge origin/master 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..971115783e6d162764570f4c353a137022fbe2ef
--- /dev/null
+++ b/blimp/common/compositor/blimp_picture_cache_registry.h
@@ -0,0 +1,57 @@
+// 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 <vector>
+
+#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, and a way of retrieving the delta in the number
+// of items with a positive reference count since last call to Commit().
+// Commit() functions provides the deltas since last call to Commit(), as sets
+// of added and removed entries.
+// It is not necessary to increment the ref count for 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();
+
+ // Increment the reference count for an |item|. Must be called before
+ // DecrementRefCount for that item.
+ void IncrementRefCount(uint32_t item);
+
+ // Decrement the reference count for an |item|.
+ void DecrementRefCount(uint32_t item);
+
+ // Calculates the delta of items that have a positive reference count since
+ // since last call to Commit() and provides the result in the output params
+ // |added_items| and |removed_items|.
+ void Commit(std::vector<uint32_t>* added_items,
+ std::vector<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> used_item_ref_counts_;
vmpstr 2016/06/01 00:10:56 std::unordered_map
nyquist 2016/06/04 00:24:57 Done.
+
+ // The full set of all committed items.
+ std::set<uint32_t> committed_;
vmpstr 2016/06/01 00:10:56 std::unordered_set
nyquist 2016/06/04 00:24:57 Done.
+
+ 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