OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer_host/image_transport_factory_android.h" | 5 #include "content/browser/renderer_host/image_transport_factory_android.h" |
6 | 6 |
7 #include "base/lazy_instance.h" | 7 #include "base/lazy_instance.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" | 9 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
10 #include "content/common/gpu/client/gl_helper.h" | 10 #include "content/common/gpu/client/gl_helper.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 if (!gl_helper_) | 97 if (!gl_helper_) |
98 gl_helper_.reset(new GLHelper(context_->GetImplementation(), | 98 gl_helper_.reset(new GLHelper(context_->GetImplementation(), |
99 context_->GetContextSupport())); | 99 context_->GetContextSupport())); |
100 | 100 |
101 return gl_helper_.get(); | 101 return gl_helper_.get(); |
102 } | 102 } |
103 | 103 |
104 } // anonymous namespace | 104 } // anonymous namespace |
105 | 105 |
106 // static | 106 // static |
| 107 void ImageTransportFactoryAndroid::InitializeForUnitTests( |
| 108 ImageTransportFactoryAndroid* test_factory) { |
| 109 DCHECK(!g_factory); |
| 110 g_factory = test_factory; |
| 111 } |
| 112 |
| 113 // static |
| 114 void ImageTransportFactoryAndroid::TerminateForUnitTests() { |
| 115 DCHECK(g_factory); |
| 116 delete g_factory; |
| 117 g_factory = NULL; |
| 118 } |
| 119 |
| 120 // static |
107 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { | 121 ImageTransportFactoryAndroid* ImageTransportFactoryAndroid::GetInstance() { |
108 if (!g_factory) | 122 if (!g_factory) |
109 g_factory = new CmdBufferImageTransportFactory(); | 123 g_factory = new CmdBufferImageTransportFactory(); |
110 | 124 |
111 return g_factory; | 125 return g_factory; |
112 } | 126 } |
113 | 127 |
114 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() | 128 ImageTransportFactoryAndroid::ImageTransportFactoryAndroid() |
115 : context_lost_listener_(new GLContextLostListener()) {} | 129 : context_lost_listener_(new GLContextLostListener()) {} |
116 | 130 |
(...skipping 20 matching lines...) Expand all Loading... |
137 | 151 |
138 void GLContextLostListener::DidLoseContext() { | 152 void GLContextLostListener::DidLoseContext() { |
139 delete g_factory; | 153 delete g_factory; |
140 g_factory = NULL; | 154 g_factory = NULL; |
141 FOR_EACH_OBSERVER(ImageTransportFactoryAndroidObserver, | 155 FOR_EACH_OBSERVER(ImageTransportFactoryAndroidObserver, |
142 g_factory_observers.Get(), | 156 g_factory_observers.Get(), |
143 OnLostResources()); | 157 OnLostResources()); |
144 } | 158 } |
145 | 159 |
146 } // namespace content | 160 } // namespace content |
OLD | NEW |