| 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 <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" | 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" | 13 #include "mojo/services/gpu/public/interfaces/gpu.mojom.h" |
| 14 #include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom.
h" | 14 #include "mojo/services/native_viewport/public/interfaces/native_viewport.mojom.
h" |
| 15 #include "services/native_viewport/onscreen_context_provider.h" | 15 #include "services/native_viewport/onscreen_context_provider.h" |
| 16 #include "services/native_viewport/platform_viewport.h" | 16 #include "services/native_viewport/platform_viewport.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 17 #include "ui/gfx/geometry/rect.h" |
| 18 | 18 |
| 19 namespace gles2 { | 19 namespace gles2 { |
| 20 class GpuState; | 20 class GpuState; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace mojo { |
| 24 class ApplicationImpl; |
| 25 } |
| 26 |
| 23 namespace ui { | 27 namespace ui { |
| 24 class Event; | 28 class Event; |
| 25 } | 29 } |
| 26 | 30 |
| 27 namespace native_viewport { | 31 namespace native_viewport { |
| 28 | 32 |
| 29 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. | 33 // 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 | 34 // The NativeViewportImpl's lifetime ends when either the message pipe is closed |
| 31 // or the PlatformViewport informs the NativeViewportImpl that it has been | 35 // or the PlatformViewport informs the NativeViewportImpl that it has been |
| 32 // destroyed. | 36 // destroyed. |
| 33 class NativeViewportImpl : public mojo::NativeViewport, | 37 class NativeViewportImpl : public mojo::NativeViewport, |
| 34 public PlatformViewport::Delegate { | 38 public PlatformViewport::Delegate { |
| 35 public: | 39 public: |
| 36 NativeViewportImpl(bool is_headless, | 40 NativeViewportImpl(mojo::ApplicationImpl* application, |
| 41 bool is_headless, |
| 37 const scoped_refptr<gles2::GpuState>& gpu_state, | 42 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 38 mojo::InterfaceRequest<mojo::NativeViewport> request); | 43 mojo::InterfaceRequest<mojo::NativeViewport> request); |
| 39 ~NativeViewportImpl() override; | 44 ~NativeViewportImpl() override; |
| 40 | 45 |
| 41 // NativeViewport implementation. | 46 // NativeViewport implementation. |
| 42 void Create(mojo::SizePtr size, | 47 void Create(mojo::SizePtr size, |
| 43 mojo::SurfaceConfigurationPtr requested_configuration, | 48 mojo::SurfaceConfigurationPtr requested_configuration, |
| 44 const CreateCallback& callback) override; | 49 const CreateCallback& callback) override; |
| 45 void RequestMetrics(const RequestMetricsCallback& callback) override; | 50 void RequestMetrics(const RequestMetricsCallback& callback) override; |
| 46 void Show() override; | 51 void Show() override; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 58 void OnAcceleratedWidgetDestroyed() override; | 63 void OnAcceleratedWidgetDestroyed() override; |
| 59 bool OnEvent(mojo::EventPtr event) override; | 64 bool OnEvent(mojo::EventPtr event) override; |
| 60 void OnDestroyed() override; | 65 void OnDestroyed() override; |
| 61 | 66 |
| 62 private: | 67 private: |
| 63 // Callback when the dispatcher has processed a message we're waiting on | 68 // Callback when the dispatcher has processed a message we're waiting on |
| 64 // an ack from. |pointer_id| identifies the pointer the message was associated | 69 // an ack from. |pointer_id| identifies the pointer the message was associated |
| 65 // with. | 70 // with. |
| 66 void AckEvent(int32 pointer_id); | 71 void AckEvent(int32 pointer_id); |
| 67 | 72 |
| 73 mojo::ApplicationImpl* application_; |
| 68 bool is_headless_; | 74 bool is_headless_; |
| 69 scoped_ptr<PlatformViewport> platform_viewport_; | 75 scoped_ptr<PlatformViewport> platform_viewport_; |
| 70 OnscreenContextProvider context_provider_; | 76 OnscreenContextProvider context_provider_; |
| 71 bool sent_metrics_; | 77 bool sent_metrics_; |
| 72 mojo::ViewportMetricsPtr metrics_; | 78 mojo::ViewportMetricsPtr metrics_; |
| 73 CreateCallback create_callback_; | 79 CreateCallback create_callback_; |
| 74 RequestMetricsCallback metrics_callback_; | 80 RequestMetricsCallback metrics_callback_; |
| 75 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; | 81 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
| 76 mojo::StrongBinding<mojo::NativeViewport> binding_; | 82 mojo::StrongBinding<mojo::NativeViewport> binding_; |
| 77 | 83 |
| 78 // Set of pointer_ids we've sent a move to and are waiting on an ack. | 84 // Set of pointer_ids we've sent a move to and are waiting on an ack. |
| 79 std::set<int32> pointers_waiting_on_ack_; | 85 std::set<int32> pointers_waiting_on_ack_; |
| 80 | 86 |
| 81 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 87 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
| 82 | 88 |
| 83 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); | 89 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
| 84 }; | 90 }; |
| 85 | 91 |
| 86 } // namespace native_viewport | 92 } // namespace native_viewport |
| 87 | 93 |
| 88 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 94 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| OLD | NEW |