OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 5 #ifndef SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
6 #define SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 6 #define SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "cc/surfaces/surface_id.h" | |
11 #include "mojo/public/cpp/bindings/strong_binding.h" | 10 #include "mojo/public/cpp/bindings/strong_binding.h" |
12 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" | 11 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" |
13 #include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom. h" | 12 #include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom. h" |
14 #include "mojo/services/surfaces/public/interfaces/surfaces.mojom.h" | 13 #include "services/native_viewport/onscreen_context_provider.h" |
15 #include "services/native_viewport/platform_viewport.h" | 14 #include "services/native_viewport/platform_viewport.h" |
16 #include "ui/gfx/geometry/rect.h" | 15 #include "ui/gfx/geometry/rect.h" |
17 | 16 |
17 namespace mojo { | |
18 class ApplicationImpl; | |
qsr
2015/02/23 12:32:53
Isn't the new style that we do not forward declare
jamesr
2015/03/04 00:19:51
Actually this can go away completely. I just re-s
| |
19 } | |
20 | |
21 namespace gles2 { | |
22 class GpuState; | |
23 } | |
24 | |
18 namespace ui { | 25 namespace ui { |
19 class Event; | 26 class Event; |
20 } | 27 } |
21 | 28 |
22 namespace mojo { | |
23 class ApplicationImpl; | |
24 } | |
25 | |
26 namespace native_viewport { | 29 namespace native_viewport { |
27 class ViewportSurface; | |
28 | 30 |
29 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. | 31 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. |
30 // The NativeViewportImpl's lifetime ends when either the message pipe is closed | 32 // The NativeViewportImpl's lifetime ends when either the message pipe is closed |
31 // or the PlatformViewport informs the NativeViewportImpl that it has been | 33 // or the PlatformViewport informs the NativeViewportImpl that it has been |
32 // destroyed. | 34 // destroyed. |
33 class NativeViewportImpl : public mojo::NativeViewport, | 35 class NativeViewportImpl : public mojo::NativeViewport, |
34 public PlatformViewport::Delegate, | 36 public PlatformViewport::Delegate, |
35 public mojo::ErrorHandler { | 37 public mojo::ErrorHandler { |
36 using CreateCallback = mojo::Callback<void(uint64_t native_viewport_id, | |
37 mojo::ViewportMetricsPtr metrics)>; | |
38 using MetricsCallback = | |
39 mojo::Callback<void(mojo::ViewportMetricsPtr metrics)>; | |
40 | |
41 public: | 38 public: |
42 NativeViewportImpl(mojo::ApplicationImpl* app, | 39 NativeViewportImpl(bool is_headless, |
43 bool is_headless, | 40 const scoped_refptr<gles2::GpuState>& gpu_state, |
44 mojo::InterfaceRequest<mojo::NativeViewport> request); | 41 mojo::InterfaceRequest<mojo::NativeViewport> request); |
45 ~NativeViewportImpl() override; | 42 ~NativeViewportImpl() override; |
46 | 43 |
47 // NativeViewport implementation. | 44 // NativeViewport implementation. |
48 void Create(mojo::SizePtr size, const CreateCallback& callback) override; | 45 void Create(mojo::SizePtr size, const CreateCallback& callback) override; |
49 void RequestMetrics(const MetricsCallback& callback) override; | 46 void RequestMetrics(const RequestMetricsCallback& callback) override; |
50 void Show() override; | 47 void Show() override; |
51 void Hide() override; | 48 void Hide() override; |
52 void Close() override; | 49 void Close() override; |
53 void SetSize(mojo::SizePtr size) override; | 50 void SetSize(mojo::SizePtr size) override; |
54 void SubmittedFrame(mojo::SurfaceIdPtr surface_id) override; | 51 void GetContextProvider( |
52 mojo::InterfaceRequest<mojo::ContextProvider> request) override; | |
55 void SetEventDispatcher( | 53 void SetEventDispatcher( |
56 mojo::NativeViewportEventDispatcherPtr dispatcher) override; | 54 mojo::NativeViewportEventDispatcherPtr dispatcher) override; |
57 | 55 |
58 // PlatformViewport::Delegate implementation. | 56 // PlatformViewport::Delegate implementation. |
59 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; | 57 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; |
60 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; | 58 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; |
61 bool OnEvent(ui::Event* ui_event) override; | 59 bool OnEvent(ui::Event* ui_event) override; |
62 void OnDestroyed() override; | 60 void OnDestroyed() override; |
63 | 61 |
64 // mojo::ErrorHandler implementation. | 62 // mojo::ErrorHandler implementation. |
65 void OnConnectionError() override; | 63 void OnConnectionError() override; |
66 | 64 |
67 void AckEvent(); | 65 void AckEvent(); |
68 | 66 |
69 private: | 67 private: |
70 bool is_headless_; | 68 bool is_headless_; |
71 scoped_ptr<PlatformViewport> platform_viewport_; | 69 scoped_ptr<PlatformViewport> platform_viewport_; |
72 scoped_ptr<ViewportSurface> viewport_surface_; | 70 OnscreenContextProvider context_provider_; |
73 uint64_t widget_id_; | |
74 bool sent_metrics_; | 71 bool sent_metrics_; |
75 mojo::ViewportMetricsPtr metrics_; | 72 mojo::ViewportMetricsPtr metrics_; |
76 mojo::GpuPtr gpu_service_; | |
77 mojo::SurfacePtr surface_; | |
78 cc::SurfaceId child_surface_id_; | |
79 bool waiting_for_event_ack_; | 73 bool waiting_for_event_ack_; |
80 CreateCallback create_callback_; | 74 CreateCallback create_callback_; |
81 MetricsCallback metrics_callback_; | 75 RequestMetricsCallback metrics_callback_; |
82 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; | 76 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
83 mojo::Binding<mojo::NativeViewport> binding_; | 77 mojo::Binding<mojo::NativeViewport> binding_; |
84 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 78 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
85 | 79 |
86 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); | 80 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
87 }; | 81 }; |
88 | 82 |
89 } // namespace native_viewport | 83 } // namespace native_viewport |
90 | 84 |
91 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 85 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
OLD | NEW |