OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "gpu/command_buffer/service/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 namespace gles2 { | 28 namespace gles2 { |
29 | 29 |
30 ContextGroup::ContextGroup( | 30 ContextGroup::ContextGroup( |
31 const scoped_refptr<MailboxManager>& mailbox_manager, | 31 const scoped_refptr<MailboxManager>& mailbox_manager, |
32 const scoped_refptr<MemoryTracker>& memory_tracker, | 32 const scoped_refptr<MemoryTracker>& memory_tracker, |
33 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, | 33 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, |
34 const scoped_refptr<FeatureInfo>& feature_info, | 34 const scoped_refptr<FeatureInfo>& feature_info, |
35 const scoped_refptr<SubscriptionRefSet>& subscription_ref_set, | 35 const scoped_refptr<SubscriptionRefSet>& subscription_ref_set, |
36 const scoped_refptr<ValueStateMap>& pending_valuebuffer_state, | 36 const scoped_refptr<ValueStateMap>& pending_valuebuffer_state, |
37 bool bind_generates_resource) | 37 bool bind_generates_resource) |
38 : mailbox_manager_(mailbox_manager), | 38 : context_type_(kContextTypeUndefined), |
| 39 mailbox_manager_(mailbox_manager), |
39 memory_tracker_(memory_tracker), | 40 memory_tracker_(memory_tracker), |
40 shader_translator_cache_(shader_translator_cache), | 41 shader_translator_cache_(shader_translator_cache), |
41 subscription_ref_set_(subscription_ref_set), | 42 subscription_ref_set_(subscription_ref_set), |
42 pending_valuebuffer_state_(pending_valuebuffer_state), | 43 pending_valuebuffer_state_(pending_valuebuffer_state), |
43 enforce_gl_minimums_(base::CommandLine::ForCurrentProcess()->HasSwitch( | 44 enforce_gl_minimums_(base::CommandLine::ForCurrentProcess()->HasSwitch( |
44 switches::kEnforceGLMinimums)), | 45 switches::kEnforceGLMinimums)), |
45 bind_generates_resource_(bind_generates_resource), | 46 bind_generates_resource_(bind_generates_resource), |
46 max_vertex_attribs_(0u), | 47 max_vertex_attribs_(0u), |
47 max_texture_units_(0u), | 48 max_texture_units_(0u), |
48 max_texture_image_units_(0u), | 49 max_texture_image_units_(0u), |
(...skipping 20 matching lines...) Expand all Loading... |
69 manager->Initialize(); | 70 manager->Initialize(); |
70 } | 71 } |
71 } | 72 } |
72 | 73 |
73 static void GetIntegerv(GLenum pname, uint32* var) { | 74 static void GetIntegerv(GLenum pname, uint32* var) { |
74 GLint value = 0; | 75 GLint value = 0; |
75 glGetIntegerv(pname, &value); | 76 glGetIntegerv(pname, &value); |
76 *var = value; | 77 *var = value; |
77 } | 78 } |
78 | 79 |
| 80 // static |
| 81 ContextGroup::ContextType ContextGroup::GetContextType( |
| 82 unsigned webgl_version) { |
| 83 switch (webgl_version) { |
| 84 case 0: |
| 85 return kContextTypeOther; |
| 86 case 1: |
| 87 return kContextTypeWebGL1; |
| 88 case 2: |
| 89 return kContextTypeWebGL2; |
| 90 default: |
| 91 return kContextTypeUndefined; |
| 92 } |
| 93 } |
| 94 |
79 bool ContextGroup::Initialize( | 95 bool ContextGroup::Initialize( |
80 GLES2Decoder* decoder, | 96 GLES2Decoder* decoder, |
| 97 ContextGroup::ContextType context_type, |
81 const DisallowedFeatures& disallowed_features) { | 98 const DisallowedFeatures& disallowed_features) { |
| 99 if (context_type == kContextTypeUndefined) { |
| 100 LOG(ERROR) << "ContextGroup::Initialize failed because of unknown " |
| 101 << "context type."; |
| 102 return false; |
| 103 } |
| 104 if (context_type_ == kContextTypeUndefined) { |
| 105 context_type_ = context_type; |
| 106 } else if (context_type_ != context_type) { |
| 107 LOG(ERROR) << "ContextGroup::Initialize failed because the type of " |
| 108 << "the context does not fit with the group."; |
| 109 return false; |
| 110 } |
| 111 |
82 // If we've already initialized the group just add the context. | 112 // If we've already initialized the group just add the context. |
83 if (HaveContexts()) { | 113 if (HaveContexts()) { |
84 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder)); | 114 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder)); |
85 return true; | 115 return true; |
86 } | 116 } |
87 | 117 |
88 if (!feature_info_->Initialize(disallowed_features)) { | 118 if (!feature_info_->Initialize(disallowed_features)) { |
89 LOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo " | 119 LOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo " |
90 << "initialization failed."; | 120 << "initialization failed."; |
91 return false; | 121 return false; |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 GLuint client_id, GLuint* service_id) const { | 445 GLuint client_id, GLuint* service_id) const { |
416 Buffer* buffer = buffer_manager_->GetBuffer(client_id); | 446 Buffer* buffer = buffer_manager_->GetBuffer(client_id); |
417 if (!buffer) | 447 if (!buffer) |
418 return false; | 448 return false; |
419 *service_id = buffer->service_id(); | 449 *service_id = buffer->service_id(); |
420 return true; | 450 return true; |
421 } | 451 } |
422 | 452 |
423 } // namespace gles2 | 453 } // namespace gles2 |
424 } // namespace gpu | 454 } // namespace gpu |
OLD | NEW |