Chromium Code Reviews| 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 20 matching lines...) Expand all Loading... | |
| 31 #include "content/child/child_shared_bitmap_manager.h" | 31 #include "content/child/child_shared_bitmap_manager.h" |
| 32 #include "content/common/content_switches_internal.h" | 32 #include "content/common/content_switches_internal.h" |
| 33 #include "content/common/gpu/client/context_provider_command_buffer.h" | 33 #include "content/common/gpu/client/context_provider_command_buffer.h" |
| 34 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
| 35 #include "content/renderer/input/input_handler_manager.h" | 35 #include "content/renderer/input/input_handler_manager.h" |
| 36 #include "content/renderer/render_thread_impl.h" | 36 #include "content/renderer/render_thread_impl.h" |
| 37 #include "gpu/command_buffer/client/gles2_interface.h" | 37 #include "gpu/command_buffer/client/gles2_interface.h" |
| 38 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" | 38 #include "third_party/WebKit/public/platform/WebCompositeAndReadbackAsyncCallbac k.h" |
| 39 #include "third_party/WebKit/public/platform/WebSelectionBound.h" | 39 #include "third_party/WebKit/public/platform/WebSelectionBound.h" |
| 40 #include "third_party/WebKit/public/platform/WebSize.h" | 40 #include "third_party/WebKit/public/platform/WebSize.h" |
| 41 #include "third_party/WebKit/public/web/WebKit.h" | |
| 41 #include "third_party/WebKit/public/web/WebWidget.h" | 42 #include "third_party/WebKit/public/web/WebWidget.h" |
| 42 #include "ui/gfx/frame_time.h" | 43 #include "ui/gfx/frame_time.h" |
| 43 #include "ui/gl/gl_switches.h" | 44 #include "ui/gl/gl_switches.h" |
| 44 #include "ui/native_theme/native_theme_switches.h" | 45 #include "ui/native_theme/native_theme_switches.h" |
| 45 | 46 |
| 46 #if defined(OS_ANDROID) | 47 #if defined(OS_ANDROID) |
| 47 #include "content/renderer/android/synchronous_compositor_factory.h" | 48 #include "content/renderer/android/synchronous_compositor_factory.h" |
| 48 #include "ui/gfx/android/device_display_info.h" | 49 #include "ui/gfx/android/device_display_info.h" |
| 49 #endif | 50 #endif |
| 50 | 51 |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 | 157 |
| 157 // static | 158 // static |
| 158 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( | 159 scoped_ptr<RenderWidgetCompositor> RenderWidgetCompositor::Create( |
| 159 RenderWidget* widget, | 160 RenderWidget* widget, |
| 160 bool threaded) { | 161 bool threaded) { |
| 161 scoped_ptr<RenderWidgetCompositor> compositor( | 162 scoped_ptr<RenderWidgetCompositor> compositor( |
| 162 new RenderWidgetCompositor(widget, threaded)); | 163 new RenderWidgetCompositor(widget, threaded)); |
| 163 | 164 |
| 164 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 165 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 165 | 166 |
| 167 if (cmd->HasSwitch(switches::kSendV8IdleNotificationAfterCommit)) | |
| 168 compositor->send_v8_idle_notification_after_commit_ = true; | |
|
jamesr
2014/08/25 18:06:26
touching a private var directly is dodgy. make thi
ernstm
2014/08/25 18:25:11
I moved the check for the command line flag into t
| |
| 169 | |
| 166 cc::LayerTreeSettings settings; | 170 cc::LayerTreeSettings settings; |
| 167 | 171 |
| 168 // For web contents, layer transforms should scale up the contents of layers | 172 // For web contents, layer transforms should scale up the contents of layers |
| 169 // to keep content always crisp when possible. | 173 // to keep content always crisp when possible. |
| 170 settings.layer_transforms_should_scale_layer_contents = true; | 174 settings.layer_transforms_should_scale_layer_contents = true; |
| 171 | 175 |
| 172 settings.throttle_frame_production = | 176 settings.throttle_frame_production = |
| 173 !cmd->HasSwitch(switches::kDisableGpuVsync); | 177 !cmd->HasSwitch(switches::kDisableGpuVsync); |
| 174 settings.begin_frame_scheduling_enabled = | 178 settings.begin_frame_scheduling_enabled = |
| 175 cmd->HasSwitch(switches::kEnableBeginFrameScheduling); | 179 cmd->HasSwitch(switches::kEnableBeginFrameScheduling); |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 | 409 |
| 406 compositor->Initialize(settings); | 410 compositor->Initialize(settings); |
| 407 | 411 |
| 408 return compositor.Pass(); | 412 return compositor.Pass(); |
| 409 } | 413 } |
| 410 | 414 |
| 411 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, | 415 RenderWidgetCompositor::RenderWidgetCompositor(RenderWidget* widget, |
| 412 bool threaded) | 416 bool threaded) |
| 413 : threaded_(threaded), | 417 : threaded_(threaded), |
| 414 suppress_schedule_composite_(false), | 418 suppress_schedule_composite_(false), |
| 415 widget_(widget) { | 419 widget_(widget), |
| 420 send_v8_idle_notification_after_commit_(false) { | |
| 416 } | 421 } |
| 417 | 422 |
| 418 RenderWidgetCompositor::~RenderWidgetCompositor() {} | 423 RenderWidgetCompositor::~RenderWidgetCompositor() {} |
| 419 | 424 |
| 420 const base::WeakPtr<cc::InputHandler>& | 425 const base::WeakPtr<cc::InputHandler>& |
| 421 RenderWidgetCompositor::GetInputHandler() { | 426 RenderWidgetCompositor::GetInputHandler() { |
| 422 return layer_tree_host_->GetInputHandler(); | 427 return layer_tree_host_->GetInputHandler(); |
| 423 } | 428 } |
| 424 | 429 |
| 425 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { | 430 void RenderWidgetCompositor::SetSuppressScheduleComposite(bool suppress) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 751 void RenderWidgetCompositor::WillBeginMainFrame(int frame_id) { | 756 void RenderWidgetCompositor::WillBeginMainFrame(int frame_id) { |
| 752 widget_->InstrumentWillBeginFrame(frame_id); | 757 widget_->InstrumentWillBeginFrame(frame_id); |
| 753 widget_->willBeginCompositorFrame(); | 758 widget_->willBeginCompositorFrame(); |
| 754 } | 759 } |
| 755 | 760 |
| 756 void RenderWidgetCompositor::DidBeginMainFrame() { | 761 void RenderWidgetCompositor::DidBeginMainFrame() { |
| 757 widget_->InstrumentDidBeginFrame(); | 762 widget_->InstrumentDidBeginFrame(); |
| 758 } | 763 } |
| 759 | 764 |
| 760 void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) { | 765 void RenderWidgetCompositor::BeginMainFrame(const cc::BeginFrameArgs& args) { |
| 766 begin_main_frame_time_ = args.frame_time; | |
| 767 begin_main_frame_interval_ = args.interval; | |
| 761 double frame_time = (args.frame_time - base::TimeTicks()).InSecondsF(); | 768 double frame_time = (args.frame_time - base::TimeTicks()).InSecondsF(); |
| 762 WebBeginFrameArgs web_begin_frame_args = WebBeginFrameArgs(frame_time); | 769 WebBeginFrameArgs web_begin_frame_args = WebBeginFrameArgs(frame_time); |
| 763 widget_->webwidget()->beginFrame(web_begin_frame_args); | 770 widget_->webwidget()->beginFrame(web_begin_frame_args); |
| 764 } | 771 } |
| 765 | 772 |
| 766 void RenderWidgetCompositor::Layout() { | 773 void RenderWidgetCompositor::Layout() { |
| 767 widget_->webwidget()->layout(); | 774 widget_->webwidget()->layout(); |
| 768 } | 775 } |
| 769 | 776 |
| 770 void RenderWidgetCompositor::ApplyScrollAndScale( | 777 void RenderWidgetCompositor::ApplyScrollAndScale( |
| 771 const gfx::Vector2d& scroll_delta, | 778 const gfx::Vector2d& scroll_delta, |
| 772 float page_scale) { | 779 float page_scale) { |
| 773 widget_->webwidget()->applyScrollAndScale(scroll_delta, page_scale); | 780 widget_->webwidget()->applyScrollAndScale(scroll_delta, page_scale); |
| 774 } | 781 } |
| 775 | 782 |
| 776 scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface( | 783 scoped_ptr<cc::OutputSurface> RenderWidgetCompositor::CreateOutputSurface( |
| 777 bool fallback) { | 784 bool fallback) { |
| 778 return widget_->CreateOutputSurface(fallback); | 785 return widget_->CreateOutputSurface(fallback); |
| 779 } | 786 } |
| 780 | 787 |
| 781 void RenderWidgetCompositor::DidInitializeOutputSurface() { | 788 void RenderWidgetCompositor::DidInitializeOutputSurface() { |
| 782 } | 789 } |
| 783 | 790 |
| 784 void RenderWidgetCompositor::WillCommit() { | 791 void RenderWidgetCompositor::WillCommit() { |
| 785 widget_->InstrumentWillComposite(); | 792 widget_->InstrumentWillComposite(); |
| 786 } | 793 } |
| 787 | 794 |
| 788 void RenderWidgetCompositor::DidCommit() { | 795 void RenderWidgetCompositor::DidCommit() { |
| 796 if (send_v8_idle_notification_after_commit_) { | |
| 797 int idle_time_in_ms = | |
| 798 std::max(0L, (begin_main_frame_time_ + | |
| 799 begin_main_frame_interval_ - | |
| 800 gfx::FrameTime::Now()).InMilliseconds()); | |
| 801 if (idle_time_in_ms) | |
| 802 blink::mainThreadIsolate()->IdleNotification(idle_time_in_ms); | |
| 803 } | |
| 804 | |
| 789 widget_->DidCommitCompositorFrame(); | 805 widget_->DidCommitCompositorFrame(); |
| 790 widget_->didBecomeReadyForAdditionalInput(); | 806 widget_->didBecomeReadyForAdditionalInput(); |
| 791 } | 807 } |
| 792 | 808 |
| 793 void RenderWidgetCompositor::DidCommitAndDrawFrame() { | 809 void RenderWidgetCompositor::DidCommitAndDrawFrame() { |
| 794 widget_->didCommitAndDrawCompositorFrame(); | 810 widget_->didCommitAndDrawCompositorFrame(); |
| 795 } | 811 } |
| 796 | 812 |
| 797 void RenderWidgetCompositor::DidCompleteSwapBuffers() { | 813 void RenderWidgetCompositor::DidCompleteSwapBuffers() { |
| 798 widget_->didCompleteSwapBuffers(); | 814 widget_->didCompleteSwapBuffers(); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 817 widget_->OnSwapBuffersAborted(); | 833 widget_->OnSwapBuffersAborted(); |
| 818 } | 834 } |
| 819 | 835 |
| 820 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { | 836 void RenderWidgetCompositor::RateLimitSharedMainThreadContext() { |
| 821 cc::ContextProvider* provider = | 837 cc::ContextProvider* provider = |
| 822 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); | 838 RenderThreadImpl::current()->SharedMainThreadContextProvider().get(); |
| 823 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); | 839 provider->ContextGL()->RateLimitOffscreenContextCHROMIUM(); |
| 824 } | 840 } |
| 825 | 841 |
| 826 } // namespace content | 842 } // namespace content |
| OLD | NEW |