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/gpu_process_transport_factory.h"
10 #include "base/command_line.h"
11 #include "base/location.h"
12 #include "base/message_loop/message_loop.h"
13 #include "base/metrics/histogram.h"
14 #include "base/profiler/scoped_tracker.h"
15 #include "base/threading/simple_thread.h"
16 #include "base/threading/thread.h"
17 #include "cc/output/compositor_frame.h"
18 #include "cc/output/output_surface.h"
19 #include "cc/resources/task_graph_runner.h"
20 #include "cc/surfaces/onscreen_display_client.h"
21 #include "cc/surfaces/surface_display_output_surface.h"
22 #include "cc/surfaces/surface_manager.h"
23 #include "content/browser/compositor/browser_compositor_output_surface.h"
24 #include "content/browser/compositor/gpu_browser_compositor_output_surface.h"
25 #include "content/browser/compositor/gpu_surfaceless_browser_compositor_output_surface.h"
26 #include "content/browser/compositor/reflector_impl.h"
27 #include "content/browser/compositor/software_browser_compositor_output_surface.h"
28 #include "content/browser/gpu/browser_gpu_channel_host_factory.h"
29 #include "content/browser/gpu/browser_gpu_memory_buffer_manager.h"
30 #include "content/browser/gpu/compositor_util.h"
31 #include "content/browser/gpu/gpu_data_manager_impl.h"
32 #include "content/browser/gpu/gpu_surface_tracker.h"
33 #include "content/browser/renderer_host/render_widget_host_impl.h"
34 #include "content/common/gpu/client/context_provider_command_buffer.h"
35 #include "content/common/gpu/client/gl_helper.h"
36 #include "content/common/gpu/client/gpu_channel_host.h"
37 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
38 #include "content/common/gpu/gpu_process_launch_causes.h"
39 #include "content/common/host_shared_bitmap_manager.h"
40 #include "content/public/common/content_switches.h"
41 #include "gpu/GLES2/gl2extchromium.h"
42 #include "gpu/command_buffer/client/gles2_interface.h"
43 #include "gpu/command_buffer/common/mailbox.h"
44 #include "third_party/khronos/GLES2/gl2.h"
45 #include "ui/compositor/compositor.h"
46 #include "ui/compositor/compositor_constants.h"
47 #include "ui/compositor/compositor_switches.h"
48 #include "ui/gfx/geometry/size.h"
49 #include "ui/gfx/native_widget_types.h"
52 #include "content/browser/compositor/software_output_device_win.h"
53 #elif defined(USE_OZONE)
54 #include "content/browser/compositor/overlay_candidate_validator_ozone.h"
55 #include "content/browser/compositor/software_output_device_ozone.h"
56 #include "ui/ozone/public/ozone_switches.h"
57 #include "ui/ozone/public/surface_factory_ozone.h"
58 #elif defined(USE_X11)
59 #include "content/browser/compositor/software_output_device_x11.h"
60 #elif defined(OS_MACOSX)
61 #include "content/browser/compositor/software_output_device_mac.h"
64 using cc::ContextProvider
;
65 using gpu::gles2::GLES2Interface
;
67 static const int kNumRetriesBeforeSoftwareFallback
= 4;
72 class RasterThread
: public base::SimpleThread
{
74 RasterThread(cc::TaskGraphRunner
* task_graph_runner
)
75 : base::SimpleThread("CompositorTileWorker1"),
76 task_graph_runner_(task_graph_runner
) {}
78 // Overridden from base::SimpleThread:
79 void Run() override
{ task_graph_runner_
->Run(); }
82 cc::TaskGraphRunner
* task_graph_runner_
;
84 DISALLOW_COPY_AND_ASSIGN(RasterThread
);
89 struct GpuProcessTransportFactory::PerCompositorData
{
91 BrowserCompositorOutputSurface
* surface
;
92 ReflectorImpl
* reflector
;
93 scoped_ptr
<cc::OnscreenDisplayClient
> display_client
;
95 PerCompositorData() : surface_id(0), surface(nullptr), reflector(nullptr) {}
98 GpuProcessTransportFactory::GpuProcessTransportFactory()
99 : next_surface_id_namespace_(1u),
100 task_graph_runner_(new cc::TaskGraphRunner
),
101 callback_factory_(this) {
102 if (UseSurfacesEnabled())
103 surface_manager_
= make_scoped_ptr(new cc::SurfaceManager
);
105 if (ui::IsUIImplSidePaintingEnabled()) {
106 raster_thread_
.reset(new RasterThread(task_graph_runner_
.get()));
107 raster_thread_
->Start();
111 GpuProcessTransportFactory::~GpuProcessTransportFactory() {
112 DCHECK(per_compositor_data_
.empty());
114 // Make sure the lost context callback doesn't try to run during destruction.
115 callback_factory_
.InvalidateWeakPtrs();
117 task_graph_runner_
->Shutdown();
119 raster_thread_
->Join();
122 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>
123 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext() {
124 CauseForGpuLaunch cause
=
125 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE
;
126 scoped_refptr
<GpuChannelHost
> gpu_channel_host(
127 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannelSync(cause
));
128 return CreateContextCommon(gpu_channel_host
, 0);
131 scoped_ptr
<cc::SoftwareOutputDevice
> CreateSoftwareOutputDevice(
132 ui::Compositor
* compositor
) {
134 return scoped_ptr
<cc::SoftwareOutputDevice
>(new SoftwareOutputDeviceWin(
136 #elif defined(USE_OZONE)
137 return scoped_ptr
<cc::SoftwareOutputDevice
>(new SoftwareOutputDeviceOzone(
139 #elif defined(USE_X11)
140 return scoped_ptr
<cc::SoftwareOutputDevice
>(new SoftwareOutputDeviceX11(
142 #elif defined(OS_MACOSX)
143 return scoped_ptr
<cc::SoftwareOutputDevice
>(
144 new SoftwareOutputDeviceMac(compositor
));
147 return scoped_ptr
<cc::SoftwareOutputDevice
>();
151 scoped_ptr
<cc::OverlayCandidateValidator
> CreateOverlayCandidateValidator(
152 gfx::AcceleratedWidget widget
) {
153 #if defined(USE_OZONE)
154 ui::OverlayCandidatesOzone
* overlay_candidates
=
155 ui::SurfaceFactoryOzone::GetInstance()->GetOverlayCandidates(widget
);
156 base::CommandLine
* command_line
= base::CommandLine::ForCurrentProcess();
157 if (overlay_candidates
&&
158 (command_line
->HasSwitch(switches::kEnableHardwareOverlays
) ||
159 command_line
->HasSwitch(switches::kOzoneTestSingleOverlaySupport
))) {
160 return scoped_ptr
<cc::OverlayCandidateValidator
>(
161 new OverlayCandidateValidatorOzone(widget
, overlay_candidates
));
164 return scoped_ptr
<cc::OverlayCandidateValidator
>();
167 static bool ShouldCreateGpuOutputSurface(ui::Compositor
* compositor
) {
168 #if defined(OS_CHROMEOS)
169 // Software fallback does not happen on Chrome OS.
174 if (::GetProp(compositor
->widget(), kForceSoftwareCompositor
) &&
175 ::RemoveProp(compositor
->widget(), kForceSoftwareCompositor
))
179 return GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor();
182 void GpuProcessTransportFactory::CreateOutputSurface(
183 base::WeakPtr
<ui::Compositor
> compositor
) {
184 DCHECK(!!compositor
);
185 PerCompositorData
* data
= per_compositor_data_
[compositor
.get()];
187 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466870
189 tracked_objects::ScopedTracker
tracking_profile1(
190 FROM_HERE_WITH_EXPLICIT_FUNCTION(
191 "466870 GpuProcessTransportFactory::CreateOutputSurface1"));
192 data
= CreatePerCompositorData(compositor
.get());
194 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
195 // output_surface_map_ here.
196 output_surface_map_
.Remove(data
->surface_id
);
197 data
->surface
= nullptr;
200 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466870
202 tracked_objects::ScopedTracker
tracking_profile2(
203 FROM_HERE_WITH_EXPLICIT_FUNCTION(
204 "466870 GpuProcessTransportFactory::CreateOutputSurface2"));
206 bool create_gpu_output_surface
=
207 ShouldCreateGpuOutputSurface(compositor
.get());
208 if (create_gpu_output_surface
) {
209 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466870
211 tracked_objects::ScopedTracker
tracking_profile3(
212 FROM_HERE_WITH_EXPLICIT_FUNCTION(
213 "466870 GpuProcessTransportFactory::CreateOutputSurface3"));
215 CauseForGpuLaunch cause
=
216 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE
;
217 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
218 cause
, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel
,
219 callback_factory_
.GetWeakPtr(), compositor
,
220 create_gpu_output_surface
, 0));
222 // TODO(robliao): Remove ScopedTracker below once https://crbug.com/466870
224 tracked_objects::ScopedTracker
tracking_profile4(
225 FROM_HERE_WITH_EXPLICIT_FUNCTION(
226 "466870 GpuProcessTransportFactory::CreateOutputSurface4"));
228 EstablishedGpuChannel(compositor
, create_gpu_output_surface
, 0);
232 void GpuProcessTransportFactory::EstablishedGpuChannel(
233 base::WeakPtr
<ui::Compositor
> compositor
,
234 bool create_gpu_output_surface
,
238 PerCompositorData
* data
= per_compositor_data_
[compositor
.get()];
241 if (num_attempts
> kNumRetriesBeforeSoftwareFallback
) {
242 #if defined(OS_CHROMEOS)
243 LOG(FATAL
) << "Unable to create a UI graphics context, and cannot use "
244 << "software compositing on ChromeOS.";
246 create_gpu_output_surface
= false;
249 scoped_refptr
<ContextProviderCommandBuffer
> context_provider
;
250 if (create_gpu_output_surface
) {
251 scoped_refptr
<GpuChannelHost
> gpu_channel_host
=
252 BrowserGpuChannelHostFactory::instance()->GetGpuChannel();
253 if (gpu_channel_host
.get()) {
254 context_provider
= ContextProviderCommandBuffer::Create(
255 GpuProcessTransportFactory::CreateContextCommon(gpu_channel_host
,
258 if (context_provider
&& !context_provider
->BindToCurrentThread())
259 context_provider
= nullptr;
262 UMA_HISTOGRAM_BOOLEAN("Aura.CreatedGpuBrowserCompositor",
263 !!context_provider
.get());
265 if (!context_provider
) {
267 CauseForGpuLaunch cause
=
268 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE
;
269 BrowserGpuChannelHostFactory::instance()->EstablishGpuChannel(
270 cause
, base::Bind(&GpuProcessTransportFactory::EstablishedGpuChannel
,
271 callback_factory_
.GetWeakPtr(), compositor
,
272 create_gpu_output_surface
, num_attempts
+ 1));
277 scoped_ptr
<BrowserCompositorOutputSurface
> surface
;
278 if (!create_gpu_output_surface
) {
279 surface
= make_scoped_ptr(new SoftwareBrowserCompositorOutputSurface(
280 CreateSoftwareOutputDevice(compositor
.get()),
281 compositor
->vsync_manager()));
283 DCHECK(context_provider
);
284 #if defined(USE_OZONE)
285 if (ui::SurfaceFactoryOzone::GetInstance()
286 ->CanShowPrimaryPlaneAsOverlay()) {
288 make_scoped_ptr(new GpuSurfacelessBrowserCompositorOutputSurface(
289 context_provider
, data
->surface_id
, compositor
->vsync_manager(),
290 CreateOverlayCandidateValidator(compositor
->widget()), GL_RGB
,
291 BrowserGpuMemoryBufferManager::current()));
295 surface
= make_scoped_ptr(new GpuBrowserCompositorOutputSurface(
296 context_provider
, compositor
->vsync_manager(),
297 CreateOverlayCandidateValidator(compositor
->widget())));
301 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
302 // output_surface_map_ here.
303 output_surface_map_
.AddWithID(surface
.get(), data
->surface_id
);
304 data
->surface
= surface
.get();
306 data
->reflector
->OnSourceSurfaceReady(data
->surface
);
308 if (!UseSurfacesEnabled()) {
309 compositor
->SetOutputSurface(surface
.Pass());
313 // This gets a bit confusing. Here we have a ContextProvider in the |surface|
314 // configured to render directly to this widget. We need to make an
315 // OnscreenDisplayClient associated with that context, then return a
316 // SurfaceDisplayOutputSurface set up to draw to the display's surface.
317 cc::SurfaceManager
* manager
= surface_manager_
.get();
318 scoped_ptr
<cc::OnscreenDisplayClient
> display_client(
319 new cc::OnscreenDisplayClient(
320 surface
.Pass(), manager
, HostSharedBitmapManager::current(),
321 BrowserGpuMemoryBufferManager::current(),
322 compositor
->GetRendererSettings(), compositor
->task_runner()));
324 scoped_ptr
<cc::SurfaceDisplayOutputSurface
> output_surface(
325 new cc::SurfaceDisplayOutputSurface(
326 manager
, compositor
->surface_id_allocator(), context_provider
));
327 display_client
->set_surface_output_surface(output_surface
.get());
328 output_surface
->set_display_client(display_client
.get());
329 display_client
->display()->Resize(compositor
->size());
330 data
->display_client
= display_client
.Pass();
331 compositor
->SetOutputSurface(output_surface
.Pass());
334 scoped_ptr
<ui::Reflector
> GpuProcessTransportFactory::CreateReflector(
335 ui::Compositor
* source_compositor
,
336 ui::Layer
* target_layer
) {
337 PerCompositorData
* source_data
= per_compositor_data_
[source_compositor
];
340 scoped_ptr
<ReflectorImpl
> reflector(
341 new ReflectorImpl(source_compositor
, target_layer
));
342 source_data
->reflector
= reflector
.get();
343 if (BrowserCompositorOutputSurface
* source_surface
= source_data
->surface
)
344 reflector
->OnSourceSurfaceReady(source_surface
);
345 return reflector
.Pass();
348 void GpuProcessTransportFactory::RemoveReflector(ui::Reflector
* reflector
) {
349 ReflectorImpl
* reflector_impl
= static_cast<ReflectorImpl
*>(reflector
);
350 PerCompositorData
* data
=
351 per_compositor_data_
[reflector_impl
->mirrored_compositor()];
353 data
->reflector
->Shutdown();
354 data
->reflector
= nullptr;
357 void GpuProcessTransportFactory::RemoveCompositor(ui::Compositor
* compositor
) {
358 PerCompositorDataMap::iterator it
= per_compositor_data_
.find(compositor
);
359 if (it
== per_compositor_data_
.end())
361 PerCompositorData
* data
= it
->second
;
363 // TODO(piman): Use GpuSurfaceTracker to map ids to surfaces instead of an
364 // output_surface_map_ here.
366 output_surface_map_
.Remove(data
->surface_id
);
367 GpuSurfaceTracker::Get()->RemoveSurface(data
->surface_id
);
369 per_compositor_data_
.erase(it
);
370 if (per_compositor_data_
.empty()) {
371 // Destroying the GLHelper may cause some async actions to be cancelled,
372 // causing things to request a new GLHelper. Due to crbug.com/176091 the
373 // GLHelper created in this case would be lost/leaked if we just reset()
374 // on the |gl_helper_| variable directly. So instead we call reset() on a
376 scoped_ptr
<GLHelper
> helper
= gl_helper_
.Pass();
378 // If there are any observer left at this point, make sure they clean up
379 // before we destroy the GLHelper.
381 ImageTransportFactoryObserver
, observer_list_
, OnLostResources());
384 DCHECK(!gl_helper_
) << "Destroying the GLHelper should not cause a new "
385 "GLHelper to be created.";
389 bool GpuProcessTransportFactory::DoesCreateTestContexts() { return false; }
391 uint32
GpuProcessTransportFactory::GetImageTextureTarget() {
392 return BrowserGpuChannelHostFactory::GetImageTextureTarget();
395 cc::SharedBitmapManager
* GpuProcessTransportFactory::GetSharedBitmapManager() {
396 return HostSharedBitmapManager::current();
399 gpu::GpuMemoryBufferManager
*
400 GpuProcessTransportFactory::GetGpuMemoryBufferManager() {
401 return BrowserGpuMemoryBufferManager::current();
404 cc::TaskGraphRunner
* GpuProcessTransportFactory::GetTaskGraphRunner() {
405 return task_graph_runner_
.get();
408 ui::ContextFactory
* GpuProcessTransportFactory::GetContextFactory() {
412 gfx::GLSurfaceHandle
GpuProcessTransportFactory::GetSharedSurfaceHandle() {
413 gfx::GLSurfaceHandle handle
= gfx::GLSurfaceHandle(
414 gfx::kNullPluginWindow
, gfx::NULL_TRANSPORT
);
415 handle
.parent_client_id
=
416 BrowserGpuChannelHostFactory::instance()->GetGpuChannelId();
420 scoped_ptr
<cc::SurfaceIdAllocator
>
421 GpuProcessTransportFactory::CreateSurfaceIdAllocator() {
422 return make_scoped_ptr(
423 new cc::SurfaceIdAllocator(next_surface_id_namespace_
++));
426 void GpuProcessTransportFactory::ResizeDisplay(ui::Compositor
* compositor
,
427 const gfx::Size
& size
) {
428 PerCompositorDataMap::iterator it
= per_compositor_data_
.find(compositor
);
429 if (it
== per_compositor_data_
.end())
431 PerCompositorData
* data
= it
->second
;
433 if (data
->display_client
)
434 data
->display_client
->display()->Resize(size
);
437 cc::SurfaceManager
* GpuProcessTransportFactory::GetSurfaceManager() {
438 return surface_manager_
.get();
441 GLHelper
* GpuProcessTransportFactory::GetGLHelper() {
442 if (!gl_helper_
&& !per_compositor_data_
.empty()) {
443 scoped_refptr
<cc::ContextProvider
> provider
=
444 SharedMainThreadContextProvider();
446 gl_helper_
.reset(new GLHelper(provider
->ContextGL(),
447 provider
->ContextSupport()));
449 return gl_helper_
.get();
452 void GpuProcessTransportFactory::AddObserver(
453 ImageTransportFactoryObserver
* observer
) {
454 observer_list_
.AddObserver(observer
);
457 void GpuProcessTransportFactory::RemoveObserver(
458 ImageTransportFactoryObserver
* observer
) {
459 observer_list_
.RemoveObserver(observer
);
462 #if defined(OS_MACOSX)
463 void GpuProcessTransportFactory::OnSurfaceDisplayed(int surface_id
) {
464 BrowserCompositorOutputSurface
* surface
= output_surface_map_
.Lookup(
467 surface
->OnSurfaceDisplayed();
470 void GpuProcessTransportFactory::OnCompositorRecycled(
471 ui::Compositor
* compositor
) {
472 PerCompositorDataMap::iterator it
= per_compositor_data_
.find(compositor
);
473 if (it
== per_compositor_data_
.end())
475 PerCompositorData
* data
= it
->second
;
477 BrowserCompositorOutputSurface
* surface
=
478 output_surface_map_
.Lookup(data
->surface_id
);
480 surface
->OnSurfaceRecycled();
483 bool GpuProcessTransportFactory::SurfaceShouldNotShowFramesAfterRecycle(
484 int surface_id
) const {
485 BrowserCompositorOutputSurface
* surface
=
486 output_surface_map_
.Lookup(surface_id
);
488 return surface
->ShouldNotShowFramesAfterRecycle();
493 scoped_refptr
<cc::ContextProvider
>
494 GpuProcessTransportFactory::SharedMainThreadContextProvider() {
495 if (shared_main_thread_contexts_
.get())
496 return shared_main_thread_contexts_
;
498 // In threaded compositing mode, we have to create our own context for the
499 // main thread since the compositor's context will be bound to the
500 // compositor thread. When not in threaded mode, we still need a separate
501 // context so that skia and gl_helper don't step on each other.
502 shared_main_thread_contexts_
= ContextProviderCommandBuffer::Create(
503 GpuProcessTransportFactory::CreateOffscreenCommandBufferContext(),
504 "Offscreen-MainThread");
506 if (shared_main_thread_contexts_
.get()) {
507 shared_main_thread_contexts_
->SetLostContextCallback(
508 base::Bind(&GpuProcessTransportFactory::
509 OnLostMainThreadSharedContextInsideCallback
,
510 callback_factory_
.GetWeakPtr()));
511 if (!shared_main_thread_contexts_
->BindToCurrentThread())
512 shared_main_thread_contexts_
= NULL
;
514 return shared_main_thread_contexts_
;
517 GpuProcessTransportFactory::PerCompositorData
*
518 GpuProcessTransportFactory::CreatePerCompositorData(
519 ui::Compositor
* compositor
) {
520 DCHECK(!per_compositor_data_
[compositor
]);
522 gfx::AcceleratedWidget widget
= compositor
->widget();
523 GpuSurfaceTracker
* tracker
= GpuSurfaceTracker::Get();
525 PerCompositorData
* data
= new PerCompositorData
;
526 data
->surface_id
= tracker
->AddSurfaceForNativeWidget(widget
);
527 tracker
->SetSurfaceHandle(
529 gfx::GLSurfaceHandle(widget
, gfx::NATIVE_DIRECT
));
531 per_compositor_data_
[compositor
] = data
;
536 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>
537 GpuProcessTransportFactory::CreateContextCommon(
538 scoped_refptr
<GpuChannelHost
> gpu_channel_host
,
540 if (!GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor())
541 return scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>();
542 blink::WebGraphicsContext3D::Attributes attrs
;
543 attrs
.shareResources
= true;
545 attrs
.stencil
= false;
546 attrs
.antialias
= false;
547 attrs
.noAutomaticFlushes
= true;
548 bool lose_context_when_out_of_memory
= true;
549 if (!gpu_channel_host
.get()) {
550 LOG(ERROR
) << "Failed to establish GPU channel.";
551 return scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>();
553 GURL
url("chrome://gpu/GpuProcessTransportFactory::CreateContextCommon");
554 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
> context(
555 new WebGraphicsContext3DCommandBufferImpl(
558 gpu_channel_host
.get(),
560 lose_context_when_out_of_memory
,
561 WebGraphicsContext3DCommandBufferImpl::SharedMemoryLimits(),
563 return context
.Pass();
566 void GpuProcessTransportFactory::OnLostMainThreadSharedContextInsideCallback() {
567 base::MessageLoop::current()->PostTask(
569 base::Bind(&GpuProcessTransportFactory::OnLostMainThreadSharedContext
,
570 callback_factory_
.GetWeakPtr()));
573 void GpuProcessTransportFactory::OnLostMainThreadSharedContext() {
574 LOG(ERROR
) << "Lost UI shared context.";
576 // Keep old resources around while we call the observers, but ensure that
577 // new resources are created if needed.
578 // Kill shared contexts for both threads in tandem so they are always in
579 // the same share group.
580 scoped_refptr
<cc::ContextProvider
> lost_shared_main_thread_contexts
=
581 shared_main_thread_contexts_
;
582 shared_main_thread_contexts_
= NULL
;
584 scoped_ptr
<GLHelper
> lost_gl_helper
= gl_helper_
.Pass();
586 FOR_EACH_OBSERVER(ImageTransportFactoryObserver
,
590 // Kill things that use the shared context before killing the shared context.
591 lost_gl_helper
.reset();
592 lost_shared_main_thread_contexts
= NULL
;
595 } // namespace content