| 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/interfaces/gpu.mojom.h" | 13 #include "mojo/services/gpu/interfaces/gpu.mojom.h" |
| 14 #include "mojo/services/native_viewport/interfaces/native_viewport.mojom.h" | 14 #include "mojo/services/native_viewport/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 { | 23 namespace mojo { |
| 24 class ApplicationImpl; | 24 class Shell; |
| 25 } | 25 } |
| 26 | 26 |
| 27 namespace ui { | 27 namespace ui { |
| 28 class Event; | 28 class Event; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace native_viewport { | 31 namespace native_viewport { |
| 32 | 32 |
| 33 // 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. |
| 34 // 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 |
| 35 // or the PlatformViewport informs the NativeViewportImpl that it has been | 35 // or the PlatformViewport informs the NativeViewportImpl that it has been |
| 36 // destroyed. | 36 // destroyed. |
| 37 class NativeViewportImpl : public mojo::NativeViewport, | 37 class NativeViewportImpl : public mojo::NativeViewport, |
| 38 public PlatformViewport::Delegate { | 38 public PlatformViewport::Delegate { |
| 39 public: | 39 public: |
| 40 NativeViewportImpl(mojo::ApplicationImpl* application, | 40 // TODO(vtl): Maybe this should take an |
| 41 // |InterfaceHandle<ApplicationConnector>| instead of a |Shell*|. |
| 42 NativeViewportImpl(mojo::Shell* shell, |
| 41 bool is_headless, | 43 bool is_headless, |
| 42 const scoped_refptr<gles2::GpuState>& gpu_state, | 44 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 43 mojo::InterfaceRequest<mojo::NativeViewport> request); | 45 mojo::InterfaceRequest<mojo::NativeViewport> request); |
| 44 ~NativeViewportImpl() override; | 46 ~NativeViewportImpl() override; |
| 45 | 47 |
| 46 // NativeViewport implementation. | 48 // NativeViewport implementation. |
| 47 void Create(mojo::SizePtr size, | 49 void Create(mojo::SizePtr size, |
| 48 mojo::SurfaceConfigurationPtr requested_configuration, | 50 mojo::SurfaceConfigurationPtr requested_configuration, |
| 49 const CreateCallback& callback) override; | 51 const CreateCallback& callback) override; |
| 50 void RequestMetrics(const RequestMetricsCallback& callback) override; | 52 void RequestMetrics(const RequestMetricsCallback& callback) override; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 64 void OnAcceleratedWidgetDestroyed() override; | 66 void OnAcceleratedWidgetDestroyed() override; |
| 65 bool OnEvent(mojo::EventPtr event) override; | 67 bool OnEvent(mojo::EventPtr event) override; |
| 66 void OnDestroyed() override; | 68 void OnDestroyed() override; |
| 67 | 69 |
| 68 private: | 70 private: |
| 69 // Callback when the dispatcher has processed a message we're waiting on | 71 // Callback when the dispatcher has processed a message we're waiting on |
| 70 // an ack from. |pointer_id| identifies the pointer the message was associated | 72 // an ack from. |pointer_id| identifies the pointer the message was associated |
| 71 // with. | 73 // with. |
| 72 void AckEvent(int32 pointer_id); | 74 void AckEvent(int32 pointer_id); |
| 73 | 75 |
| 74 mojo::ApplicationImpl* application_; | 76 mojo::Shell* const shell_; |
| 75 bool is_headless_; | 77 const bool is_headless_; |
| 76 scoped_ptr<PlatformViewport> platform_viewport_; | 78 scoped_ptr<PlatformViewport> platform_viewport_; |
| 77 OnscreenContextProvider context_provider_; | 79 OnscreenContextProvider context_provider_; |
| 78 bool sent_metrics_; | 80 bool sent_metrics_; |
| 79 mojo::ViewportMetricsPtr metrics_; | 81 mojo::ViewportMetricsPtr metrics_; |
| 80 CreateCallback create_callback_; | 82 CreateCallback create_callback_; |
| 81 RequestMetricsCallback metrics_callback_; | 83 RequestMetricsCallback metrics_callback_; |
| 82 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; | 84 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
| 83 mojo::StrongBinding<mojo::NativeViewport> binding_; | 85 mojo::StrongBinding<mojo::NativeViewport> binding_; |
| 84 | 86 |
| 85 // Set of pointer_ids we've sent a move to and are waiting on an ack. | 87 // Set of pointer_ids we've sent a move to and are waiting on an ack. |
| 86 std::set<int32> pointers_waiting_on_ack_; | 88 std::set<int32> pointers_waiting_on_ack_; |
| 87 | 89 |
| 88 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 90 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
| 89 | 91 |
| 90 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); | 92 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
| 91 }; | 93 }; |
| 92 | 94 |
| 93 } // namespace native_viewport | 95 } // namespace native_viewport |
| 94 | 96 |
| 95 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 97 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| OLD | NEW |