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 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 609 } |
610 | 610 |
611 void RenderWidget::OnViewContextSwapBuffersPosted() { | 611 void RenderWidget::OnViewContextSwapBuffersPosted() { |
612 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); | 612 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersPosted"); |
613 | 613 |
614 if (using_asynchronous_swapbuffers_) { | 614 if (using_asynchronous_swapbuffers_) { |
615 ViewHostMsg_UpdateRect* msg = NULL; | 615 ViewHostMsg_UpdateRect* msg = NULL; |
616 // pending_update_params_ can be NULL if the swap doesn't correspond to an | 616 // pending_update_params_ can be NULL if the swap doesn't correspond to an |
617 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect | 617 // DoDeferredUpdate compositing pass, hence doesn't require an UpdateRect |
618 // message. | 618 // message. |
619 if (pending_update_params_.get()) { | 619 if (pending_update_params_) { |
620 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_); | 620 msg = new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_); |
621 pending_update_params_.reset(); | 621 pending_update_params_.reset(); |
622 } | 622 } |
623 updates_pending_swap_.push_back(msg); | 623 updates_pending_swap_.push_back(msg); |
624 num_swapbuffers_complete_pending_++; | 624 num_swapbuffers_complete_pending_++; |
625 } | 625 } |
626 } | 626 } |
627 | 627 |
628 void RenderWidget::OnViewContextSwapBuffersComplete() { | 628 void RenderWidget::OnViewContextSwapBuffersComplete() { |
629 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); | 629 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersComplete"); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
760 compositor_->commitRequested(); | 760 compositor_->commitRequested(); |
761 } | 761 } |
762 | 762 |
763 bool is_input_throttled = | 763 bool is_input_throttled = |
764 throttle_input_events_ && | 764 throttle_input_events_ && |
765 frame_pending; | 765 frame_pending; |
766 | 766 |
767 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) { | 767 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) { |
768 // We want to rate limit the input events in this case, so we'll wait for | 768 // We want to rate limit the input events in this case, so we'll wait for |
769 // painting to finish before ACKing this message. | 769 // painting to finish before ACKing this message. |
770 if (pending_input_event_ack_.get()) { | 770 if (pending_input_event_ack_) { |
771 // As two different kinds of events could cause us to postpone an ack | 771 // As two different kinds of events could cause us to postpone an ack |
772 // we send it now, if we have one pending. The Browser should never | 772 // we send it now, if we have one pending. The Browser should never |
773 // send us the same kind of event we are delaying the ack for. | 773 // send us the same kind of event we are delaying the ack for. |
774 Send(pending_input_event_ack_.release()); | 774 Send(pending_input_event_ack_.release()); |
775 } | 775 } |
776 pending_input_event_ack_.reset(response); | 776 pending_input_event_ack_.reset(response); |
777 } else { | 777 } else { |
778 Send(response); | 778 Send(response); |
779 } | 779 } |
780 | 780 |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 | 1029 |
1030 void RenderWidget::InvalidationCallback() { | 1030 void RenderWidget::InvalidationCallback() { |
1031 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback"); | 1031 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback"); |
1032 invalidation_task_posted_ = false; | 1032 invalidation_task_posted_ = false; |
1033 DoDeferredUpdateAndSendInputAck(); | 1033 DoDeferredUpdateAndSendInputAck(); |
1034 } | 1034 } |
1035 | 1035 |
1036 void RenderWidget::DoDeferredUpdateAndSendInputAck() { | 1036 void RenderWidget::DoDeferredUpdateAndSendInputAck() { |
1037 DoDeferredUpdate(); | 1037 DoDeferredUpdate(); |
1038 | 1038 |
1039 if (pending_input_event_ack_.get()) | 1039 if (pending_input_event_ack_) |
1040 Send(pending_input_event_ack_.release()); | 1040 Send(pending_input_event_ack_.release()); |
1041 } | 1041 } |
1042 | 1042 |
1043 void RenderWidget::DoDeferredUpdate() { | 1043 void RenderWidget::DoDeferredUpdate() { |
1044 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); | 1044 TRACE_EVENT0("renderer", "RenderWidget::DoDeferredUpdate"); |
1045 | 1045 |
1046 if (!webwidget_) | 1046 if (!webwidget_) |
1047 return; | 1047 return; |
1048 | 1048 |
1049 if (!init_complete_) { | 1049 if (!init_complete_) { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1188 bounds.Inset(-1, -1); | 1188 bounds.Inset(-1, -1); |
1189 bounds.Intersect(gfx::Rect(size_)); | 1189 bounds.Intersect(gfx::Rect(size_)); |
1190 } | 1190 } |
1191 | 1191 |
1192 gfx::Rect pixel_bounds = gfx::ToEnclosingRect( | 1192 gfx::Rect pixel_bounds = gfx::ToEnclosingRect( |
1193 gfx::ScaleRect(bounds, device_scale_factor_)); | 1193 gfx::ScaleRect(bounds, device_scale_factor_)); |
1194 | 1194 |
1195 scoped_ptr<skia::PlatformCanvas> canvas( | 1195 scoped_ptr<skia::PlatformCanvas> canvas( |
1196 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, | 1196 RenderProcess::current()->GetDrawingCanvas(¤t_paint_buf_, |
1197 pixel_bounds)); | 1197 pixel_bounds)); |
1198 if (!canvas.get()) { | 1198 if (!canvas) { |
1199 NOTREACHED(); | 1199 NOTREACHED(); |
1200 return; | 1200 return; |
1201 } | 1201 } |
1202 | 1202 |
1203 // We may get back a smaller canvas than we asked for. | 1203 // We may get back a smaller canvas than we asked for. |
1204 // TODO(darin): This seems like it could cause painting problems! | 1204 // TODO(darin): This seems like it could cause painting problems! |
1205 DCHECK_EQ(pixel_bounds.width(), canvas->getDevice()->width()); | 1205 DCHECK_EQ(pixel_bounds.width(), canvas->getDevice()->width()); |
1206 DCHECK_EQ(pixel_bounds.height(), canvas->getDevice()->height()); | 1206 DCHECK_EQ(pixel_bounds.height(), canvas->getDevice()->height()); |
1207 pixel_bounds.set_width(canvas->getDevice()->width()); | 1207 pixel_bounds.set_width(canvas->getDevice()->width()); |
1208 pixel_bounds.set_height(canvas->getDevice()->height()); | 1208 pixel_bounds.set_height(canvas->getDevice()->height()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1244 // If it needs to (e.g. composited UI), the GPU process does its own ACK | 1244 // If it needs to (e.g. composited UI), the GPU process does its own ACK |
1245 // with the browser for the GPU surface. | 1245 // with the browser for the GPU surface. |
1246 pending_update_params_->needs_ack = false; | 1246 pending_update_params_->needs_ack = false; |
1247 Composite(frame_begin_ticks); | 1247 Composite(frame_begin_ticks); |
1248 } | 1248 } |
1249 | 1249 |
1250 // If we're holding a pending input event ACK, send the ACK before sending the | 1250 // If we're holding a pending input event ACK, send the ACK before sending the |
1251 // UpdateReply message so we can receive another input event before the | 1251 // UpdateReply message so we can receive another input event before the |
1252 // UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within | 1252 // UpdateRect_ACK on platforms where the UpdateRect_ACK is sent from within |
1253 // the UpdateRect IPC message handler. | 1253 // the UpdateRect IPC message handler. |
1254 if (pending_input_event_ack_.get()) | 1254 if (pending_input_event_ack_) |
1255 Send(pending_input_event_ack_.release()); | 1255 Send(pending_input_event_ack_.release()); |
1256 | 1256 |
1257 // If Composite() called SwapBuffers, pending_update_params_ will be reset (in | 1257 // If Composite() called SwapBuffers, pending_update_params_ will be reset (in |
1258 // OnSwapBuffersPosted), meaning a message has been added to the | 1258 // OnSwapBuffersPosted), meaning a message has been added to the |
1259 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send | 1259 // updates_pending_swap_ queue, that will be sent later. Otherwise, we send |
1260 // the message now. | 1260 // the message now. |
1261 if (pending_update_params_.get()) { | 1261 if (pending_update_params_) { |
1262 // sending an ack to browser process that the paint is complete... | 1262 // sending an ack to browser process that the paint is complete... |
1263 update_reply_pending_ = pending_update_params_->needs_ack; | 1263 update_reply_pending_ = pending_update_params_->needs_ack; |
1264 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_)); | 1264 Send(new ViewHostMsg_UpdateRect(routing_id_, *pending_update_params_)); |
1265 pending_update_params_.reset(); | 1265 pending_update_params_.reset(); |
1266 } | 1266 } |
1267 | 1267 |
1268 // If we're software rendering then we're done initiating the paint. | 1268 // If we're software rendering then we're done initiating the paint. |
1269 if (!is_accelerated_compositing_active_) | 1269 if (!is_accelerated_compositing_active_) |
1270 DidInitiatePaint(); | 1270 DidInitiatePaint(); |
1271 } | 1271 } |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 // enable GPU acceleration so they need to be called before any painting | 1456 // enable GPU acceleration so they need to be called before any painting |
1457 // is done. | 1457 // is done. |
1458 UpdateTextInputState(DO_NOT_SHOW_IME); | 1458 UpdateTextInputState(DO_NOT_SHOW_IME); |
1459 UpdateSelectionBounds(); | 1459 UpdateSelectionBounds(); |
1460 | 1460 |
1461 WillInitiatePaint(); | 1461 WillInitiatePaint(); |
1462 } | 1462 } |
1463 | 1463 |
1464 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1464 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1465 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1465 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1466 if (pending_input_event_ack_.get()) | 1466 if (pending_input_event_ack_) |
1467 Send(pending_input_event_ack_.release()); | 1467 Send(pending_input_event_ack_.release()); |
1468 } | 1468 } |
1469 | 1469 |
1470 void RenderWidget::DidCommitCompositorFrame() { | 1470 void RenderWidget::DidCommitCompositorFrame() { |
1471 } | 1471 } |
1472 | 1472 |
1473 void RenderWidget::didCommitAndDrawCompositorFrame() { | 1473 void RenderWidget::didCommitAndDrawCompositorFrame() { |
1474 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); | 1474 TRACE_EVENT0("gpu", "RenderWidget::didCommitAndDrawCompositorFrame"); |
1475 // Accelerated FPS tick for performance tests. See throughput_tests.cc. | 1475 // Accelerated FPS tick for performance tests. See throughput_tests.cc. |
1476 // NOTE: Tests may break if this event is renamed or moved. | 1476 // NOTE: Tests may break if this event is renamed or moved. |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1788 static_cast<float>(canvas_size.height()); | 1788 static_cast<float>(canvas_size.height()); |
1789 | 1789 |
1790 gfx::Rect orig_bounds(canvas_size); | 1790 gfx::Rect orig_bounds(canvas_size); |
1791 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale)); | 1791 canvas_size.set_width(static_cast<int>(canvas_size.width() * x_scale)); |
1792 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale)); | 1792 canvas_size.set_height(static_cast<int>(canvas_size.height() * y_scale)); |
1793 gfx::Rect bounds(canvas_size); | 1793 gfx::Rect bounds(canvas_size); |
1794 | 1794 |
1795 scoped_ptr<skia::PlatformCanvas> canvas( | 1795 scoped_ptr<skia::PlatformCanvas> canvas( |
1796 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(), | 1796 paint_at_size_buffer->GetPlatformCanvas(canvas_size.width(), |
1797 canvas_size.height())); | 1797 canvas_size.height())); |
1798 if (!canvas.get()) { | 1798 if (!canvas) { |
1799 NOTREACHED(); | 1799 NOTREACHED(); |
1800 return; | 1800 return; |
1801 } | 1801 } |
1802 | 1802 |
1803 // Reset bounds to what we actually received, but they should be the | 1803 // Reset bounds to what we actually received, but they should be the |
1804 // same. | 1804 // same. |
1805 DCHECK_EQ(bounds.width(), canvas->getDevice()->width()); | 1805 DCHECK_EQ(bounds.width(), canvas->getDevice()->width()); |
1806 DCHECK_EQ(bounds.height(), canvas->getDevice()->height()); | 1806 DCHECK_EQ(bounds.height(), canvas->getDevice()->height()); |
1807 bounds.set_width(canvas->getDevice()->width()); | 1807 bounds.set_width(canvas->getDevice()->width()); |
1808 bounds.set_height(canvas->getDevice()->height()); | 1808 bounds.set_height(canvas->getDevice()->height()); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1846 | 1846 |
1847 gfx::Rect viewport_size = gfx::IntersectRects( | 1847 gfx::Rect viewport_size = gfx::IntersectRects( |
1848 src_subrect, gfx::Rect(physical_backing_size_)); | 1848 src_subrect, gfx::Rect(physical_backing_size_)); |
1849 | 1849 |
1850 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef( | 1850 skia::RefPtr<SkCanvas> canvas = skia::AdoptRef( |
1851 skia::CreatePlatformCanvas(viewport_size.width(), | 1851 skia::CreatePlatformCanvas(viewport_size.width(), |
1852 viewport_size.height(), | 1852 viewport_size.height(), |
1853 true, | 1853 true, |
1854 NULL, | 1854 NULL, |
1855 skia::RETURN_NULL_ON_FAILURE)); | 1855 skia::RETURN_NULL_ON_FAILURE)); |
1856 if (!canvas.get()) | 1856 if (!canvas) |
1857 return false; | 1857 return false; |
1858 | 1858 |
1859 canvas->save(); | 1859 canvas->save(); |
1860 webwidget_->layout(); | 1860 webwidget_->layout(); |
1861 | 1861 |
1862 PaintRect(viewport_size, viewport_size.origin(), canvas.get()); | 1862 PaintRect(viewport_size, viewport_size.origin(), canvas.get()); |
1863 canvas->restore(); | 1863 canvas->restore(); |
1864 | 1864 |
1865 const SkBitmap& bitmap = skia::GetTopDevice(*canvas)->accessBitmap(false); | 1865 const SkBitmap& bitmap = skia::GetTopDevice(*canvas)->accessBitmap(false); |
1866 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)) | 1866 if (!bitmap.copyTo(snapshot, SkBitmap::kARGB_8888_Config)) |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2311 | 2311 |
2312 if (!context->Initialize( | 2312 if (!context->Initialize( |
2313 attributes, | 2313 attributes, |
2314 false /* bind generates resources */, | 2314 false /* bind generates resources */, |
2315 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) | 2315 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE)
) |
2316 return NULL; | 2316 return NULL; |
2317 return context.release(); | 2317 return context.release(); |
2318 } | 2318 } |
2319 | 2319 |
2320 } // namespace content | 2320 } // namespace content |
OLD | NEW |