OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #ifndef UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ | 5 #ifndef UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ |
6 #define UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ | 6 #define UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/weak_ptr.h" |
11 #include "cc/surfaces/surface_manager.h" | 13 #include "cc/surfaces/surface_manager.h" |
12 #include "services/ui/public/cpp/raster_thread_helper.h" | 14 #include "services/ui/public/cpp/raster_thread_helper.h" |
13 #include "services/ui/public/interfaces/window_tree.mojom.h" | 15 #include "services/ui/public/interfaces/window_tree.mojom.h" |
14 #include "ui/aura/aura_export.h" | 16 #include "ui/aura/aura_export.h" |
15 #include "ui/compositor/compositor.h" | 17 #include "ui/compositor/compositor.h" |
16 | 18 |
| 19 namespace gpu { |
| 20 class GpuChannelHost; |
| 21 } |
| 22 |
17 namespace ui { | 23 namespace ui { |
18 class Gpu; | 24 class Gpu; |
19 } | 25 } |
20 | 26 |
21 namespace aura { | 27 namespace aura { |
22 | 28 |
23 // ContextFactory implementation that can be used with Mus. | 29 // ContextFactory implementation that can be used with Mus. |
24 class AURA_EXPORT MusContextFactory : public ui::ContextFactory { | 30 class AURA_EXPORT MusContextFactory : public ui::ContextFactory { |
25 public: | 31 public: |
26 explicit MusContextFactory(ui::Gpu* gpu); | 32 explicit MusContextFactory(ui::Gpu* gpu); |
27 ~MusContextFactory() override; | 33 ~MusContextFactory() override; |
28 | 34 |
29 private: | 35 private: |
| 36 // Callback function for Gpu::EstablishGpuChannel(). |
| 37 void OnEstablishedGpuChannel(base::WeakPtr<ui::Compositor> compositor, |
| 38 scoped_refptr<gpu::GpuChannelHost> gpu_channel); |
| 39 |
30 // ContextFactory: | 40 // ContextFactory: |
31 void CreateCompositorFrameSink( | 41 void CreateCompositorFrameSink( |
32 base::WeakPtr<ui::Compositor> compositor) override; | 42 base::WeakPtr<ui::Compositor> compositor) override; |
33 scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override; | 43 scoped_refptr<cc::ContextProvider> SharedMainThreadContextProvider() override; |
34 void RemoveCompositor(ui::Compositor* compositor) override; | 44 void RemoveCompositor(ui::Compositor* compositor) override; |
35 bool DoesCreateTestContexts() override; | 45 bool DoesCreateTestContexts() override; |
36 uint32_t GetImageTextureTarget(gfx::BufferFormat format, | 46 uint32_t GetImageTextureTarget(gfx::BufferFormat format, |
37 gfx::BufferUsage usage) override; | 47 gfx::BufferUsage usage) override; |
38 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; | 48 gpu::GpuMemoryBufferManager* GetGpuMemoryBufferManager() override; |
39 cc::TaskGraphRunner* GetTaskGraphRunner() override; | 49 cc::TaskGraphRunner* GetTaskGraphRunner() override; |
40 void AddObserver(ui::ContextFactoryObserver* observer) override {} | 50 void AddObserver(ui::ContextFactoryObserver* observer) override {} |
41 void RemoveObserver(ui::ContextFactoryObserver* observer) override {} | 51 void RemoveObserver(ui::ContextFactoryObserver* observer) override {} |
42 | 52 |
43 ui::RasterThreadHelper raster_thread_helper_; | 53 ui::RasterThreadHelper raster_thread_helper_; |
44 ui::Gpu* gpu_; | 54 ui::Gpu* gpu_; |
| 55 base::WeakPtrFactory<MusContextFactory> weak_ptr_factory_; |
45 | 56 |
46 DISALLOW_COPY_AND_ASSIGN(MusContextFactory); | 57 DISALLOW_COPY_AND_ASSIGN(MusContextFactory); |
47 }; | 58 }; |
48 | 59 |
49 } // namespace aura | 60 } // namespace aura |
50 | 61 |
51 #endif // UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ | 62 #endif // UI_AURA_MUS_MUS_CONTEXT_FACTORY_H_ |
OLD | NEW |