| 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_
|
|
|