| 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/lazy_instance.h" | 12 #include "base/lazy_instance.h" |
| 12 #include "base/logging.h" | 13 #include "base/logging.h" |
| 13 #include "base/threading/thread_local.h" | 14 #include "base/threading/thread_local.h" |
| 14 #include "ui/gl/gl_context.h" | 15 #include "ui/gl/gl_context.h" |
| 15 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
| 16 | 17 |
| 17 namespace gfx { | 18 namespace gfx { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky | 21 base::LazyInstance<base::ThreadLocalPointer<GLSurface> >::Leaky |
| 21 current_surface_ = LAZY_INSTANCE_INITIALIZER; | 22 current_surface_ = LAZY_INSTANCE_INITIALIZER; |
| 22 } // namespace | 23 } // namespace |
| 23 | 24 |
| 24 // static | 25 // static |
| 25 bool GLSurface::InitializeOneOff() { | 26 bool GLSurface::InitializeOneOff() { |
| 26 static bool initialized = false; | 27 static bool initialized = false; |
| 27 if (initialized) | 28 if (initialized) |
| 28 return true; | 29 return true; |
| 29 | 30 |
| 31 TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff"); |
| 32 |
| 30 std::vector<GLImplementation> allowed_impls; | 33 std::vector<GLImplementation> allowed_impls; |
| 31 GetAllowedGLImplementations(&allowed_impls); | 34 GetAllowedGLImplementations(&allowed_impls); |
| 32 DCHECK(!allowed_impls.empty()); | 35 DCHECK(!allowed_impls.empty()); |
| 33 | 36 |
| 34 // The default implementation is always the first one in list. | 37 // The default implementation is always the first one in list. |
| 35 GLImplementation impl = allowed_impls[0]; | 38 GLImplementation impl = allowed_impls[0]; |
| 36 bool fallback_to_osmesa = false; | 39 bool fallback_to_osmesa = false; |
| 37 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { | 40 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { |
| 38 std::string requested_implementation_name = | 41 std::string requested_implementation_name = |
| 39 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); | 42 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 return surface_->GetConfig(); | 209 return surface_->GetConfig(); |
| 207 } | 210 } |
| 208 | 211 |
| 209 unsigned GLSurfaceAdapter::GetFormat() { | 212 unsigned GLSurfaceAdapter::GetFormat() { |
| 210 return surface_->GetFormat(); | 213 return surface_->GetFormat(); |
| 211 } | 214 } |
| 212 | 215 |
| 213 GLSurfaceAdapter::~GLSurfaceAdapter() {} | 216 GLSurfaceAdapter::~GLSurfaceAdapter() {} |
| 214 | 217 |
| 215 } // namespace gfx | 218 } // namespace gfx |
| OLD | NEW |