1// Copyright 2014 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include "cc/surfaces/surface_id_allocator.h"
6
7namespace cc {
8
9SurfaceIdAllocator::SurfaceIdAllocator(uint32_t id_namespace)
10    : id_namespace_(id_namespace), next_id_(1u) {
11}
12
13SurfaceId SurfaceIdAllocator::GenerateId() {
14  SurfaceId id(static_cast<uint64_t>(id_namespace_) << 32 | next_id_);
15  next_id_++;
16  return id;
17}
18
19// static
20uint32_t SurfaceIdAllocator::NamespaceForId(SurfaceId id) {
21  return id.id >> 32;
22}
23
24}  // namespace cc
25