Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(326)

Side by Side Diff: content/browser/android/content_view_core_impl.cc

Issue 11959036: Implement vsync notification on Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebased. Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 void ContentViewCoreImpl::Show() { 351 void ContentViewCoreImpl::Show() {
352 GetWebContents()->WasShown(); 352 GetWebContents()->WasShown();
353 } 353 }
354 354
355 void ContentViewCoreImpl::Hide() { 355 void ContentViewCoreImpl::Hide() {
356 GetWebContents()->WasHidden(); 356 GetWebContents()->WasHidden();
357 } 357 }
358 358
359 void ContentViewCoreImpl::OnTabCrashed() { 359 void ContentViewCoreImpl::OnTabCrashed() {
360 JNIEnv* env = AttachCurrentThread();
361 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
362 if (obj.is_null())
363 return;
364 Java_ContentViewCore_resetVSyncNotification(env, obj.obj());
365
360 // if tab_crashed_ is already true, just return. e.g. if two tabs share the 366 // if tab_crashed_ is already true, just return. e.g. if two tabs share the
361 // render process, this will be called for each tab when the render process 367 // render process, this will be called for each tab when the render process
362 // crashed. If user reload one tab, a new render process is created. It can be 368 // crashed. If user reload one tab, a new render process is created. It can be
363 // shared by the other tab. But if user closes the tab before reload the other 369 // shared by the other tab. But if user closes the tab before reload the other
364 // tab, the new render process will be shut down. This will trigger the other 370 // tab, the new render process will be shut down. This will trigger the other
365 // tab's OnTabCrashed() called again as two tabs share the same 371 // tab's OnTabCrashed() called again as two tabs share the same
366 // BrowserRenderProcessHost. 372 // BrowserRenderProcessHost.
367 if (tab_crashed_) 373 if (tab_crashed_)
368 return; 374 return;
369 tab_crashed_ = true; 375 tab_crashed_ = true;
370 JNIEnv* env = AttachCurrentThread();
371 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
372 if (obj.is_null())
373 return;
374 Java_ContentViewCore_onTabCrash(env, obj.obj()); 376 Java_ContentViewCore_onTabCrash(env, obj.obj());
375 } 377 }
376 378
377 // All positions and sizes are in CSS pixels. 379 // All positions and sizes are in CSS pixels.
378 // Note that viewport_width/height is a best effort based. 380 // Note that viewport_width/height is a best effort based.
379 // ContentViewCore has the actual information about the physical viewport size. 381 // ContentViewCore has the actual information about the physical viewport size.
380 void ContentViewCoreImpl::UpdateFrameInfo( 382 void ContentViewCoreImpl::UpdateFrameInfo(
381 const gfx::Vector2dF& scroll_offset, 383 const gfx::Vector2dF& scroll_offset,
382 float page_scale_factor, 384 float page_scale_factor,
383 const gfx::Vector2dF& page_scale_factor_limits, 385 const gfx::Vector2dF& page_scale_factor_limits,
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after
692 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) { 694 void ContentViewCoreImpl::RemoveLayer(scoped_refptr<cc::Layer> layer) {
693 layer->RemoveFromParent(); 695 layer->RemoveFromParent();
694 } 696 }
695 697
696 void ContentViewCoreImpl::LoadUrl( 698 void ContentViewCoreImpl::LoadUrl(
697 NavigationController::LoadURLParams& params) { 699 NavigationController::LoadURLParams& params) {
698 GetWebContents()->GetController().LoadURLWithParams(params); 700 GetWebContents()->GetController().LoadURLWithParams(params);
699 tab_crashed_ = false; 701 tab_crashed_ = false;
700 } 702 }
701 703
704 void ContentViewCoreImpl::SetVSyncNotificationEnabled(bool enabled) {
705 JNIEnv* env = AttachCurrentThread();
706 ScopedJavaLocalRef<jobject> obj = java_ref_.get(env);
707 if (obj.is_null())
708 return;
709 Java_ContentViewCore_setVSyncNotificationEnabled(
710 env, obj.obj(), static_cast<jboolean>(enabled));
711 }
712
702 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const { 713 ui::WindowAndroid* ContentViewCoreImpl::GetWindowAndroid() const {
703 // This should never be NULL for Chrome, but will be NULL for WebView. 714 // This should never be NULL for Chrome, but will be NULL for WebView.
704 DCHECK(window_android_); 715 DCHECK(window_android_);
705 return window_android_; 716 return window_android_;
706 } 717 }
707 718
708 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const { 719 scoped_refptr<cc::Layer> ContentViewCoreImpl::GetLayer() const {
709 return root_layer_.get(); 720 return root_layer_.get();
710 } 721 }
711 722
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 return; 1208 return;
1198 1209
1199 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From( 1210 RenderWidgetHostImpl* host = RenderWidgetHostImpl::From(
1200 view->GetRenderWidgetHost()); 1211 view->GetRenderWidgetHost());
1201 1212
1202 host->UpdateVSyncParameters( 1213 host->UpdateVSyncParameters(
1203 base::TimeTicks::FromInternalValue(timebase_micros), 1214 base::TimeTicks::FromInternalValue(timebase_micros),
1204 base::TimeDelta::FromMicroseconds(interval_micros)); 1215 base::TimeDelta::FromMicroseconds(interval_micros));
1205 } 1216 }
1206 1217
1218 void ContentViewCoreImpl::OnVSync(JNIEnv* env, jobject /* obj */,
1219 jlong frame_time_micros) {
1220 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
1221 if (!view)
1222 return;
1223
1224 view->SendVSync(base::TimeTicks::FromInternalValue(frame_time_micros));
1225 }
1226
1207 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env, 1227 jboolean ContentViewCoreImpl::PopulateBitmapFromCompositor(JNIEnv* env,
1208 jobject obj, 1228 jobject obj,
1209 jobject jbitmap) { 1229 jobject jbitmap) {
1210 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid(); 1230 RenderWidgetHostViewAndroid* view = GetRenderWidgetHostViewAndroid();
1211 if (!view) 1231 if (!view)
1212 return false; 1232 return false;
1213 1233
1214 return view->PopulateBitmapWithContents(jbitmap); 1234 return view->PopulateBitmapWithContents(jbitmap);
1215 } 1235 }
1216 1236
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1500 reinterpret_cast<WebContents*>(native_web_contents), 1520 reinterpret_cast<WebContents*>(native_web_contents),
1501 reinterpret_cast<ui::WindowAndroid*>(native_window)); 1521 reinterpret_cast<ui::WindowAndroid*>(native_window));
1502 return reinterpret_cast<jint>(view); 1522 return reinterpret_cast<jint>(view);
1503 } 1523 }
1504 1524
1505 bool RegisterContentViewCore(JNIEnv* env) { 1525 bool RegisterContentViewCore(JNIEnv* env) {
1506 return RegisterNativesImpl(env); 1526 return RegisterNativesImpl(env);
1507 } 1527 }
1508 1528
1509 } // namespace content 1529 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/content_view_core_impl.h ('k') | content/browser/renderer_host/render_widget_host_view_android.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698