Chromium Code Reviews| 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..9ac1c3946479f7ab7025e71d078a0c8f1330ac75 |
| --- /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 FrameSinkIdAllocator(uint32_t client_id) |
|
Fady Samuel
2017/02/17 16:00:30
Another nit, just noticed. This needs explicit.
danakj
2017/02/21 22:56:56
Presubmit should warn about this I thought? Does t
xlai (Olivia)
2017/02/22 16:24:07
Done, added explicit. I don't think constexpr and
|
| + : 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_ |