From ef081cd578ed801e5b1e56772a25dd9e75fd04d2 Mon Sep 17 00:00:00 2001 From: "sievers@chromium.org" Date: Wed, 17 Apr 2013 21:01:55 +0000 Subject: [PATCH] Consolidate UpdateFrameInfo and SwapCompositorFrame. The 'frame info' comes from the CompositorFrame message, and the fields are useful only if the update implies a Swap (--composite-to-mailbox or ubercomp). (In other words, a scroll offset is not useful if you don't know what frame it is for.) Review URL: https://codereview.chromium.org/14210004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@194669 0039d316-1c4b-4281-b951-d872f2087c98 --- content/browser/android/content_view_core_impl.cc | 12 ------- content/browser/android/content_view_core_impl.h | 7 ---- .../renderer_host/render_widget_host_impl.cc | 13 ------- .../render_widget_host_view_android.cc | 40 +++++++++------------- .../render_widget_host_view_android.h | 8 ----- .../renderer_host/render_widget_host_view_guest.cc | 11 ------ .../renderer_host/render_widget_host_view_guest.h | 8 ----- .../browser/renderer_host/test_render_view_host.h | 8 ----- content/common/view_messages.h | 9 ----- .../port/browser/render_widget_host_view_port.h | 8 ----- .../chromium/content/browser/ContentViewCore.java | 16 +++++---- content/renderer/render_view_impl.cc | 1 - content/renderer/render_view_impl.h | 3 -- 13 files changed, 26 insertions(+), 118 deletions(-) diff --git a/content/browser/android/content_view_core_impl.cc b/content/browser/android/content_view_core_impl.cc index 204145c77364..293b2636d6b5 100644 --- a/content/browser/android/content_view_core_impl.cc +++ b/content/browser/android/content_view_core_impl.cc @@ -158,7 +158,6 @@ ContentViewCoreImpl::ContentViewCoreImpl(JNIEnv* env, jobject obj, root_layer_(cc::Layer::Create()), tab_crashed_(false), input_events_delivered_at_vsync_(input_events_delivered_at_vsync), - renderer_frame_pending_(false), window_android_(window_android) { CHECK(web_contents) << "A ContentViewCoreImpl should be created with a valid WebContents."; @@ -667,10 +666,6 @@ void ContentViewCoreImpl::RemoveLayer(scoped_refptr layer) { layer->RemoveFromParent(); } -void ContentViewCoreImpl::DidProduceRendererFrame() { - renderer_frame_pending_ = true; -} - void ContentViewCoreImpl::LoadUrl( NavigationController::LoadURLParams& params) { GetWebContents()->GetController().LoadURLWithParams(params); @@ -1212,13 +1207,6 @@ jboolean ContentViewCoreImpl::IsShowingInterstitialPage(JNIEnv* env, return web_contents_->ShowingInterstitialPage(); } -jboolean ContentViewCoreImpl::ConsumePendingRendererFrame(JNIEnv* env, - jobject obj) { - bool had_pending_frame = renderer_frame_pending_; - renderer_frame_pending_ = false; - return had_pending_frame; -} - void ContentViewCoreImpl::AttachExternalVideoSurface(JNIEnv* env, jobject obj, jint player_id, diff --git a/content/browser/android/content_view_core_impl.h b/content/browser/android/content_view_core_impl.h index 72a7256e6392..45dddfd49699 100644 --- a/content/browser/android/content_view_core_impl.h +++ b/content/browser/android/content_view_core_impl.h @@ -213,8 +213,6 @@ class ContentViewCoreImpl : public ContentViewCore, jint delegate); jboolean IsShowingInterstitialPage(JNIEnv* env, jobject obj); - jboolean ConsumePendingRendererFrame(JNIEnv* env, jobject obj); - void AttachExternalVideoSurface(JNIEnv* env, jobject obj, jint player_id, @@ -284,7 +282,6 @@ class ContentViewCoreImpl : public ContentViewCore, void AttachLayer(scoped_refptr layer); void RemoveLayer(scoped_refptr layer); - void DidProduceRendererFrame(); private: class ContentViewUserData; @@ -338,10 +335,6 @@ class ContentViewCoreImpl : public ContentViewCore, // Whether input events will be consistently delivered at vsync time. bool input_events_delivered_at_vsync_; - // Whether a new frame from the renderer is waiting to be displayed by the - // browser compositor. - bool renderer_frame_pending_; - // Device scale factor. float dpi_scale_; diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc index 6803a53a4876..1861547b675d 100644 --- a/content/browser/renderer_host/render_widget_host_impl.cc +++ b/content/browser/renderer_host/render_widget_host_impl.cc @@ -1607,19 +1607,6 @@ bool RenderWidgetHostImpl::OnSwapCompositorFrame( param.a.AssignTo(frame.get()); if (view_) { -#if defined(OS_ANDROID) - view_->UpdateFrameInfo( - frame->metadata.root_scroll_offset, - frame->metadata.page_scale_factor, - gfx::Vector2dF( - frame->metadata.min_page_scale_factor, - frame->metadata.max_page_scale_factor), - frame->metadata.root_layer_size, - frame->metadata.viewport_size, - frame->metadata.location_bar_offset, - frame->metadata.location_bar_content_translation, - frame->metadata.overdraw_bottom_height); -#endif view_->OnSwapCompositorFrame(frame.Pass()); } else { cc::CompositorFrameAck ack; diff --git a/content/browser/renderer_host/render_widget_host_view_android.cc b/content/browser/renderer_host/render_widget_host_view_android.cc index 1067355b005a..e247e3b7b9dc 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.cc +++ b/content/browser/renderer_host/render_widget_host_view_android.cc @@ -504,6 +504,22 @@ void RenderWidgetHostViewAndroid::OnAcceleratedCompositingStateChange() { void RenderWidgetHostViewAndroid::OnSwapCompositorFrame( scoped_ptr frame) { + // Always let ContentViewCore know about the new frame first, so it can decide + // to schedule a Draw immediately when it sees the texture layer invalidation. + if (content_view_core_) { + // All offsets and sizes are in CSS pixels. + content_view_core_->UpdateFrameInfo( + frame->metadata.root_scroll_offset, + frame->metadata.page_scale_factor, + gfx::Vector2dF(frame->metadata.min_page_scale_factor, + frame->metadata.max_page_scale_factor), + frame->metadata.root_layer_size, + frame->metadata.viewport_size, + frame->metadata.location_bar_offset, + frame->metadata.location_bar_content_translation, + frame->metadata.overdraw_bottom_height); + } + if (!frame->gl_frame_data || frame->gl_frame_data->mailbox.IsZero()) return; @@ -585,12 +601,6 @@ void RenderWidgetHostViewAndroid::BuffersSwapped( ImageTransportFactoryAndroid::GetInstance()->AcquireTexture( texture_id_in_layer_, mailbox.name); - // We need to tell ContentViewCore about the new frame before calling - // setNeedsDisplay() below so that it has the needed information schedule the - // next compositor frame. - if (content_view_core_) - content_view_core_->DidProduceRendererFrame(); - texture_layer_->SetNeedsDisplay(); texture_layer_->SetBounds(gfx::Size(content_size.width(), content_size.height())); @@ -745,24 +755,6 @@ SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { return cached_background_color_; } -void RenderWidgetHostViewAndroid::UpdateFrameInfo( - const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) { - if (content_view_core_) { - // All offsets and sizes are in CSS pixels. - content_view_core_->UpdateFrameInfo( - scroll_offset, page_scale_factor, page_scale_factor_limits, - content_size, viewport_size, controls_offset, content_offset, - overdraw_bottom_height); - } -} - void RenderWidgetHostViewAndroid::SetContentViewCore( ContentViewCoreImpl* content_view_core) { if (content_view_core_ && is_layer_attached_) diff --git a/content/browser/renderer_host/render_widget_host_view_android.h b/content/browser/renderer_host/render_widget_host_view_android.h index f4a52cde5e1d..44bc78609531 100644 --- a/content/browser/renderer_host/render_widget_host_view_android.h +++ b/content/browser/renderer_host/render_widget_host_view_android.h @@ -144,14 +144,6 @@ class RenderWidgetHostViewAndroid : public RenderWidgetHostViewBase { virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE; virtual void OnSwapCompositorFrame( scoped_ptr frame) OVERRIDE; - virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) OVERRIDE; virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) OVERRIDE; diff --git a/content/browser/renderer_host/render_widget_host_view_guest.cc b/content/browser/renderer_host/render_widget_host_view_guest.cc index 97851154375b..327518f19393 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.cc +++ b/content/browser/renderer_host/render_widget_host_view_guest.cc @@ -415,17 +415,6 @@ void RenderWidgetHostViewGuest::ShowDisambiguationPopup( const SkBitmap& zoomed_bitmap) { } -void RenderWidgetHostViewGuest::UpdateFrameInfo( - const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) { -} - void RenderWidgetHostViewGuest::HasTouchEventHandlers(bool need_touch_events) { } #endif // defined(OS_ANDROID) diff --git a/content/browser/renderer_host/render_widget_host_view_guest.h b/content/browser/renderer_host/render_widget_host_view_guest.h index b9721615148a..e5acc110ac85 100644 --- a/content/browser/renderer_host/render_widget_host_view_guest.h +++ b/content/browser/renderer_host/render_widget_host_view_guest.h @@ -165,14 +165,6 @@ class CONTENT_EXPORT RenderWidgetHostViewGuest // RenderWidgetHostViewPort implementation. virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) OVERRIDE; - virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) OVERRIDE; virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE; #endif // defined(OS_ANDROID) diff --git a/content/browser/renderer_host/test_render_view_host.h b/content/browser/renderer_host/test_render_view_host.h index aecedb6fe351..f28a652d6bd4 100644 --- a/content/browser/renderer_host/test_render_view_host.h +++ b/content/browser/renderer_host/test_render_view_host.h @@ -141,14 +141,6 @@ class TestRenderWidgetHostView : public RenderWidgetHostViewBase { virtual void ShowDisambiguationPopup( const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) OVERRIDE {} - virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) OVERRIDE {} virtual void HasTouchEventHandlers(bool need_touch_events) OVERRIDE {} #elif defined(OS_WIN) && !defined(USE_AURA) virtual void WillWmDestroy() OVERRIDE; diff --git a/content/common/view_messages.h b/content/common/view_messages.h index d83b077dde88..7dc161844909 100644 --- a/content/common/view_messages.h +++ b/content/common/view_messages.h @@ -2341,15 +2341,6 @@ IPC_MESSAGE_ROUTED1(ViewHostMsg_StartContentIntent, IPC_MESSAGE_ROUTED1(ViewHostMsg_DidChangeBodyBackgroundColor, uint32 /* bg_color */) -// Information about current document scroll, scale and size. Sent on a -// best-effort basis. -IPC_MESSAGE_ROUTED5(ViewHostMsg_UpdateFrameInfo, - gfx::Vector2d /* scroll_offset */, - float /* page_scale_factor */, - float /* min_page_scale_factor */, - float /* max_page_scale_factor */, - gfx::Size /* content_size */) - // This message is an ACK that the batch state change has been received by // the renderer and all IME related messages should be processed accordingly. IPC_MESSAGE_ROUTED1(ViewHostMsg_ImeBatchStateChanged_ACK, diff --git a/content/port/browser/render_widget_host_view_port.h b/content/port/browser/render_widget_host_view_port.h index 051a64f27b87..e67f214eaea1 100644 --- a/content/port/browser/render_widget_host_view_port.h +++ b/content/port/browser/render_widget_host_view_port.h @@ -303,14 +303,6 @@ class CONTENT_EXPORT RenderWidgetHostViewPort : public RenderWidgetHostView, #if defined(OS_ANDROID) virtual void ShowDisambiguationPopup(const gfx::Rect& target_rect, const SkBitmap& zoomed_bitmap) = 0; - virtual void UpdateFrameInfo(const gfx::Vector2dF& scroll_offset, - float page_scale_factor, - const gfx::Vector2dF& page_scale_factor_limits, - const gfx::SizeF& content_size, - const gfx::SizeF& viewport_size, - const gfx::Vector2dF& controls_offset, - const gfx::Vector2dF& content_offset, - float overdraw_bottom_height) = 0; virtual void HasTouchEventHandlers(bool need_touch_events) = 0; #endif diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java index 6d44e042af53..cc1296bddd4a 100644 --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java @@ -248,6 +248,9 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { // Whether we use hardware-accelerated drawing. private boolean mHardwareAccelerated = false; + // Whether we received a new frame since consumePendingRendererFrame() was last called. + private boolean mPendingRendererFrame = false; + /** * Constructs a new ContentViewCore. Embedders must call initialize() after constructing * a ContentViewCore and before using it. @@ -796,13 +799,14 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { } /** - * Indicate that the browser compositor has consumed a pending renderer frame. + * Mark any new frames that have arrived since this function was last called as non-pending. * - * @return Whether there was a pending renderer frame. + * @return Whether there was a pending frame from the renderer. */ public boolean consumePendingRendererFrame() { - return mNativeContentViewCore == 0 ? - false : nativeConsumePendingRendererFrame(mNativeContentViewCore); + boolean hadPendingFrame = mPendingRendererFrame; + mPendingRendererFrame = false; + return hadPendingFrame; } /** @@ -2056,6 +2060,8 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { final float overdrawBottomHeightPix = overdrawBottomHeightCss * deviceScale; getContentViewClient().onOffsetsForFullscreenChanged( controlsOffsetPix, contentOffsetYPix, overdrawBottomHeightPix); + + mPendingRendererFrame = true; } @SuppressWarnings("unused") @@ -2670,8 +2676,6 @@ public class ContentViewCore implements MotionEventDelegate, NavigationClient { int nativeContentViewCoreImpl, String url, int nativeInterstitialPageDelegateAndroid); private native boolean nativeIsShowingInterstitialPage(int nativeContentViewCoreImpl); - private native boolean nativeConsumePendingRendererFrame(int nativeContentViewCoreImpl); - private native boolean nativeIsIncognito(int nativeContentViewCoreImpl); // Returns true if the native side crashed so that java side can draw a sad tab. diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 7e0f9cb75d45..7a3133d7144d 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -663,7 +663,6 @@ RenderViewImpl::RenderViewImpl(RenderViewImplParams* params) mouse_lock_dispatcher_(NULL), #if defined(OS_ANDROID) body_background_color_(SK_ColorWHITE), - update_frame_info_scheduled_(false), expected_content_intent_id_(0), media_player_proxy_(NULL), enumeration_completion_id_(0), diff --git a/content/renderer/render_view_impl.h b/content/renderer/render_view_impl.h index cb4e0a08d6fd..fcdfde9d58aa 100644 --- a/content/renderer/render_view_impl.h +++ b/content/renderer/render_view_impl.h @@ -1426,9 +1426,6 @@ class CONTENT_EXPORT RenderViewImpl // have the actual content. SkColor body_background_color_; - // True if SendUpdateFrameInfo is pending. - bool update_frame_info_scheduled_; - // Expected id of the next content intent launched. Used to prevent scheduled // intents to be launched if aborted. size_t expected_content_intent_id_; -- 2.11.4.GIT