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 "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" | 5 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
6 | 6 |
7 #include "third_party/khronos/GLES2/gl2.h" | 7 #include "third_party/khronos/GLES2/gl2.h" |
8 #ifndef GL_GLEXT_PROTOTYPES | 8 #ifndef GL_GLEXT_PROTOTYPES |
9 #define GL_GLEXT_PROTOTYPES 1 | 9 #define GL_GLEXT_PROTOTYPES 1 |
10 #endif | 10 #endif |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 share_group_ = share_context->share_group_; | 112 share_group_ = share_context->share_group_; |
113 } else if (share_resources) { | 113 } else if (share_resources) { |
114 share_group_ = GetDefaultShareGroupForHost(host); | 114 share_group_ = GetDefaultShareGroupForHost(host); |
115 } else { | 115 } else { |
116 share_group_ = make_scoped_refptr(new ShareGroup); | 116 share_group_ = make_scoped_refptr(new ShareGroup); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 WebGraphicsContext3DCommandBufferImpl:: | 120 WebGraphicsContext3DCommandBufferImpl:: |
121 ~WebGraphicsContext3DCommandBufferImpl() { | 121 ~WebGraphicsContext3DCommandBufferImpl() { |
122 if (real_gl_) { | 122 if (real_gl_) |
123 real_gl_->SetErrorMessageCallback( | |
124 base::Callback<void(const char*, int32_t)>()); | |
125 real_gl_->SetLostContextCallback(base::Closure()); | 123 real_gl_->SetLostContextCallback(base::Closure()); |
126 } | |
127 | 124 |
128 Destroy(); | 125 Destroy(); |
129 } | 126 } |
130 | 127 |
131 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { | 128 bool WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL() { |
132 if (initialized_) | 129 if (initialized_) |
133 return true; | 130 return true; |
134 | 131 |
135 if (initialize_failed_) | 132 if (initialize_failed_) |
136 return false; | 133 return false; |
137 | 134 |
138 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); | 135 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::MaybeInitializeGL"); |
139 | 136 |
140 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. | 137 // TODO(vadimt): Remove ScopedTracker below once crbug.com/125248 is fixed. |
141 tracked_objects::ScopedTracker tracking_profile( | 138 tracked_objects::ScopedTracker tracking_profile( |
142 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 139 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
143 "125248 WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL")); | 140 "125248 WebGraphicsContext3DCommandBufferImpl::MaybeInitializeGL")); |
144 | 141 |
145 if (!CreateContext()) { | 142 if (!CreateContext()) { |
146 Destroy(); | 143 Destroy(); |
147 | 144 |
148 initialize_failed_ = true; | 145 initialize_failed_ = true; |
149 return false; | 146 return false; |
150 } | 147 } |
151 | 148 |
152 real_gl_->SetErrorMessageCallback( | |
153 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnErrorMessage, | |
154 // The callback is unset in the destructor. | |
155 base::Unretained(this))); | |
156 real_gl_->SetLostContextCallback( | 149 real_gl_->SetLostContextCallback( |
157 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, | 150 base::Bind(&WebGraphicsContext3DCommandBufferImpl::OnContextLost, |
158 // The callback is unset in the destructor. | 151 // The callback is unset in the destructor. |
159 base::Unretained(this))); | 152 base::Unretained(this))); |
160 | 153 |
161 real_gl_->TraceBeginCHROMIUM("WebGraphicsContext3D", | 154 real_gl_->TraceBeginCHROMIUM("WebGraphicsContext3D", |
162 "CommandBufferContext"); | 155 "CommandBufferContext"); |
163 | 156 |
164 initialized_ = true; | 157 initialized_ = true; |
165 return true; | 158 return true; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 DCHECK(host_.get()); | 350 DCHECK(host_.get()); |
358 { | 351 { |
359 base::AutoLock lock(g_default_share_groups_lock.Get()); | 352 base::AutoLock lock(g_default_share_groups_lock.Get()); |
360 g_default_share_groups.Get().erase(host_.get()); | 353 g_default_share_groups.Get().erase(host_.get()); |
361 } | 354 } |
362 | 355 |
363 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 356 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
364 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); | 357 UmaRecordContextLost(context_type_, state.error, state.context_lost_reason); |
365 } | 358 } |
366 | 359 |
367 void WebGraphicsContext3DCommandBufferImpl::OnErrorMessage(const char* message, | |
368 int id) { | |
369 if (error_message_callback_) { | |
370 blink::WebString str = blink::WebString::fromUTF8(message); | |
371 error_message_callback_->onErrorMessage(str, id); | |
372 } | |
373 } | |
374 | |
375 } // namespace content | 360 } // namespace content |
OLD | NEW |