Remove implicit conversions from scoped_refptr to T* in content/browser/service_worker
[chromium-blink-merge.git] / content / browser / compositor / gpu_process_transport_factory.h
blob6b65c1725fafd7d2d4a72cb4520f516aec478a2a
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_
8 #include <map>
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"
18 namespace base {
19 class Thread;
22 namespace cc {
23 class SurfaceManager;
26 namespace content {
27 class BrowserCompositorOutputSurface;
28 class BrowserCompositorOutputSurfaceProxy;
29 class CompositorSwapClient;
30 class ContextProviderCommandBuffer;
31 class ReflectorImpl;
32 class WebGraphicsContext3DCommandBufferImpl;
34 class GpuProcessTransportFactory
35 : public ui::ContextFactory,
36 public ImageTransportFactory {
37 public:
38 GpuProcessTransportFactory();
40 virtual ~GpuProcessTransportFactory();
42 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
43 CreateOffscreenCommandBufferContext();
45 // ui::ContextFactory implementation.
46 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(
47 ui::Compositor* compositor, bool software_fallback) OVERRIDE;
48 virtual scoped_refptr<ui::Reflector> CreateReflector(
49 ui::Compositor* source,
50 ui::Layer* target) OVERRIDE;
51 virtual void RemoveReflector(
52 scoped_refptr<ui::Reflector> reflector) OVERRIDE;
53 virtual void RemoveCompositor(ui::Compositor* compositor) OVERRIDE;
54 virtual scoped_refptr<cc::ContextProvider>
55 SharedMainThreadContextProvider() OVERRIDE;
56 virtual bool DoesCreateTestContexts() OVERRIDE;
57 virtual cc::SharedBitmapManager* GetSharedBitmapManager() OVERRIDE;
58 virtual base::MessageLoopProxy* GetCompositorMessageLoop() OVERRIDE;
60 // ImageTransportFactory implementation.
61 virtual ui::ContextFactory* GetContextFactory() OVERRIDE;
62 virtual gfx::GLSurfaceHandle GetSharedSurfaceHandle() OVERRIDE;
63 virtual scoped_ptr<cc::SurfaceIdAllocator> CreateSurfaceIdAllocator()
64 OVERRIDE;
65 virtual cc::SurfaceManager* GetSurfaceManager() OVERRIDE;
66 virtual GLHelper* GetGLHelper() OVERRIDE;
67 virtual void AddObserver(ImageTransportFactoryObserver* observer) OVERRIDE;
68 virtual void RemoveObserver(
69 ImageTransportFactoryObserver* observer) OVERRIDE;
70 #if defined(OS_MACOSX)
71 virtual void OnSurfaceDisplayed(int surface_id) OVERRIDE;
72 #endif
74 private:
75 struct PerCompositorData;
77 PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor);
78 scoped_ptr<WebGraphicsContext3DCommandBufferImpl>
79 CreateContextCommon(int surface_id);
81 void OnLostMainThreadSharedContextInsideCallback();
82 void OnLostMainThreadSharedContext();
84 typedef std::map<ui::Compositor*, PerCompositorData*> PerCompositorDataMap;
85 scoped_ptr<base::Thread> compositor_thread_;
86 PerCompositorDataMap per_compositor_data_;
87 scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_;
88 scoped_ptr<GLHelper> gl_helper_;
89 ObserverList<ImageTransportFactoryObserver> observer_list_;
90 base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_;
91 scoped_ptr<cc::SurfaceManager> surface_manager_;
92 uint32_t next_surface_id_namespace_;
94 // The contents of this map and its methods may only be used on the compositor
95 // thread.
96 IDMap<BrowserCompositorOutputSurface> output_surface_map_;
98 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_;
100 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory);
103 } // namespace content
105 #endif // CONTENT_BROWSER_COMPOSITOR_GPU_PROCESS_TRANSPORT_FACTORY_H_