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/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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 } | 362 } |
363 | 363 |
364 bool RenderWidget::UsingSynchronousRendererCompositor() const { | 364 bool RenderWidget::UsingSynchronousRendererCompositor() const { |
365 #if defined(OS_ANDROID) | 365 #if defined(OS_ANDROID) |
366 return SynchronousCompositorFactory::GetInstance() != NULL; | 366 return SynchronousCompositorFactory::GetInstance() != NULL; |
367 #else | 367 #else |
368 return false; | 368 return false; |
369 #endif | 369 #endif |
370 } | 370 } |
371 | 371 |
| 372 void RenderWidget::ScheduleCompositeWithForcedRedraw() { |
| 373 ScheduleCompositeImpl(true); |
| 374 } |
| 375 |
| 376 void RenderWidget::ScheduleCompositeImpl(bool force_redraw) { |
| 377 if (compositor_ && force_redraw) { |
| 378 // Regardless of whether threaded compositing is enabled, always |
| 379 // use this mechanism to force the compositor to redraw. However, |
| 380 // the invalidation code path below is still needed for the |
| 381 // non-threaded case. |
| 382 compositor_->SetNeedsForcedRedraw(); |
| 383 } |
| 384 |
| 385 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && |
| 386 compositor_) { |
| 387 if (!force_redraw) { |
| 388 compositor_->setNeedsRedraw(); |
| 389 } |
| 390 } else { |
| 391 // TODO(nduca): replace with something a little less hacky. The reason this |
| 392 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
| 393 // contains a lot of host-renderer synchronization logic that is still |
| 394 // important for the accelerated compositing case. The option of simply |
| 395 // duplicating all that code is less desirable than "faking out" the |
| 396 // invalidation path using a magical damage rect. |
| 397 didInvalidateRect(WebRect(0, 0, 1, 1)); |
| 398 } |
| 399 } |
| 400 |
372 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { | 401 bool RenderWidget::OnMessageReceived(const IPC::Message& message) { |
373 bool handled = true; | 402 bool handled = true; |
374 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) | 403 IPC_BEGIN_MESSAGE_MAP(RenderWidget, message) |
375 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) | 404 IPC_MESSAGE_HANDLER(InputMsg_HandleInputEvent, OnHandleInputEvent) |
376 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, | 405 IPC_MESSAGE_HANDLER(InputMsg_CursorVisibilityChange, |
377 OnCursorVisibilityChange) | 406 OnCursorVisibilityChange) |
378 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) | 407 IPC_MESSAGE_HANDLER(InputMsg_MouseCaptureLost, OnMouseCaptureLost) |
379 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) | 408 IPC_MESSAGE_HANDLER(InputMsg_SetFocus, OnSetFocus) |
380 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 409 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
381 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 410 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1652 params.scroll_offset = GetScrollOffset(); | 1681 params.scroll_offset = GetScrollOffset(); |
1653 params.needs_ack = false; | 1682 params.needs_ack = false; |
1654 params.scale_factor = device_scale_factor_; | 1683 params.scale_factor = device_scale_factor_; |
1655 | 1684 |
1656 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); | 1685 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); |
1657 next_paint_flags_ = 0; | 1686 next_paint_flags_ = 0; |
1658 need_update_rect_for_auto_resize_ = false; | 1687 need_update_rect_for_auto_resize_ = false; |
1659 } | 1688 } |
1660 | 1689 |
1661 void RenderWidget::scheduleComposite() { | 1690 void RenderWidget::scheduleComposite() { |
1662 if (RenderThreadImpl::current()->compositor_message_loop_proxy().get() && | 1691 ScheduleCompositeImpl(false); |
1663 compositor_) { | |
1664 compositor_->setNeedsRedraw(); | |
1665 } else { | |
1666 // TODO(nduca): replace with something a little less hacky. The reason this | |
1667 // hack is still used is because the Invalidate-DoDeferredUpdate loop | |
1668 // contains a lot of host-renderer synchronization logic that is still | |
1669 // important for the accelerated compositing case. The option of simply | |
1670 // duplicating all that code is less desirable than "faking out" the | |
1671 // invalidation path using a magical damage rect. | |
1672 didInvalidateRect(WebRect(0, 0, 1, 1)); | |
1673 } | |
1674 } | 1692 } |
1675 | 1693 |
1676 void RenderWidget::scheduleAnimation() { | 1694 void RenderWidget::scheduleAnimation() { |
1677 if (animation_update_pending_) | 1695 if (animation_update_pending_) |
1678 return; | 1696 return; |
1679 | 1697 |
1680 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 1698 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); |
1681 animation_update_pending_ = true; | 1699 animation_update_pending_ = true; |
1682 if (!animation_timer_.IsRunning()) { | 1700 if (!animation_timer_.IsRunning()) { |
1683 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, | 1701 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this, |
(...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 kDefaultCommandBufferSize, | 2593 kDefaultCommandBufferSize, |
2576 kDefaultStartTransferBufferSize, | 2594 kDefaultStartTransferBufferSize, |
2577 kDefaultMinTransferBufferSize, | 2595 kDefaultMinTransferBufferSize, |
2578 kDefaultMaxTransferBufferSize, | 2596 kDefaultMaxTransferBufferSize, |
2579 mapped_memory_reclaim_limit)) | 2597 mapped_memory_reclaim_limit)) |
2580 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); | 2598 return scoped_ptr<WebGraphicsContext3DCommandBufferImpl>(); |
2581 return context.Pass(); | 2599 return context.Pass(); |
2582 } | 2600 } |
2583 | 2601 |
2584 } // namespace content | 2602 } // namespace content |
OLD | NEW |