| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef UI_BASE_ANDROID_WINDOW_ANDROID_H_ | 5 #ifndef UI_BASE_ANDROID_WINDOW_ANDROID_H_ |
| 6 #define UI_BASE_ANDROID_WINDOW_ANDROID_H_ | 6 #define UI_BASE_ANDROID_WINDOW_ANDROID_H_ |
| 7 | 7 |
| 8 #include <jni.h> | 8 #include <jni.h> |
| 9 #include <vector> | 9 #include <vector> |
| 10 #include "base/android/jni_helper.h" | 10 #include "base/android/jni_helper.h" |
| 11 #include "base/android/scoped_java_ref.h" | 11 #include "base/android/scoped_java_ref.h" |
| 12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 13 #include "base/time/time.h" |
| 13 #include "ui/base/ui_base_export.h" | 14 #include "ui/base/ui_base_export.h" |
| 14 #include "ui/gfx/vector2d_f.h" | 15 #include "ui/gfx/vector2d_f.h" |
| 15 | 16 |
| 16 namespace ui { | 17 namespace ui { |
| 17 | 18 |
| 18 class WindowAndroidCompositor; | 19 class WindowAndroidCompositor; |
| 19 class WindowAndroidObserver; | 20 class WindowAndroidObserver; |
| 20 | 21 |
| 21 // Android implementation of the activity window. | 22 // Android implementation of the activity window. |
| 22 class UI_BASE_EXPORT WindowAndroid { | 23 class UI_BASE_EXPORT WindowAndroid { |
| 23 public: | 24 public: |
| 24 WindowAndroid(JNIEnv* env, jobject obj); | 25 WindowAndroid(JNIEnv* env, jobject obj, jlong vsync_period); |
| 25 | 26 |
| 26 void Destroy(JNIEnv* env, jobject obj); | 27 void Destroy(JNIEnv* env, jobject obj); |
| 27 | 28 |
| 28 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); | 29 base::android::ScopedJavaLocalRef<jobject> GetJavaObject(); |
| 29 | 30 |
| 30 static bool RegisterWindowAndroid(JNIEnv* env); | 31 static bool RegisterWindowAndroid(JNIEnv* env); |
| 31 | 32 |
| 32 // The content offset is used to translate snapshots to the correct part of | 33 // The content offset is used to translate snapshots to the correct part of |
| 33 // the window. | 34 // the window. |
| 34 void set_content_offset(const gfx::Vector2dF& content_offset) { | 35 void set_content_offset(const gfx::Vector2dF& content_offset) { |
| 35 content_offset_ = content_offset; | 36 content_offset_ = content_offset; |
| 36 } | 37 } |
| 37 | 38 |
| 38 bool GrabSnapshot(int content_x, int content_y, int width, int height, | 39 bool GrabSnapshot(int content_x, int content_y, int width, int height, |
| 39 std::vector<unsigned char>* png_representation); | 40 std::vector<unsigned char>* png_representation); |
| 40 | 41 |
| 41 // Compositor callback relay. | 42 // Compositor callback relay. |
| 42 void OnCompositingDidCommit(); | 43 void OnCompositingDidCommit(); |
| 43 | 44 |
| 44 void AttachCompositor(WindowAndroidCompositor* compositor); | 45 void AttachCompositor(WindowAndroidCompositor* compositor); |
| 45 void DetachCompositor(); | 46 void DetachCompositor(); |
| 46 | 47 |
| 47 void AddObserver(WindowAndroidObserver* observer); | 48 void AddObserver(WindowAndroidObserver* observer); |
| 48 void RemoveObserver(WindowAndroidObserver* observer); | 49 void RemoveObserver(WindowAndroidObserver* observer); |
| 49 | 50 |
| 50 WindowAndroidCompositor* GetCompositor() { return compositor_; } | 51 WindowAndroidCompositor* GetCompositor() { return compositor_; } |
| 51 | 52 |
| 53 void RequestVSyncUpdate(); |
| 54 void OnVSync(JNIEnv* env, jobject obj, jlong time_micros); |
| 55 |
| 52 private: | 56 private: |
| 53 ~WindowAndroid(); | 57 ~WindowAndroid(); |
| 54 | 58 |
| 55 JavaObjectWeakGlobalRef weak_java_window_; | 59 JavaObjectWeakGlobalRef weak_java_window_; |
| 56 gfx::Vector2dF content_offset_; | 60 gfx::Vector2dF content_offset_; |
| 57 WindowAndroidCompositor* compositor_; | 61 WindowAndroidCompositor* compositor_; |
| 62 base::TimeDelta vsync_period_; |
| 58 | 63 |
| 59 ObserverList<WindowAndroidObserver> observer_list_; | 64 ObserverList<WindowAndroidObserver> observer_list_; |
| 60 | 65 |
| 61 DISALLOW_COPY_AND_ASSIGN(WindowAndroid); | 66 DISALLOW_COPY_AND_ASSIGN(WindowAndroid); |
| 62 }; | 67 }; |
| 63 | 68 |
| 64 } // namespace ui | 69 } // namespace ui |
| 65 | 70 |
| 66 #endif // UI_BASE_ANDROID_WINDOW_ANDROID_H_ | 71 #endif // UI_BASE_ANDROID_WINDOW_ANDROID_H_ |
| OLD | NEW |