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_surface.h" | 5 #include "ui/gl/gl_surface.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/debug/trace_event.h" | 11 #include "base/debug/trace_event.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/threading/thread_local.h" | 14 #include "base/threading/thread_local.h" |
15 #include "ui/gl/gl_context.h" | 15 #include "ui/gl/gl_context.h" |
16 #include "ui/gl/gl_implementation.h" | |
17 | 16 |
18 namespace gfx { | 17 namespace gfx { |
19 | 18 |
20 namespace { | 19 namespace { |
21 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky | 20 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky |
22 current_surface_ = LAZY_INSTANCE_INITIALIZER; | 21 current_surface_ = LAZY_INSTANCE_INITIALIZER; |
23 } // namespace | 22 } // namespace |
24 | 23 |
25 // static | 24 // static |
26 bool GLSurface::InitializeOneOff() { | 25 bool GLSurface::InitializeOneOff() { |
(...skipping 21 matching lines...) Expand all Loading... |
48 impl = GetNamedGLImplementation(requested_implementation_name); | 47 impl = GetNamedGLImplementation(requested_implementation_name); |
49 if (std::find(allowed_impls.begin(), | 48 if (std::find(allowed_impls.begin(), |
50 allowed_impls.end(), | 49 allowed_impls.end(), |
51 impl) == allowed_impls.end()) { | 50 impl) == allowed_impls.end()) { |
52 LOG(ERROR) << "Requested GL implementation is not available."; | 51 LOG(ERROR) << "Requested GL implementation is not available."; |
53 return false; | 52 return false; |
54 } | 53 } |
55 } | 54 } |
56 } | 55 } |
57 | 56 |
58 initialized = InitializeGLBindings(impl) && InitializeOneOffInternal(); | 57 initialized = InitializePreBindingsInternal(impl); |
| 58 if (initialized) |
| 59 initialized = InitializeStaticGLBindings(impl) && |
| 60 InitializeOneOffInternal(); |
59 if (!initialized && fallback_to_osmesa) { | 61 if (!initialized && fallback_to_osmesa) { |
60 ClearGLBindings(); | 62 ClearGLBindings(); |
61 initialized = InitializeGLBindings(kGLImplementationOSMesaGL) && | 63 initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) && |
62 InitializeOneOffInternal(); | 64 InitializeOneOffInternal(); |
63 } | 65 } |
64 | 66 |
65 if (initialized) { | 67 if (initialized) { |
66 DVLOG(1) << "Using " | 68 DVLOG(1) << "Using " |
67 << GetGLImplementationName(GetGLImplementation()) | 69 << GetGLImplementationName(GetGLImplementation()) |
68 << " GL implementation."; | 70 << " GL implementation."; |
69 if (CommandLine::ForCurrentProcess()->HasSwitch( | 71 if (CommandLine::ForCurrentProcess()->HasSwitch( |
70 switches::kEnableGPUServiceLogging)) | 72 switches::kEnableGPUServiceLogging)) |
71 InitializeDebugGLBindings(); | 73 InitializeDebugGLBindings(); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
254 return surface_->GetFormat(); | 256 return surface_->GetFormat(); |
255 } | 257 } |
256 | 258 |
257 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { | 259 VSyncProvider* GLSurfaceAdapter::GetVSyncProvider() { |
258 return surface_->GetVSyncProvider(); | 260 return surface_->GetVSyncProvider(); |
259 } | 261 } |
260 | 262 |
261 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 263 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
262 | 264 |
263 } // namespace gfx | 265 } // namespace gfx |
OLD | NEW |