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