1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/browser/compositor/image_transport_factory.h"
7 #include "base/command_line.h"
8 #include "content/browser/compositor/gpu_process_transport_factory.h"
9 #include "content/browser/compositor/no_transport_image_transport_factory.h"
10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h"
12 #include "ui/gl/gl_implementation.h"
17 ImageTransportFactory* g_factory = NULL;
18 bool g_initialized_for_unit_tests = false;
19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
21 void SetFactory(ImageTransportFactory* factory) {
23 ui::ContextFactory::SetInstance(factory->GetContextFactory());
29 void ImageTransportFactory::Initialize() {
30 DCHECK(!g_factory || g_initialized_for_unit_tests);
31 if (g_initialized_for_unit_tests)
33 SetFactory(new GpuProcessTransportFactory);
36 void ImageTransportFactory::InitializeForUnitTests(
37 scoped_ptr<ui::ContextFactory> test_factory) {
39 DCHECK(!g_initialized_for_unit_tests);
40 g_initialized_for_unit_tests = true;
42 CommandLine* command_line = CommandLine::ForCurrentProcess();
43 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
44 g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
46 SetFactory(new NoTransportImageTransportFactory(test_factory.Pass()));
50 void ImageTransportFactory::Terminate() {
51 ui::ContextFactory::SetInstance(NULL);
54 delete g_disable_null_draw;
55 g_disable_null_draw = NULL;
56 g_initialized_for_unit_tests = false;
60 ImageTransportFactory* ImageTransportFactory::GetInstance() {
64 } // namespace content