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

Side by Side Diff: content/renderer/render_widget.cc

Issue 68893031: Unifies LayerTreeHost::SetNeedsUpdateLayers and SetNeedsAnimate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix forced redraw breakage Created 7 years 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
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/web_layer_tree_view_impl_for_testing.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { 555 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) {
556 popup->SetOriginScaleAndOffsetForEmulation( 556 popup->SetOriginScaleAndOffsetForEmulation(
557 emulator->scale(), emulator->offset()); 557 emulator->scale(), emulator->offset());
558 } 558 }
559 559
560 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { 560 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
561 if (screen_metrics_emulator_) 561 if (screen_metrics_emulator_)
562 screen_metrics_emulator_->OnShowContextMenu(params); 562 screen_metrics_emulator_->OnShowContextMenu(params);
563 } 563 }
564 564
565 void RenderWidget::ScheduleAnimation() {
566 if (animation_update_pending_)
567 return;
568
569 TRACE_EVENT0("gpu", "RenderWidget::ScheduleAnimation");
570 animation_update_pending_ = true;
571 if (!animation_timer_.IsRunning()) {
572 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
573 &RenderWidget::AnimationCallback);
574 }
575 }
576
577 void RenderWidget::ScheduleComposite() {
578 if (is_accelerated_compositing_active_ &&
579 RenderThreadImpl::current()->compositor_message_loop_proxy().get()) {
580 DCHECK(compositor_);
581 compositor_->setNeedsAnimate();
582 } else {
583 // TODO(nduca): replace with something a little less hacky. The reason this
584 // hack is still used is because the Invalidate-DoDeferredUpdate loop
585 // contains a lot of host-renderer synchronization logic that is still
586 // important for the accelerated compositing case. The option of simply
587 // duplicating all that code is less desirable than "faking out" the
588 // invalidation path using a magical damage rect.
589 didInvalidateRect(WebRect(0, 0, 1, 1));
590 }
591 }
592
565 void RenderWidget::ScheduleCompositeWithForcedRedraw() { 593 void RenderWidget::ScheduleCompositeWithForcedRedraw() {
566 if (compositor_) { 594 if (compositor_) {
567 // Regardless of whether threaded compositing is enabled, always 595 // Regardless of whether threaded compositing is enabled, always
568 // use this mechanism to force the compositor to redraw. However, 596 // use this mechanism to force the compositor to redraw. However,
569 // the invalidation code path below is still needed for the 597 // the invalidation code path below is still needed for the
570 // non-threaded case. 598 // non-threaded case.
571 compositor_->SetNeedsForcedRedraw(); 599 compositor_->SetNeedsForcedRedraw();
572 } 600 }
573 scheduleComposite(); 601 ScheduleComposite();
574 } 602 }
575 603
576 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 604 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
577 bool handled = true; 605 bool handled = true;
578 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 606 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
579 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 607 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
580 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 608 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
581 OnCursorVisibilityChange) 609 OnCursorVisibilityChange)
582 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 610 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
583 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 611 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
798 needs_repainting_on_restore_ = false; 826 needs_repainting_on_restore_ = false;
799 827
800 // Tag the next paint as a restore ack, which is picked up by 828 // Tag the next paint as a restore ack, which is picked up by
801 // DoDeferredUpdate when it sends out the next PaintRect message. 829 // DoDeferredUpdate when it sends out the next PaintRect message.
802 set_next_paint_is_restore_ack(); 830 set_next_paint_is_restore_ack();
803 831
804 // Generate a full repaint. 832 // Generate a full repaint.
805 if (!is_accelerated_compositing_active_) { 833 if (!is_accelerated_compositing_active_) {
806 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); 834 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
807 } else { 835 } else {
808 if (compositor_) 836 ScheduleCompositeWithForcedRedraw();
809 compositor_->SetNeedsForcedRedraw();
810 scheduleComposite();
811 } 837 }
812 } 838 }
813 839
814 void RenderWidget::OnWasSwappedOut() { 840 void RenderWidget::OnWasSwappedOut() {
815 // If we have been swapped out and no one else is using this process, 841 // If we have been swapped out and no one else is using this process,
816 // it's safe to exit now. If we get swapped back in, we will call 842 // it's safe to exit now. If we get swapped back in, we will call
817 // AddRefProcess in SetSwappedOut. 843 // AddRefProcess in SetSwappedOut.
818 if (is_swapped_out_) 844 if (is_swapped_out_)
819 RenderProcess::current()->ReleaseProcess(); 845 RenderProcess::current()->ReleaseProcess();
820 } 846 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
960 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); 986 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
961 updates_pending_swap_.pop_front(); 987 updates_pending_swap_.pop_front();
962 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate 988 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
963 // compositing pass, hence doesn't require an UpdateRect message. 989 // compositing pass, hence doesn't require an UpdateRect message.
964 if (msg) 990 if (msg)
965 Send(msg); 991 Send(msg);
966 } 992 }
967 num_swapbuffers_complete_pending_ = 0; 993 num_swapbuffers_complete_pending_ = 0;
968 using_asynchronous_swapbuffers_ = false; 994 using_asynchronous_swapbuffers_ = false;
969 // Schedule another frame so the compositor learns about it. 995 // Schedule another frame so the compositor learns about it.
970 scheduleComposite(); 996 ScheduleComposite();
971 } 997 }
972 998
973 void RenderWidget::OnSwapBuffersPosted() { 999 void RenderWidget::OnSwapBuffersPosted() {
974 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); 1000 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
975 1001
976 if (using_asynchronous_swapbuffers_) { 1002 if (using_asynchronous_swapbuffers_) {
977 ViewHostMsg_UpdateRect* msg = NULL; 1003 ViewHostMsg_UpdateRect* msg = NULL;
978 // pending_update_params_ can be NULL if the swap doesn't correspond to an 1004 // pending_update_params_ can be NULL if the swap doesn't correspond to an
979 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect 1005 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect
980 // message. 1006 // message.
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 params.flags = next_paint_flags_; 1942 params.flags = next_paint_flags_;
1917 params.scroll_offset = GetScrollOffset(); 1943 params.scroll_offset = GetScrollOffset();
1918 params.needs_ack = false; 1944 params.needs_ack = false;
1919 params.scale_factor = device_scale_factor_; 1945 params.scale_factor = device_scale_factor_;
1920 1946
1921 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); 1947 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1922 next_paint_flags_ = 0; 1948 next_paint_flags_ = 0;
1923 need_update_rect_for_auto_resize_ = false; 1949 need_update_rect_for_auto_resize_ = false;
1924 } 1950 }
1925 1951
1926 void RenderWidget::scheduleComposite() { 1952 // Renamed. Staged for removal.
1927 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && 1953 void RenderWidget::scheduleAnimation() { scheduleUpdate(); }
1928 compositor_) { 1954
1929 compositor_->setNeedsAnimate(); 1955 void RenderWidget::scheduleUpdate() {
1956 if (is_accelerated_compositing_active_) {
1957 DCHECK(compositor_);
1958 compositor_->setNeedsUpdateLayers();
1930 } else { 1959 } else {
1931 // TODO(nduca): replace with something a little less hacky. The reason this 1960 ScheduleAnimation();
1932 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1933 // contains a lot of host-renderer synchronization logic that is still
1934 // important for the accelerated compositing case. The option of simply
1935 // duplicating all that code is less desirable than "faking out" the
1936 // invalidation path using a magical damage rect.
1937 didInvalidateRect(WebRect(0, 0, 1, 1));
1938 } 1961 }
1939 } 1962 }
1940 1963
1941 void RenderWidget::scheduleAnimation() {
1942 if (animation_update_pending_)
1943 return;
1944
1945 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
1946 animation_update_pending_ = true;
1947 if (!animation_timer_.IsRunning()) {
1948 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
1949 &RenderWidget::AnimationCallback);
1950 }
1951 }
1952
1953 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { 1964 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
1954 // TODO(darin): Eliminate this temporary. 1965 // TODO(darin): Eliminate this temporary.
1955 WebCursor cursor; 1966 WebCursor cursor;
1956 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); 1967 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info);
1957 // Only send a SetCursor message if we need to make a change. 1968 // Only send a SetCursor message if we need to make a change.
1958 if (!current_cursor_.IsEqual(cursor)) { 1969 if (!current_cursor_.IsEqual(cursor)) {
1959 current_cursor_ = cursor; 1970 current_cursor_ = cursor;
1960 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); 1971 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1961 } 1972 }
1962 } 1973 }
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
2345 2356
2346 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { 2357 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
2347 if (device_scale_factor_ == device_scale_factor) 2358 if (device_scale_factor_ == device_scale_factor)
2348 return; 2359 return;
2349 2360
2350 device_scale_factor_ = device_scale_factor; 2361 device_scale_factor_ = device_scale_factor;
2351 2362
2352 if (!is_accelerated_compositing_active_) { 2363 if (!is_accelerated_compositing_active_) {
2353 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); 2364 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
2354 } else { 2365 } else {
2355 scheduleComposite(); 2366 ScheduleComposite();
2356 } 2367 }
2357 } 2368 }
2358 2369
2359 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint( 2370 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint(
2360 const gfx::Rect& paint_bounds, 2371 const gfx::Rect& paint_bounds,
2361 TransportDIB** dib, 2372 TransportDIB** dib,
2362 gfx::Rect* location, 2373 gfx::Rect* location,
2363 gfx::Rect* clip, 2374 gfx::Rect* clip,
2364 float* scale_factor) { 2375 float* scale_factor) {
2365 // Bare RenderWidgets don't support optimized plugin painting. 2376 // Bare RenderWidgets don't support optimized plugin painting.
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
2860 surface_id(), 2871 surface_id(),
2861 GetURLForGraphicsContext3D(), 2872 GetURLForGraphicsContext3D(),
2862 gpu_channel_host.get(), 2873 gpu_channel_host.get(),
2863 attributes, 2874 attributes,
2864 false /* bind generates resources */, 2875 false /* bind generates resources */,
2865 limits)); 2876 limits));
2866 return context.Pass(); 2877 return context.Pass();
2867 } 2878 }
2868 2879
2869 } // namespace content 2880 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/test/web_layer_tree_view_impl_for_testing.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698