Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(438)

Side by Side Diff: services/native_viewport/native_viewport_impl.h

Issue 940293003: Add a Display and ContextProvider concept to mojom, use to recreate (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « services/native_viewport/main.cc ('k') | services/native_viewport/native_viewport_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 gles2 {
18 class GpuState;
19 }
20
18 namespace ui { 21 namespace ui {
19 class Event; 22 class Event;
20 } 23 }
21 24
22 namespace mojo {
23 class ApplicationImpl;
24 }
25
26 namespace native_viewport { 25 namespace native_viewport {
27 class ViewportSurface;
28 26
29 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. 27 // 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 28 // The NativeViewportImpl's lifetime ends when either the message pipe is closed
31 // or the PlatformViewport informs the NativeViewportImpl that it has been 29 // or the PlatformViewport informs the NativeViewportImpl that it has been
32 // destroyed. 30 // destroyed.
33 class NativeViewportImpl : public mojo::NativeViewport, 31 class NativeViewportImpl : public mojo::NativeViewport,
34 public PlatformViewport::Delegate, 32 public PlatformViewport::Delegate,
35 public mojo::ErrorHandler { 33 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: 34 public:
42 NativeViewportImpl(mojo::ApplicationImpl* app, 35 NativeViewportImpl(bool is_headless,
43 bool is_headless, 36 const scoped_refptr<gles2::GpuState>& gpu_state,
44 mojo::InterfaceRequest<mojo::NativeViewport> request); 37 mojo::InterfaceRequest<mojo::NativeViewport> request);
45 ~NativeViewportImpl() override; 38 ~NativeViewportImpl() override;
46 39
47 // NativeViewport implementation. 40 // NativeViewport implementation.
48 void Create(mojo::SizePtr size, const CreateCallback& callback) override; 41 void Create(mojo::SizePtr size, const CreateCallback& callback) override;
49 void RequestMetrics(const MetricsCallback& callback) override; 42 void RequestMetrics(const RequestMetricsCallback& callback) override;
50 void Show() override; 43 void Show() override;
51 void Hide() override; 44 void Hide() override;
52 void Close() override; 45 void Close() override;
53 void SetSize(mojo::SizePtr size) override; 46 void SetSize(mojo::SizePtr size) override;
54 void SubmittedFrame(mojo::SurfaceIdPtr surface_id) override; 47 void GetContextProvider(
48 mojo::InterfaceRequest<mojo::ContextProvider> request) override;
55 void SetEventDispatcher( 49 void SetEventDispatcher(
56 mojo::NativeViewportEventDispatcherPtr dispatcher) override; 50 mojo::NativeViewportEventDispatcherPtr dispatcher) override;
57 51
58 // PlatformViewport::Delegate implementation. 52 // PlatformViewport::Delegate implementation.
59 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; 53 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override;
60 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; 54 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
61 bool OnEvent(ui::Event* ui_event) override; 55 bool OnEvent(ui::Event* ui_event) override;
62 void OnDestroyed() override; 56 void OnDestroyed() override;
63 57
64 // mojo::ErrorHandler implementation. 58 // mojo::ErrorHandler implementation.
65 void OnConnectionError() override; 59 void OnConnectionError() override;
66 60
67 void AckEvent(); 61 void AckEvent();
68 62
69 private: 63 private:
70 bool is_headless_; 64 bool is_headless_;
71 scoped_ptr<PlatformViewport> platform_viewport_; 65 scoped_ptr<PlatformViewport> platform_viewport_;
72 scoped_ptr<ViewportSurface> viewport_surface_; 66 OnscreenContextProvider context_provider_;
73 uint64_t widget_id_;
74 bool sent_metrics_; 67 bool sent_metrics_;
75 mojo::ViewportMetricsPtr metrics_; 68 mojo::ViewportMetricsPtr metrics_;
76 mojo::GpuPtr gpu_service_;
77 mojo::SurfacePtr surface_;
78 cc::SurfaceId child_surface_id_;
79 bool waiting_for_event_ack_; 69 bool waiting_for_event_ack_;
80 CreateCallback create_callback_; 70 CreateCallback create_callback_;
81 MetricsCallback metrics_callback_; 71 RequestMetricsCallback metrics_callback_;
82 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; 72 mojo::NativeViewportEventDispatcherPtr event_dispatcher_;
83 mojo::Binding<mojo::NativeViewport> binding_; 73 mojo::Binding<mojo::NativeViewport> binding_;
84 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; 74 base::WeakPtrFactory<NativeViewportImpl> weak_factory_;
85 75
86 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); 76 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl);
87 }; 77 };
88 78
89 } // namespace native_viewport 79 } // namespace native_viewport
90 80
91 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ 81 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_
OLDNEW
« no previous file with comments | « services/native_viewport/main.cc ('k') | services/native_viewport/native_viewport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698