OLD | NEW |
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/gles2_conform_support/egl/thread_state.h" | 5 #include "gpu/gles2_conform_support/egl/thread_state.h" |
6 | 6 |
7 #include "base/at_exit.h" | 7 #include "base/at_exit.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/environment.h" | 9 #include "base/environment.h" |
10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
14 #include "gpu/command_buffer/client/gles2_lib.h" | 14 #include "gpu/command_buffer/client/gles2_lib.h" |
15 #include "gpu/command_buffer/common/thread_local.h" | 15 #include "gpu/command_buffer/common/thread_local.h" |
16 #include "gpu/command_buffer/service/gpu_switches.h" | 16 #include "gpu/command_buffer/service/gpu_switches.h" |
17 #include "gpu/config/gpu_info_collector.h" | 17 #include "gpu/config/gpu_info_collector.h" |
18 #include "gpu/config/gpu_util.h" | 18 #include "gpu/config/gpu_util.h" |
19 #include "gpu/gles2_conform_support/egl/context.h" | 19 #include "gpu/gles2_conform_support/egl/context.h" |
20 #include "gpu/gles2_conform_support/egl/display.h" | 20 #include "gpu/gles2_conform_support/egl/display.h" |
21 #include "gpu/gles2_conform_support/egl/surface.h" | 21 #include "gpu/gles2_conform_support/egl/surface.h" |
22 #include "gpu/gles2_conform_support/egl/test_support.h" | 22 #include "gpu/gles2_conform_support/egl/test_support.h" |
23 #include "ui/gl/gl_context.h" | 23 #include "ui/gl/gl_context.h" |
24 #include "ui/gl/gl_surface.h" | 24 #include "ui/gl/gl_surface.h" |
| 25 #include "ui/gl/init/gl_factory.h" |
25 | 26 |
26 // Thread local key for ThreadState instance. Accessed when holding g_egl_lock | 27 // Thread local key for ThreadState instance. Accessed when holding g_egl_lock |
27 // only, since the initialization can not be Guaranteed otherwise. Not in | 28 // only, since the initialization can not be Guaranteed otherwise. Not in |
28 // anonymous namespace due to Mac OS X 10.6 linker. See gles2_lib.cc. | 29 // anonymous namespace due to Mac OS X 10.6 linker. See gles2_lib.cc. |
29 static gpu::ThreadLocalKey g_egl_thread_state_key; | 30 static gpu::ThreadLocalKey g_egl_thread_state_key; |
30 | 31 |
31 namespace { | 32 namespace { |
32 base::LazyInstance<base::Lock>::Leaky g_egl_lock; | 33 base::LazyInstance<base::Lock>::Leaky g_egl_lock; |
33 int g_egl_active_thread_count; | 34 int g_egl_active_thread_count; |
34 | 35 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 77 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
77 // Need to call both Init and InitFromArgv, since Windows does not use | 78 // Need to call both Init and InitFromArgv, since Windows does not use |
78 // argc, argv in CommandLine::Init(argc, argv). | 79 // argc, argv in CommandLine::Init(argc, argv). |
79 command_line->InitFromArgv(argv); | 80 command_line->InitFromArgv(argv); |
80 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { | 81 if (!command_line->HasSwitch(switches::kDisableGpuDriverBugWorkarounds)) { |
81 gpu::GPUInfo gpu_info; | 82 gpu::GPUInfo gpu_info; |
82 gpu::CollectBasicGraphicsInfo(&gpu_info); | 83 gpu::CollectBasicGraphicsInfo(&gpu_info); |
83 gpu::ApplyGpuDriverBugWorkarounds(gpu_info, command_line); | 84 gpu::ApplyGpuDriverBugWorkarounds(gpu_info, command_line); |
84 } | 85 } |
85 | 86 |
86 gfx::GLSurface::InitializeOneOff(); | 87 gl::init::InitializeGLOneOff(); |
87 } | 88 } |
88 | 89 |
89 g_egl_default_display = new egl::Display(); | 90 g_egl_default_display = new egl::Display(); |
90 g_egl_thread_state_key = gpu::ThreadLocalAlloc(); | 91 g_egl_thread_state_key = gpu::ThreadLocalAlloc(); |
91 } | 92 } |
92 egl::ThreadState* thread_state = static_cast<egl::ThreadState*>( | 93 egl::ThreadState* thread_state = static_cast<egl::ThreadState*>( |
93 gpu::ThreadLocalGetValue(g_egl_thread_state_key)); | 94 gpu::ThreadLocalGetValue(g_egl_thread_state_key)); |
94 if (!thread_state) { | 95 if (!thread_state) { |
95 thread_state = new egl::ThreadState; | 96 thread_state = new egl::ThreadState; |
96 gpu::ThreadLocalSetValue(g_egl_thread_state_key, thread_state); | 97 gpu::ThreadLocalSetValue(g_egl_thread_state_key, thread_state); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 Context::ApplyContextReleased(); | 190 Context::ApplyContextReleased(); |
190 } | 191 } |
191 } | 192 } |
192 | 193 |
193 void ThreadState::AutoCurrentContextRestore::SetCurrent(Surface* surface, | 194 void ThreadState::AutoCurrentContextRestore::SetCurrent(Surface* surface, |
194 Context* context) { | 195 Context* context) { |
195 thread_state_->SetCurrent(surface, context); | 196 thread_state_->SetCurrent(surface, context); |
196 } | 197 } |
197 | 198 |
198 } // namespace egl | 199 } // namespace egl |
OLD | NEW |