diff options
30 files changed, 424 insertions, 342 deletions
diff --git a/ash/test/ash_test_helper.cc b/ash/test/ash_test_helper.cc index 8981507..4b84a2e 100644 --- a/ash/test/ash_test_helper.cc +++ b/ash/test/ash_test_helper.cc @@ -19,6 +19,7 @@ #include "ui/aura/test/env_test_helper.h" #include "ui/base/ime/input_method_initializer.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/message_center/message_center.h" #include "ui/views/corewm/capture_controller.h" @@ -54,6 +55,9 @@ void AshTestHelper::SetUp(bool start_session) { ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); ui::InitializeInputMethodForTesting(); + bool allow_test_contexts = true; + ui::InitializeContextFactoryForTests(allow_test_contexts); + // Creates Shell and hook with Desktop. test_shell_delegate_ = new TestShellDelegate; @@ -111,6 +115,7 @@ void AshTestHelper::TearDown() { #endif aura::Env::DeleteInstance(); + ui::TerminateContextFactoryForTests(); // Need to reset the initial login status. TestSystemTrayDelegate::SetInitialLoginStatus(user::LOGGED_IN_USER); diff --git a/ash/test/test_shell_delegate.cc b/ash/test/test_shell_delegate.cc index b7a4823..7676e42 100644 --- a/ash/test/test_shell_delegate.cc +++ b/ash/test/test_shell_delegate.cc @@ -23,7 +23,6 @@ #include "base/logging.h" #include "content/public/test/test_browser_context.h" #include "ui/aura/window.h" -#include "ui/compositor/compositor.h" namespace ash { namespace test { @@ -142,10 +141,6 @@ ui::MenuModel* TestShellDelegate::CreateContextMenu(aura::Window* root) { } RootWindowHostFactory* TestShellDelegate::CreateRootWindowHostFactory() { - // The ContextFactory must exist before any Compositors are created. - bool allow_test_contexts = true; - ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); - return RootWindowHostFactory::Create(); } diff --git a/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc b/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc index aa60943..d9bc82f 100644 --- a/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc +++ b/chrome/browser/extensions/api/tab_capture/tab_capture_performancetest.cc @@ -125,7 +125,7 @@ class TabCapturePerformanceTest command_line->AppendSwitchASCII(switches::kWindowSize, "2000,1500"); } - command_line->AppendSwitch(switches::kDisableTestCompositor); + UseRealGLContexts(); if (!HasFlag(kUseGpu)) { command_line->AppendSwitch(switches::kDisableGpu); diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc index 9d07c8b..c62ae50 100644 --- a/chrome/browser/notifications/desktop_notifications_unittest.cc +++ b/chrome/browser/notifications/desktop_notifications_unittest.cc @@ -24,6 +24,7 @@ #include "ui/aura/env.h" #include "ui/aura/root_window.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/compositor/test/context_factories_for_test.h" #endif @@ -107,6 +108,9 @@ void DesktopNotificationsTest::SetUp() { // The message center is notmally initialized on |g_browser_process| which // is not created for these tests. message_center::MessageCenter::Initialize(); + // The ContextFactory must exist before any Compositors are created. + bool allow_test_contexts = true; + ui::InitializeContextFactoryForTests(allow_test_contexts); // MockBalloonCollection retrieves information about the screen on creation. // So it is necessary to make sure the desktop gets created first. ash::Shell::CreateInstance(new ash::test::TestShellDelegate); @@ -131,6 +135,7 @@ void DesktopNotificationsTest::TearDown() { // is not created for these tests. message_center::MessageCenter::Shutdown(); aura::Env::DeleteInstance(); + ui::TerminateContextFactoryForTests(); #endif ui::ShutdownInputMethodForTesting(); } diff --git a/chrome/test/base/view_event_test_base.cc b/chrome/test/base/view_event_test_base.cc index eb9fb3d..ac4d8ac 100644 --- a/chrome/test/base/view_event_test_base.cc +++ b/chrome/test/base/view_event_test_base.cc @@ -13,6 +13,7 @@ #include "content/public/browser/browser_thread.h" #include "ui/base/ime/input_method_initializer.h" #include "ui/base/test/ui_controls.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/message_center/message_center.h" #include "ui/views/view.h" #include "ui/views/widget/desktop_aura/desktop_screen.h" @@ -22,9 +23,6 @@ #include "ash/shell.h" #include "ash/test/test_session_state_delegate.h" #include "ash/test/test_shell_delegate.h" -#if defined(OS_WIN) -#include "ui/compositor/compositor.h" -#endif #endif #if defined(USE_AURA) @@ -102,17 +100,15 @@ void ViewEventTestBase::SetUp() { gfx::NativeView context = NULL; #if defined(USE_ASH) + // The ContextFactory must exist before any Compositors are created. + bool allow_test_contexts = true; + ui::InitializeContextFactoryForTests(allow_test_contexts); #if defined(OS_WIN) // http://crbug.com/154081 use ash::Shell code path below on win_ash bots when // interactive_ui_tests is brought up on that platform. gfx::Screen::SetScreenInstance( gfx::SCREEN_TYPE_NATIVE, views::CreateDesktopScreen()); - // The ContextFactory must exist before any Compositors are created. The - // ash::Shell code path below handles this, but since we skip it we must - // do this here. - bool allow_test_contexts = true; - ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); #else // !OS_WIN // Ash Shell can't just live on its own without a browser process, we need to // also create the message center. @@ -164,6 +160,7 @@ void ViewEventTestBase::TearDown() { message_center::MessageCenter::Shutdown(); #endif // !OS_WIN aura::Env::DeleteInstance(); + ui::TerminateContextFactoryForTests(); #elif defined(USE_AURA) aura_test_helper_->TearDown(); #endif // !USE_ASH && USE_AURA diff --git a/content/browser/aura/image_transport_factory.cc b/content/browser/aura/image_transport_factory.cc index ca83149..4a20e7d 100644 --- a/content/browser/aura/image_transport_factory.cc +++ b/content/browser/aura/image_transport_factory.cc @@ -4,56 +4,32 @@ #include "content/browser/aura/image_transport_factory.h" -#include "base/command_line.h" -#include "base/sys_info.h" #include "content/browser/aura/gpu_process_transport_factory.h" #include "content/browser/aura/no_transport_image_transport_factory.h" -#include "content/public/common/content_switches.h" #include "ui/compositor/compositor.h" -#include "ui/compositor/compositor_switches.h" namespace content { namespace { -ImageTransportFactory* g_factory; -} - - -static bool UseTestContextAndTransportFactory() { -#if defined(OS_CHROMEOS) - // If the test is running on the chromeos envrionment (such as - // device or vm bots), always use real contexts. - if (base::SysInfo::IsRunningOnChromeOS()) - return false; -#endif - - // Only used if the enable command line flag is used. - CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (!command_line->HasSwitch(switches::kTestCompositor)) - return false; - - // The disable command line flag preempts the enable flag. - if (!command_line->HasSwitch(switches::kDisableTestCompositor)) - return true; - - return false; +ImageTransportFactory* g_factory = NULL; +bool g_initialized_for_unit_tests = false; } // static void ImageTransportFactory::Initialize() { - DCHECK(!g_factory); - if (UseTestContextAndTransportFactory()) { - g_factory = - new NoTransportImageTransportFactory(new ui::TestContextFactory); - } else { - g_factory = new GpuProcessTransportFactory; - } + DCHECK(!g_factory || g_initialized_for_unit_tests); + if (g_initialized_for_unit_tests) + return; + g_factory = new GpuProcessTransportFactory; ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); } -void ImageTransportFactory::InitializeForUnitTests() { +void ImageTransportFactory::InitializeForUnitTests( + scoped_ptr<ui::ContextFactory> test_factory) { DCHECK(!g_factory); - g_factory = new NoTransportImageTransportFactory(new ui::TestContextFactory); + DCHECK(!g_initialized_for_unit_tests); + g_initialized_for_unit_tests = true; + g_factory = new NoTransportImageTransportFactory(test_factory.Pass()); ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); } @@ -62,6 +38,7 @@ void ImageTransportFactory::Terminate() { ui::ContextFactory::SetInstance(NULL); delete g_factory; g_factory = NULL; + g_initialized_for_unit_tests = false; } // static diff --git a/content/browser/aura/image_transport_factory.h b/content/browser/aura/image_transport_factory.h index 7cd2523..bfe7057c 100644 --- a/content/browser/aura/image_transport_factory.h +++ b/content/browser/aura/image_transport_factory.h @@ -8,6 +8,7 @@ #include <string> #include "base/memory/ref_counted.h" +#include "base/memory/scoped_ptr.h" #include "content/common/content_export.h" #include "ui/gfx/native_widget_types.h" @@ -52,9 +53,10 @@ class CONTENT_EXPORT ImageTransportFactory { // Initializes the global transport factory. static void Initialize(); - // Initializes the global transport factory for unit tests, using a test - // context. - static void InitializeForUnitTests(); + // Initializes the global transport factory for unit tests using the provided + // context factory. + static void InitializeForUnitTests( + scoped_ptr<ui::ContextFactory> test_factory); // Terminates the global transport factory. static void Terminate(); diff --git a/content/browser/aura/no_transport_image_transport_factory.cc b/content/browser/aura/no_transport_image_transport_factory.cc index 496362a..5764805 100644 --- a/content/browser/aura/no_transport_image_transport_factory.cc +++ b/content/browser/aura/no_transport_image_transport_factory.cc @@ -44,8 +44,8 @@ class FakeTexture : public ui::Texture { } // anonymous namespace NoTransportImageTransportFactory::NoTransportImageTransportFactory( - ui::ContextFactory* context_factory) - : context_factory_(context_factory) {} + scoped_ptr<ui::ContextFactory> context_factory) + : context_factory_(context_factory.Pass()) {} NoTransportImageTransportFactory::~NoTransportImageTransportFactory() {} diff --git a/content/browser/aura/no_transport_image_transport_factory.h b/content/browser/aura/no_transport_image_transport_factory.h index 0d57164..dd551d9 100644 --- a/content/browser/aura/no_transport_image_transport_factory.h +++ b/content/browser/aura/no_transport_image_transport_factory.h @@ -18,7 +18,7 @@ namespace content { class NoTransportImageTransportFactory : public ImageTransportFactory { public: explicit NoTransportImageTransportFactory( - ui::ContextFactory* context_factory); + scoped_ptr<ui::ContextFactory> context_factory); virtual ~NoTransportImageTransportFactory(); // ImageTransportFactory implementation. diff --git a/content/browser/aura/software_output_device_ozone_unittest.cc b/content/browser/aura/software_output_device_ozone_unittest.cc index 552116e..30c696c 100644 --- a/content/browser/aura/software_output_device_ozone_unittest.cc +++ b/content/browser/aura/software_output_device_ozone_unittest.cc @@ -9,6 +9,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "third_party/skia/include/core/SkBitmapDevice.h" #include "ui/compositor/compositor.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/gfx/ozone/surface_factory_ozone.h" #include "ui/gfx/size.h" #include "ui/gfx/skia_util.h" @@ -83,7 +84,7 @@ SoftwareOutputDeviceOzoneTest::~SoftwareOutputDeviceOzoneTest() { } void SoftwareOutputDeviceOzoneTest::SetUp() { - ui::Compositor::InitializeContextFactoryForTests(false); + ui::InitializeContextFactoryForTests(false); ui::Compositor::Initialize(); surface_factory_.reset(new MockSurfaceFactoryOzone()); @@ -103,6 +104,7 @@ void SoftwareOutputDeviceOzoneTest::TearDown() { output_device_.reset(); compositor_.reset(); surface_factory_.reset(); + ui::TerminateContextFactoryForTests(); ui::Compositor::Terminate(); } diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc index 3dcdc35..88669e0 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc @@ -38,6 +38,7 @@ #include "ui/aura/window_observer.h" #include "ui/base/ui_base_types.h" #include "ui/compositor/compositor.h" +#include "ui/compositor/test/test_context_factory.h" #include "ui/events/event.h" #include "ui/events/event_utils.h" @@ -153,7 +154,8 @@ class RenderWidgetHostViewAuraTest : public testing::Test { : browser_thread_for_ui_(BrowserThread::UI, &message_loop_) {} virtual void SetUp() { - ImageTransportFactory::InitializeForUnitTests(); + ImageTransportFactory::InitializeForUnitTests( + scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); aura_test_helper_.reset(new aura::test::AuraTestHelper(&message_loop_)); aura_test_helper_->SetUp(); diff --git a/content/content_tests.gypi b/content/content_tests.gypi index 3831088..c69df7c 100644 --- a/content/content_tests.gypi +++ b/content/content_tests.gypi @@ -642,6 +642,7 @@ '../third_party/icu/icu.gyp:icuuc', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', '../third_party/libjingle/libjingle.gyp:libjingle', + '../ui/compositor/compositor.gyp:compositor_test_support', '../ui/gl/gl.gyp:gl', '../v8/tools/gyp/v8.gyp:v8', '../webkit/common/webkit_common.gyp:webkit_common', diff --git a/content/public/common/content_switches.cc b/content/public/common/content_switches.cc index 97ac38c..66403b2 100644 --- a/content/public/common/content_switches.cc +++ b/content/public/common/content_switches.cc @@ -989,11 +989,6 @@ const char kUseCoreAnimation[] = "use-core-animation"; const char kChildCleanExit[] = "child-clean-exit"; #endif -#if defined(USE_AURA) -// Forces usage of the test compositor. Needed to run ui tests on bots. -extern const char kTestCompositor[] = "test-compositor"; -#endif - // Don't dump stuff here, follow the same order as the header. } // namespace switches diff --git a/content/public/common/content_switches.h b/content/public/common/content_switches.h index cc69e57..073d6a8 100644 --- a/content/public/common/content_switches.h +++ b/content/public/common/content_switches.h @@ -294,10 +294,6 @@ extern const char kUseCoreAnimation[]; extern const char kChildCleanExit[]; #endif -#if defined(USE_AURA) -CONTENT_EXPORT extern const char kTestCompositor[]; -#endif - // DON'T ADD RANDOM STUFF HERE. Put it in the main section above in // alphabetical order, or in one of the ifdefs (also in order in each section). diff --git a/content/public/test/browser_test_base.cc b/content/public/test/browser_test_base.cc index c0617c4..871c271 100644 --- a/content/public/test/browser_test_base.cc +++ b/content/public/test/browser_test_base.cc @@ -36,6 +36,11 @@ #include "content/public/browser/browser_thread.h" #endif +#if defined(USE_AURA) +#include "content/browser/aura/image_transport_factory.h" +#include "ui/compositor/test/test_context_factory.h" +#endif + namespace content { namespace { @@ -148,11 +153,23 @@ void BrowserTestBase::SetUp() { // GPU blacklisting decisions were made. command_line->AppendSwitch(switches::kLogGpuControlListDecisions); +#if defined(OS_CHROMEOS) + // If the test is running on the chromeos envrionment (such as + // device or vm bots), always use real contexts. + if (base::SysInfo::IsRunningOnChromeOS()) + allow_test_contexts_ = false; +#endif + #if defined(USE_AURA) + if (command_line->HasSwitch(switches::kDisableTestCompositor)) + allow_test_contexts_ = false; + // Use test contexts for browser tests unless they override and force us to // use a real context. - if (allow_test_contexts_) - command_line->AppendSwitch(switches::kTestCompositor); + if (allow_test_contexts_) { + content::ImageTransportFactory::InitializeForUnitTests( + scoped_ptr<ui::ContextFactory>(new ui::TestContextFactory)); + } #endif // When using real GL contexts, we usually use OSMesa as this works on all diff --git a/ui/aura/aura.gyp b/ui/aura/aura.gyp index 0352ec1..70334fe 100644 --- a/ui/aura/aura.gyp +++ b/ui/aura/aura.gyp @@ -133,6 +133,7 @@ 'dependencies': [ '../../skia/skia.gyp:skia', '../../testing/gtest.gyp:gtest', + '../compositor/compositor.gyp:compositor_test_support', '../events/events.gyp:events', '../gfx/gfx.gyp:gfx', '../ui.gyp:ui', diff --git a/ui/aura/bench/bench_main.cc b/ui/aura/bench/bench_main.cc index 67ba3a6..a8dd537 100644 --- a/ui/aura/bench/bench_main.cc +++ b/ui/aura/bench/bench_main.cc @@ -26,6 +26,7 @@ #include "ui/compositor/compositor_observer.h" #include "ui/compositor/debug_utils.h" #include "ui/compositor/layer.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/gfx/canvas.h" #include "ui/gfx/rect.h" #include "ui/gfx/skia_util.h" @@ -301,7 +302,7 @@ int main(int argc, char** argv) { // The ContextFactory must exist before any Compositors are created. bool allow_test_contexts = false; - ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); + ui::InitializeContextFactoryForTests(allow_test_contexts); ui::RegisterPathProvider(); base::i18n::InitializeICU(); diff --git a/ui/aura/demo/demo_main.cc b/ui/aura/demo/demo_main.cc index f9d8986..75b1d60 100644 --- a/ui/aura/demo/demo_main.cc +++ b/ui/aura/demo/demo_main.cc @@ -19,7 +19,7 @@ #include "ui/base/hit_test.h" #include "ui/base/resource/resource_bundle.h" #include "ui/base/ui_base_paths.h" -#include "ui/compositor/compositor.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/events/event.h" #include "ui/gfx/canvas.h" #include "ui/gfx/rect.h" @@ -112,7 +112,7 @@ int DemoMain() { // The ContextFactory must exist before any Compositors are created. bool allow_test_contexts = false; - ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); + ui::InitializeContextFactoryForTests(allow_test_contexts); aura::Env::CreateInstance(); scoped_ptr<aura::TestScreen> test_screen(aura::TestScreen::Create()); diff --git a/ui/aura/test/aura_test_helper.cc b/ui/aura/test/aura_test_helper.cc index e5d0776..4d2e6a2 100644 --- a/ui/aura/test/aura_test_helper.cc +++ b/ui/aura/test/aura_test_helper.cc @@ -22,6 +22,7 @@ #include "ui/compositor/compositor.h" #include "ui/compositor/layer_animator.h" #include "ui/compositor/scoped_animation_duration_scale_mode.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/gfx/screen.h" #if defined(USE_X11) @@ -66,7 +67,7 @@ void AuraTestHelper::SetUp() { // The ContextFactory must exist before any Compositors are created. bool allow_test_contexts = true; - ui::Compositor::InitializeContextFactoryForTests(allow_test_contexts); + ui::InitializeContextFactoryForTests(allow_test_contexts); Env::CreateInstance(); // Unit tests generally don't want to query the system, rather use the state @@ -115,6 +116,8 @@ void AuraTestHelper::TearDown() { ui::ShutdownInputMethodForTesting(); Env::DeleteInstance(); + + ui::TerminateContextFactoryForTests(); } void AuraTestHelper::RunAllPendingInMessageLoop() { diff --git a/ui/compositor/compositor.cc b/ui/compositor/compositor.cc index 9c57dc7..0605f62 100644 --- a/ui/compositor/compositor.cc +++ b/ui/compositor/compositor.cc @@ -18,27 +18,18 @@ #include "base/threading/thread.h" #include "base/threading/thread_restrictions.h" #include "cc/base/switches.h" -#include "cc/debug/test_context_provider.h" -#include "cc/debug/test_web_graphics_context_3d.h" #include "cc/input/input_handler.h" #include "cc/layers/layer.h" #include "cc/output/context_provider.h" -#include "cc/output/output_surface.h" #include "cc/trees/layer_tree_host.h" #include "third_party/skia/include/core/SkBitmap.h" #include "ui/compositor/compositor_observer.h" #include "ui/compositor/compositor_switches.h" #include "ui/compositor/dip_util.h" #include "ui/compositor/layer.h" -#include "ui/compositor/reflector.h" #include "ui/gfx/frame_time.h" #include "ui/gl/gl_context.h" -#include "ui/gl/gl_implementation.h" -#include "ui/gl/gl_surface.h" #include "ui/gl/gl_switches.h" -#include "webkit/common/gpu/context_provider_in_process.h" -#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" -#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" namespace { @@ -53,7 +44,6 @@ enum SwapType { bool g_compositor_initialized = false; base::Thread* g_compositor_thread = NULL; -ui::ContextFactory* g_implicit_factory = NULL; ui::ContextFactory* g_context_factory = NULL; const int kCompositorLockTimeoutMs = 67; @@ -91,141 +81,6 @@ void ContextFactory::SetInstance(ContextFactory* instance) { g_context_factory = instance; } -DefaultContextFactory::DefaultContextFactory() { -} - -DefaultContextFactory::~DefaultContextFactory() { -} - -bool DefaultContextFactory::Initialize() { - if (!gfx::GLSurface::InitializeOneOff() || - gfx::GetGLImplementation() == gfx::kGLImplementationNone) { - LOG(ERROR) << "Could not load the GL bindings"; - return false; - } - return true; -} - -scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( - Compositor* compositor) { - WebKit::WebGraphicsContext3D::Attributes attrs; - attrs.depth = false; - attrs.stencil = false; - attrs.antialias = false; - attrs.shareResources = true; - - using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; - scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( - WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( - attrs, compositor->widget())); - CHECK(context3d); - - using webkit::gpu::ContextProviderInProcess; - scoped_refptr<ContextProviderInProcess> context_provider = - ContextProviderInProcess::Create(context3d.Pass(), - "UICompositor"); - - return make_scoped_ptr(new cc::OutputSurface(context_provider)); -} - -scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( - Compositor* mirroed_compositor, - Layer* mirroring_layer) { - return NULL; -} - -void DefaultContextFactory::RemoveReflector( - scoped_refptr<Reflector> reflector) { -} - -scoped_refptr<cc::ContextProvider> -DefaultContextFactory::OffscreenCompositorContextProvider() { - if (!offscreen_compositor_contexts_.get() || - !offscreen_compositor_contexts_->DestroyedOnMainThread()) { - offscreen_compositor_contexts_ = - webkit::gpu::ContextProviderInProcess::CreateOffscreen(); - } - return offscreen_compositor_contexts_; -} - -scoped_refptr<cc::ContextProvider> -DefaultContextFactory::SharedMainThreadContextProvider() { - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->DestroyedOnMainThread()) - return shared_main_thread_contexts_; - - if (ui::Compositor::WasInitializedWithThread()) { - shared_main_thread_contexts_ = - webkit::gpu::ContextProviderInProcess::CreateOffscreen(); - } else { - shared_main_thread_contexts_ = - static_cast<webkit::gpu::ContextProviderInProcess*>( - OffscreenCompositorContextProvider().get()); - } - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->BindToCurrentThread()) - shared_main_thread_contexts_ = NULL; - - return shared_main_thread_contexts_; -} - -void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { -} - -bool DefaultContextFactory::DoesCreateTestContexts() { return false; } - -TestContextFactory::TestContextFactory() {} - -TestContextFactory::~TestContextFactory() {} - -scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( - Compositor* compositor) { - return make_scoped_ptr( - new cc::OutputSurface(cc::TestContextProvider::Create())); -} - -scoped_refptr<Reflector> TestContextFactory::CreateReflector( - Compositor* mirrored_compositor, - Layer* mirroring_layer) { - return new Reflector(); -} - -void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) { -} - -scoped_refptr<cc::ContextProvider> -TestContextFactory::OffscreenCompositorContextProvider() { - if (!offscreen_compositor_contexts_.get() || - offscreen_compositor_contexts_->DestroyedOnMainThread()) - offscreen_compositor_contexts_ = cc::TestContextProvider::Create(); - return offscreen_compositor_contexts_; -} - -scoped_refptr<cc::ContextProvider> -TestContextFactory::SharedMainThreadContextProvider() { - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->DestroyedOnMainThread()) - return shared_main_thread_contexts_; - - if (ui::Compositor::WasInitializedWithThread()) { - shared_main_thread_contexts_ = cc::TestContextProvider::Create(); - } else { - shared_main_thread_contexts_ = - static_cast<cc::TestContextProvider*>( - OffscreenCompositorContextProvider().get()); - } - if (shared_main_thread_contexts_ && - !shared_main_thread_contexts_->BindToCurrentThread()) - shared_main_thread_contexts_ = NULL; - - return shared_main_thread_contexts_; -} - -void TestContextFactory::RemoveCompositor(Compositor* compositor) { -} - -bool TestContextFactory::DoesCreateTestContexts() { return true; } - Texture::Texture(bool flipped, const gfx::Size& size, float device_scale_factor) : size_(size), flipped_(flipped), @@ -460,44 +315,6 @@ Compositor::~Compositor() { } // static -void Compositor::InitializeContextFactoryForTests(bool allow_test_contexts) { - // The factory may already have been initialized by the content layer, in - // which case, use that one. - if (g_context_factory) - return; - DCHECK(!g_implicit_factory) << - "ContextFactory for tests already initialized."; - - bool use_test_contexts = true; - - // 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; - -#if defined(OS_CHROMEOS) - // If the test is running on the chromeos envrionment (such as - // device or vm bots), always use real contexts. - if (base::SysInfo::IsRunningOnChromeOS()) - use_test_contexts = false; -#endif - - if (!allow_test_contexts) - use_test_contexts = false; - - if (use_test_contexts) { - g_implicit_factory = new ui::TestContextFactory; - } else { - DVLOG(1) << "Using DefaultContextFactory"; - scoped_ptr<ui::DefaultContextFactory> instance( - new ui::DefaultContextFactory()); - if (instance->Initialize()) - g_implicit_factory = instance.release(); - } - g_context_factory = g_implicit_factory; -} - -// static void Compositor::Initialize() { #if defined(OS_CHROMEOS) bool use_thread = !CommandLine::ForCurrentProcess()->HasSwitch( @@ -534,17 +351,7 @@ scoped_refptr<base::MessageLoopProxy> Compositor::GetCompositorMessageLoop() { // static void Compositor::Terminate() { - if (g_context_factory) { - if (g_implicit_factory) { - delete g_implicit_factory; - g_implicit_factory = NULL; - } - g_context_factory = NULL; - } - if (g_compositor_thread) { - DCHECK(!g_context_factory) - << "The ContextFactory should not outlive the compositor thread."; g_compositor_thread->Stop(); delete g_compositor_thread; g_compositor_thread = NULL; diff --git a/ui/compositor/compositor.gyp b/ui/compositor/compositor.gyp index 00c6873..5c6291f 100644 --- a/ui/compositor/compositor.gyp +++ b/ui/compositor/compositor.gyp @@ -20,7 +20,6 @@ '<(DEPTH)/ui/gfx/gfx.gyp:gfx', '<(DEPTH)/ui/gl/gl.gyp:gl', '<(DEPTH)/ui/ui.gyp:ui', - '<(DEPTH)/webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', ], 'defines': [ 'COMPOSITOR_IMPLEMENTATION', @@ -78,16 +77,25 @@ 'type': 'static_library', 'dependencies': [ '<(DEPTH)/base/base.gyp:base', + '<(DEPTH)/cc/cc.gyp:cc', '<(DEPTH)/skia/skia.gyp:skia', + '<(DEPTH)/third_party/WebKit/public/blink.gyp:blink_minimal', '<(DEPTH)/ui/events/events.gyp:events', '<(DEPTH)/ui/gfx/gfx.gyp:gfx', '<(DEPTH)/ui/gl/gl.gyp:gl', '<(DEPTH)/ui/ui.gyp:ui', + '<(DEPTH)/webkit/common/gpu/webkit_gpu.gyp:webkit_gpu', 'compositor', ], 'sources': [ 'test/test_layers.cc', 'test/test_layers.h', + 'test/test_context_factory.cc', + 'test/test_context_factory.h', + 'test/default_context_factory.cc', + 'test/default_context_factory.h', + 'test/context_factories_for_test.cc', + 'test/context_factories_for_test.h', 'test/test_suite.cc', 'test/test_suite.h', ], diff --git a/ui/compositor/compositor.h b/ui/compositor/compositor.h index 8992969..513822a 100644 --- a/ui/compositor/compositor.h +++ b/ui/compositor/compositor.h @@ -34,7 +34,6 @@ class ContextProvider; class Layer; class LayerTreeDebugState; class LayerTreeHost; -class TestContextProvider; } namespace gfx { @@ -117,68 +116,6 @@ class COMPOSITOR_EXPORT ContextFactory { virtual bool DoesCreateTestContexts() = 0; }; -// The default factory that creates in-process contexts. -class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { - public: - DefaultContextFactory(); - virtual ~DefaultContextFactory(); - - // ContextFactory implementation - virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( - Compositor* compositor) OVERRIDE; - - virtual scoped_refptr<Reflector> CreateReflector( - Compositor* compositor, - Layer* layer) OVERRIDE; - virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; - - virtual scoped_refptr<cc::ContextProvider> - OffscreenCompositorContextProvider() OVERRIDE; - virtual scoped_refptr<cc::ContextProvider> - SharedMainThreadContextProvider() OVERRIDE; - virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; - virtual bool DoesCreateTestContexts() OVERRIDE; - - bool Initialize(); - - private: - scoped_refptr<webkit::gpu::ContextProviderInProcess> - offscreen_compositor_contexts_; - scoped_refptr<webkit::gpu::ContextProviderInProcess> - shared_main_thread_contexts_; - - DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); -}; - -// The factory that creates test contexts. -class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory { - public: - TestContextFactory(); - virtual ~TestContextFactory(); - - // ContextFactory implementation - virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( - Compositor* compositor) OVERRIDE; - - virtual scoped_refptr<Reflector> CreateReflector( - Compositor* mirrored_compositor, - Layer* mirroring_layer) OVERRIDE; - virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; - - virtual scoped_refptr<cc::ContextProvider> - OffscreenCompositorContextProvider() OVERRIDE; - virtual scoped_refptr<cc::ContextProvider> - SharedMainThreadContextProvider() OVERRIDE; - virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; - virtual bool DoesCreateTestContexts() OVERRIDE; - - private: - scoped_refptr<cc::TestContextProvider> offscreen_compositor_contexts_; - scoped_refptr<cc::TestContextProvider> shared_main_thread_contexts_; - - DISALLOW_COPY_AND_ASSIGN(TestContextFactory); -}; - // Texture provide an abstraction over the external texture that can be passed // to a layer. class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { @@ -288,14 +225,6 @@ class COMPOSITOR_EXPORT Compositor gfx::AcceleratedWidget widget); virtual ~Compositor(); - // Set up the compositor ContextFactory for a test environment. Unit tests - // that do not have a full content environment need to call this before - // initializing the Compositor. - // Some tests expect pixel output, and they should pass false for - // |allow_test_contexts|. Most unit tests should pass true. Once this has been - // called, the Initialize() and Terminate() methods should be used as normal. - static void InitializeContextFactoryForTests(bool allow_test_contexts); - static void Initialize(); static bool WasInitializedWithThread(); static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc index 7ba9dc7..ea21e24 100644 --- a/ui/compositor/layer_unittest.cc +++ b/ui/compositor/layer_unittest.cc @@ -22,6 +22,7 @@ #include "ui/compositor/layer.h" #include "ui/compositor/layer_animation_sequence.h" #include "ui/compositor/layer_animator.h" +#include "ui/compositor/test/context_factories_for_test.h" #include "ui/compositor/test/test_compositor_host.h" #include "ui/compositor/test/test_layers.h" #include "ui/gfx/canvas.h" @@ -84,7 +85,7 @@ class LayerWithRealCompositorTest : public testing::Test { // Overridden from testing::Test: virtual void SetUp() OVERRIDE { bool allow_test_contexts = false; - Compositor::InitializeContextFactoryForTests(allow_test_contexts); + InitializeContextFactoryForTests(allow_test_contexts); Compositor::Initialize(); const gfx::Rect host_bounds(10, 10, 500, 500); @@ -94,6 +95,7 @@ class LayerWithRealCompositorTest : public testing::Test { virtual void TearDown() OVERRIDE { window_.reset(); + TerminateContextFactoryForTests(); Compositor::Terminate(); } @@ -351,7 +353,7 @@ class LayerWithDelegateTest : public testing::Test { // Overridden from testing::Test: virtual void SetUp() OVERRIDE { bool allow_test_contexts = true; - Compositor::InitializeContextFactoryForTests(allow_test_contexts); + InitializeContextFactoryForTests(allow_test_contexts); Compositor::Initialize(); compositor_.reset(new Compositor(false, gfx::kNullAcceleratedWidget)); compositor_->SetScaleAndSize(1.0f, gfx::Size(1000, 1000)); @@ -359,6 +361,7 @@ class LayerWithDelegateTest : public testing::Test { virtual void TearDown() OVERRIDE { compositor_.reset(); + TerminateContextFactoryForTests(); Compositor::Terminate(); } diff --git a/ui/compositor/reflector.h b/ui/compositor/reflector.h index e6fb94c..4145695 100644 --- a/ui/compositor/reflector.h +++ b/ui/compositor/reflector.h @@ -5,12 +5,11 @@ #ifndef UI_COMPOSITOR_REFLECTOR_H_ #define UI_COMPOSITOR_REFLECTOR_H_ -#include "ui/compositor/compositor_export.h" +#include "base/memory/ref_counted.h" namespace ui { -class COMPOSITOR_EXPORT Reflector - : public base::RefCountedThreadSafe<Reflector> { +class Reflector : public base::RefCountedThreadSafe<Reflector> { public: Reflector() {} diff --git a/ui/compositor/test/context_factories_for_test.cc b/ui/compositor/test/context_factories_for_test.cc new file mode 100644 index 0000000..795f56d --- /dev/null +++ b/ui/compositor/test/context_factories_for_test.cc @@ -0,0 +1,58 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/compositor/test/context_factories_for_test.h" + +#include "base/command_line.h" +#include "base/sys_info.h" +#include "ui/compositor/compositor.h" +#include "ui/compositor/compositor_switches.h" +#include "ui/compositor/test/default_context_factory.h" +#include "ui/compositor/test/test_context_factory.h" + +namespace ui { + +static ContextFactory* g_implicit_factory = NULL; + +// static +void InitializeContextFactoryForTests(bool allow_test_contexts) { + DCHECK(!g_implicit_factory) << + "ContextFactory for tests already initialized."; + + bool use_test_contexts = true; + + // 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; + +#if defined(OS_CHROMEOS) + // If the test is running on the chromeos envrionment (such as + // device or vm bots), always use real contexts. + if (base::SysInfo::IsRunningOnChromeOS()) + use_test_contexts = false; +#endif + + if (!allow_test_contexts) + use_test_contexts = false; + + if (use_test_contexts) { + g_implicit_factory = new ui::TestContextFactory; + } else { + DVLOG(1) << "Using DefaultContextFactory"; + scoped_ptr<ui::DefaultContextFactory> instance( + new ui::DefaultContextFactory()); + if (instance->Initialize()) + g_implicit_factory = instance.release(); + } + ContextFactory::SetInstance(g_implicit_factory); +} + +void TerminateContextFactoryForTests() { + ContextFactory::SetInstance(NULL); + delete g_implicit_factory; + g_implicit_factory = NULL; +} + +} // namespace ui diff --git a/ui/compositor/test/context_factories_for_test.h b/ui/compositor/test/context_factories_for_test.h new file mode 100644 index 0000000..a2b314f --- /dev/null +++ b/ui/compositor/test/context_factories_for_test.h @@ -0,0 +1,16 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +namespace ui { + +// Set up the compositor ContextFactory for a test environment. Unit tests +// that do not have a full content environment need to call this before +// initializing the Compositor. +// Some tests expect pixel output, and they should pass false for +// |allow_test_contexts|. Most unit tests should pass true. Once this has been +// called, the caller must call TerminateContextFactoryForTests() to clean up. +void InitializeContextFactoryForTests(bool allow_test_contexts); +void TerminateContextFactoryForTests(); + +} // namespace ui diff --git a/ui/compositor/test/default_context_factory.cc b/ui/compositor/test/default_context_factory.cc new file mode 100644 index 0000000..c1700fe --- /dev/null +++ b/ui/compositor/test/default_context_factory.cc @@ -0,0 +1,100 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/compositor/test/default_context_factory.h" + +#include "cc/output/output_surface.h" +#include "ui/compositor/reflector.h" +#include "ui/gl/gl_implementation.h" +#include "ui/gl/gl_surface.h" +#include "webkit/common/gpu/context_provider_in_process.h" +#include "webkit/common/gpu/grcontext_for_webgraphicscontext3d.h" +#include "webkit/common/gpu/webgraphicscontext3d_in_process_command_buffer_impl.h" + +namespace ui { + +DefaultContextFactory::DefaultContextFactory() { +} + +DefaultContextFactory::~DefaultContextFactory() { +} + +bool DefaultContextFactory::Initialize() { + if (!gfx::GLSurface::InitializeOneOff() || + gfx::GetGLImplementation() == gfx::kGLImplementationNone) { + LOG(ERROR) << "Could not load the GL bindings"; + return false; + } + return true; +} + +scoped_ptr<cc::OutputSurface> DefaultContextFactory::CreateOutputSurface( + Compositor* compositor) { + WebKit::WebGraphicsContext3D::Attributes attrs; + attrs.depth = false; + attrs.stencil = false; + attrs.antialias = false; + attrs.shareResources = true; + + using webkit::gpu::WebGraphicsContext3DInProcessCommandBufferImpl; + scoped_ptr<WebGraphicsContext3DInProcessCommandBufferImpl> context3d( + WebGraphicsContext3DInProcessCommandBufferImpl::CreateViewContext( + attrs, compositor->widget())); + CHECK(context3d); + + using webkit::gpu::ContextProviderInProcess; + scoped_refptr<ContextProviderInProcess> context_provider = + ContextProviderInProcess::Create(context3d.Pass(), + "UICompositor"); + + return make_scoped_ptr(new cc::OutputSurface(context_provider)); +} + +scoped_refptr<Reflector> DefaultContextFactory::CreateReflector( + Compositor* mirroed_compositor, + Layer* mirroring_layer) { + return NULL; +} + +void DefaultContextFactory::RemoveReflector( + scoped_refptr<Reflector> reflector) { +} + +scoped_refptr<cc::ContextProvider> +DefaultContextFactory::OffscreenCompositorContextProvider() { + if (!offscreen_compositor_contexts_.get() || + !offscreen_compositor_contexts_->DestroyedOnMainThread()) { + offscreen_compositor_contexts_ = + webkit::gpu::ContextProviderInProcess::CreateOffscreen(); + } + return offscreen_compositor_contexts_; +} + +scoped_refptr<cc::ContextProvider> +DefaultContextFactory::SharedMainThreadContextProvider() { + if (shared_main_thread_contexts_ && + !shared_main_thread_contexts_->DestroyedOnMainThread()) + return shared_main_thread_contexts_; + + if (ui::Compositor::WasInitializedWithThread()) { + shared_main_thread_contexts_ = + webkit::gpu::ContextProviderInProcess::CreateOffscreen(); + } else { + shared_main_thread_contexts_ = + static_cast<webkit::gpu::ContextProviderInProcess*>( + OffscreenCompositorContextProvider().get()); + } + if (shared_main_thread_contexts_ && + !shared_main_thread_contexts_->BindToCurrentThread()) + shared_main_thread_contexts_ = NULL; + + return shared_main_thread_contexts_; +} + +void DefaultContextFactory::RemoveCompositor(Compositor* compositor) { +} + +bool DefaultContextFactory::DoesCreateTestContexts() { return false; } + +} // namespace ui diff --git a/ui/compositor/test/default_context_factory.h b/ui/compositor/test/default_context_factory.h new file mode 100644 index 0000000..b89bdd8 --- /dev/null +++ b/ui/compositor/test/default_context_factory.h @@ -0,0 +1,53 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_COMPOSITOR_TEST_DEFAULT_CONTEXT_FACTORY_H_ +#define UI_COMPOSITOR_TEST_DEFAULT_CONTEXT_FACTORY_H_ + +#include "ui/compositor/compositor.h" + +namespace webkit { +namespace gpu { +class ContextProviderInProcess; +} +} + +namespace ui { + +// The default factory that creates in-process contexts. +class DefaultContextFactory : public ContextFactory { + public: + DefaultContextFactory(); + virtual ~DefaultContextFactory(); + + // ContextFactory implementation + virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( + Compositor* compositor) OVERRIDE; + + virtual scoped_refptr<Reflector> CreateReflector( + Compositor* compositor, + Layer* layer) OVERRIDE; + virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; + + virtual scoped_refptr<cc::ContextProvider> + OffscreenCompositorContextProvider() OVERRIDE; + virtual scoped_refptr<cc::ContextProvider> + SharedMainThreadContextProvider() OVERRIDE; + virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; + virtual bool DoesCreateTestContexts() OVERRIDE; + + bool Initialize(); + + private: + scoped_refptr<webkit::gpu::ContextProviderInProcess> + offscreen_compositor_contexts_; + scoped_refptr<webkit::gpu::ContextProviderInProcess> + shared_main_thread_contexts_; + + DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); +}; + +} // namespace ui + +#endif // UI_COMPOSITOR_TEST_DEFAULT_CONTEXT_FACTORY_H_ diff --git a/ui/compositor/test/test_context_factory.cc b/ui/compositor/test/test_context_factory.cc new file mode 100644 index 0000000..30f84fb --- /dev/null +++ b/ui/compositor/test/test_context_factory.cc @@ -0,0 +1,65 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "ui/compositor/test/test_context_factory.h" + +#include "cc/debug/test_context_provider.h" +#include "cc/output/output_surface.h" +#include "ui/compositor/reflector.h" + +namespace ui { + +TestContextFactory::TestContextFactory() {} + +TestContextFactory::~TestContextFactory() {} + +scoped_ptr<cc::OutputSurface> TestContextFactory::CreateOutputSurface( + Compositor* compositor) { + return make_scoped_ptr( + new cc::OutputSurface(cc::TestContextProvider::Create())); +} + +scoped_refptr<Reflector> TestContextFactory::CreateReflector( + Compositor* mirrored_compositor, + Layer* mirroring_layer) { + return new Reflector(); +} + +void TestContextFactory::RemoveReflector(scoped_refptr<Reflector> reflector) { +} + +scoped_refptr<cc::ContextProvider> +TestContextFactory::OffscreenCompositorContextProvider() { + if (!offscreen_compositor_contexts_.get() || + offscreen_compositor_contexts_->DestroyedOnMainThread()) + offscreen_compositor_contexts_ = cc::TestContextProvider::Create(); + return offscreen_compositor_contexts_; +} + +scoped_refptr<cc::ContextProvider> +TestContextFactory::SharedMainThreadContextProvider() { + if (shared_main_thread_contexts_ && + !shared_main_thread_contexts_->DestroyedOnMainThread()) + return shared_main_thread_contexts_; + + if (ui::Compositor::WasInitializedWithThread()) { + shared_main_thread_contexts_ = cc::TestContextProvider::Create(); + } else { + shared_main_thread_contexts_ = + static_cast<cc::TestContextProvider*>( + OffscreenCompositorContextProvider().get()); + } + if (shared_main_thread_contexts_ && + !shared_main_thread_contexts_->BindToCurrentThread()) + shared_main_thread_contexts_ = NULL; + + return shared_main_thread_contexts_; +} + +void TestContextFactory::RemoveCompositor(Compositor* compositor) { +} + +bool TestContextFactory::DoesCreateTestContexts() { return true; } + +} // namespace ui diff --git a/ui/compositor/test/test_context_factory.h b/ui/compositor/test/test_context_factory.h new file mode 100644 index 0000000..d419292 --- /dev/null +++ b/ui/compositor/test/test_context_factory.h @@ -0,0 +1,45 @@ +// Copyright 2013 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_ +#define UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_ + +#include "ui/compositor/compositor.h" + +namespace cc { class TestContextProvider; } + +namespace ui { + +// The factory that creates test contexts. +class TestContextFactory : public ContextFactory { + public: + TestContextFactory(); + virtual ~TestContextFactory(); + + // ContextFactory implementation + virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( + Compositor* compositor) OVERRIDE; + + virtual scoped_refptr<Reflector> CreateReflector( + Compositor* mirrored_compositor, + Layer* mirroring_layer) OVERRIDE; + virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; + + virtual scoped_refptr<cc::ContextProvider> + OffscreenCompositorContextProvider() OVERRIDE; + virtual scoped_refptr<cc::ContextProvider> + SharedMainThreadContextProvider() OVERRIDE; + virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; + virtual bool DoesCreateTestContexts() OVERRIDE; + + private: + scoped_refptr<cc::TestContextProvider> offscreen_compositor_contexts_; + scoped_refptr<cc::TestContextProvider> shared_main_thread_contexts_; + + DISALLOW_COPY_AND_ASSIGN(TestContextFactory); +}; + +} // namespace ui + +#endif // UI_COMPOSITOR_TEST_TEST_CONTEXT_FACTORY_H_ |