| 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 COMPONENTS_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 5 #ifndef COMPONENTS_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| 6 #define COMPONENTS_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 6 #define COMPONENTS_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 "components/gpu/public/interfaces/gpu.mojom.h" | 12 #include "components/gpu/public/interfaces/gpu.mojom.h" |
| 13 #include "components/native_viewport/onscreen_context_provider.h" | 13 #include "components/native_viewport/onscreen_context_provider.h" |
| 14 #include "components/native_viewport/platform_viewport.h" | 14 #include "components/native_viewport/platform_viewport.h" |
| 15 #include "components/native_viewport/public/interfaces/native_viewport.mojom.h" | 15 #include "components/native_viewport/public/interfaces/native_viewport.mojom.h" |
| 16 #include "mojo/application/app_lifetime_helper.h" |
| 16 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" | 17 #include "third_party/mojo/src/mojo/public/cpp/bindings/strong_binding.h" |
| 17 #include "ui/gfx/geometry/rect.h" | 18 #include "ui/gfx/geometry/rect.h" |
| 18 | 19 |
| 19 namespace gles2 { | 20 namespace gles2 { |
| 20 class GpuState; | 21 class GpuState; |
| 21 } | 22 } |
| 22 | 23 |
| 23 namespace ui { | 24 namespace ui { |
| 24 class Event; | 25 class Event; |
| 25 } | 26 } |
| 26 | 27 |
| 27 namespace native_viewport { | 28 namespace native_viewport { |
| 28 | 29 |
| 29 // A NativeViewportImpl is bound to a message pipe and to a PlatformViewport. | 30 // 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 | 31 // The NativeViewportImpl's lifetime ends when either the message pipe is closed |
| 31 // or the PlatformViewport informs the NativeViewportImpl that it has been | 32 // or the PlatformViewport informs the NativeViewportImpl that it has been |
| 32 // destroyed. | 33 // destroyed. |
| 33 class NativeViewportImpl : public mojo::NativeViewport, | 34 class NativeViewportImpl : public mojo::NativeViewport, |
| 34 public PlatformViewport::Delegate, | 35 public PlatformViewport::Delegate, |
| 35 public mojo::ErrorHandler { | 36 public mojo::ErrorHandler { |
| 36 public: | 37 public: |
| 37 NativeViewportImpl(bool is_headless, | 38 NativeViewportImpl(bool is_headless, |
| 38 const scoped_refptr<gles2::GpuState>& gpu_state, | 39 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 39 mojo::InterfaceRequest<mojo::NativeViewport> request); | 40 mojo::InterfaceRequest<mojo::NativeViewport> request, |
| 41 scoped_ptr<mojo::AppRefCount> app_refcount); |
| 40 ~NativeViewportImpl() override; | 42 ~NativeViewportImpl() override; |
| 41 | 43 |
| 42 // NativeViewport implementation. | 44 // NativeViewport implementation. |
| 43 void Create(mojo::SizePtr size, const CreateCallback& callback) override; | 45 void Create(mojo::SizePtr size, const CreateCallback& callback) override; |
| 44 void RequestMetrics(const RequestMetricsCallback& callback) override; | 46 void RequestMetrics(const RequestMetricsCallback& callback) override; |
| 45 void Show() override; | 47 void Show() override; |
| 46 void Hide() override; | 48 void Hide() override; |
| 47 void Close() override; | 49 void Close() override; |
| 48 void SetSize(mojo::SizePtr size) override; | 50 void SetSize(mojo::SizePtr size) override; |
| 49 void GetContextProvider( | 51 void GetContextProvider( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 62 // mojo::ErrorHandler implementation. | 64 // mojo::ErrorHandler implementation. |
| 63 void OnConnectionError() override; | 65 void OnConnectionError() override; |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 // 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 |
| 67 // 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 |
| 68 // with. | 70 // with. |
| 69 void AckEvent(int32 pointer_id); | 71 void AckEvent(int32 pointer_id); |
| 70 | 72 |
| 71 bool is_headless_; | 73 bool is_headless_; |
| 74 scoped_ptr<mojo::AppRefCount> app_refcount_; |
| 72 scoped_ptr<PlatformViewport> platform_viewport_; | 75 scoped_ptr<PlatformViewport> platform_viewport_; |
| 73 scoped_ptr<OnscreenContextProvider> context_provider_; | 76 scoped_ptr<OnscreenContextProvider> context_provider_; |
| 74 bool sent_metrics_; | 77 bool sent_metrics_; |
| 75 mojo::ViewportMetricsPtr metrics_; | 78 mojo::ViewportMetricsPtr metrics_; |
| 76 CreateCallback create_callback_; | 79 CreateCallback create_callback_; |
| 77 RequestMetricsCallback metrics_callback_; | 80 RequestMetricsCallback metrics_callback_; |
| 78 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; | 81 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
| 79 mojo::Binding<mojo::NativeViewport> binding_; | 82 mojo::Binding<mojo::NativeViewport> binding_; |
| 80 | 83 |
| 81 // 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. |
| 82 std::set<int32> pointers_waiting_on_ack_; | 85 std::set<int32> pointers_waiting_on_ack_; |
| 83 | 86 |
| 84 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; | 87 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
| 85 | 88 |
| 86 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); | 89 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
| 87 }; | 90 }; |
| 88 | 91 |
| 89 } // namespace native_viewport | 92 } // namespace native_viewport |
| 90 | 93 |
| 91 #endif // COMPONENTS_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ | 94 #endif // COMPONENTS_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| OLD | NEW |