Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Side by Side Diff: cc/surfaces/surface_id_allocator.cc

Issue 1996783002: Make cc::SurfaceId unguessable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed more build targets Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/surfaces/surface_id_allocator.h" 5 #include "cc/surfaces/surface_id_allocator.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 10
11 namespace cc { 11 namespace cc {
12 12
13 SurfaceIdAllocator::SurfaceIdAllocator(uint32_t id_namespace) 13 SurfaceIdAllocator::SurfaceIdAllocator(uint32_t id_namespace)
14 : id_namespace_(id_namespace), next_id_(1u), manager_(nullptr) { 14 : id_namespace_(id_namespace), next_id_(1u), manager_(nullptr) {
15 } 15 }
16 16
17 void SurfaceIdAllocator::RegisterSurfaceIdNamespace(SurfaceManager* manager) { 17 void SurfaceIdAllocator::RegisterSurfaceIdNamespace(SurfaceManager* manager) {
18 DCHECK(!manager_); 18 DCHECK(!manager_);
19 manager_ = manager; 19 manager_ = manager;
20 manager_->RegisterSurfaceIdNamespace(id_namespace_); 20 manager_->RegisterSurfaceIdNamespace(id_namespace_);
21 } 21 }
22 22
23 SurfaceIdAllocator::~SurfaceIdAllocator() { 23 SurfaceIdAllocator::~SurfaceIdAllocator() {
24 if (manager_) 24 if (manager_)
25 manager_->InvalidateSurfaceIdNamespace(id_namespace_); 25 manager_->InvalidateSurfaceIdNamespace(id_namespace_);
26 } 26 }
27 27
28 SurfaceId SurfaceIdAllocator::GenerateId() { 28 SurfaceId SurfaceIdAllocator::GenerateId() {
29 SurfaceId id(static_cast<uint64_t>(id_namespace_) << 32 | next_id_); 29 SurfaceId id(id_namespace_, next_id_);
30 next_id_++; 30 next_id_++;
31 return id; 31 return id;
32 } 32 }
33 33
34 // static 34 // static
35 uint32_t SurfaceIdAllocator::NamespaceForId(SurfaceId id) { 35 uint32_t SurfaceIdAllocator::NamespaceForId(SurfaceId id) {
36 return id.id >> 32; 36 return id.id_namespace;
37 } 37 }
38 38
39 } // namespace cc 39 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698