| 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 "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" | 5 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" |
| 6 | 6 |
| 7 #include <GLES2/gl2.h> | 7 #include <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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 LAZY_INSTANCE_INITIALIZER; | 261 LAZY_INSTANCE_INITIALIZER; |
| 262 | 262 |
| 263 static base::LazyInstance< | 263 static base::LazyInstance< |
| 264 std::set<GLInProcessContext*> > | 264 std::set<GLInProcessContext*> > |
| 265 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER; | 265 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER; |
| 266 | 266 |
| 267 static bool g_use_virtualized_gl_context = false; | 267 static bool g_use_virtualized_gl_context = false; |
| 268 | 268 |
| 269 namespace { | 269 namespace { |
| 270 | 270 |
| 271 // Also calls DetachFromThread on all GLES2Decoders before the lock is released | 271 // Also calls DetachFromThreadHack on all GLES2Decoders before the lock is |
| 272 // to maintain the invariant that all decoders are unbounded while the lock is | 272 // released to maintain the invariant that all decoders are unbound while the |
| 273 // not held. This is to workaround DumpRenderTree uses WGC3DIPCBI with shared | 273 // lock is not held. This is to workaround DumpRenderTree using WGC3DIPCBI with |
| 274 // resources on different threads. | 274 // shared resources on different threads. |
| 275 // Remove this as part of crbug.com/234964. |
| 275 class AutoLockAndDecoderDetachThread { | 276 class AutoLockAndDecoderDetachThread { |
| 276 public: | 277 public: |
| 277 AutoLockAndDecoderDetachThread(base::Lock& lock, | 278 AutoLockAndDecoderDetachThread(base::Lock& lock, |
| 278 const std::set<GLInProcessContext*>& contexts); | 279 const std::set<GLInProcessContext*>& contexts); |
| 279 ~AutoLockAndDecoderDetachThread(); | 280 ~AutoLockAndDecoderDetachThread(); |
| 280 | 281 |
| 281 private: | 282 private: |
| 282 base::AutoLock auto_lock_; | 283 base::AutoLock auto_lock_; |
| 283 const std::set<GLInProcessContext*>& contexts_; | 284 const std::set<GLInProcessContext*>& contexts_; |
| 284 }; | 285 }; |
| 285 | 286 |
| 286 AutoLockAndDecoderDetachThread::AutoLockAndDecoderDetachThread( | 287 AutoLockAndDecoderDetachThread::AutoLockAndDecoderDetachThread( |
| 287 base::Lock& lock, | 288 base::Lock& lock, |
| 288 const std::set<GLInProcessContext*>& contexts) | 289 const std::set<GLInProcessContext*>& contexts) |
| 289 : auto_lock_(lock), | 290 : auto_lock_(lock), |
| 290 contexts_(contexts) { | 291 contexts_(contexts) { |
| 291 } | 292 } |
| 292 | 293 |
| 293 void DetachThread(GLInProcessContext* context) { | 294 void DetachThread(GLInProcessContext* context) { |
| 294 if (context->GetDecoder()) | 295 if (context->GetDecoder()) |
| 295 context->GetDecoder()->DetachFromThread(); | 296 context->GetDecoder()->DetachFromThreadHack(); |
| 296 } | 297 } |
| 297 | 298 |
| 298 AutoLockAndDecoderDetachThread::~AutoLockAndDecoderDetachThread() { | 299 AutoLockAndDecoderDetachThread::~AutoLockAndDecoderDetachThread() { |
| 299 std::for_each(contexts_.begin(), | 300 std::for_each(contexts_.begin(), |
| 300 contexts_.end(), | 301 contexts_.end(), |
| 301 &DetachThread); | 302 &DetachThread); |
| 302 } | 303 } |
| 303 | 304 |
| 304 static WebGraphicsContext3DInProcessCommandBufferImpl::GpuMemoryBufferCreator* | 305 static WebGraphicsContext3DInProcessCommandBufferImpl::GpuMemoryBufferCreator* |
| 305 g_gpu_memory_buffer_creator = NULL; | 306 g_gpu_memory_buffer_creator = NULL; |
| (...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1980 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, | 1981 DELEGATE_TO_GL_1(waitAsyncTexImage2DCHROMIUM, WaitAsyncTexImage2DCHROMIUM, |
| 1981 WGC3Denum) | 1982 WGC3Denum) |
| 1982 | 1983 |
| 1983 void WebGraphicsContext3DInProcessCommandBufferImpl::SetGpuMemoryBufferCreator( | 1984 void WebGraphicsContext3DInProcessCommandBufferImpl::SetGpuMemoryBufferCreator( |
| 1984 GpuMemoryBufferCreator* creator) { | 1985 GpuMemoryBufferCreator* creator) { |
| 1985 g_gpu_memory_buffer_creator = creator; | 1986 g_gpu_memory_buffer_creator = creator; |
| 1986 } | 1987 } |
| 1987 | 1988 |
| 1988 } // namespace gpu | 1989 } // namespace gpu |
| 1989 } // namespace webkit | 1990 } // namespace webkit |
| OLD | NEW |