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