diff options
author | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 05:32:06 +0000 |
---|---|---|
committer | jamesr@chromium.org <jamesr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-23 05:32:06 +0000 |
commit | 8926c6022c44dd87b0d705e61b80be08d2eff5bf (patch) | |
tree | aaf2013b7cd1a5dd22b96aa9e78eaf0981cac15c | |
parent | 5053d4099a9a91cd5800ddcfb7669413b785006c (diff) | |
download | chromium_src-8926c6022c44dd87b0d705e61b80be08d2eff5bf.zip chromium_src-8926c6022c44dd87b0d705e61b80be08d2eff5bf.tar.gz chromium_src-8926c6022c44dd87b0d705e61b80be08d2eff5bf.tar.bz2 |
Make RenderWidget responsible for the composited view's lifetime
Chromium side of https://bugs.webkit.org/show_bug.cgi?id=105071.
content::RenderWidget constructs a WebLayerTreeView when WebKit
asks it and then retains ownership. This has to be destroyed
before the WebWidget is closed since the WLTVClient is (currently)
a WebKit object.
BUG=156175
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=175303
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=175827
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=176271
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=176707
Review URL: https://codereview.chromium.org/11575049
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178256 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/renderer/render_view_impl.cc | 2 | ||||
-rw-r--r-- | content/renderer/render_widget.cc | 65 | ||||
-rw-r--r-- | content/renderer/render_widget.h | 9 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_layer_tree_view_impl.cc | 5 | ||||
-rw-r--r-- | webkit/compositor_bindings/web_layer_tree_view_impl.h | 2 |
5 files changed, 74 insertions, 9 deletions
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc index 2795458..da817a8 100644 --- a/content/renderer/render_view_impl.cc +++ b/content/renderer/render_view_impl.cc @@ -5753,6 +5753,8 @@ void RenderViewImpl::OnClearFocusedNode() { void RenderViewImpl::OnSetBackground(const SkBitmap& background) { if (webview()) webview()->setIsTransparent(!background.empty()); + if (web_layer_tree_view_) + web_layer_tree_view_->setHasTransparentBackground(!background.empty()); SetBackground(background); } diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc index e8b6d29..5143f434 100644 --- a/content/renderer/render_widget.cc +++ b/content/renderer/render_widget.cc @@ -14,9 +14,13 @@ #include "base/stl_util.h" #include "base/utf_string_conversions.h" #include "build/build_config.h" +#include "cc/layer_tree_host.h" +#include "cc/thread.h" +#include "cc/thread_impl.h" #include "content/common/swapped_out_messages.h" #include "content/common/view_messages.h" #include "content/public/common/content_switches.h" +#include "content/renderer/gpu/compositor_thread.h" #include "content/renderer/render_process.h" #include "content/renderer/render_thread_impl.h" #include "content/renderer/renderer_webkitplatformsupport_impl.h" @@ -246,10 +250,11 @@ void RenderWidget::CompleteInit() { init_complete_ = true; - if (webwidget_) { - webwidget_->setCompositorSurfaceReady(); - if (is_threaded_compositing_enabled_) - webwidget_->enterForceCompositingMode(true); + if (webwidget_ && is_threaded_compositing_enabled_) { + webwidget_->enterForceCompositingMode(true); + } + if (web_layer_tree_view_) { + web_layer_tree_view_->setSurfaceReady(); } DoDeferredUpdate(); @@ -668,10 +673,16 @@ void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, input_event->type == WebInputEvent::MouseMove || input_event->type == WebInputEvent::MouseWheel || WebInputEvent::isTouchEventType(input_event->type); + + bool frame_pending = paint_aggregator_.HasPendingUpdate(); + if (is_accelerated_compositing_active_) { + frame_pending = web_layer_tree_view_ && + web_layer_tree_view_->commitRequested(); + } + bool is_input_throttled = throttle_input_events_ && - ((webwidget_ ? webwidget_->isInputThrottled() : false) || - paint_aggregator_.HasPendingUpdate()); + frame_pending; if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) { // We want to rate limit the input events in this case, so we'll wait for @@ -902,7 +913,12 @@ void RenderWidget::AnimateIfNeeded() { animation_timer_.Start(FROM_HERE, animationInterval, this, &RenderWidget::AnimationCallback); animation_update_pending_ = false; - webwidget_->animate(0.0); + if (is_accelerated_compositing_active_ && web_layer_tree_view_) { + web_layer_tree_view_->layer_tree_host()->updateAnimations( + base::TimeTicks::Now()); + } else { + webwidget_->animate(0.0); + } return; } TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); @@ -1289,6 +1305,33 @@ void RenderWidget::didDeactivateCompositor() { webwidget_->enterForceCompositingMode(false); } +void RenderWidget::initializeLayerTreeView( + WebKit::WebLayerTreeViewClient* client, + const WebKit::WebLayer& root_layer, + const WebKit::WebLayerTreeView::Settings& settings) { + DCHECK(!web_layer_tree_view_); + web_layer_tree_view_.reset(new WebKit::WebLayerTreeViewImpl(client)); + + scoped_ptr<cc::Thread> impl_thread; + CompositorThread* compositor_thread = + RenderThreadImpl::current()->compositor_thread(); + if (compositor_thread) + impl_thread = cc::ThreadImpl::createForDifferentThread( + compositor_thread->message_loop()->message_loop_proxy()); + if (!web_layer_tree_view_->initialize(settings, impl_thread.Pass())) { + web_layer_tree_view_.reset(); + return; + } + web_layer_tree_view_->setRootLayer(root_layer); + if (init_complete_) { + web_layer_tree_view_->setSurfaceReady(); + } +} + +WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { + return web_layer_tree_view_.get(); +} + void RenderWidget::willBeginCompositorFrame() { TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); @@ -1442,6 +1485,8 @@ void RenderWidget::closeWidgetSoon() { void RenderWidget::Close() { if (webwidget_) { + webwidget_->willCloseLayerTreeView(); + web_layer_tree_view_.reset(); webwidget_->close(); webwidget_ = NULL; } @@ -1656,7 +1701,8 @@ void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) { set_next_paint_is_repaint_ack(); if (is_accelerated_compositing_active_) { - webwidget_->setNeedsRedraw(); + if (web_layer_tree_view_) + web_layer_tree_view_->setNeedsRedraw(); scheduleComposite(); } else { gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); @@ -1990,7 +2036,8 @@ void RenderWidget::CleanupWindowInPluginMoves(gfx::PluginWindowHandle window) { void RenderWidget::GetRenderingStats( WebKit::WebRenderingStatsImpl& stats) const { - webwidget()->renderingStats(stats); + if (web_layer_tree_view_) + web_layer_tree_view_->renderingStats(stats); stats.rendering_stats.numAnimationFrames += software_stats_.numAnimationFrames; diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h index ae8067c1..a36300c 100644 --- a/content/renderer/render_widget.h +++ b/content/renderer/render_widget.h @@ -32,6 +32,7 @@ #include "ui/gfx/rect.h" #include "ui/gfx/vector2d.h" #include "ui/surface/transport_dib.h" +#include "webkit/compositor_bindings/web_layer_tree_view_impl.h" #include "webkit/glue/webcursor.h" struct ViewHostMsg_UpdateRect_Params; @@ -121,6 +122,11 @@ class CONTENT_EXPORT RenderWidget virtual void didAutoResize(const WebKit::WebSize& new_size); virtual void didActivateCompositor(int input_handler_identifier); virtual void didDeactivateCompositor(); + virtual void initializeLayerTreeView( + WebKit::WebLayerTreeViewClient* client, + const WebKit::WebLayer& root_layer, + const WebKit::WebLayerTreeView::Settings& settings); + virtual WebKit::WebLayerTreeView* layerTreeView(); virtual void didBecomeReadyForAdditionalInput(); virtual void didCommitAndDrawCompositorFrame(); virtual void didCompleteSwapBuffers(); @@ -450,6 +456,9 @@ class CONTENT_EXPORT RenderWidget // We are responsible for destroying this object via its Close method. WebKit::WebWidget* webwidget_; + // This is lazily constructed and must not outlive webwidget_. + scoped_ptr<WebKit::WebLayerTreeViewImpl> web_layer_tree_view_; + // Set to the ID of the view that initiated creating this view, if any. When // the view was initiated by the browser (the common case), this will be // MSG_ROUTING_NONE. This is used in determining ownership when opening diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.cc b/webkit/compositor_bindings/web_layer_tree_view_impl.cc index ea71f57..856e1ec 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl.cc +++ b/webkit/compositor_bindings/web_layer_tree_view_impl.cc @@ -73,6 +73,11 @@ bool WebLayerTreeViewImpl::initialize(const WebLayerTreeView::Settings& webSetti return true; } +cc::LayerTreeHost* WebLayerTreeViewImpl::layer_tree_host() const +{ + return m_layerTreeHost.get(); +} + void WebLayerTreeViewImpl::setSurfaceReady() { m_layerTreeHost->setSurfaceReady(); diff --git a/webkit/compositor_bindings/web_layer_tree_view_impl.h b/webkit/compositor_bindings/web_layer_tree_view_impl.h index 4817221..c69ccbe 100644 --- a/webkit/compositor_bindings/web_layer_tree_view_impl.h +++ b/webkit/compositor_bindings/web_layer_tree_view_impl.h @@ -30,6 +30,8 @@ public: WEBKIT_COMPOSITOR_BINDINGS_EXPORT bool initialize( const Settings&, scoped_ptr<cc::Thread> implThread); + WEBKIT_COMPOSITOR_BINDINGS_EXPORT cc::LayerTreeHost* layer_tree_host() const; + // WebLayerTreeView implementation. virtual void setSurfaceReady() OVERRIDE; virtual void setRootLayer(const WebLayer&) OVERRIDE; |