| 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 18 matching lines...) Expand all Loading... |
| 29 ContextGroup::ContextGroup( | 29 ContextGroup::ContextGroup( |
| 30 const scoped_refptr<MailboxManager>& mailbox_manager, | 30 const scoped_refptr<MailboxManager>& mailbox_manager, |
| 31 const scoped_refptr<MemoryTracker>& memory_tracker, | 31 const scoped_refptr<MemoryTracker>& memory_tracker, |
| 32 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, | 32 const scoped_refptr<ShaderTranslatorCache>& shader_translator_cache, |
| 33 const scoped_refptr<FramebufferCompletenessCache>& | 33 const scoped_refptr<FramebufferCompletenessCache>& |
| 34 framebuffer_completeness_cache, | 34 framebuffer_completeness_cache, |
| 35 const scoped_refptr<FeatureInfo>& feature_info, | 35 const scoped_refptr<FeatureInfo>& feature_info, |
| 36 const scoped_refptr<SubscriptionRefSet>& subscription_ref_set, | 36 const scoped_refptr<SubscriptionRefSet>& subscription_ref_set, |
| 37 const scoped_refptr<ValueStateMap>& pending_valuebuffer_state, | 37 const scoped_refptr<ValueStateMap>& pending_valuebuffer_state, |
| 38 bool bind_generates_resource) | 38 bool bind_generates_resource) |
| 39 : context_type_(CONTEXT_TYPE_UNDEFINED), | 39 : context_type_(CONTEXT_TYPE_OPENGLES2), |
| 40 mailbox_manager_(mailbox_manager), | 40 mailbox_manager_(mailbox_manager), |
| 41 memory_tracker_(memory_tracker), | 41 memory_tracker_(memory_tracker), |
| 42 shader_translator_cache_(shader_translator_cache), | 42 shader_translator_cache_(shader_translator_cache), |
| 43 #if defined(OS_MACOSX) | 43 #if defined(OS_MACOSX) |
| 44 // Framebuffer completeness is not cacheable on OS X because of dynamic | 44 // Framebuffer completeness is not cacheable on OS X because of dynamic |
| 45 // graphics switching. | 45 // graphics switching. |
| 46 // http://crbug.com/180876 | 46 // http://crbug.com/180876 |
| 47 // TODO(tobiasjs): determine whether GPU switching is possible | 47 // TODO(tobiasjs): determine whether GPU switching is possible |
| 48 // programmatically, rather than just hardcoding this behaviour | 48 // programmatically, rather than just hardcoding this behaviour |
| 49 // for OS X. | 49 // for OS X. |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); | 82 transfer_buffer_manager_ = new TransferBufferManager(memory_tracker_.get()); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 | 85 |
| 86 static void GetIntegerv(GLenum pname, uint32* var) { | 86 static void GetIntegerv(GLenum pname, uint32* var) { |
| 87 GLint value = 0; | 87 GLint value = 0; |
| 88 glGetIntegerv(pname, &value); | 88 glGetIntegerv(pname, &value); |
| 89 *var = value; | 89 *var = value; |
| 90 } | 90 } |
| 91 | 91 |
| 92 // static | |
| 93 ContextGroup::ContextType ContextGroup::GetContextType( | |
| 94 unsigned webgl_version) { | |
| 95 switch (webgl_version) { | |
| 96 case 0: | |
| 97 return CONTEXT_TYPE_OTHER; | |
| 98 case 1: | |
| 99 return CONTEXT_TYPE_WEBGL1; | |
| 100 case 2: | |
| 101 return CONTEXT_TYPE_WEBGL2; | |
| 102 default: | |
| 103 return CONTEXT_TYPE_UNDEFINED; | |
| 104 } | |
| 105 } | |
| 106 | |
| 107 bool ContextGroup::Initialize( | 92 bool ContextGroup::Initialize( |
| 108 GLES2Decoder* decoder, | 93 GLES2Decoder* decoder, |
| 109 ContextGroup::ContextType context_type, | 94 ContextGroup::ContextType context_type, |
| 110 const DisallowedFeatures& disallowed_features) { | 95 const DisallowedFeatures& disallowed_features) { |
| 111 if (context_type == CONTEXT_TYPE_UNDEFINED) { | 96 if (!HaveContexts()) { |
| 112 LOG(ERROR) << "ContextGroup::Initialize failed because of unknown " | |
| 113 << "context type."; | |
| 114 return false; | |
| 115 } | |
| 116 if (context_type_ == CONTEXT_TYPE_UNDEFINED) { | |
| 117 context_type_ = context_type; | 97 context_type_ = context_type; |
| 118 } else if (context_type_ != context_type) { | 98 } else if (context_type_ != context_type) { |
| 119 LOG(ERROR) << "ContextGroup::Initialize failed because the type of " | 99 LOG(ERROR) << "ContextGroup::Initialize failed because the type of " |
| 120 << "the context does not fit with the group."; | 100 << "the context does not fit with the group."; |
| 121 return false; | 101 return false; |
| 122 } | 102 } |
| 123 | 103 |
| 124 // If we've already initialized the group just add the context. | 104 // If we've already initialized the group just add the context. |
| 125 if (HaveContexts()) { | 105 if (HaveContexts()) { |
| 126 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder)); | 106 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder)); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 GLuint client_id, GLuint* service_id) const { | 446 GLuint client_id, GLuint* service_id) const { |
| 467 Buffer* buffer = buffer_manager_->GetBuffer(client_id); | 447 Buffer* buffer = buffer_manager_->GetBuffer(client_id); |
| 468 if (!buffer) | 448 if (!buffer) |
| 469 return false; | 449 return false; |
| 470 *service_id = buffer->service_id(); | 450 *service_id = buffer->service_id(); |
| 471 return true; | 451 return true; |
| 472 } | 452 } |
| 473 | 453 |
| 474 } // namespace gles2 | 454 } // namespace gles2 |
| 475 } // namespace gpu | 455 } // namespace gpu |
| OLD | NEW |