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

Unified Diff: trunk/src/ui/gl/gl_surface.cc

Issue 149953003: Revert 247793 "Ensure GL initialization only happens once, and p..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « trunk/src/ui/gl/gl_surface.h ('k') | trunk/src/ui/gl/gl_surface_egl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: trunk/src/ui/gl/gl_surface.cc
===================================================================
--- trunk/src/ui/gl/gl_surface.cc (revision 247809)
+++ trunk/src/ui/gl/gl_surface.cc (working copy)
@@ -14,7 +14,6 @@
#include "base/threading/thread_local.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
-#include "ui/gl/gl_switches.h"
namespace gfx {
@@ -25,7 +24,9 @@
// static
bool GLSurface::InitializeOneOff() {
- DCHECK_EQ(kGLImplementationNone, GetGLImplementation());
+ static bool initialized = false;
+ if (initialized)
+ return true;
TRACE_EVENT0("gpu", "GLSurface::InitializeOneOff");
@@ -33,14 +34,12 @@
GetAllowedGLImplementations(&allowed_impls);
DCHECK(!allowed_impls.empty());
- CommandLine* cmd = CommandLine::ForCurrentProcess();
-
// The default implementation is always the first one in list.
GLImplementation impl = allowed_impls[0];
bool fallback_to_osmesa = false;
- if (cmd->HasSwitch(switches::kUseGL)) {
+ if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) {
std::string requested_implementation_name =
- cmd->GetSwitchValueASCII(switches::kUseGL);
+ CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL);
if (requested_implementation_name == "any") {
fallback_to_osmesa = true;
} else if (requested_implementation_name == "swiftshader") {
@@ -56,94 +55,27 @@
}
}
- bool gpu_service_logging = cmd->HasSwitch(switches::kEnableGPUServiceLogging);
- bool disable_gl_drawing = cmd->HasSwitch(switches::kDisableGLDrawingForTests);
-
- return InitializeOneOffImplementation(
- impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing);
-}
-
-// static
-bool GLSurface::InitializeOneOffImplementation(GLImplementation impl,
- bool fallback_to_osmesa,
- bool gpu_service_logging,
- bool disable_gl_drawing) {
- bool initialized =
- InitializeStaticGLBindings(impl) && InitializeOneOffInternal();
+ initialized = InitializeStaticGLBindings(impl) && InitializeOneOffInternal();
if (!initialized && fallback_to_osmesa) {
ClearGLBindings();
initialized = InitializeStaticGLBindings(kGLImplementationOSMesaGL) &&
InitializeOneOffInternal();
}
- if (!initialized)
- ClearGLBindings();
if (initialized) {
DVLOG(1) << "Using "
<< GetGLImplementationName(GetGLImplementation())
<< " GL implementation.";
- if (gpu_service_logging)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableGPUServiceLogging))
InitializeDebugGLBindings();
- if (disable_gl_drawing)
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kDisableGLDrawingForTests))
InitializeNullDrawGLBindings();
}
return initialized;
}
-// static
-void GLSurface::InitializeOneOffForTests() {
- bool use_osmesa = true;
-
-#if defined(OS_ANDROID)
- // On Android we always use hardware GL.
- use_osmesa = false;
-#endif
-
- std::vector<GLImplementation> allowed_impls;
- GetAllowedGLImplementations(&allowed_impls);
- DCHECK(!allowed_impls.empty());
-
- GLImplementation impl = allowed_impls[0];
- if (use_osmesa)
- impl = kGLImplementationOSMesaGL;
-
- DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL))
- << "kUseGL has not effect in tests";
-
- bool fallback_to_osmesa = false;
- bool gpu_service_logging = false;
- bool disable_gl_drawing = false;
- // TODO(danakj): Unit tests do not produce pixel output by default.
- // bool disable_gl_drawing = true;
-
- CHECK(InitializeOneOffImplementation(
- impl, fallback_to_osmesa, gpu_service_logging, disable_gl_drawing));
-}
-
-// static
-void GLSurface::InitializeOneOffWithMockBindingsForTests() {
- DCHECK(!CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL))
- << "kUseGL has not effect in tests";
-
- // This method may be called multiple times in the same process to set up
- // mock bindings in different ways.
- ClearGLBindings();
-
- bool fallback_to_osmesa = false;
- bool gpu_service_logging = false;
- bool disable_gl_drawing = false;
-
- CHECK(InitializeOneOffImplementation(kGLImplementationMockGL,
- fallback_to_osmesa,
- gpu_service_logging,
- disable_gl_drawing));
-}
-
-// static
-void GLSurface::InitializeDynamicMockBindingsForTests(GLContext* context) {
- CHECK(InitializeDynamicGLBindings(kGLImplementationMockGL, context));
-}
-
GLSurface::GLSurface() {}
bool GLSurface::Initialize() {
« no previous file with comments | « trunk/src/ui/gl/gl_surface.h ('k') | trunk/src/ui/gl/gl_surface_egl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698