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

Unified Diff: cc/surfaces/frame_sink_id_allocator.h

Issue 2691363002: Centralize FrameSinkId allocation in one place (Closed)
Patch Set: explicit Created 3 years, 10 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
« no previous file with comments | « cc/surfaces/BUILD.gn ('k') | content/browser/compositor/gpu_process_transport_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/surfaces/frame_sink_id_allocator.h
diff --git a/cc/surfaces/frame_sink_id_allocator.h b/cc/surfaces/frame_sink_id_allocator.h
new file mode 100644
index 0000000000000000000000000000000000000000..48bf1aaad8a62bf853399d2c514347bd4843687a
--- /dev/null
+++ b/cc/surfaces/frame_sink_id_allocator.h
@@ -0,0 +1,32 @@
+// Copyright 2017 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 CC_SURFACES_FRAME_SINK_ID_ALLOCATOR_H_
+#define CC_SURFACES_FRAME_SINK_ID_ALLOCATOR_H_
+
+#include "cc/surfaces/frame_sink_id.h"
+
+namespace cc {
+
+// This class generates FrameSinkId with a fixed client_id and an
+// incrementally-increasing sink_id.
+class FrameSinkIdAllocator {
+ public:
+ constexpr explicit FrameSinkIdAllocator(uint32_t client_id)
+ : client_id_(client_id), next_sink_id_(1u) {}
+
+ FrameSinkId NextFrameSinkId() {
+ return FrameSinkId(client_id_, next_sink_id_++);
+ }
+
+ private:
+ const uint32_t client_id_;
+ uint32_t next_sink_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(FrameSinkIdAllocator);
+};
+
+} // namespace cc
+
+#endif // CC_SURFACES_FRAME_SINK_ID_ALLOCATOR_H_
« no previous file with comments | « cc/surfaces/BUILD.gn ('k') | content/browser/compositor/gpu_process_transport_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698