James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 1 | // Copyright 2013 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 | |
James Robinson | c9b163e | 2014-12-03 13:31:32 -0800 | [diff] [blame] | 5 | #ifndef SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_ANDROID_H_ |
| 6 | #define SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_ANDROID_H_ |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 7 | |
| 8 | #include "base/android/jni_weak_ref.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 9 | #include "base/macros.h" |
| 10 | #include "base/memory/weak_ptr.h" |
Etienne Membrives | 1473183 | 2015-08-11 15:42:42 +0200 | [diff] [blame] | 11 | #include "services/native_viewport/native_viewport_support.mojom.h" |
James Robinson | c9b163e | 2014-12-03 13:31:32 -0800 | [diff] [blame] | 12 | #include "services/native_viewport/platform_viewport.h" |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 13 | #include "ui/events/event_constants.h" |
| 14 | #include "ui/gfx/rect.h" |
| 15 | #include "ui/gfx/sequential_id_generator.h" |
| 16 | #include "ui/gfx/size.h" |
| 17 | |
| 18 | namespace gpu { |
| 19 | class GLInProcessContext; |
| 20 | } |
| 21 | |
Etienne Membrives | fbd9af0 | 2015-08-07 16:26:09 +0200 | [diff] [blame] | 22 | namespace mojo { |
| 23 | class ApplicationImpl; |
| 24 | } |
| 25 | |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 26 | struct ANativeWindow; |
| 27 | |
James Robinson | bd9353b | 2014-12-12 17:56:18 -0800 | [diff] [blame] | 28 | namespace native_viewport { |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 29 | |
| 30 | class PlatformViewportAndroid : public PlatformViewport { |
| 31 | public: |
| 32 | static bool Register(JNIEnv* env); |
| 33 | |
Etienne Membrives | fbd9af0 | 2015-08-07 16:26:09 +0200 | [diff] [blame] | 34 | explicit PlatformViewportAndroid(mojo::ApplicationImpl* application, |
| 35 | Delegate* delegate); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 36 | virtual ~PlatformViewportAndroid(); |
| 37 | |
| 38 | void Destroy(JNIEnv* env, jobject obj); |
Etienne Membrives | fbd9af0 | 2015-08-07 16:26:09 +0200 | [diff] [blame] | 39 | void SurfaceAttached(JNIEnv* env, jobject obj, jobject platform_viewport); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 40 | void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface); |
| 41 | void SurfaceDestroyed(JNIEnv* env, jobject obj); |
Adam Barth | 9329c44 | 2015-01-09 21:56:43 -0800 | [diff] [blame] | 42 | void SurfaceSetSize(JNIEnv* env, |
| 43 | jobject obj, |
| 44 | jint width, |
| 45 | jint height, |
| 46 | jfloat density); |
Scott Violet | 6aadda5 | 2015-03-24 09:13:10 -0700 | [diff] [blame] | 47 | bool TouchEvent(JNIEnv* env, |
| 48 | jobject obj, |
| 49 | jlong time_ms, |
| 50 | jint masked_action, |
| 51 | jint pointer_id, |
| 52 | jfloat x, |
| 53 | jfloat y, |
| 54 | jfloat pressure, |
| 55 | jfloat touch_major, |
| 56 | jfloat touch_minor, |
| 57 | jfloat orientation, |
| 58 | jfloat h_wheel, |
| 59 | jfloat v_wheel); |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 60 | |
| 61 | private: |
| 62 | // Overridden from PlatformViewport: |
| 63 | virtual void Init(const gfx::Rect& bounds) override; |
| 64 | virtual void Show() override; |
| 65 | virtual void Hide() override; |
| 66 | virtual void Close() override; |
| 67 | virtual gfx::Size GetSize() override; |
| 68 | virtual void SetBounds(const gfx::Rect& bounds) override; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 69 | |
| 70 | void ReleaseWindow(); |
| 71 | |
Etienne Membrives | fbd9af0 | 2015-08-07 16:26:09 +0200 | [diff] [blame] | 72 | mojo::ApplicationImpl* application_; |
Etienne Membrives | 1473183 | 2015-08-11 15:42:42 +0200 | [diff] [blame] | 73 | NativeViewportSupportServicePtr support_service_; |
Viet-Trung Luu | dc865d4 | 2015-04-15 15:15:08 -0700 | [diff] [blame] | 74 | Delegate* const delegate_; |
| 75 | JavaObjectWeakGlobalRef java_platform_viewport_android_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 76 | ANativeWindow* window_; |
Adam Barth | 9329c44 | 2015-01-09 21:56:43 -0800 | [diff] [blame] | 77 | mojo::ViewportMetricsPtr metrics_; |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 78 | ui::SequentialIDGenerator id_generator_; |
| 79 | |
| 80 | base::WeakPtrFactory<PlatformViewportAndroid> weak_factory_; |
| 81 | |
| 82 | DISALLOW_COPY_AND_ASSIGN(PlatformViewportAndroid); |
| 83 | }; |
| 84 | |
James Robinson | bd9353b | 2014-12-12 17:56:18 -0800 | [diff] [blame] | 85 | } // namespace native_viewport |
James Robinson | 646469d | 2014-10-03 15:33:28 -0700 | [diff] [blame] | 86 | |
James Robinson | c9b163e | 2014-12-03 13:31:32 -0800 | [diff] [blame] | 87 | #endif // SERVICES_NATIVE_VIEWPORT_PLATFORM_VIEWPORT_ANDROID_H_ |