diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 21:18:58 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-21 21:18:58 +0000 |
commit | ae967b0184c3dd9c6948db603c95a76043483449 (patch) | |
tree | ed9395de9614412a6b03494ac5143daf630fa02f /ui | |
parent | fcb1a0d70fff55aa2addcd27c83a14d05174c09d (diff) | |
download | chromium_src-ae967b0184c3dd9c6948db603c95a76043483449.zip chromium_src-ae967b0184c3dd9c6948db603c95a76043483449.tar.gz chromium_src-ae967b0184c3dd9c6948db603c95a76043483449.tar.bz2 |
ui: Allow individual test suites to opt-out of the TestCompositor.
This adds a temporary bool to GLSurface::InitializeOneOffForTests()
allowing a test suite to opt-in to NullDraw bindings. When a test
suite as opted in, the InitializeContextFactoryForTests() method
can see, and will not use the TestContextFactory, instead using the
InProcessContextFactory.
Once all test suites are optign into NullDraw bindings. The bool
and query method for HasInitializedNullDrawGLBindings() will be
removed.
R=kbr@chromium.org, sievers@chromium.org
BUG=270918
Review URL: https://codereview.chromium.org/175093004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@252647 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/compositor/test/context_factories_for_test.cc | 20 | ||||
-rw-r--r-- | ui/gl/gl_bindings.h | 2 | ||||
-rw-r--r-- | ui/gl/gl_gl_api_implementation.cc | 9 | ||||
-rw-r--r-- | ui/gl/gl_gl_api_implementation.h | 2 | ||||
-rw-r--r-- | ui/gl/gl_implementation.cc | 4 | ||||
-rw-r--r-- | ui/gl/gl_implementation.h | 3 | ||||
-rw-r--r-- | ui/gl/gl_surface.cc | 4 | ||||
-rw-r--r-- | ui/gl/gl_surface.h | 3 |
8 files changed, 41 insertions, 6 deletions
diff --git a/ui/compositor/test/context_factories_for_test.cc b/ui/compositor/test/context_factories_for_test.cc index 0c452c5..63b2d3a 100644 --- a/ui/compositor/test/context_factories_for_test.cc +++ b/ui/compositor/test/context_factories_for_test.cc @@ -12,19 +12,29 @@ #include "ui/compositor/test/test_context_factory.h" #include "ui/gl/gl_implementation.h" -namespace ui { +namespace { + +static ui::ContextFactory* g_implicit_factory = NULL; +static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; -static ContextFactory* g_implicit_factory = NULL; +} // namespace + +namespace ui { // static void InitializeContextFactoryForTests(bool enable_pixel_output) { DCHECK(!g_implicit_factory) << "ContextFactory for tests already initialized."; + CommandLine* command_line = CommandLine::ForCurrentProcess(); + if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) + enable_pixel_output = true; bool use_test_contexts = true; + if (gfx::HasInitializedNullDrawGLBindings()) + use_test_contexts = false; + // Always use test contexts unless the disable command line flag is used. - CommandLine* command_line = CommandLine::ForCurrentProcess(); if (command_line->HasSwitch(switches::kDisableTestCompositor)) use_test_contexts = false; @@ -43,6 +53,8 @@ void InitializeContextFactoryForTests(bool enable_pixel_output) { } else { DCHECK_NE(gfx::kGLImplementationNone, gfx::GetGLImplementation()); DVLOG(1) << "Using InProcessContextFactory"; + if (enable_pixel_output && gfx::HasInitializedNullDrawGLBindings()) + g_disable_null_draw = new gfx::DisableNullDrawGLBindings; g_implicit_factory = new ui::InProcessContextFactory(); } ContextFactory::SetInstance(g_implicit_factory); @@ -52,6 +64,8 @@ void TerminateContextFactoryForTests() { ContextFactory::SetInstance(NULL); delete g_implicit_factory; g_implicit_factory = NULL; + delete g_disable_null_draw; + g_disable_null_draw = NULL; } } // namespace ui diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h index cf1435f..8a28a64 100644 --- a/ui/gl/gl_bindings.h +++ b/ui/gl/gl_bindings.h @@ -229,6 +229,8 @@ struct GL_EXPORT DriverGL { void InitializeCustomDynamicBindings(GLContext* context); void InitializeDebugBindings(); void InitializeNullDrawBindings(); + // TODO(danakj): Remove this when all test suites are using null-draw. + bool HasInitializedNullDrawBindings(); bool SetNullDrawBindingsEnabled(bool enabled); void ClearBindings(); diff --git a/ui/gl/gl_gl_api_implementation.cc b/ui/gl/gl_gl_api_implementation.cc index 2b7a590..f925f64 100644 --- a/ui/gl/gl_gl_api_implementation.cc +++ b/ui/gl/gl_gl_api_implementation.cc @@ -237,6 +237,11 @@ void DriverGL::InitializeNullDrawBindings() { null_draw_bindings_enabled = true; } +bool DriverGL::HasInitializedNullDrawBindings() { + return orig_fn.glClearFn != NULL && orig_fn.glDrawArraysFn != NULL && + orig_fn.glDrawElementsFn != NULL; +} + bool DriverGL::SetNullDrawBindingsEnabled(bool enabled) { DCHECK(orig_fn.glClearFn != NULL); DCHECK(orig_fn.glDrawArraysFn != NULL); @@ -290,6 +295,10 @@ void InitializeNullDrawGLBindingsGL() { g_driver_gl.InitializeNullDrawBindings(); } +bool HasInitializedNullDrawGLBindingsGL() { + return g_driver_gl.HasInitializedNullDrawBindings(); +} + bool SetNullDrawGLBindingsEnabledGL(bool enabled) { return g_driver_gl.SetNullDrawBindingsEnabled(enabled); } diff --git a/ui/gl/gl_gl_api_implementation.h b/ui/gl/gl_gl_api_implementation.h index 1739172..c87dbd1 100644 --- a/ui/gl/gl_gl_api_implementation.h +++ b/ui/gl/gl_gl_api_implementation.h @@ -23,6 +23,8 @@ void InitializeStaticGLBindingsGL(); void InitializeDynamicGLBindingsGL(GLContext* context); void InitializeDebugGLBindingsGL(); void InitializeNullDrawGLBindingsGL(); +// TODO(danakj): Remove this when all test suites are using null-draw. +bool HasInitializedNullDrawGLBindingsGL(); bool SetNullDrawGLBindingsEnabledGL(bool enabled); void ClearGLBindingsGL(); void SetGLToRealGLApi(); diff --git a/ui/gl/gl_implementation.cc b/ui/gl/gl_implementation.cc index 3c576a04..a7db8b0 100644 --- a/ui/gl/gl_implementation.cc +++ b/ui/gl/gl_implementation.cc @@ -149,6 +149,10 @@ void InitializeNullDrawGLBindings() { InitializeNullDrawGLBindingsGL(); } +bool HasInitializedNullDrawGLBindings() { + return HasInitializedNullDrawGLBindingsGL(); +} + DisableNullDrawGLBindings::DisableNullDrawGLBindings() { initial_enabled_ = SetNullDrawGLBindingsEnabledGL(false); } diff --git a/ui/gl/gl_implementation.h b/ui/gl/gl_implementation.h index f163e07..6f4eaf7 100644 --- a/ui/gl/gl_implementation.h +++ b/ui/gl/gl_implementation.h @@ -56,6 +56,9 @@ void InitializeDebugGLBindings(); // null draw bindings default to enabled, so that draw operations do nothing. void InitializeNullDrawGLBindings(); +// TODO(danakj): Remove this when all test suites are using null-draw. +GL_EXPORT bool HasInitializedNullDrawGLBindings(); + // Once initialized, instantiating this turns the stub methods for drawing // operations off allowing drawing will occur while the object is alive. class GL_EXPORT DisableNullDrawGLBindings { diff --git a/ui/gl/gl_surface.cc b/ui/gl/gl_surface.cc index c08da8c..b58fc13 100644 --- a/ui/gl/gl_surface.cc +++ b/ui/gl/gl_surface.cc @@ -95,7 +95,7 @@ bool GLSurface::InitializeOneOffImplementation(GLImplementation impl, } // static -void GLSurface::InitializeOneOffForTests() { +void GLSurface::InitializeOneOffForTests(bool disable_drawing) { #if defined(USE_X11) XInitThreads(); #endif @@ -125,7 +125,7 @@ void GLSurface::InitializeOneOffForTests() { bool fallback_to_osmesa = false; bool gpu_service_logging = false; - bool disable_gl_drawing = false; + bool disable_gl_drawing = disable_drawing; // TODO(danakj): Unit tests do not produce pixel output by default. // bool disable_gl_drawing = true; diff --git a/ui/gl/gl_surface.h b/ui/gl/gl_surface.h index f7a02f0..e8ef8dd 100644 --- a/ui/gl/gl_surface.h +++ b/ui/gl/gl_surface.h @@ -75,7 +75,8 @@ class GL_EXPORT GLSurface : public base::RefCounted<GLSurface> { // Unit tests should call these instead of InitializeOneOff() to set up // GL bindings appropriate for tests. - static void InitializeOneOffForTests(); + // TODO(danakj): Once all callers pass true, remove the argument. + static void InitializeOneOffForTests(bool disable_drawing = false); static void InitializeOneOffWithMockBindingsForTests(); static void InitializeDynamicMockBindingsForTests(GLContext* context); |