Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / base / android / window_android.h
blobcd8ae3408c85f2677e2f8472a7357c4e0f9d3012
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.
5 #ifndef UI_BASE_ANDROID_WINDOW_ANDROID_H_
6 #define UI_BASE_ANDROID_WINDOW_ANDROID_H_
8 #include <jni.h>
9 #include <vector>
10 #include "base/android/jni_weak_ref.h"
11 #include "base/android/scoped_java_ref.h"
12 #include "base/observer_list.h"
13 #include "base/time/time.h"
14 #include "ui/base/ui_base_export.h"
15 #include "ui/gfx/vector2d_f.h"
17 namespace ui {
19 class WindowAndroidCompositor;
20 class WindowAndroidObserver;
22 // Android implementation of the activity window.
23 class UI_BASE_EXPORT WindowAndroid {
24 public:
25 WindowAndroid(JNIEnv* env, jobject obj, jlong vsync_period);
27 void Destroy(JNIEnv* env, jobject obj);
29 base::android::ScopedJavaLocalRef<jobject> GetJavaObject();
31 static bool RegisterWindowAndroid(JNIEnv* env);
33 // The content offset is used to translate snapshots to the correct part of
34 // the window.
35 void set_content_offset(const gfx::Vector2dF& content_offset) {
36 content_offset_ = content_offset;
39 gfx::Vector2dF content_offset() const {
40 return content_offset_;
43 // Compositor callback relay.
44 void OnCompositingDidCommit();
46 void AttachCompositor(WindowAndroidCompositor* compositor);
47 void DetachCompositor();
49 void AddObserver(WindowAndroidObserver* observer);
50 void RemoveObserver(WindowAndroidObserver* observer);
52 WindowAndroidCompositor* GetCompositor() { return compositor_; }
54 void RequestVSyncUpdate();
55 void SetNeedsAnimate();
56 void OnVSync(JNIEnv* env, jobject obj, jlong time_micros);
57 void Animate(base::TimeTicks begin_frame_time);
59 private:
60 ~WindowAndroid();
62 JavaObjectWeakGlobalRef weak_java_window_;
63 gfx::Vector2dF content_offset_;
64 WindowAndroidCompositor* compositor_;
65 base::TimeDelta vsync_period_;
67 ObserverList<WindowAndroidObserver> observer_list_;
69 DISALLOW_COPY_AND_ASSIGN(WindowAndroid);
72 } // namespace ui
74 #endif // UI_BASE_ANDROID_WINDOW_ANDROID_H_