| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "content/browser/android/content_view_core_impl.h" | 5 #include "content/browser/android/content_view_core_impl.h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 | 692 |
| 693 void ContentViewCoreImpl::SetVSyncNotificationEnabled(bool enabled) { | 693 void ContentViewCoreImpl::SetVSyncNotificationEnabled(bool enabled) { |
| 694 JNIEnv* env = AttachCurrentThread(); | 694 JNIEnv* env = AttachCurrentThread(); |
| 695 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); | 695 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 696 if (obj.is_null()) | 696 if (obj.is_null()) |
| 697 return; | 697 return; |
| 698 Java_ContentViewCore_setVSyncNotificationEnabled( | 698 Java_ContentViewCore_setVSyncNotificationEnabled( |
| 699 env, obj.obj(), static_cast<jboolean>(enabled)); | 699 env, obj.obj(), static_cast<jboolean>(enabled)); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void ContentViewCoreImpl::SetNeedsAnimate() { |
| 703 JNIEnv* env = AttachCurrentThread(); |
| 704 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env); |
| 705 if (obj.is_null()) |
| 706 return; |
| 707 Java_ContentViewCore_setNeedsAnimate(env, obj.obj()); |
| 708 } |
| 709 |
| 702 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { | 710 ui::ViewAndroid* ContentViewCoreImpl::GetViewAndroid() const { |
| 703 // view_android_ should never be null for Chrome. | 711 // view_android_ should never be null for Chrome. |
| 704 DCHECK(view_android_); | 712 DCHECK(view_android_); |
| 705 return view_android_; | 713 return view_android_; |
| 706 } | 714 } |
| 707 | 715 |
| 708 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { | 716 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { |
| 709 // This should never be NULL for Chrome, but will be NULL for WebView. | 717 // This should never be NULL for Chrome, but will be NULL for WebView. |
| 710 DCHECK(window_android_); | 718 DCHECK(window_android_); |
| 711 return window_android_; | 719 return window_android_; |
| (...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 | 1240 |
| 1233 void ContentViewCoreImpl::OnVSync(JNIEnv* env, jobject /* obj */, | 1241 void ContentViewCoreImpl::OnVSync(JNIEnv* env, jobject /* obj */, |
| 1234 jlong frame_time_micros) { | 1242 jlong frame_time_micros) { |
| 1235 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1243 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1236 if (!view) | 1244 if (!view) |
| 1237 return; | 1245 return; |
| 1238 | 1246 |
| 1239 view->SendVSync(base::TimeTicks::FromInternalValue(frame_time_micros)); | 1247 view->SendVSync(base::TimeTicks::FromInternalValue(frame_time_micros)); |
| 1240 } | 1248 } |
| 1241 | 1249 |
| 1250 jboolean ContentViewCoreImpl::Animate(JNIEnv* env, jobject /* obj */, |
| 1251 jlong frame_time_micros) { |
| 1252 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1253 if (!view) |
| 1254 return false; |
| 1255 |
| 1256 return view->Animate(base::TimeTicks::FromInternalValue(frame_time_micros)); |
| 1257 } |
| 1258 |
| 1242 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, | 1259 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, |
| 1243 jobject obj, | 1260 jobject obj, |
| 1244 jobject jbitmap) { | 1261 jobject jbitmap) { |
| 1245 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); | 1262 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); |
| 1246 if (!view) | 1263 if (!view) |
| 1247 return false; | 1264 return false; |
| 1248 | 1265 |
| 1249 return view->PopulateBitmapWithContents(jbitmap); | 1266 return view->PopulateBitmapWithContents(jbitmap); |
| 1250 } | 1267 } |
| 1251 | 1268 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1545 reinterpret_cast<ui::ViewAndroid*>(view_android), | 1562 reinterpret_cast<ui::ViewAndroid*>(view_android), |
| 1546 reinterpret_cast<ui::WindowAndroid*>(window_android)); | 1563 reinterpret_cast<ui::WindowAndroid*>(window_android)); |
| 1547 return reinterpret_cast<jint>(view); | 1564 return reinterpret_cast<jint>(view); |
| 1548 } | 1565 } |
| 1549 | 1566 |
| 1550 bool RegisterContentViewCore(JNIEnv* env) { | 1567 bool RegisterContentViewCore(JNIEnv* env) { |
| 1551 return RegisterNativesImpl(env); | 1568 return RegisterNativesImpl(env); |
| 1552 } | 1569 } |
| 1553 | 1570 |
| 1554 } // namespace content | 1571 } // namespace content |
| OLD | NEW |