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
5#ifndef MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
6#define MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
7
8#include "base/android/jni_helper.h"
9#include "base/android/scoped_java_ref.h"
10#include "base/memory/weak_ptr.h"
11#include "mojo/services/native_viewport/native_viewport.h"
12#include "ui/events/event_constants.h"
13#include "ui/gfx/sequential_id_generator.h"
14#include "ui/gfx/size.h"
15
16namespace gpu {
17class GLInProcessContext;
18}
19
20struct ANativeWindow;
21
22namespace mojo {
23namespace services {
24
25class NativeViewportAndroid : public NativeViewport {
26 public:
27  static bool Register(JNIEnv* env);
28
29  explicit NativeViewportAndroid(shell::Context* context,
30                                 NativeViewportDelegate* delegate);
31  virtual ~NativeViewportAndroid();
32
33  void Destroy(JNIEnv* env, jobject obj);
34  void SurfaceCreated(JNIEnv* env, jobject obj, jobject jsurface);
35  void SurfaceDestroyed(JNIEnv* env, jobject obj);
36  void SurfaceSetSize(JNIEnv* env, jobject obj, jint width, jint height);
37  bool TouchEvent(JNIEnv* env, jobject obj, jint pointer_id, jint action,
38                  jfloat x, jfloat y, jlong time_ms);
39
40 private:
41  // Overridden from NativeViewport:
42  virtual void Init() OVERRIDE;
43  virtual void Close() OVERRIDE;
44  virtual gfx::Size GetSize() OVERRIDE;
45  virtual void SetCapture() OVERRIDE;
46  virtual void ReleaseCapture() OVERRIDE;
47
48  void ReleaseWindow();
49
50  NativeViewportDelegate* delegate_;
51  shell::Context* context_;
52  ANativeWindow* window_;
53  gfx::Size size_;
54  ui::SequentialIDGenerator id_generator_;
55
56  base::WeakPtrFactory<NativeViewportAndroid> weak_factory_;
57
58  DISALLOW_COPY_AND_ASSIGN(NativeViewportAndroid);
59};
60
61
62}  // namespace services
63}  // namespace mojo
64
65#endif  // MOJO_SERVICES_NATIVE_VIEWPORT_NATIVE_VIEWPORT_ANDROID_H_
66