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

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

Issue 307963007: Removes ContextFactory::Get/SetInstance (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix aura_bench Created 6 years, 6 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
« no previous file with comments | « no previous file | ui/aura/bench/bench_main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/command_line.h"
8 #include "content/browser/compositor/gpu_process_transport_factory.h" 8 #include "content/browser/compositor/gpu_process_transport_factory.h"
9 #include "content/browser/compositor/no_transport_image_transport_factory.h" 9 #include "content/browser/compositor/no_transport_image_transport_factory.h"
10 #include "ui/compositor/compositor.h" 10 #include "ui/compositor/compositor.h"
11 #include "ui/compositor/compositor_switches.h" 11 #include "ui/compositor/compositor_switches.h"
12 #include "ui/gl/gl_implementation.h" 12 #include "ui/gl/gl_implementation.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 namespace { 16 namespace {
17 ImageTransportFactory* g_factory = NULL; 17 ImageTransportFactory* g_factory = NULL;
18 bool g_initialized_for_unit_tests = false; 18 bool g_initialized_for_unit_tests = false;
19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL; 19 static gfx::DisableNullDrawGLBindings* g_disable_null_draw = NULL;
20 20
21 void SetFactory(ImageTransportFactory* factory) { 21 void SetFactory(ImageTransportFactory* factory) {
22 g_factory = factory; 22 g_factory = factory;
23 ui::ContextFactory::SetInstance(factory->GetContextFactory());
24 } 23 }
25 24
26 } 25 }
27 26
28 // static 27 // static
29 void ImageTransportFactory::Initialize() { 28 void ImageTransportFactory::Initialize() {
30 DCHECK(!g_factory || g_initialized_for_unit_tests); 29 DCHECK(!g_factory || g_initialized_for_unit_tests);
31 if (g_initialized_for_unit_tests) 30 if (g_initialized_for_unit_tests)
32 return; 31 return;
33 SetFactory(new GpuProcessTransportFactory); 32 SetFactory(new GpuProcessTransportFactory);
34 } 33 }
35 34
36 void ImageTransportFactory::InitializeForUnitTests( 35 void ImageTransportFactory::InitializeForUnitTests(
37 scoped_ptr<ui::ContextFactory> test_factory) { 36 scoped_ptr<ui::ContextFactory> test_factory) {
38 DCHECK(!g_factory); 37 DCHECK(!g_factory);
39 DCHECK(!g_initialized_for_unit_tests); 38 DCHECK(!g_initialized_for_unit_tests);
40 g_initialized_for_unit_tests = true; 39 g_initialized_for_unit_tests = true;
41 40
42 CommandLine* command_line = CommandLine::ForCurrentProcess(); 41 CommandLine* command_line = CommandLine::ForCurrentProcess();
43 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests)) 42 if (command_line->HasSwitch(switches::kEnablePixelOutputInTests))
44 g_disable_null_draw = new gfx::DisableNullDrawGLBindings; 43 g_disable_null_draw = new gfx::DisableNullDrawGLBindings;
45 44
46 SetFactory(new NoTransportImageTransportFactory(test_factory.Pass())); 45 SetFactory(new NoTransportImageTransportFactory(test_factory.Pass()));
47 } 46 }
48 47
49 // static 48 // static
50 void ImageTransportFactory::Terminate() { 49 void ImageTransportFactory::Terminate() {
51 ui::ContextFactory::SetInstance(NULL);
52 delete g_factory; 50 delete g_factory;
53 g_factory = NULL; 51 g_factory = NULL;
54 delete g_disable_null_draw; 52 delete g_disable_null_draw;
55 g_disable_null_draw = NULL; 53 g_disable_null_draw = NULL;
56 g_initialized_for_unit_tests = false; 54 g_initialized_for_unit_tests = false;
57 } 55 }
58 56
59 // static 57 // static
60 ImageTransportFactory* ImageTransportFactory::GetInstance() { 58 ImageTransportFactory* ImageTransportFactory::GetInstance() {
61 return g_factory; 59 return g_factory;
62 } 60 }
63 61
64 } // namespace content 62 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/aura/bench/bench_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698