OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| 6 #define SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
| 7 |
| 8 #include <set> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 13 #include "mojo/services/native_viewport/onscreen_context_provider.h" |
| 14 #include "mojo/services/native_viewport/platform_viewport.h" |
| 15 #include "third_party/mojo_services/src/gpu/public/interfaces/gpu.mojom.h" |
| 16 #include "third_party/mojo_services/src/native_viewport/public/interfaces/native
_viewport.mojom.h" |
| 17 #include "ui/gfx/geometry/rect.h" |
| 18 |
| 19 namespace gles2 { |
| 20 class GpuState; |
| 21 } |
| 22 |
| 23 namespace ui { |
| 24 class Event; |
| 25 } |
| 26 |
| 27 namespace native_viewport { |
| 28 |
| 29 // 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 // or the PlatformViewport informs the NativeViewportImpl that it has been |
| 32 // destroyed. |
| 33 class NativeViewportImpl : public mojo::NativeViewport, |
| 34 public PlatformViewport::Delegate, |
| 35 public mojo::ErrorHandler { |
| 36 public: |
| 37 NativeViewportImpl(bool is_headless, |
| 38 const scoped_refptr<gles2::GpuState>& gpu_state, |
| 39 mojo::InterfaceRequest<mojo::NativeViewport> request); |
| 40 ~NativeViewportImpl() override; |
| 41 |
| 42 // NativeViewport implementation. |
| 43 void Create(mojo::SizePtr size, const CreateCallback& callback) override; |
| 44 void RequestMetrics(const RequestMetricsCallback& callback) override; |
| 45 void Show() override; |
| 46 void Hide() override; |
| 47 void Close() override; |
| 48 void SetSize(mojo::SizePtr size) override; |
| 49 void GetContextProvider( |
| 50 mojo::InterfaceRequest<mojo::ContextProvider> request) override; |
| 51 void SetEventDispatcher( |
| 52 mojo::NativeViewportEventDispatcherPtr dispatcher) override; |
| 53 |
| 54 // PlatformViewport::Delegate implementation. |
| 55 void OnMetricsChanged(mojo::ViewportMetricsPtr metrics) override; |
| 56 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override; |
| 57 void OnAcceleratedWidgetDestroyed() override; |
| 58 bool OnEvent(mojo::EventPtr event) override; |
| 59 void OnDestroyed() override; |
| 60 |
| 61 // mojo::ErrorHandler implementation. |
| 62 void OnConnectionError() override; |
| 63 |
| 64 private: |
| 65 // Callback when the dispatcher has processed a message we're waiting on |
| 66 // an ack from. |pointer_id| identifies the pointer the message was associated |
| 67 // with. |
| 68 void AckEvent(int32 pointer_id); |
| 69 |
| 70 bool is_headless_; |
| 71 scoped_ptr<PlatformViewport> platform_viewport_; |
| 72 OnscreenContextProvider context_provider_; |
| 73 bool sent_metrics_; |
| 74 mojo::ViewportMetricsPtr metrics_; |
| 75 CreateCallback create_callback_; |
| 76 RequestMetricsCallback metrics_callback_; |
| 77 mojo::NativeViewportEventDispatcherPtr event_dispatcher_; |
| 78 mojo::Binding<mojo::NativeViewport> binding_; |
| 79 |
| 80 // Set of pointer_ids we've sent a move to and are waiting on an ack. |
| 81 std::set<int32> pointers_waiting_on_ack_; |
| 82 |
| 83 base::WeakPtrFactory<NativeViewportImpl> weak_factory_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(NativeViewportImpl); |
| 86 }; |
| 87 |
| 88 } // namespace native_viewport |
| 89 |
| 90 #endif // SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_IMPL_H_ |
OLD | NEW |