Index: components/view_manager/native_viewport/native_viewport.h |
diff --git a/components/view_manager/native_viewport/native_viewport.h b/components/view_manager/native_viewport/native_viewport.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d79021cda620dc66b6e6ebee28fc2b2bcae755df |
--- /dev/null |
+++ b/components/view_manager/native_viewport/native_viewport.h |
@@ -0,0 +1,89 @@ |
+// Copyright 2015 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_ |
+#define COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_ |
+ |
+#include "base/callback.h" |
+#include "base/memory/ref_counted.h" |
+#include "base/memory/weak_ptr.h" |
+#include "components/view_manager/native_viewport/onscreen_context_provider.h" |
+#include "components/view_manager/native_viewport/platform_viewport.h" |
+#include "components/view_manager/public/interfaces/gpu.mojom.h" |
+ |
+namespace gles2 { |
+class GpuState; |
+} // namespace gles2 |
+ |
+namespace gfx { |
+class Size; |
+} // namespace gfx |
+ |
+namespace view_manager { |
+ |
+class EventDispatcher; |
+ |
+class NativeViewport : public native_viewport::PlatformViewport::Delegate { |
+ public: |
+ using ViewDestroyedCallback = mojo::Callback<void()>; |
+ |
+ NativeViewport(const gfx::Size& size, |
+ bool is_headless, |
+ const scoped_refptr<gles2::GpuState>& gpu_state, |
+ EventDispatcher* event_dispatcher, |
sky
2015/06/04 22:37:58
I would prefer there to still be an interface and
Fady Samuel
2015/06/05 22:14:31
Done.
|
+ const ViewDestroyedCallback& view_destroyed_callback); |
+ ~NativeViewport() override; |
+ |
+ using RequestMetricsCallback = mojo::Callback<void (const gfx::Size&, float)>; |
+ void RequestMetrics(const RequestMetricsCallback& callback); |
+ |
+ void Show(); |
+ |
+ void Hide(); |
+ |
+ void Close(); |
+ |
+ void SetSize(const gfx::Size& size); |
+ |
+ void GetContextProvider( |
+ mojo::InterfaceRequest<mojo::ContextProvider> request); |
+ |
+ // PlatformViewport::Delegate implementation. |
+ void OnMetricsChanged(const gfx::Size& size, |
+ float device_scale_factor) override; |
+ void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
+ float device_pixel_ratio) override; |
+ void OnAcceleratedWidgetDestroyed() override; |
+ bool OnEvent(mojo::EventPtr event) override; |
+ void OnDestroyed() override; |
+ |
+ private: |
+ // Callback when the dispatcher has processed a message we're waiting on |
+ // an ack from. |pointer_id| identifies the pointer the message was associated |
+ // with. |
+ void AckEvent(int32 pointer_id); |
+ |
+ scoped_ptr<native_viewport::PlatformViewport> platform_viewport_; |
+ scoped_ptr<native_viewport::OnscreenContextProvider> context_provider_; |
+ |
+ // Metrics members. |
+ gfx::Size size_; |
+ float device_scale_factor_; |
+ bool metrics_ready_; |
+ RequestMetricsCallback metrics_callback_; |
+ |
+ EventDispatcher* event_dispatcher_; |
+ |
+ ViewDestroyedCallback view_destroyed_callback_; |
+ |
+ // Set of pointer_ids we've sent a move to and are waiting on an ack. |
+ std::set<int32> pointers_waiting_on_ack_; |
+ |
+ base::WeakPtrFactory<NativeViewport> weak_factory_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NativeViewport); |
+}; |
+} // namespace view_manager |
+ |
+#endif // COMPONENTS_VIEW_MANAGER_NATIVE_VIEWPORT_NATIVE_VIEWPORT_H_ |