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 #ifndef CONTENT_BROWSER_COMPOSITOR_GPU_PROCESS_TRANSPORT_FACTORY_H_
6 #define CONTENT_BROWSER_COMPOSITOR_GPU_PROCESS_TRANSPORT_FACTORY_H_
10 #include "base/id_map.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/memory/weak_ptr.h"
14 #include "base/observer_list.h"
15 #include "content/browser/compositor/image_transport_factory.h"
16 #include "ui/compositor/compositor.h"
19 class BrowserCompositorOutputSurface
;
20 class BrowserCompositorOutputSurfaceProxy
;
21 class CompositorSwapClient
;
22 class ContextProviderCommandBuffer
;
24 class WebGraphicsContext3DCommandBufferImpl
;
26 class GpuProcessTransportFactory
27 : public ui::ContextFactory
,
28 public ImageTransportFactory
{
30 GpuProcessTransportFactory();
32 virtual ~GpuProcessTransportFactory();
34 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>
35 CreateOffscreenCommandBufferContext();
37 // ui::ContextFactory implementation.
38 virtual scoped_ptr
<cc::OutputSurface
> CreateOutputSurface(
39 ui::Compositor
* compositor
, bool software_fallback
) OVERRIDE
;
40 virtual scoped_refptr
<ui::Reflector
> CreateReflector(
41 ui::Compositor
* source
,
42 ui::Layer
* target
) OVERRIDE
;
43 virtual void RemoveReflector(
44 scoped_refptr
<ui::Reflector
> reflector
) OVERRIDE
;
45 virtual void RemoveCompositor(ui::Compositor
* compositor
) OVERRIDE
;
46 virtual scoped_refptr
<cc::ContextProvider
>
47 SharedMainThreadContextProvider() OVERRIDE
;
48 virtual bool DoesCreateTestContexts() OVERRIDE
;
50 // ImageTransportFactory implementation.
51 virtual ui::ContextFactory
* AsContextFactory() OVERRIDE
;
52 virtual gfx::GLSurfaceHandle
GetSharedSurfaceHandle() OVERRIDE
;
53 virtual GLHelper
* GetGLHelper() OVERRIDE
;
54 virtual void AddObserver(ImageTransportFactoryObserver
* observer
) OVERRIDE
;
55 virtual void RemoveObserver(
56 ImageTransportFactoryObserver
* observer
) OVERRIDE
;
59 struct PerCompositorData
;
61 PerCompositorData
* CreatePerCompositorData(ui::Compositor
* compositor
);
62 scoped_ptr
<WebGraphicsContext3DCommandBufferImpl
>
63 CreateContextCommon(int surface_id
);
65 void OnLostMainThreadSharedContextInsideCallback();
66 void OnLostMainThreadSharedContext();
68 typedef std::map
<ui::Compositor
*, PerCompositorData
*> PerCompositorDataMap
;
69 PerCompositorDataMap per_compositor_data_
;
70 scoped_refptr
<ContextProviderCommandBuffer
> shared_main_thread_contexts_
;
71 scoped_ptr
<GLHelper
> gl_helper_
;
72 ObserverList
<ImageTransportFactoryObserver
> observer_list_
;
73 base::WeakPtrFactory
<GpuProcessTransportFactory
> callback_factory_
;
75 // The contents of this map and its methods may only be used on the compositor
77 IDMap
<BrowserCompositorOutputSurface
> output_surface_map_
;
79 scoped_refptr
<BrowserCompositorOutputSurfaceProxy
> output_surface_proxy_
;
81 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory
);
84 } // namespace content
86 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_PROCESS_TRANSPORT_FACTORY_H_