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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc

Issue 8491043: Allow linker initialization of lazy instance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: willchan comments + rebase Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | webkit/plugins/npapi/plugin_list.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" 7 #include "webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h"
8 8
9 #include <GLES2/gl2.h> 9 #include <GLES2/gl2.h>
10 #ifndef GL_GLEXT_PROTOTYPES 10 #ifndef GL_GLEXT_PROTOTYPES
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 201
202 namespace { 202 namespace {
203 203
204 const int32 kCommandBufferSize = 1024 * 1024; 204 const int32 kCommandBufferSize = 1024 * 1024;
205 // TODO(kbr): make the transfer buffer size configurable via context 205 // TODO(kbr): make the transfer buffer size configurable via context
206 // creation attributes. 206 // creation attributes.
207 const int32 kTransferBufferSize = 1024 * 1024; 207 const int32 kTransferBufferSize = 1024 * 1024;
208 208
209 static base::LazyInstance< 209 static base::LazyInstance<
210 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> > 210 std::set<WebGraphicsContext3DInProcessCommandBufferImpl*> >
211 g_all_shared_contexts(base::LINKER_INITIALIZED); 211 g_all_shared_contexts = LAZY_INSTANCE_INITIALIZER;
212 static base::LazyInstance<base::Lock, 212 static base::LazyInstance<base::Lock,
213 base::LeakyLazyInstanceTraits<base::Lock> > 213 base::LeakyLazyInstanceTraits<base::Lock> >
214 g_all_shared_contexts_lock(base::LINKER_INITIALIZED); 214 g_all_shared_contexts_lock = LAZY_INSTANCE_INITIALIZER;
215 215
216 // Singleton used to initialize and terminate the gles2 library. 216 // Singleton used to initialize and terminate the gles2 library.
217 class GLES2Initializer { 217 class GLES2Initializer {
218 public: 218 public:
219 GLES2Initializer() { 219 GLES2Initializer() {
220 gles2::Initialize(); 220 gles2::Initialize();
221 } 221 }
222 222
223 ~GLES2Initializer() { 223 ~GLES2Initializer() {
224 gles2::Terminate(); 224 gles2::Terminate();
225 } 225 }
226 226
227 private: 227 private:
228 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer); 228 DISALLOW_COPY_AND_ASSIGN(GLES2Initializer);
229 }; 229 };
230 230
231 //////////////////////////////////////////////////////////////////////////////// 231 ////////////////////////////////////////////////////////////////////////////////
232 232
233 static base::LazyInstance<GLES2Initializer> g_gles2_initializer( 233 static base::LazyInstance<GLES2Initializer> g_gles2_initializer =
234 base::LINKER_INITIALIZED); 234 LAZY_INSTANCE_INITIALIZER;
235 235
236 } // namespace anonymous 236 } // namespace anonymous
237 237
238 GLInProcessContext::~GLInProcessContext() { 238 GLInProcessContext::~GLInProcessContext() {
239 Destroy(); 239 Destroy();
240 } 240 }
241 241
242 GLInProcessContext* GLInProcessContext::CreateViewContext( 242 GLInProcessContext* GLInProcessContext::CreateViewContext(
243 gfx::PluginWindowHandle render_surface, 243 gfx::PluginWindowHandle render_surface,
244 GLInProcessContext* context_group, 244 GLInProcessContext* context_group,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 #else 290 #else
291 return NULL; 291 return NULL;
292 #endif 292 #endif
293 } 293 }
294 294
295 // In the normal command buffer implementation, all commands are passed over IPC 295 // In the normal command buffer implementation, all commands are passed over IPC
296 // to the gpu process where they are fed to the GLES2Decoder from a single 296 // to the gpu process where they are fed to the GLES2Decoder from a single
297 // thread. In layout tests, any thread could call this function. GLES2Decoder, 297 // thread. In layout tests, any thread could call this function. GLES2Decoder,
298 // and in particular the GL implementations behind it, are not generally 298 // and in particular the GL implementations behind it, are not generally
299 // threadsafe, so we guard entry points with a mutex. 299 // threadsafe, so we guard entry points with a mutex.
300 static base::LazyInstance<base::Lock> 300 static base::LazyInstance<base::Lock> g_decoder_lock =
301 g_decoder_lock(base::LINKER_INITIALIZED); 301 LAZY_INSTANCE_INITIALIZER;
302 302
303 void GLInProcessContext::PumpCommands() { 303 void GLInProcessContext::PumpCommands() {
304 base::AutoLock lock(g_decoder_lock.Get()); 304 base::AutoLock lock(g_decoder_lock.Get());
305 decoder_->MakeCurrent(); 305 decoder_->MakeCurrent();
306 gpu_scheduler_->PutChanged(); 306 gpu_scheduler_->PutChanged();
307 ::gpu::CommandBuffer::State state = command_buffer_->GetState(); 307 ::gpu::CommandBuffer::State state = command_buffer_->GetState();
308 CHECK(state.error == ::gpu::error::kNoError); 308 CHECK(state.error == ::gpu::error::kNoError);
309 } 309 }
310 310
311 uint32 GLInProcessContext::GetParentTextureId() { 311 uint32 GLInProcessContext::GetParentTextureId() {
(...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB; 1672 context_lost_reason_ = GL_UNKNOWN_CONTEXT_RESET_ARB;
1673 if (context_lost_callback_) { 1673 if (context_lost_callback_) {
1674 context_lost_callback_->onContextLost(); 1674 context_lost_callback_->onContextLost();
1675 } 1675 }
1676 } 1676 }
1677 1677
1678 } // namespace gpu 1678 } // namespace gpu
1679 } // namespace webkit 1679 } // namespace webkit
1680 1680
1681 #endif // defined(ENABLE_GPU) 1681 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | webkit/plugins/npapi/plugin_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698