Vectorize website settings icons in omnibox
[chromium-blink-merge.git] / cc / surfaces / surface_id_allocator.h
blob31b1e8717d1763e3d2482307fb50ec38ccc95fac
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 #ifndef CC_SURFACES_SURFACE_ID_ALLOCATOR_H_
6 #define CC_SURFACES_SURFACE_ID_ALLOCATOR_H_
8 #include "cc/surfaces/surface_id.h"
9 #include "cc/surfaces/surfaces_export.h"
11 namespace cc {
13 class SurfaceManager;
15 // This is a helper class for generating surface IDs within a specified
16 // namespace. This is not threadsafe, to use from multiple threads wrap this
17 // class in a mutex.
18 class CC_SURFACES_EXPORT SurfaceIdAllocator {
19 public:
20 explicit SurfaceIdAllocator(uint32_t id_namespace);
21 ~SurfaceIdAllocator();
23 SurfaceId GenerateId();
25 static uint32_t NamespaceForId(SurfaceId id);
27 // This needs to be called before any sequences with this allocator's
28 // namespace will be used to enforce destruction dependencies.
29 // When this SurfaceIdAllocator is destroyed, its namespace is
30 // automatically invalidated and any remaining sequences with that
31 // namespace will be ignored. This method does not need to be called in
32 // contexts where there is no SurfaceManager (e.g. a renderer process).
33 void RegisterSurfaceIdNamespace(SurfaceManager* manager);
35 uint32_t id_namespace() const { return id_namespace_; }
37 private:
38 const uint32_t id_namespace_;
39 uint32_t next_id_;
40 SurfaceManager* manager_;
42 DISALLOW_COPY_AND_ASSIGN(SurfaceIdAllocator);
45 } // namespace cc
47 #endif // CC_SURFACES_SURFACE_ID_ALLOCATOR_H_