OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/gpu/render_widget_compositor.h" | 5 #include "content/renderer/gpu/render_widget_compositor.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
416 | 416 |
417 compositor->Initialize(settings); | 417 compositor->Initialize(settings); |
418 | 418 |
419 return compositor.Pass(); | 419 return compositor.Pass(); |
420 } | 420 } |
421 | 421 |
422 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 422 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
423 bool threaded) | 423 bool threaded) |
424 : threaded_(threaded), | 424 : threaded_(threaded), |
425 widget_(widget), | 425 widget_(widget), |
426 send_v8_idle_notification_after_commit_(false) { | 426 send_v8_idle_notification_after_commit_(true) { |
427 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 427 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
428 | 428 |
429 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) | 429 if (cmd->HasSwitch(switches::kEnableV8IdleNotificationAfterCommit)) |
430 send_v8_idle_notification_after_commit_ = true; | 430 send_v8_idle_notification_after_commit_ = true; |
431 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit)) | 431 if (cmd->HasSwitch(switches::kDisableV8IdleNotificationAfterCommit)) |
432 send_v8_idle_notification_after_commit_ = false; | 432 send_v8_idle_notification_after_commit_ = false; |
433 } | 433 } |
434 | 434 |
435 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 435 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
436 | 436 |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 | 810 |
811 void RenderWidgetCompositor::DidCommit() { | 811 void RenderWidgetCompositor::DidCommit() { |
812 if (send_v8_idle_notification_after_commit_) { | 812 if (send_v8_idle_notification_after_commit_) { |
813 base::TimeDelta idle_time = begin_main_frame_time_ + | 813 base::TimeDelta idle_time = begin_main_frame_time_ + |
814 begin_main_frame_interval_ - | 814 begin_main_frame_interval_ - |
815 gfx::FrameTime::Now(); | 815 gfx::FrameTime::Now(); |
816 if (idle_time > base::TimeDelta()) { | 816 if (idle_time > base::TimeDelta()) { |
817 // Convert to 32-bit microseconds first to avoid costly 64-bit division. | 817 // Convert to 32-bit microseconds first to avoid costly 64-bit division. |
818 int32 idle_time_in_us = idle_time.InMicroseconds(); | 818 int32 idle_time_in_us = idle_time.InMicroseconds(); |
819 int32 idle_time_in_ms = idle_time_in_us / 1000; | 819 int32 idle_time_in_ms = idle_time_in_us / 1000; |
820 blink::mainThreadIsolate()->IdleNotification(idle_time_in_ms); | 820 if (idle_time_in_ms) |
| 821 blink::mainThreadIsolate()->IdleNotification(idle_time_in_ms); |
821 } | 822 } |
822 } | 823 } |
823 | 824 |
824 widget_->DidCommitCompositorFrame(); | 825 widget_->DidCommitCompositorFrame(); |
825 widget_->didBecomeReadyForAdditionalInput(); | 826 widget_->didBecomeReadyForAdditionalInput(); |
826 widget_->webwidget()->didCommitFrameToCompositor(); | 827 widget_->webwidget()->didCommitFrameToCompositor(); |
827 } | 828 } |
828 | 829 |
829 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 830 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
830 widget_->didCommitAndDrawCompositorFrame(); | 831 widget_->didCommitAndDrawCompositorFrame(); |
(...skipping 17 matching lines...) Expand all Loading... |
848 widget_->OnSwapBuffersAborted(); | 849 widget_->OnSwapBuffersAborted(); |
849 } | 850 } |
850 | 851 |
851 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 852 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
852 cc::ContextProvider* provider = | 853 cc::ContextProvider* provider = |
853 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 854 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
854 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 855 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
855 } | 856 } |
856 | 857 |
857 } // namespace content | 858 } // namespace content |
OLD | NEW |