| OLD | NEW |
| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 popup->SetOriginScaleAndOffsetForEmulation( | 692 popup->SetOriginScaleAndOffsetForEmulation( |
| 693 emulator->scale(), emulator->offset()); | 693 emulator->scale(), emulator->offset()); |
| 694 } | 694 } |
| 695 #endif | 695 #endif |
| 696 | 696 |
| 697 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { | 697 void RenderWidget::OnShowHostContextMenu(ContextMenuParams* params) { |
| 698 if (screen_metrics_emulator_) | 698 if (screen_metrics_emulator_) |
| 699 screen_metrics_emulator_->OnShowContextMenu(params); | 699 screen_metrics_emulator_->OnShowContextMenu(params); |
| 700 } | 700 } |
| 701 | 701 |
| 702 void RenderWidget::ScheduleCompositeWithForcedRedraw() { | |
| 703 if (compositor_) { | |
| 704 // Regardless of whether threaded compositing is enabled, always | |
| 705 // use this mechanism to force the compositor to redraw. However, | |
| 706 // the invalidation code path below is still needed for the | |
| 707 // non-threaded case. | |
| 708 compositor_->SetNeedsForcedRedraw(); | |
| 709 } | |
| 710 scheduleComposite(); | |
| 711 } | |
| 712 | |
| 713 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { | 702 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
| 714 bool handled = true; | 703 bool handled = true; |
| 715 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 704 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
| 716 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 705 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
| 717 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 706 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
| 718 OnCursorVisibilityChange) | 707 OnCursorVisibilityChange) |
| 719 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) | 708 IPC_MESSAGE_HANDLER(InputMsg_ImeSetComposition, OnImeSetComposition) |
| 720 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) | 709 IPC_MESSAGE_HANDLER(InputMsg_ImeConfirmComposition, OnImeConfirmComposition) |
| 721 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 710 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
| 722 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 711 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 961 if (!needs_repainting) | 950 if (!needs_repainting) |
| 962 return; | 951 return; |
| 963 | 952 |
| 964 // Generate a full repaint. | 953 // Generate a full repaint. |
| 965 if (compositor_) { | 954 if (compositor_) { |
| 966 ui::LatencyInfo swap_latency_info(latency_info); | 955 ui::LatencyInfo swap_latency_info(latency_info); |
| 967 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( | 956 scoped_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( |
| 968 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); | 957 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); |
| 969 compositor_->SetNeedsForcedRedraw(); | 958 compositor_->SetNeedsForcedRedraw(); |
| 970 } | 959 } |
| 971 scheduleComposite(); | 960 ScheduleComposite(); |
| 972 } | 961 } |
| 973 | 962 |
| 974 void RenderWidget::OnRequestMoveAck() { | 963 void RenderWidget::OnRequestMoveAck() { |
| 975 DCHECK(pending_window_rect_count_); | 964 DCHECK(pending_window_rect_count_); |
| 976 pending_window_rect_count_--; | 965 pending_window_rect_count_--; |
| 977 } | 966 } |
| 978 | 967 |
| 979 GURL RenderWidget::GetURLForGraphicsContext3D() { | 968 GURL RenderWidget::GetURLForGraphicsContext3D() { |
| 980 return GURL(); | 969 return GURL(); |
| 981 } | 970 } |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1049 bool use_swap_compositor_frame_message = false; | 1038 bool use_swap_compositor_frame_message = false; |
| 1050 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 1039 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
| 1051 routing_id(), output_surface_id, context_provider, | 1040 routing_id(), output_surface_id, context_provider, |
| 1052 worker_context_provider, scoped_ptr<cc::SoftwareOutputDevice>(), | 1041 worker_context_provider, scoped_ptr<cc::SoftwareOutputDevice>(), |
| 1053 frame_swap_message_queue_, use_swap_compositor_frame_message)); | 1042 frame_swap_message_queue_, use_swap_compositor_frame_message)); |
| 1054 } | 1043 } |
| 1055 | 1044 |
| 1056 void RenderWidget::OnSwapBuffersAborted() { | 1045 void RenderWidget::OnSwapBuffersAborted() { |
| 1057 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 1046 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
| 1058 // Schedule another frame so the compositor learns about it. | 1047 // Schedule another frame so the compositor learns about it. |
| 1059 scheduleComposite(); | 1048 ScheduleComposite(); |
| 1060 } | 1049 } |
| 1061 | 1050 |
| 1062 void RenderWidget::OnSwapBuffersPosted() { | 1051 void RenderWidget::OnSwapBuffersPosted() { |
| 1063 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 1052 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
| 1064 } | 1053 } |
| 1065 | 1054 |
| 1066 void RenderWidget::OnSwapBuffersComplete() { | 1055 void RenderWidget::OnSwapBuffersComplete() { |
| 1067 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); | 1056 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); |
| 1068 | 1057 |
| 1069 // Notify subclasses that composited rendering was flushed to the screen. | 1058 // Notify subclasses that composited rendering was flushed to the screen. |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1379 // Always send this notification to prevent new layer tree views from | 1368 // Always send this notification to prevent new layer tree views from |
| 1380 // being created, even if one hasn't been created yet. | 1369 // being created, even if one hasn't been created yet. |
| 1381 if (webwidget_) | 1370 if (webwidget_) |
| 1382 webwidget_->willCloseLayerTreeView(); | 1371 webwidget_->willCloseLayerTreeView(); |
| 1383 } | 1372 } |
| 1384 | 1373 |
| 1385 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1374 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1386 return compositor_.get(); | 1375 return compositor_.get(); |
| 1387 } | 1376 } |
| 1388 | 1377 |
| 1389 void RenderWidget::willBeginCompositorFrame() { | 1378 void RenderWidget::WillBeginCompositorFrame() { |
| 1390 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1379 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
| 1391 | 1380 |
| 1392 // The following two can result in further layout and possibly | 1381 // The following two can result in further layout and possibly |
| 1393 // enable GPU acceleration so they need to be called before any painting | 1382 // enable GPU acceleration so they need to be called before any painting |
| 1394 // is done. | 1383 // is done. |
| 1395 UpdateTextInputType(); | 1384 UpdateTextInputType(); |
| 1396 #if defined(OS_ANDROID) | 1385 #if defined(OS_ANDROID) |
| 1397 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1386 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
| 1398 #endif | 1387 #endif |
| 1399 UpdateSelectionBounds(); | 1388 UpdateSelectionBounds(); |
| 1400 } | 1389 } |
| 1401 | 1390 |
| 1402 void RenderWidget::didBecomeReadyForAdditionalInput() { | |
| 1403 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | |
| 1404 FlushPendingInputEventAck(); | |
| 1405 } | |
| 1406 | |
| 1407 void RenderWidget::DidCommitCompositorFrame() { | 1391 void RenderWidget::DidCommitCompositorFrame() { |
| 1408 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 1392 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 1409 DidCommitCompositorFrame()); | 1393 DidCommitCompositorFrame()); |
| 1410 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, | 1394 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, |
| 1411 DidCommitCompositorFrame()); | 1395 DidCommitCompositorFrame()); |
| 1412 #if defined(VIDEO_HOLE) | 1396 #if defined(VIDEO_HOLE) |
| 1413 FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_, | 1397 FOR_EACH_OBSERVER(RenderFrameImpl, video_hole_frames_, |
| 1414 DidCommitCompositorFrame()); | 1398 DidCommitCompositorFrame()); |
| 1415 #endif // defined(VIDEO_HOLE) | 1399 #endif // defined(VIDEO_HOLE) |
| 1400 FlushPendingInputEventAck(); |
| 1401 } |
| 1402 |
| 1403 void RenderWidget::DidCommitAndDrawCompositorFrame() { |
| 1404 // NOTE: Tests may break if this event is renamed or moved. See |
| 1405 // tab_capture_performancetest.cc. |
| 1406 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); |
| 1407 // Notify subclasses that we initiated the paint operation. |
| 1408 DidInitiatePaint(); |
| 1409 } |
| 1410 |
| 1411 void RenderWidget::DidCompleteSwapBuffers() { |
| 1412 TRACE_EVENT0("renderer", "RenderWidget::DidCompleteSwapBuffers"); |
| 1413 |
| 1414 // Notify subclasses threaded composited rendering was flushed to the screen. |
| 1415 DidFlushPaint(); |
| 1416 |
| 1417 if (!next_paint_flags_ && |
| 1418 !need_update_rect_for_auto_resize_ && |
| 1419 !plugin_window_moves_.size()) { |
| 1420 return; |
| 1421 } |
| 1422 |
| 1423 ViewHostMsg_UpdateRect_Params params; |
| 1424 params.view_size = size_; |
| 1425 params.plugin_window_moves.swap(plugin_window_moves_); |
| 1426 params.flags = next_paint_flags_; |
| 1427 |
| 1428 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
| 1429 next_paint_flags_ = 0; |
| 1430 need_update_rect_for_auto_resize_ = false; |
| 1431 } |
| 1432 |
| 1433 void RenderWidget::ScheduleComposite() { |
| 1434 if (compositor_ && |
| 1435 compositor_deps_->GetCompositorImplThreadTaskRunner().get()) { |
| 1436 compositor_->setNeedsAnimate(); |
| 1437 } |
| 1438 } |
| 1439 |
| 1440 void RenderWidget::ScheduleCompositeWithForcedRedraw() { |
| 1441 if (compositor_) { |
| 1442 // Regardless of whether threaded compositing is enabled, always |
| 1443 // use this mechanism to force the compositor to redraw. However, |
| 1444 // the invalidation code path below is still needed for the |
| 1445 // non-threaded case. |
| 1446 compositor_->SetNeedsForcedRedraw(); |
| 1447 } |
| 1448 ScheduleComposite(); |
| 1416 } | 1449 } |
| 1417 | 1450 |
| 1418 // static | 1451 // static |
| 1419 scoped_ptr<cc::SwapPromise> RenderWidget::QueueMessageImpl( | 1452 scoped_ptr<cc::SwapPromise> RenderWidget::QueueMessageImpl( |
| 1420 IPC::Message* msg, | 1453 IPC::Message* msg, |
| 1421 MessageDeliveryPolicy policy, | 1454 MessageDeliveryPolicy policy, |
| 1422 FrameSwapMessageQueue* frame_swap_message_queue, | 1455 FrameSwapMessageQueue* frame_swap_message_queue, |
| 1423 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, | 1456 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter, |
| 1424 int source_frame_number) { | 1457 int source_frame_number) { |
| 1425 bool first_message_for_frame = false; | 1458 bool first_message_for_frame = false; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1455 // Request a commit. This might either A) request a commit ahead of time | 1488 // Request a commit. This might either A) request a commit ahead of time |
| 1456 // or B) request a commit which is not needed because there are not | 1489 // or B) request a commit which is not needed because there are not |
| 1457 // pending updates. If B) then the commit will be skipped and the swap | 1490 // pending updates. If B) then the commit will be skipped and the swap |
| 1458 // promises will be broken (see EarlyOut_NoUpdates). To achieve that we | 1491 // promises will be broken (see EarlyOut_NoUpdates). To achieve that we |
| 1459 // call SetNeedsUpdateLayers instead of SetNeedsCommit so that | 1492 // call SetNeedsUpdateLayers instead of SetNeedsCommit so that |
| 1460 // can_cancel_commit is not unset. | 1493 // can_cancel_commit is not unset. |
| 1461 compositor_->SetNeedsUpdateLayers(); | 1494 compositor_->SetNeedsUpdateLayers(); |
| 1462 } | 1495 } |
| 1463 } | 1496 } |
| 1464 | 1497 |
| 1465 void RenderWidget::didCommitAndDrawCompositorFrame() { | |
| 1466 // NOTE: Tests may break if this event is renamed or moved. See | |
| 1467 // tab_capture_performancetest.cc. | |
| 1468 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); | |
| 1469 // Notify subclasses that we initiated the paint operation. | |
| 1470 DidInitiatePaint(); | |
| 1471 } | |
| 1472 | |
| 1473 void RenderWidget::didCompleteSwapBuffers() { | |
| 1474 TRACE_EVENT0("renderer", "RenderWidget::didCompleteSwapBuffers"); | |
| 1475 | |
| 1476 // Notify subclasses threaded composited rendering was flushed to the screen. | |
| 1477 DidFlushPaint(); | |
| 1478 | |
| 1479 if (!next_paint_flags_ && | |
| 1480 !need_update_rect_for_auto_resize_ && | |
| 1481 !plugin_window_moves_.size()) { | |
| 1482 return; | |
| 1483 } | |
| 1484 | |
| 1485 ViewHostMsg_UpdateRect_Params params; | |
| 1486 params.view_size = size_; | |
| 1487 params.plugin_window_moves.swap(plugin_window_moves_); | |
| 1488 params.flags = next_paint_flags_; | |
| 1489 | |
| 1490 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | |
| 1491 next_paint_flags_ = 0; | |
| 1492 need_update_rect_for_auto_resize_ = false; | |
| 1493 } | |
| 1494 | |
| 1495 void RenderWidget::scheduleComposite() { | |
| 1496 if (compositor_ && | |
| 1497 compositor_deps_->GetCompositorImplThreadTaskRunner().get()) { | |
| 1498 compositor_->setNeedsAnimate(); | |
| 1499 } | |
| 1500 } | |
| 1501 | |
| 1502 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { | 1498 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { |
| 1503 // TODO(darin): Eliminate this temporary. | 1499 // TODO(darin): Eliminate this temporary. |
| 1504 WebCursor cursor; | 1500 WebCursor cursor; |
| 1505 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); | 1501 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); |
| 1506 // Only send a SetCursor message if we need to make a change. | 1502 // Only send a SetCursor message if we need to make a change. |
| 1507 if (!current_cursor_.IsEqual(cursor)) { | 1503 if (!current_cursor_.IsEqual(cursor)) { |
| 1508 current_cursor_ = cursor; | 1504 current_cursor_ = cursor; |
| 1509 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); | 1505 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); |
| 1510 } | 1506 } |
| 1511 } | 1507 } |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1786 | 1782 |
| 1787 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() { | 1783 void RenderWidget::IgnoreAckForMouseMoveFromDebugger() { |
| 1788 ignore_ack_for_mouse_move_from_debugger_ = true; | 1784 ignore_ack_for_mouse_move_from_debugger_ = true; |
| 1789 } | 1785 } |
| 1790 | 1786 |
| 1791 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { | 1787 void RenderWidget::SetDeviceScaleFactor(float device_scale_factor) { |
| 1792 if (device_scale_factor_ == device_scale_factor) | 1788 if (device_scale_factor_ == device_scale_factor) |
| 1793 return; | 1789 return; |
| 1794 | 1790 |
| 1795 device_scale_factor_ = device_scale_factor; | 1791 device_scale_factor_ = device_scale_factor; |
| 1796 scheduleComposite(); | 1792 ScheduleComposite(); |
| 1797 } | 1793 } |
| 1798 | 1794 |
| 1799 bool RenderWidget::SetDeviceColorProfile( | 1795 bool RenderWidget::SetDeviceColorProfile( |
| 1800 const std::vector<char>& color_profile) { | 1796 const std::vector<char>& color_profile) { |
| 1801 if (device_color_profile_ == color_profile) | 1797 if (device_color_profile_ == color_profile) |
| 1802 return false; | 1798 return false; |
| 1803 | 1799 |
| 1804 device_color_profile_ = color_profile; | 1800 device_color_profile_ = color_profile; |
| 1805 return true; | 1801 return true; |
| 1806 } | 1802 } |
| (...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2456 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2452 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2457 video_hole_frames_.AddObserver(frame); | 2453 video_hole_frames_.AddObserver(frame); |
| 2458 } | 2454 } |
| 2459 | 2455 |
| 2460 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2456 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2461 video_hole_frames_.RemoveObserver(frame); | 2457 video_hole_frames_.RemoveObserver(frame); |
| 2462 } | 2458 } |
| 2463 #endif // defined(VIDEO_HOLE) | 2459 #endif // defined(VIDEO_HOLE) |
| 2464 | 2460 |
| 2465 } // namespace content | 2461 } // namespace content |
| OLD | NEW |