OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 SERVICES_UI_WS_GPU_HOST_H_ | 5 #ifndef SERVICES_UI_WS_GPU_HOST_H_ |
6 #define SERVICES_UI_WS_GPU_HOST_H_ | 6 #define SERVICES_UI_WS_GPU_HOST_H_ |
7 | 7 |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
11 #include "gpu/config/gpu_info.h" | 11 #include "gpu/config/gpu_info.h" |
12 #include "gpu/ipc/client/gpu_channel_host.h" | 12 #include "gpu/ipc/client/gpu_channel_host.h" |
13 #include "mojo/public/cpp/bindings/binding_set.h" | 13 #include "mojo/public/cpp/bindings/binding_set.h" |
14 #include "mojo/public/cpp/bindings/interface_request.h" | 14 #include "mojo/public/cpp/bindings/interface_request.h" |
| 15 #include "mojo/public/cpp/bindings/strong_binding_set.h" |
15 #include "services/ui/gpu/gpu_main.h" | 16 #include "services/ui/gpu/gpu_main.h" |
16 #include "services/ui/gpu/interfaces/gpu_host.mojom.h" | 17 #include "services/ui/gpu/interfaces/gpu_host.mojom.h" |
17 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" | 18 #include "services/ui/gpu/interfaces/gpu_service.mojom.h" |
18 #include "services/ui/public/interfaces/gpu.mojom.h" | 19 #include "services/ui/public/interfaces/gpu.mojom.h" |
19 | 20 |
20 namespace ui { | 21 namespace ui { |
21 | 22 |
22 class ServerGpuMemoryBufferManager; | 23 class ServerGpuMemoryBufferManager; |
23 | 24 |
24 namespace ws { | 25 namespace ws { |
25 | 26 |
| 27 namespace test { |
| 28 class GpuHostTest; |
| 29 } // namespace test |
| 30 |
26 class GpuHostDelegate; | 31 class GpuHostDelegate; |
27 | 32 |
28 // Sets up connection from clients to the real service implementation in the GPU | 33 // Sets up connection from clients to the real service implementation in the GPU |
29 // process. | 34 // process. |
30 class GpuHost : public mojom::GpuHost { | 35 class GpuHost : public mojom::GpuHost { |
31 public: | 36 public: |
32 explicit GpuHost(GpuHostDelegate* delegate); | 37 explicit GpuHost(GpuHostDelegate* delegate); |
33 ~GpuHost() override; | 38 ~GpuHost() override; |
34 | 39 |
35 void Add(mojom::GpuRequest request); | 40 mojom::Gpu* Add(mojom::GpuRequest request); |
36 | 41 |
37 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); | 42 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget); |
38 void OnAcceleratedWidgetDestroyed(gfx::AcceleratedWidget widget); | 43 void OnAcceleratedWidgetDestroyed(gfx::AcceleratedWidget widget); |
39 | 44 |
40 // Requests a cc::mojom::DisplayCompositor interface from mus-gpu. | 45 // Requests a cc::mojom::DisplayCompositor interface from mus-gpu. |
41 void CreateDisplayCompositor(cc::mojom::DisplayCompositorRequest request, | 46 void CreateDisplayCompositor(cc::mojom::DisplayCompositorRequest request, |
42 cc::mojom::DisplayCompositorClientPtr client); | 47 cc::mojom::DisplayCompositorClientPtr client); |
43 | 48 |
44 private: | 49 private: |
| 50 friend class test::GpuHostTest; |
| 51 |
45 void OnBadMessageFromGpu(); | 52 void OnBadMessageFromGpu(); |
46 | 53 |
47 // mojom::GpuHost: | 54 // mojom::GpuHost: |
48 void DidInitialize(const gpu::GPUInfo& gpu_info) override; | 55 void DidInitialize(const gpu::GPUInfo& gpu_info) override; |
49 void DidCreateOffscreenContext(const GURL& url) override; | 56 void DidCreateOffscreenContext(const GURL& url) override; |
50 void DidDestroyOffscreenContext(const GURL& url) override; | 57 void DidDestroyOffscreenContext(const GURL& url) override; |
51 void DidDestroyChannel(int32_t client_id) override; | 58 void DidDestroyChannel(int32_t client_id) override; |
52 void DidLoseContext(bool offscreen, | 59 void DidLoseContext(bool offscreen, |
53 gpu::error::ContextLostReason reason, | 60 gpu::error::ContextLostReason reason, |
54 const GURL& active_url) override; | 61 const GURL& active_url) override; |
(...skipping 10 matching lines...) Expand all Loading... |
65 mojo::Binding<mojom::GpuHost> gpu_host_binding_; | 72 mojo::Binding<mojom::GpuHost> gpu_host_binding_; |
66 gpu::GPUInfo gpu_info_; | 73 gpu::GPUInfo gpu_info_; |
67 std::unique_ptr<ServerGpuMemoryBufferManager> gpu_memory_buffer_manager_; | 74 std::unique_ptr<ServerGpuMemoryBufferManager> gpu_memory_buffer_manager_; |
68 | 75 |
69 mojom::GpuMainPtr gpu_main_; | 76 mojom::GpuMainPtr gpu_main_; |
70 | 77 |
71 // TODO(fsamuel): GpuHost should not be holding onto |gpu_main_impl| | 78 // TODO(fsamuel): GpuHost should not be holding onto |gpu_main_impl| |
72 // because that will live in another process soon. | 79 // because that will live in another process soon. |
73 std::unique_ptr<GpuMain> gpu_main_impl_; | 80 std::unique_ptr<GpuMain> gpu_main_impl_; |
74 | 81 |
| 82 mojo::StrongBindingSet<mojom::Gpu> gpu_bindings_; |
| 83 |
75 DISALLOW_COPY_AND_ASSIGN(GpuHost); | 84 DISALLOW_COPY_AND_ASSIGN(GpuHost); |
76 }; | 85 }; |
77 | 86 |
78 } // namespace ws | 87 } // namespace ws |
79 } // namespace ui | 88 } // namespace ui |
80 | 89 |
81 #endif // SERVICES_UI_WS_GPU_HOST_H_ | 90 #endif // SERVICES_UI_WS_GPU_HOST_H_ |
OLD | NEW |