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 "ui/compositor/compositor.h"
10 #include "ui/compositor/compositor_switches.h"
11 #include "ui/gl/gl_implementation.h"
16 ImageTransportFactory
* g_factory
= NULL
;
17 bool g_initialized_for_unit_tests
= false;
18 static gfx::DisableNullDrawGLBindings
* g_disable_null_draw
= NULL
;
20 void SetFactory(ImageTransportFactory
* factory
) {
27 void ImageTransportFactory::Initialize() {
28 DCHECK(!g_factory
|| g_initialized_for_unit_tests
);
29 if (g_initialized_for_unit_tests
)
31 SetFactory(new GpuProcessTransportFactory
);
34 void ImageTransportFactory::InitializeForUnitTests(
35 scoped_ptr
<ImageTransportFactory
> factory
) {
37 DCHECK(!g_initialized_for_unit_tests
);
38 g_initialized_for_unit_tests
= true;
40 const base::CommandLine
* command_line
=
41 base::CommandLine::ForCurrentProcess();
42 if (command_line
->HasSwitch(switches::kEnablePixelOutputInTests
))
43 g_disable_null_draw
= new gfx::DisableNullDrawGLBindings
;
45 SetFactory(factory
.release());
49 void ImageTransportFactory::Terminate() {
52 delete g_disable_null_draw
;
53 g_disable_null_draw
= NULL
;
54 g_initialized_for_unit_tests
= false;
58 ImageTransportFactory
* ImageTransportFactory::GetInstance() {
62 } // namespace content