summaryrefslogtreecommitdiffstats
path: root/content/renderer
diff options
context:
space:
mode:
authortrchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 04:11:29 +0000
committertrchen@chromium.org <trchen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-11 04:11:29 +0000
commit807f55ecb7ece39b25866405125d7e58b4bad9f2 (patch)
treeb87e4511156b3da88943957dc91282eff426e47b /content/renderer
parentc8af3918820921a280bbe9dbaacadeb63d5c65b9 (diff)
downloadchromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.zip
chromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.tar.gz
chromium_src-807f55ecb7ece39b25866405125d7e58b4bad9f2.tar.bz2
Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate
[2/2] Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate They basically do the same thing except that SetNeedsAnimate makes the next commit non-cancellable. However there is really no reason why SetNeedsAnimate need to enforce a commit even if no tiles are updated and no layer properties changed. SetNeedsAnimate is thus merged into SetNeedsUpdateLayers. The proper use of it is when there are potential layout/tile changes, we can use it to defer calculation until the next frame. A commit will be scheduled but can be cancelled if no updates are needed after calculation. This part of the patch changes code behavior slightly. SingleThreadProxy::SetNeedsUpdateLayers was originally implemented as RenderWidget::ScheduleComposite but now it is RenderWidget::ScheduleAnimation. ThreadProxy::SetNeedsAnimate was non-cancellable but is now cancellable. [1/2] Cleanup RenderWidget::scheduleComposite/scheduleAnimation scheduleComposite has been renamed to ScheduleComposite as it is no longer a part of WebWidgetClient API. scheduleAnimation has been renamed to ScheduleAnimation. The semantics is to schedule a composite and also (potentially) animating WebWidget. A new WebWidgetClient API scheduleUpdate has been added, to replace the old scheduleAnimation. The semantics is to notify the embedder that something in the WebWidget may change in 0 seconds. (i.e. it is allowed to be called during a redraw, in such case another redraw will be scheduled after frame delay. This part of the patch should not change code behavior. BUG=316929 R=danakj,jamesr,piman Review URL: https://codereview.chromium.org/68893031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@240008 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/renderer')
-rw-r--r--content/renderer/gpu/render_widget_compositor.cc22
-rw-r--r--content/renderer/gpu/render_widget_compositor.h5
-rw-r--r--content/renderer/render_view_impl.cc2
-rw-r--r--content/renderer/render_widget.cc69
-rw-r--r--content/renderer/render_widget.h6
5 files changed, 64 insertions, 40 deletions
diff --git a/content/renderer/gpu/render_widget_compositor.cc b/content/renderer/gpu/render_widget_compositor.cc
index b4c147f..71cbe11 100644
--- a/content/renderer/gpu/render_widget_compositor.cc
+++ b/content/renderer/gpu/render_widget_compositor.cc
@@ -359,8 +359,8 @@ void RenderWidgetCompositor::SetNeedsRedrawRect(gfx::Rect damage_rect) {
}
void RenderWidgetCompositor::SetNeedsForcedRedraw() {
- layer_tree_host_->SetNextCommitForcesRedraw();
- setNeedsAnimate();
+ layer_tree_host_->set_next_commit_forces_redraw();
+ setNeedsUpdateLayers();
}
scoped_ptr<cc::SwapPromiseMonitor>
@@ -479,12 +479,19 @@ void RenderWidgetCompositor::startPageScaleAnimation(
duration);
}
+// Renamed. Staged for removal.
void RenderWidgetCompositor::setNeedsAnimate() {
- layer_tree_host_->SetNeedsAnimate();
+ setNeedsUpdateLayers();
}
+void RenderWidgetCompositor::setNeedsUpdateLayers() {
+ layer_tree_host_->SetNeedsUpdateLayers();
+}
+
+// Unused. Staged for removal.
bool RenderWidgetCompositor::commitRequested() const {
- return layer_tree_host_->CommitRequested();
+ NOTREACHED();
+ return false;
}
void RenderWidgetCompositor::didStopFlinging() {
@@ -622,11 +629,14 @@ RenderWidgetCompositor::OffscreenContextProvider() {
void RenderWidgetCompositor::ScheduleComposite() {
if (!suppress_schedule_composite_)
- widget_->scheduleComposite();
+ widget_->ScheduleComposite();
}
void RenderWidgetCompositor::ScheduleAnimation() {
- widget_->scheduleAnimation();
+ widget_->ScheduleAnimation();
+ // ScheduleAnimation alone doesn't trigger a redraw.
+ // ScheduleComposite here to send an artifical invalidation.
+ ScheduleComposite();
}
void RenderWidgetCompositor::DidPostSwapBuffers() {
diff --git a/content/renderer/gpu/render_widget_compositor.h b/content/renderer/gpu/render_widget_compositor.h
index 941fe31..2ffc5a4 100644
--- a/content/renderer/gpu/render_widget_compositor.h
+++ b/content/renderer/gpu/render_widget_compositor.h
@@ -98,8 +98,9 @@ class RenderWidgetCompositor : public blink::WebLayerTreeView,
bool use_anchor,
float new_page_scale,
double duration_sec);
- virtual void setNeedsAnimate();
- virtual bool commitRequested() const;
+ virtual void setNeedsAnimate(); // Renamed. Staged for removal.
+ virtual void setNeedsUpdateLayers();
+ virtual bool commitRequested() const; // Unused. Staged for removal.
virtual void didStopFlinging();
virtual bool compositeAndReadback(void *pixels, const blink::WebRect& rect);
virtual void finishAllRendering();
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index 8d18f95..a1f9280 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -6127,7 +6127,7 @@ void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent,
return;
// Remove the content highlighting if any.
- scheduleComposite();
+ ScheduleComposite();
if (!intent.is_empty())
Send(new ViewHostMsg_StartContentIntent(routing_id_, intent));
diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
index b44c0f7..47fa6c9 100644
--- a/content/renderer/render_widget.cc
+++ b/content/renderer/render_widget.cc
@@ -562,6 +562,34 @@ void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
screen_metrics_emulator_->OnShowContextMenu(params);
}
+void RenderWidget::ScheduleAnimation() {
+ if (animation_update_pending_)
+ return;
+
+ TRACE_EVENT0("gpu", "RenderWidget::ScheduleAnimation");
+ animation_update_pending_ = true;
+ if (!animation_timer_.IsRunning()) {
+ animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
+ &RenderWidget::AnimationCallback);
+ }
+}
+
+void RenderWidget::ScheduleComposite() {
+ if (is_accelerated_compositing_active_ &&
+ RenderThreadImpl::current()->compositor_message_loop_proxy().get()) {
+ DCHECK(compositor_);
+ compositor_->setNeedsAnimate();
+ } else {
+ // TODO(nduca): replace with something a little less hacky. The reason this
+ // hack is still used is because the Invalidate-DoDeferredUpdate loop
+ // contains a lot of host-renderer synchronization logic that is still
+ // important for the accelerated compositing case. The option of simply
+ // duplicating all that code is less desirable than "faking out" the
+ // invalidation path using a magical damage rect.
+ didInvalidateRect(WebRect(0, 0, 1, 1));
+ }
+}
+
void RenderWidget::ScheduleCompositeWithForcedRedraw() {
if (compositor_) {
// Regardless of whether threaded compositing is enabled, always
@@ -570,7 +598,7 @@ void RenderWidget::ScheduleCompositeWithForcedRedraw() {
// non-threaded case.
compositor_->SetNeedsForcedRedraw();
}
- scheduleComposite();
+ ScheduleComposite();
}
bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
@@ -805,9 +833,7 @@ void RenderWidget::OnWasShown(bool needs_repainting) {
if (!is_accelerated_compositing_active_) {
didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
} else {
- if (compositor_)
- compositor_->SetNeedsForcedRedraw();
- scheduleComposite();
+ ScheduleCompositeWithForcedRedraw();
}
}
@@ -967,7 +993,7 @@ void RenderWidget::OnSwapBuffersAborted() {
num_swapbuffers_complete_pending_ = 0;
using_asynchronous_swapbuffers_ = false;
// Schedule another frame so the compositor learns about it.
- scheduleComposite();
+ ScheduleComposite();
}
void RenderWidget::OnSwapBuffersPosted() {
@@ -1923,30 +1949,15 @@ void RenderWidget::didCompleteSwapBuffers() {
need_update_rect_for_auto_resize_ = false;
}
-void RenderWidget::scheduleComposite() {
- if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() &&
- compositor_) {
- compositor_->setNeedsAnimate();
- } else {
- // TODO(nduca): replace with something a little less hacky. The reason this
- // hack is still used is because the Invalidate-DoDeferredUpdate loop
- // contains a lot of host-renderer synchronization logic that is still
- // important for the accelerated compositing case. The option of simply
- // duplicating all that code is less desirable than "faking out" the
- // invalidation path using a magical damage rect.
- didInvalidateRect(WebRect(0, 0, 1, 1));
- }
-}
+// Renamed. Staged for removal.
+void RenderWidget::scheduleAnimation() { scheduleUpdate(); }
-void RenderWidget::scheduleAnimation() {
- if (animation_update_pending_)
- return;
-
- TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
- animation_update_pending_ = true;
- if (!animation_timer_.IsRunning()) {
- animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
- &RenderWidget::AnimationCallback);
+void RenderWidget::scheduleUpdate() {
+ if (is_accelerated_compositing_active_) {
+ DCHECK(compositor_);
+ compositor_->setNeedsUpdateLayers();
+ } else {
+ ScheduleAnimation();
}
}
@@ -2352,7 +2363,7 @@ void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
if (!is_accelerated_compositing_active_) {
didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
} else {
- scheduleComposite();
+ ScheduleComposite();
}
}
diff --git a/content/renderer/render_widget.h b/content/renderer/render_widget.h
index 043d3aa..4b521fb 100644
--- a/content/renderer/render_widget.h
+++ b/content/renderer/render_widget.h
@@ -133,8 +133,8 @@ class CONTENT_EXPORT RenderWidget
virtual void didBecomeReadyForAdditionalInput();
virtual void didCommitAndDrawCompositorFrame();
virtual void didCompleteSwapBuffers();
- virtual void scheduleComposite();
- virtual void scheduleAnimation();
+ virtual void scheduleAnimation(); // Renamed. Staged for removal.
+ virtual void scheduleUpdate();
virtual void didFocus();
virtual void didBlur();
virtual void didChangeCursor(const blink::WebCursorInfo&);
@@ -226,6 +226,8 @@ class CONTENT_EXPORT RenderWidget
void DisableScreenMetricsEmulation();
void SetPopupOriginAdjustmentsForEmulation(ScreenMetricsEmulator* emulator);
+ void ScheduleAnimation();
+ void ScheduleComposite();
void ScheduleCompositeWithForcedRedraw();
// Called by the compositor in single-threaded mode when a swap is posted,