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 "ui/gl/gl_context.h" | 5 #include "ui/gl/gl_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
15 #include "base/strings/string_util.h" | 15 #include "base/strings/string_util.h" |
16 #include "base/threading/thread_local.h" | 16 #include "base/threading/thread_local.h" |
17 #include "ui/gl/gl_bindings.h" | 17 #include "ui/gl/gl_bindings.h" |
18 #include "ui/gl/gl_gl_api_implementation.h" | 18 #include "ui/gl/gl_gl_api_implementation.h" |
19 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
20 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.h" |
21 #include "ui/gl/gl_switches.h" | 21 #include "ui/gl/gl_switches.h" |
22 #include "ui/gl/gl_version_info.h" | 22 #include "ui/gl/gl_version_info.h" |
23 #include "ui/gl/gpu_timing.h" | 23 #include "ui/gl/gpu_timing.h" |
24 | 24 |
25 namespace gfx { | 25 namespace gl { |
26 | 26 |
27 namespace { | 27 namespace { |
28 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky | 28 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky |
29 current_context_ = LAZY_INSTANCE_INITIALIZER; | 29 current_context_ = LAZY_INSTANCE_INITIALIZER; |
30 | 30 |
31 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky | 31 base::LazyInstance<base::ThreadLocalPointer<GLContext> >::Leaky |
32 current_real_context_ = LAZY_INSTANCE_INITIALIZER; | 32 current_real_context_ = LAZY_INSTANCE_INITIALIZER; |
33 } // namespace | 33 } // namespace |
34 | 34 |
35 GLContext::ScopedReleaseCurrent::ScopedReleaseCurrent() : canceled_(false) {} | 35 GLContext::ScopedReleaseCurrent::ScopedReleaseCurrent() : canceled_(false) {} |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); | 206 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); |
207 } | 207 } |
208 | 208 |
209 void GLContext::SetRealGLApi() { | 209 void GLContext::SetRealGLApi() { |
210 SetGLToRealGLApi(); | 210 SetGLToRealGLApi(); |
211 } | 211 } |
212 | 212 |
213 GLContextReal::GLContextReal(GLShareGroup* share_group) | 213 GLContextReal::GLContextReal(GLShareGroup* share_group) |
214 : GLContext(share_group) {} | 214 : GLContext(share_group) {} |
215 | 215 |
216 scoped_refptr<gfx::GPUTimingClient> GLContextReal::CreateGPUTimingClient() { | 216 scoped_refptr<gl::GPUTimingClient> GLContextReal::CreateGPUTimingClient() { |
217 if (!gpu_timing_) { | 217 if (!gpu_timing_) { |
218 gpu_timing_.reset(GPUTiming::CreateGPUTiming(this)); | 218 gpu_timing_.reset(GPUTiming::CreateGPUTiming(this)); |
219 } | 219 } |
220 return gpu_timing_->CreateGPUTimingClient(); | 220 return gpu_timing_->CreateGPUTimingClient(); |
221 } | 221 } |
222 | 222 |
223 GLContextReal::~GLContextReal() { | 223 GLContextReal::~GLContextReal() { |
224 if (GetRealCurrent() == this) | 224 if (GetRealCurrent() == this) |
225 current_real_context_.Pointer()->Set(nullptr); | 225 current_real_context_.Pointer()->Set(nullptr); |
226 } | 226 } |
227 | 227 |
228 void GLContextReal::SetCurrent(GLSurface* surface) { | 228 void GLContextReal::SetCurrent(GLSurface* surface) { |
229 GLContext::SetCurrent(surface); | 229 GLContext::SetCurrent(surface); |
230 current_real_context_.Pointer()->Set(surface ? this : nullptr); | 230 current_real_context_.Pointer()->Set(surface ? this : nullptr); |
231 } | 231 } |
232 | 232 |
233 } // namespace gfx | 233 } // namespace gl |
OLD | NEW |