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

Side by Side Diff: content/browser/compositor/image_transport_factory.cc

Issue 145293007: ui: No more TestCompositor. Use NullDraw contexts in unit tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: testsnulldraw: Created 6 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/compositor/image_transport_factory.h" 5 #include "content/browser/compositor/image_transport_factory.h"
6 6
7 #include "base/command_line.h"
7 #include "content/browser/compositor/gpu_process_transport_factory.h" 8 #include "content/browser/compositor/gpu_process_transport_factory.h"
8 #include "content/browser/compositor/no_transport_image_transport_factory.h" 9 #include "content/browser/compositor/no_transport_image_transport_factory.h"
9 #include "ui/compositor/compositor.h" 10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h"
12 #include "ui/gl/gl_implementation.h"
10 13
11 namespace content { 14 namespace content {
12 15
13 namespace { 16 namespace {
14 ImageTransportFactory* g_factory = NULL; 17 ImageTransportFactory* g_factory = NULL;
15 bool g_initialized_for_unit_tests = false; 18 bool g_initialized_for_unit_tests = false;
19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
16 } 20 }
17 21
18 // static 22 // static
19 void ImageTransportFactory::Initialize() { 23 void ImageTransportFactory::Initialize() {
20 DCHECK(!g_factory || g_initialized_for_unit_tests); 24 DCHECK(!g_factory || g_initialized_for_unit_tests);
21 if (g_initialized_for_unit_tests) 25 if (g_initialized_for_unit_tests)
22 return; 26 return;
23 g_factory = new GpuProcessTransportFactory; 27 g_factory = new GpuProcessTransportFactory;
24 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); 28 ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
25 } 29 }
26 30
27 void ImageTransportFactory::InitializeForUnitTests( 31 void ImageTransportFactory::InitializeForUnitTests(
28 scoped_ptr<ui::ContextFactory> test_factory) { 32 scoped_ptr<ui::ContextFactory> test_factory) {
29 DCHECK(!g_factory); 33 DCHECK(!g_factory);
30 DCHECK(!g_initialized_for_unit_tests); 34 DCHECK(!g_initialized_for_unit_tests);
31 g_initialized_for_unit_tests = true; 35 g_initialized_for_unit_tests = true;
36
37 CommandLine* command_line = CommandLine::ForCurrentProcess();
38 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
39 g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
danakj 2014/01/29 01:28:21 This is duplicated with the InitializeContextFacto
40
32 g_factory = new NoTransportImageTransportFactory(test_factory.Pass()); 41 g_factory = new NoTransportImageTransportFactory(test_factory.Pass());
33 ui::ContextFactory::SetInstance(g_factory->AsContextFactory()); 42 ui::ContextFactory::SetInstance(g_factory->AsContextFactory());
34 } 43 }
35 44
36 // static 45 // static
37 void ImageTransportFactory::Terminate() { 46 void ImageTransportFactory::Terminate() {
38 ui::ContextFactory::SetInstance(NULL); 47 ui::ContextFactory::SetInstance(NULL);
39 delete g_factory; 48 delete g_factory;
40 g_factory = NULL; 49 g_factory = NULL;
50 delete g_disable_null_draw;
51 g_disable_null_draw = NULL;
41 g_initialized_for_unit_tests = false; 52 g_initialized_for_unit_tests = false;
42 } 53 }
43 54
44 // static 55 // static
45 ImageTransportFactory* ImageTransportFactory::GetInstance() { 56 ImageTransportFactory* ImageTransportFactory::GetInstance() {
46 return g_factory; 57 return g_factory;
47 } 58 }
48 59
49 } // namespace content 60 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698