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

Side by Side Diff: gpu/command_buffer/service/context_group.cc

Issue 1325433003: command_buffer: Add support for creating non-WebGL ES 3 contexts (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: missing hunk Created 5 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
OLDNEW
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
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
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 92 bool ContextGroup::Initialize(GLES2Decoder* decoder,
93 ContextGroup::ContextType ContextGroup::GetContextType( 93 ContextType context_type,
94 unsigned webgl_version) { 94 const DisallowedFeatures& disallowed_features) {
95 switch (webgl_version) { 95 if (!HaveContexts()) {
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(
108 GLES2Decoder* decoder,
109 ContextGroup::ContextType context_type,
110 const DisallowedFeatures& disallowed_features) {
111 if (context_type == CONTEXT_TYPE_UNDEFINED) {
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; 96 context_type_ = context_type;
118 } else if (context_type_ != context_type) { 97 } else if (context_type_ != context_type) {
119 LOG(ERROR) << "ContextGroup::Initialize failed because the type of " 98 LOG(ERROR) << "ContextGroup::Initialize failed because the type of "
120 << "the context does not fit with the group."; 99 << "the context does not fit with the group.";
121 return false; 100 return false;
122 } 101 }
123 102
124 // If we've already initialized the group just add the context. 103 // If we've already initialized the group just add the context.
125 if (HaveContexts()) { 104 if (HaveContexts()) {
126 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder)); 105 decoders_.push_back(base::AsWeakPtr<GLES2Decoder>(decoder));
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 GLuint client_id, GLuint* service_id) const { 445 GLuint client_id, GLuint* service_id) const {
467 Buffer* buffer = buffer_manager_->GetBuffer(client_id); 446 Buffer* buffer = buffer_manager_->GetBuffer(client_id);
468 if (!buffer) 447 if (!buffer)
469 return false; 448 return false;
470 *service_id = buffer->service_id(); 449 *service_id = buffer->service_id();
471 return true; 450 return true;
472 } 451 }
473 452
474 } // namespace gles2 453 } // namespace gles2
475 } // namespace gpu 454 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/context_group.h ('k') | gpu/command_buffer/service/context_group_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698