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

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

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

Powered by Google App Engine
This is Rietveld 408576698