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

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

Issue 141833002: Revert 245445 "Unifies LayerTreeHost::SetNeedsUpdateLayers and S..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 11 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/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/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) { 559 ExternalPopupMenu* popup, ScreenMetricsEmulator* emulator) {
560 popup->SetOriginScaleAndOffsetForEmulation( 560 popup->SetOriginScaleAndOffsetForEmulation(
561 emulator->scale(), emulator->offset()); 561 emulator->scale(), emulator->offset());
562 } 562 }
563 563
564 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { 564 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) {
565 if (screen_metrics_emulator_) 565 if (screen_metrics_emulator_)
566 screen_metrics_emulator_->OnShowContextMenu(params); 566 screen_metrics_emulator_->OnShowContextMenu(params);
567 } 567 }
568 568
569 void RenderWidget::ScheduleAnimation() {
570 if (animation_update_pending_)
571 return;
572
573 TRACE_EVENT0("gpu", "RenderWidget::ScheduleAnimation");
574 animation_update_pending_ = true;
575 if (!animation_timer_.IsRunning()) {
576 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
577 &RenderWidget::AnimationCallback);
578 }
579 }
580
581 void RenderWidget::ScheduleComposite() {
582 if (is_accelerated_compositing_active_ &&
583 RenderThreadImpl::current()->compositor_message_loop_proxy().get()) {
584 DCHECK(compositor_);
585 compositor_->setNeedsAnimate();
586 } else {
587 // TODO(nduca): replace with something a little less hacky. The reason this
588 // hack is still used is because the Invalidate-DoDeferredUpdate loop
589 // contains a lot of host-renderer synchronization logic that is still
590 // important for the accelerated compositing case. The option of simply
591 // duplicating all that code is less desirable than "faking out" the
592 // invalidation path using a magical damage rect.
593 didInvalidateRect(WebRect(0, 0, 1, 1));
594 }
595 }
596
597 void RenderWidget::ScheduleCompositeWithForcedRedraw() { 569 void RenderWidget::ScheduleCompositeWithForcedRedraw() {
598 if (compositor_) { 570 if (compositor_) {
599 // Regardless of whether threaded compositing is enabled, always 571 // Regardless of whether threaded compositing is enabled, always
600 // use this mechanism to force the compositor to redraw. However, 572 // use this mechanism to force the compositor to redraw. However,
601 // the invalidation code path below is still needed for the 573 // the invalidation code path below is still needed for the
602 // non-threaded case. 574 // non-threaded case.
603 compositor_->SetNeedsForcedRedraw(); 575 compositor_->SetNeedsForcedRedraw();
604 } 576 }
605 ScheduleComposite(); 577 scheduleComposite();
606 } 578 }
607 579
608 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { 580 bool RenderWidget::OnMessageReceived(const IPC::Message& message) {
609 bool handled = true; 581 bool handled = true;
610 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) 582 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message)
611 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) 583 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent)
612 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, 584 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange,
613 OnCursorVisibilityChange) 585 OnCursorVisibilityChange)
614 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) 586 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost)
615 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) 587 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus)
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 needs_repainting_on_restore_ = false; 804 needs_repainting_on_restore_ = false;
833 805
834 // Tag the next paint as a restore ack, which is picked up by 806 // Tag the next paint as a restore ack, which is picked up by
835 // DoDeferredUpdate when it sends out the next PaintRect message. 807 // DoDeferredUpdate when it sends out the next PaintRect message.
836 set_next_paint_is_restore_ack(); 808 set_next_paint_is_restore_ack();
837 809
838 // Generate a full repaint. 810 // Generate a full repaint.
839 if (!is_accelerated_compositing_active_) { 811 if (!is_accelerated_compositing_active_) {
840 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); 812 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
841 } else { 813 } else {
842 ScheduleCompositeWithForcedRedraw(); 814 if (compositor_)
815 compositor_->SetNeedsForcedRedraw();
816 scheduleComposite();
843 } 817 }
844 } 818 }
845 819
846 void RenderWidget::OnWasSwappedOut() { 820 void RenderWidget::OnWasSwappedOut() {
847 // If we have been swapped out and no one else is using this process, 821 // If we have been swapped out and no one else is using this process,
848 // it's safe to exit now. If we get swapped back in, we will call 822 // it's safe to exit now. If we get swapped back in, we will call
849 // AddRefProcess in SetSwappedOut. 823 // AddRefProcess in SetSwappedOut.
850 if (is_swapped_out_) 824 if (is_swapped_out_)
851 RenderProcess::current()->ReleaseProcess(); 825 RenderProcess::current()->ReleaseProcess();
852 } 826 }
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); 966 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
993 updates_pending_swap_.pop_front(); 967 updates_pending_swap_.pop_front();
994 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate 968 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
995 // compositing pass, hence doesn't require an UpdateRect message. 969 // compositing pass, hence doesn't require an UpdateRect message.
996 if (msg) 970 if (msg)
997 Send(msg); 971 Send(msg);
998 } 972 }
999 num_swapbuffers_complete_pending_ = 0; 973 num_swapbuffers_complete_pending_ = 0;
1000 using_asynchronous_swapbuffers_ = false; 974 using_asynchronous_swapbuffers_ = false;
1001 // Schedule another frame so the compositor learns about it. 975 // Schedule another frame so the compositor learns about it.
1002 ScheduleComposite(); 976 scheduleComposite();
1003 } 977 }
1004 978
1005 void RenderWidget::OnSwapBuffersPosted() { 979 void RenderWidget::OnSwapBuffersPosted() {
1006 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); 980 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted");
1007 981
1008 if (using_asynchronous_swapbuffers_) { 982 if (using_asynchronous_swapbuffers_) {
1009 ViewHostMsg_UpdateRect* msg = NULL; 983 ViewHostMsg_UpdateRect* msg = NULL;
1010 // pending_update_params_ can be NULL if the swap doesn't correspond to an 984 // pending_update_params_ can be NULL if the swap doesn't correspond to an
1011 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect 985 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect
1012 // message. 986 // message.
(...skipping 937 matching lines...) Expand 10 before | Expand all | Expand 10 after
1950 params.flags = next_paint_flags_; 1924 params.flags = next_paint_flags_;
1951 params.scroll_offset = GetScrollOffset(); 1925 params.scroll_offset = GetScrollOffset();
1952 params.needs_ack = false; 1926 params.needs_ack = false;
1953 params.scale_factor = device_scale_factor_; 1927 params.scale_factor = device_scale_factor_;
1954 1928
1955 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); 1929 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1956 next_paint_flags_ = 0; 1930 next_paint_flags_ = 0;
1957 need_update_rect_for_auto_resize_ = false; 1931 need_update_rect_for_auto_resize_ = false;
1958 } 1932 }
1959 1933
1960 // Renamed. Staged for removal. 1934 void RenderWidget::scheduleComposite() {
1961 void RenderWidget::scheduleAnimation() { scheduleUpdate(); } 1935 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() &&
1936 compositor_) {
1937 compositor_->setNeedsAnimate();
1938 } else {
1939 // TODO(nduca): replace with something a little less hacky. The reason this
1940 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1941 // contains a lot of host-renderer synchronization logic that is still
1942 // important for the accelerated compositing case. The option of simply
1943 // duplicating all that code is less desirable than "faking out" the
1944 // invalidation path using a magical damage rect.
1945 didInvalidateRect(WebRect(0, 0, 1, 1));
1946 }
1947 }
1962 1948
1963 void RenderWidget::scheduleUpdate() { 1949 void RenderWidget::scheduleAnimation() {
1964 if (is_accelerated_compositing_active_) { 1950 if (animation_update_pending_)
1965 DCHECK(compositor_); 1951 return;
1966 compositor_->setNeedsUpdateLayers(); 1952
1967 } else { 1953 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
1968 ScheduleAnimation(); 1954 animation_update_pending_ = true;
1955 if (!animation_timer_.IsRunning()) {
1956 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
1957 &RenderWidget::AnimationCallback);
1969 } 1958 }
1970 } 1959 }
1971 1960
1972 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { 1961 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
1973 // TODO(darin): Eliminate this temporary. 1962 // TODO(darin): Eliminate this temporary.
1974 WebCursor cursor; 1963 WebCursor cursor;
1975 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); 1964 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info);
1976 // Only send a SetCursor message if we need to make a change. 1965 // Only send a SetCursor message if we need to make a change.
1977 if (!current_cursor_.IsEqual(cursor)) { 1966 if (!current_cursor_.IsEqual(cursor)) {
1978 current_cursor_ = cursor; 1967 current_cursor_ = cursor;
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 2353
2365 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { 2354 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) {
2366 if (device_scale_factor_ == device_scale_factor) 2355 if (device_scale_factor_ == device_scale_factor)
2367 return; 2356 return;
2368 2357
2369 device_scale_factor_ = device_scale_factor; 2358 device_scale_factor_ = device_scale_factor;
2370 2359
2371 if (!is_accelerated_compositing_active_) { 2360 if (!is_accelerated_compositing_active_) {
2372 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); 2361 didInvalidateRect(gfx::Rect(size_.width(), size_.height()));
2373 } else { 2362 } else {
2374 ScheduleComposite(); 2363 scheduleComposite();
2375 } 2364 }
2376 } 2365 }
2377 2366
2378 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint( 2367 PepperPluginInstanceImpl* RenderWidget::GetBitmapForOptimizedPluginPaint(
2379 const gfx::Rect& paint_bounds, 2368 const gfx::Rect& paint_bounds,
2380 TransportDIB** dib, 2369 TransportDIB** dib,
2381 gfx::Rect* location, 2370 gfx::Rect* location,
2382 gfx::Rect* clip, 2371 gfx::Rect* clip,
2383 float* scale_factor) { 2372 float* scale_factor) {
2384 // Bare RenderWidgets don't support optimized plugin painting. 2373 // Bare RenderWidgets don't support optimized plugin painting.
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after
2884 surface_id(), 2873 surface_id(),
2885 GetURLForGraphicsContext3D(), 2874 GetURLForGraphicsContext3D(),
2886 gpu_channel_host.get(), 2875 gpu_channel_host.get(),
2887 attributes, 2876 attributes,
2888 false /* bind generates resources */, 2877 false /* bind generates resources */,
2889 limits)); 2878 limits));
2890 return context.Pass(); 2879 return context.Pass();
2891 } 2880 }
2892 2881
2893 } // namespace content 2882 } // namespace content
OLDNEW
« no previous file with comments | « trunk/src/content/renderer/render_widget.h ('k') | trunk/src/content/shell/renderer/test_runner/WebTestProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698