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

Side by Side Diff: gpu/command_buffer/service/client_service_map.h

Issue 2317363005: Add basic GL functionality to the passthrough command buffer. (Closed)
Patch Set: Handle bind_generates_resource Created 4 years, 3 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
« no previous file with comments | « gpu/command_buffer/service/BUILD.gn ('k') | gpu/command_buffer/service/context_group.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016 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 #ifndef GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
6 #define GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
7
8 #include <limits>
9 #include <unordered_map>
10
11 namespace gpu {
12
13 namespace gles2 {
14
15 template <typename ClientType, typename ServiceType>
16 class ClientServiceMap {
17 public:
18 ClientServiceMap() : client_to_service_() {}
19
20 void SetIDMapping(ClientType client_id, ServiceType service_id) {
21 DCHECK(client_to_service_.find(client_id) == client_to_service_.end());
22 DCHECK(service_id != invalid_service_id());
23 client_to_service_[client_id] = service_id;
24 }
25
26 void RemoveClientID(ClientType client_id) {
27 client_to_service_.erase(client_id);
28 }
29
30 void Clear() { client_to_service_.clear(); }
31
32 bool GetServiceID(ClientType client_id, ServiceType* service_id) const {
33 if (client_id == 0) {
34 if (service_id) {
35 *service_id = 0;
36 }
37 return true;
38 }
39 auto iter = client_to_service_.find(client_id);
40 if (iter != client_to_service_.end()) {
41 if (service_id) {
42 *service_id = iter->second;
43 }
44 return true;
45 }
46 return false;
47 }
48
49 ServiceType GetServiceIDOrInvalid(ClientType client_id) {
50 ServiceType service_id;
51 if (GetServiceID(client_id, &service_id)) {
52 return service_id;
53 }
54 return invalid_service_id();
55 }
56
57 ServiceType invalid_service_id() const {
58 return std::numeric_limits<ServiceType>::max();
59 }
60
61 typedef typename std::unordered_map<ClientType, ServiceType>::const_iterator
62 const_iterator;
63 const_iterator begin() const { return client_to_service_.begin(); }
64 const_iterator end() const { return client_to_service_.end(); }
65
66 private:
67 std::unordered_map<ClientType, ServiceType> client_to_service_;
68 };
69
70 } // namespace gles2
71 } // namespace gpu
72
73 #endif // GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/BUILD.gn ('k') | gpu/command_buffer/service/context_group.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698