Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/debug/trace_event.h" | 8 #include "base/debug/trace_event.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 | 381 |
| 382 // Continue painting if necessary... | 382 // Continue painting if necessary... |
| 383 DoDeferredUpdateAndSendInputAck(); | 383 DoDeferredUpdateAndSendInputAck(); |
| 384 } | 384 } |
| 385 | 385 |
| 386 bool RenderWidget::SupportsAsynchronousSwapBuffers() | 386 bool RenderWidget::SupportsAsynchronousSwapBuffers() |
| 387 { | 387 { |
| 388 return false; | 388 return false; |
| 389 } | 389 } |
| 390 | 390 |
| 391 void RenderWidget::OnSwapBuffersAborted() | 391 void RenderWidget::OnSwapBuffersAborted() { |
| 392 { | 392 if (WebWidgetHandlesCompositorScheduling()) |
| 393 return; | |
| 394 | |
| 393 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); | 395 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); |
| 394 while (!updates_pending_swap_.empty()) { | 396 while (!updates_pending_swap_.empty()) { |
| 395 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 397 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
| 396 updates_pending_swap_.pop(); | 398 updates_pending_swap_.pop(); |
| 397 if (msg) | 399 if (msg) |
| 398 Send(msg); | 400 Send(msg); |
| 399 } | 401 } |
| 400 num_swapbuffers_complete_pending_ = 0; | 402 num_swapbuffers_complete_pending_ = 0; |
| 401 using_asynchronous_swapbuffers_ = false; | 403 using_asynchronous_swapbuffers_ = false; |
| 402 // Schedule another frame so the compositor learns about it. | 404 // Schedule another frame so the compositor learns about it. |
| 403 scheduleComposite(); | 405 scheduleComposite(); |
| 404 } | 406 } |
| 405 | 407 |
| 406 void RenderWidget::OnSwapBuffersPosted() { | 408 void RenderWidget::OnSwapBuffersPosted() { |
|
nduca
2011/11/11 06:01:08
Can we get rid of this completely? E.g. never use
| |
| 409 if (WebWidgetHandlesCompositorScheduling()) | |
| 410 return; | |
| 411 | |
| 407 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 412 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
| 408 | 413 |
| 409 if (using_asynchronous_swapbuffers_) { | 414 if (using_asynchronous_swapbuffers_) { |
| 410 ViewHostMsg_UpdateRect* msg = NULL; | 415 ViewHostMsg_UpdateRect* msg = NULL; |
| 411 if (pending_update_params_.get()) { | 416 if (pending_update_params_.get()) { |
| 412 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_); | 417 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_); |
| 413 pending_update_params_.reset(); | 418 pending_update_params_.reset(); |
| 414 } | 419 } |
| 415 updates_pending_swap_.push(msg); | 420 updates_pending_swap_.push(msg); |
| 416 num_swapbuffers_complete_pending_++; | 421 num_swapbuffers_complete_pending_++; |
| 417 } | 422 } |
| 418 } | 423 } |
| 419 | 424 |
| 420 void RenderWidget::OnSwapBuffersComplete() { | 425 void RenderWidget::OnSwapBuffersComplete() { |
| 426 if (WebWidgetHandlesCompositorScheduling()) | |
| 427 return; | |
| 428 | |
| 421 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); | 429 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); |
| 422 // When compositing deactivates, we reset the swapbuffers pending count. The | 430 // When compositing deactivates, we reset the swapbuffers pending count. The |
| 423 // swapbuffers acks may still arrive, however. | 431 // swapbuffers acks may still arrive, however. |
| 424 if (num_swapbuffers_complete_pending_ == 0) { | 432 if (num_swapbuffers_complete_pending_ == 0) { |
| 425 TRACE_EVENT0("renderer", "EarlyOut_ZeroSwapbuffersPending"); | 433 TRACE_EVENT0("renderer", "EarlyOut_ZeroSwapbuffersPending"); |
| 426 return; | 434 return; |
| 427 } | 435 } |
| 428 DCHECK(!updates_pending_swap_.empty()); | 436 DCHECK(!updates_pending_swap_.empty()); |
| 429 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | 437 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); |
| 430 updates_pending_swap_.pop(); | 438 updates_pending_swap_.pop(); |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 983 | 991 |
| 984 void RenderWidget::didDeactivateCompositor() { | 992 void RenderWidget::didDeactivateCompositor() { |
| 985 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); | 993 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); |
| 986 | 994 |
| 987 is_accelerated_compositing_active_ = false; | 995 is_accelerated_compositing_active_ = false; |
| 988 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 996 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 989 routing_id_, is_accelerated_compositing_active_)); | 997 routing_id_, is_accelerated_compositing_active_)); |
| 990 | 998 |
| 991 if (using_asynchronous_swapbuffers_) | 999 if (using_asynchronous_swapbuffers_) |
| 992 using_asynchronous_swapbuffers_ = false; | 1000 using_asynchronous_swapbuffers_ = false; |
| 1001 | |
| 1002 // Clear out pending updates. | |
| 1003 while (!updates_pending_swap_.empty()) { | |
| 1004 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | |
| 1005 updates_pending_swap_.pop(); | |
| 1006 if (msg) | |
| 1007 Send(msg); | |
| 1008 } | |
| 1009 } | |
| 1010 | |
| 1011 void RenderWidget::didBeginFrame() | |
| 1012 { | |
| 1013 if (!WebWidgetHandlesCompositorScheduling()) | |
| 1014 return; | |
| 1015 | |
| 1016 ViewHostMsg_UpdateRect* msg = NULL; | |
| 1017 if (next_paint_flags_ || plugin_window_moves_.size()) { | |
| 1018 DCHECK(!pending_update_params_.get()); | |
| 1019 pending_update_params_.reset(new ViewHostMsg_UpdateRect_Params); | |
| 1020 pending_update_params_->view_size = size_; | |
| 1021 pending_update_params_->resizer_rect = resizer_rect_; | |
| 1022 pending_update_params_->plugin_window_moves.swap(plugin_window_moves_); | |
| 1023 pending_update_params_->flags = next_paint_flags_; | |
| 1024 pending_update_params_->scroll_offset = GetScrollOffset(); | |
| 1025 pending_update_params_->flags = next_paint_flags_; | |
| 1026 next_paint_flags_ = 0; | |
| 1027 } | |
| 1028 | |
| 1029 if (pending_update_params_.get()) { | |
| 1030 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_); | |
| 1031 pending_update_params_.reset(); | |
| 1032 } | |
| 1033 updates_pending_swap_.push(msg); | |
| 1034 } | |
| 1035 | |
| 1036 void RenderWidget::didFinishFrame() | |
|
nduca
2011/11/11 06:01:08
One thing that nags me here is that Antoine's patc
| |
| 1037 { | |
| 1038 if (!WebWidgetHandlesCompositorScheduling()) | |
| 1039 return; | |
| 1040 | |
| 1041 if (updates_pending_swap_.empty()) | |
| 1042 return; | |
| 1043 | |
| 1044 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); | |
| 1045 updates_pending_swap_.pop(); | |
| 1046 if (msg) { | |
| 1047 Send(msg); | |
| 1048 } | |
| 993 } | 1049 } |
| 994 | 1050 |
| 995 void RenderWidget::scheduleComposite() { | 1051 void RenderWidget::scheduleComposite() { |
| 996 if (WebWidgetHandlesCompositorScheduling()) | 1052 if (WebWidgetHandlesCompositorScheduling()) |
| 997 webwidget_->composite(false); | 1053 webwidget_->composite(false); |
| 998 else { | 1054 else { |
| 999 // TODO(nduca): replace with something a little less hacky. The reason this | 1055 // TODO(nduca): replace with something a little less hacky. The reason this |
| 1000 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 1056 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
| 1001 // contains a lot of host-renderer synchronization logic that is still | 1057 // contains a lot of host-renderer synchronization logic that is still |
| 1002 // important for the accelerated compositing case. The option of simply | 1058 // important for the accelerated compositing case. The option of simply |
| (...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1499 } | 1555 } |
| 1500 } | 1556 } |
| 1501 | 1557 |
| 1502 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1558 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1503 return false; | 1559 return false; |
| 1504 } | 1560 } |
| 1505 | 1561 |
| 1506 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { | 1562 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1507 return false; | 1563 return false; |
| 1508 } | 1564 } |
| OLD | NEW |