| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2013 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. | |
| 4 | |
| 5 #ifndef CONTENT_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_ | |
| 6 #define CONTENT_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 | |
| 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/aura/image_transport_factory.h" | |
| 16 #include "ui/compositor/compositor.h" | |
| 17 | |
| 18 namespace content { | |
| 19 class BrowserCompositorOutputSurface; | |
| 20 class BrowserCompositorOutputSurfaceProxy; | |
| 21 class CompositorSwapClient; | |
| 22 class ContextProviderCommandBuffer; | |
| 23 class ReflectorImpl; | |
| 24 class WebGraphicsContext3DCommandBufferImpl; | |
| 25 | |
| 26 class GpuProcessTransportFactory | |
| 27 : public ui::ContextFactory, | |
| 28 public ImageTransportFactory { | |
| 29 public: | |
| 30 GpuProcessTransportFactory(); | |
| 31 | |
| 32 virtual ~GpuProcessTransportFactory(); | |
| 33 | |
| 34 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | |
| 35 CreateOffscreenCommandBufferContext(); | |
| 36 | |
| 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 OffscreenCompositorContextProvider() OVERRIDE; | |
| 48 virtual scoped_refptr<cc::ContextProvider> | |
| 49 SharedMainThreadContextProvider() OVERRIDE; | |
| 50 virtual bool DoesCreateTestContexts() OVERRIDE; | |
| 51 | |
| 52 // ImageTransportFactory implementation. | |
| 53 virtual ui::ContextFactory* AsContextFactory() OVERRIDE; | |
| 54 virtual gfx::GLSurfaceHandle GetSharedSurfaceHandle() OVERRIDE; | |
| 55 virtual scoped_refptr<ui::Texture> CreateTransportClient( | |
| 56 float device_scale_factor) OVERRIDE; | |
| 57 virtual scoped_refptr<ui::Texture> CreateOwnedTexture( | |
| 58 const gfx::Size& size, | |
| 59 float device_scale_factor, | |
| 60 unsigned int texture_id) OVERRIDE; | |
| 61 virtual GLHelper* GetGLHelper() OVERRIDE; | |
| 62 virtual void AddObserver(ImageTransportFactoryObserver* observer) OVERRIDE; | |
| 63 virtual void RemoveObserver( | |
| 64 ImageTransportFactoryObserver* observer) OVERRIDE; | |
| 65 | |
| 66 private: | |
| 67 struct PerCompositorData; | |
| 68 | |
| 69 PerCompositorData* CreatePerCompositorData(ui::Compositor* compositor); | |
| 70 scoped_ptr<WebGraphicsContext3DCommandBufferImpl> | |
| 71 CreateContextCommon(int surface_id); | |
| 72 | |
| 73 void OnLostMainThreadSharedContextInsideCallback(); | |
| 74 void OnLostMainThreadSharedContext(); | |
| 75 | |
| 76 typedef std::map<ui::Compositor*, PerCompositorData*> PerCompositorDataMap; | |
| 77 PerCompositorDataMap per_compositor_data_; | |
| 78 scoped_refptr<ContextProviderCommandBuffer> offscreen_compositor_contexts_; | |
| 79 scoped_refptr<ContextProviderCommandBuffer> shared_main_thread_contexts_; | |
| 80 scoped_ptr<GLHelper> gl_helper_; | |
| 81 ObserverList<ImageTransportFactoryObserver> observer_list_; | |
| 82 base::WeakPtrFactory<GpuProcessTransportFactory> callback_factory_; | |
| 83 | |
| 84 // The contents of this map and its methods may only be used on the compositor | |
| 85 // thread. | |
| 86 IDMap<BrowserCompositorOutputSurface> output_surface_map_; | |
| 87 | |
| 88 scoped_refptr<BrowserCompositorOutputSurfaceProxy> output_surface_proxy_; | |
| 89 | |
| 90 DISALLOW_COPY_AND_ASSIGN(GpuProcessTransportFactory); | |
| 91 }; | |
| 92 | |
| 93 } // namespace content | |
| 94 | |
| 95 #endif // CONTENT_BROWSER_AURA_GPU_PROCESS_TRANSPORT_FACTORY_H_ | |
| OLD | NEW |