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.
5 #include "cc/surfaces/surface_id_allocator.h"
7 #include "cc/surfaces/surface_manager.h"
11 SurfaceIdAllocator::SurfaceIdAllocator(uint32_t id_namespace
)
12 : id_namespace_(id_namespace
), next_id_(1u), manager_(nullptr) {
15 void SurfaceIdAllocator::RegisterSurfaceIdNamespace(SurfaceManager
* manager
) {
18 manager_
->RegisterSurfaceIdNamespace(id_namespace_
);
21 SurfaceIdAllocator::~SurfaceIdAllocator() {
23 manager_
->InvalidateSurfaceIdNamespace(id_namespace_
);
26 SurfaceId
SurfaceIdAllocator::GenerateId() {
27 SurfaceId
id(static_cast<uint64_t>(id_namespace_
) << 32 | next_id_
);
33 uint32_t SurfaceIdAllocator::NamespaceForId(SurfaceId id
) {