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

Side by Side Diff: content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.cc

Issue 470973002: gpu: Remove WebGraphicsContext3D::makeContextCurrent() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use scoped_ptr and remove unrelated changes. Created 6 years, 4 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 "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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 << command_buffer_->GetLastError(); 220 << command_buffer_->GetLastError();
221 // Initialize the command buffer. 221 // Initialize the command buffer.
222 bool result = command_buffer_->Initialize(); 222 bool result = command_buffer_->Initialize();
223 LOG_IF(ERROR, !result) << "CommandBufferProxy::Initialize failed."; 223 LOG_IF(ERROR, !result) << "CommandBufferProxy::Initialize failed.";
224 return result; 224 return result;
225 } 225 }
226 226
227 bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) { 227 bool WebGraphicsContext3DCommandBufferImpl::CreateContext(bool onscreen) {
228 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext"); 228 TRACE_EVENT0("gpu", "WebGfxCtx3DCmdBfrImpl::CreateContext");
229 // Ensure the gles2 library is initialized first in a thread safe way. 229 // Ensure the gles2 library is initialized first in a thread safe way.
230 g_gles2_initializer.Get(); 230 g_gles2_initializer.Get();
piman 2014/08/15 17:47:34 If we move out the ::gles2::SetGLContext, then we
231 231
232 scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group; 232 scoped_refptr<gpu::gles2::ShareGroup> gles2_share_group;
233 233
234 scoped_ptr<base::AutoLock> share_group_lock; 234 scoped_ptr<base::AutoLock> share_group_lock;
235 bool add_to_share_group = false; 235 bool add_to_share_group = false;
236 if (!command_buffer_) { 236 if (!command_buffer_) {
237 WebGraphicsContext3DCommandBufferImpl* share_context = NULL; 237 WebGraphicsContext3DCommandBufferImpl* share_context = NULL;
238 238
239 share_group_lock.reset(new base::AutoLock(share_group_->lock())); 239 share_group_lock.reset(new base::AutoLock(share_group_->lock()));
240 share_context = share_group_->GetAnyContextLocked(); 240 share_context = share_group_->GetAnyContextLocked();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 share_group_->AddContextLocked(this); 289 share_group_->AddContextLocked(this);
290 290
291 if (CommandLine::ForCurrentProcess()->HasSwitch( 291 if (CommandLine::ForCurrentProcess()->HasSwitch(
292 switches::kEnableGpuClientTracing)) { 292 switches::kEnableGpuClientTracing)) {
293 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface())); 293 trace_gl_.reset(new gpu::gles2::GLES2TraceImplementation(GetGLInterface()));
294 setGLInterface(trace_gl_.get()); 294 setGLInterface(trace_gl_.get());
295 } 295 }
296 return true; 296 return true;
297 } 297 }
298 298
299 bool WebGraphicsContext3DCommandBufferImpl::makeContextCurrent() { 299 bool WebGraphicsContext3DCommandBufferImpl::BindToCurrentThread() {
300 if (!MaybeInitializeGL()) { 300 if (!MaybeInitializeGL()) {
301 DLOG(ERROR) << "Failed to initialize context."; 301 DLOG(ERROR) << "Failed to initialize context.";
302 return false; 302 return false;
303 } 303 }
304 gles2::SetGLContext(GetGLInterface());
305 if (gpu::error::IsError(command_buffer_->GetLastError())) { 304 if (gpu::error::IsError(command_buffer_->GetLastError())) {
306 LOG(ERROR) << "Context dead on arrival. Last error: " 305 LOG(ERROR) << "Context dead on arrival. Last error: "
307 << command_buffer_->GetLastError(); 306 << command_buffer_->GetLastError();
308 return false; 307 return false;
309 } 308 }
310 309
311 return true; 310 return true;
312 } 311 }
313 312
314 void WebGraphicsContext3DCommandBufferImpl::Destroy() { 313 void WebGraphicsContext3DCommandBufferImpl::Destroy() {
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 share_group_->RemoveAllContexts(); 421 share_group_->RemoveAllContexts();
423 422
424 DCHECK(host_.get()); 423 DCHECK(host_.get());
425 { 424 {
426 base::AutoLock lock(g_default_share_groups_lock.Get()); 425 base::AutoLock lock(g_default_share_groups_lock.Get());
427 g_default_share_groups.Get().erase(host_.get()); 426 g_default_share_groups.Get().erase(host_.get());
428 } 427 }
429 } 428 }
430 429
431 } // namespace content 430 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698