| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 needs_repainting_on_restore_ = false; | 319 needs_repainting_on_restore_ = false; |
| 320 | 320 |
| 321 // Tag the next paint as a restore ack, which is picked up by | 321 // Tag the next paint as a restore ack, which is picked up by |
| 322 // DoDeferredUpdate when it sends out the next PaintRect message. | 322 // DoDeferredUpdate when it sends out the next PaintRect message. |
| 323 set_next_paint_is_restore_ack(); | 323 set_next_paint_is_restore_ack(); |
| 324 | 324 |
| 325 // Generate a full repaint. | 325 // Generate a full repaint. |
| 326 if (!is_accelerated_compositing_active_) { | 326 if (!is_accelerated_compositing_active_) { |
| 327 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); | 327 didInvalidateRect(gfx::Rect(size_.width(), size_.height())); |
| 328 } else { | 328 } else { |
| 329 #ifdef WTF_USE_THREADED_COMPOSITING | |
| 330 webwidget_->composite(false); | |
| 331 #else | |
| 332 scheduleComposite(); | 329 scheduleComposite(); |
| 333 #endif | |
| 334 } | 330 } |
| 335 } | 331 } |
| 336 | 332 |
| 337 void RenderWidget::OnWasSwappedOut() { | 333 void RenderWidget::OnWasSwappedOut() { |
| 338 // If we have been swapped out and no one else is using this process, | 334 // If we have been swapped out and no one else is using this process, |
| 339 // it's safe to exit now. If we get swapped back in, we will call | 335 // it's safe to exit now. If we get swapped back in, we will call |
| 340 // AddRefProcess in SetSwappedOut. | 336 // AddRefProcess in SetSwappedOut. |
| 341 if (is_swapped_out_) | 337 if (is_swapped_out_) |
| 342 RenderProcess::current()->ReleaseProcess(); | 338 RenderProcess::current()->ReleaseProcess(); |
| 343 } | 339 } |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 this, &RenderWidget::InvalidationCallback)); | 918 this, &RenderWidget::InvalidationCallback)); |
| 923 } | 919 } |
| 924 | 920 |
| 925 void RenderWidget::didActivateCompositor(int compositorIdentifier) { | 921 void RenderWidget::didActivateCompositor(int compositorIdentifier) { |
| 926 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); | 922 TRACE_EVENT0("gpu", "RenderWidget::didActivateCompositor"); |
| 927 | 923 |
| 928 is_accelerated_compositing_active_ = true; | 924 is_accelerated_compositing_active_ = true; |
| 929 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 925 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 930 routing_id_, is_accelerated_compositing_active_)); | 926 routing_id_, is_accelerated_compositing_active_)); |
| 931 | 927 |
| 932 #ifndef WTF_USE_THREADED_COMPOSITING | 928 // Note: asynchronous swapbuffer support currently only matters if |
| 929 // compositing scheduling happens on the RenderWidget. |
| 933 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); | 930 using_asynchronous_swapbuffers_ = SupportsAsynchronousSwapBuffers(); |
| 934 #endif | |
| 935 } | 931 } |
| 936 | 932 |
| 937 void RenderWidget::didDeactivateCompositor() { | 933 void RenderWidget::didDeactivateCompositor() { |
| 938 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); | 934 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); |
| 939 | 935 |
| 940 is_accelerated_compositing_active_ = false; | 936 is_accelerated_compositing_active_ = false; |
| 941 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( | 937 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( |
| 942 routing_id_, is_accelerated_compositing_active_)); | 938 routing_id_, is_accelerated_compositing_active_)); |
| 943 | 939 |
| 944 #ifndef WTF_USE_THREADED_COMPOSITING | |
| 945 if (using_asynchronous_swapbuffers_) | 940 if (using_asynchronous_swapbuffers_) |
| 946 using_asynchronous_swapbuffers_ = false; | 941 using_asynchronous_swapbuffers_ = false; |
| 947 #endif | |
| 948 } | 942 } |
| 949 | 943 |
| 950 void RenderWidget::scheduleComposite() { | 944 void RenderWidget::scheduleComposite() { |
| 951 #if WTF_USE_THREADED_COMPOSITING | 945 if (WebWidgetHandlesCompositorScheduling()) |
| 952 NOTREACHED(); | 946 webwidget_->composite(false); |
| 953 #else | 947 else { |
| 954 // TODO(nduca): replace with something a little less hacky. The reason this | 948 // TODO(nduca): replace with something a little less hacky. The reason this |
| 955 // hack is still used is because the Invalidate-DoDeferredUpdate loop | 949 // hack is still used is because the Invalidate-DoDeferredUpdate loop |
| 956 // contains a lot of host-renderer synchronization logic that is still | 950 // contains a lot of host-renderer synchronization logic that is still |
| 957 // important for the accelerated compositing case. The option of simply | 951 // important for the accelerated compositing case. The option of simply |
| 958 // duplicating all that code is less desirable than "faking out" the | 952 // duplicating all that code is less desirable than "faking out" the |
| 959 // invalidation path using a magical damage rect. | 953 // invalidation path using a magical damage rect. |
| 960 didInvalidateRect(WebRect(0, 0, 1, 1)); | 954 didInvalidateRect(WebRect(0, 0, 1, 1)); |
| 961 #endif | 955 } |
| 962 } | 956 } |
| 963 | 957 |
| 964 void RenderWidget::scheduleAnimation() { | 958 void RenderWidget::scheduleAnimation() { |
| 965 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); | 959 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation"); |
| 966 if (!animation_update_pending_) { | 960 if (!animation_update_pending_) { |
| 967 animation_update_pending_ = true; | 961 animation_update_pending_ = true; |
| 968 if (!animation_task_posted_) { | 962 if (!animation_task_posted_) { |
| 969 animation_task_posted_ = true; | 963 animation_task_posted_ = true; |
| 970 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( | 964 MessageLoop::current()->PostTask(FROM_HERE, NewRunnableMethod( |
| 971 this, &RenderWidget::AnimationCallback)); | 965 this, &RenderWidget::AnimationCallback)); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1220 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); | 1214 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); |
| 1221 } | 1215 } |
| 1222 | 1216 |
| 1223 void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) { | 1217 void RenderWidget::OnMsgRepaint(const gfx::Size& size_to_paint) { |
| 1224 // During shutdown we can just ignore this message. | 1218 // During shutdown we can just ignore this message. |
| 1225 if (!webwidget_) | 1219 if (!webwidget_) |
| 1226 return; | 1220 return; |
| 1227 | 1221 |
| 1228 set_next_paint_is_repaint_ack(); | 1222 set_next_paint_is_repaint_ack(); |
| 1229 if (is_accelerated_compositing_active_) { | 1223 if (is_accelerated_compositing_active_) { |
| 1230 #ifndef WTF_USE_THREADED_COMPOSITING | |
| 1231 scheduleComposite(); | 1224 scheduleComposite(); |
| 1232 #else | |
| 1233 #ifdef WEBWIDGET_HAS_THREADED_COMPOSITING_CHANGES | |
| 1234 webwidget_->composite(false); | |
| 1235 #endif | |
| 1236 #endif | |
| 1237 } else { | 1225 } else { |
| 1238 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); | 1226 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); |
| 1239 didInvalidateRect(repaint_rect); | 1227 didInvalidateRect(repaint_rect); |
| 1240 } | 1228 } |
| 1241 } | 1229 } |
| 1242 | 1230 |
| 1243 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1231 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
| 1244 if (!webwidget_) | 1232 if (!webwidget_) |
| 1245 return; | 1233 return; |
| 1246 webwidget_->setTextDirection(direction); | 1234 webwidget_->setTextDirection(direction); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1407 if (i->window == window) { | 1395 if (i->window == window) { |
| 1408 plugin_window_moves_.erase(i); | 1396 plugin_window_moves_.erase(i); |
| 1409 break; | 1397 break; |
| 1410 } | 1398 } |
| 1411 } | 1399 } |
| 1412 } | 1400 } |
| 1413 | 1401 |
| 1414 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 1402 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
| 1415 return false; | 1403 return false; |
| 1416 } | 1404 } |
| 1405 |
| 1406 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { |
| 1407 return false; |
| 1408 } |
| OLD | NEW |