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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gpu/command_buffer/service/client_service_map.h
diff --git a/gpu/command_buffer/service/client_service_map.h b/gpu/command_buffer/service/client_service_map.h
new file mode 100644
index 0000000000000000000000000000000000000000..b28f1f7b48677b6664152e602ea120b2f6daaf7d
--- /dev/null
+++ b/gpu/command_buffer/service/client_service_map.h
@@ -0,0 +1,73 @@
+// Copyright (c) 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
+#define GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
+
+#include <limits>
+#include <unordered_map>
+
+namespace gpu {
+
+namespace gles2 {
+
+template <typename ClientType, typename ServiceType>
+class ClientServiceMap {
+ public:
+ ClientServiceMap() : client_to_service_() {}
+
+ void SetIDMapping(ClientType client_id, ServiceType service_id) {
+ DCHECK(client_to_service_.find(client_id) == client_to_service_.end());
+ DCHECK(service_id != invalid_service_id());
+ client_to_service_[client_id] = service_id;
+ }
+
+ void RemoveClientID(ClientType client_id) {
+ client_to_service_.erase(client_id);
+ }
+
+ void Clear() { client_to_service_.clear(); }
+
+ bool GetServiceID(ClientType client_id, ServiceType* service_id) const {
+ if (client_id == 0) {
+ if (service_id) {
+ *service_id = 0;
+ }
+ return true;
+ }
+ auto iter = client_to_service_.find(client_id);
+ if (iter != client_to_service_.end()) {
+ if (service_id) {
+ *service_id = iter->second;
+ }
+ return true;
+ }
+ return false;
+ }
+
+ ServiceType GetServiceIDOrInvalid(ClientType client_id) {
+ ServiceType service_id;
+ if (GetServiceID(client_id, &service_id)) {
+ return service_id;
+ }
+ return invalid_service_id();
+ }
+
+ ServiceType invalid_service_id() const {
+ return std::numeric_limits<ServiceType>::max();
+ }
+
+ typedef typename std::unordered_map<ClientType, ServiceType>::const_iterator
+ const_iterator;
+ const_iterator begin() const { return client_to_service_.begin(); }
+ const_iterator end() const { return client_to_service_.end(); }
+
+ private:
+ std::unordered_map<ClientType, ServiceType> client_to_service_;
+};
+
+} // namespace gles2
+} // namespace gpu
+
+#endif // GPU_COMMAND_BUFFER_SERVICE_CLIENT_SERVICE_MAP_H_
« 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