| 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/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { | 142 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { |
| 143 static TextInputModeMapSingleton* singleton = | 143 static TextInputModeMapSingleton* singleton = |
| 144 TextInputModeMapSingleton::GetInstance(); | 144 TextInputModeMapSingleton::GetInstance(); |
| 145 TextInputModeMap::const_iterator it = | 145 TextInputModeMap::const_iterator it = |
| 146 singleton->map().find(input_mode.utf8()); | 146 singleton->map().find(input_mode.utf8()); |
| 147 if (it == singleton->map().end()) | 147 if (it == singleton->map().end()) |
| 148 return ui::TEXT_INPUT_MODE_DEFAULT; | 148 return ui::TEXT_INPUT_MODE_DEFAULT; |
| 149 return it->second; | 149 return it->second; |
| 150 } | 150 } |
| 151 | 151 |
| 152 bool IsThreadedCompositingEnabled() { |
| 153 content::RenderThreadImpl* impl = content::RenderThreadImpl::current(); |
| 154 return impl && !!impl->compositor_message_loop_proxy().get(); |
| 155 } |
| 156 |
| 152 // TODO(brianderson): Replace the hard-coded threshold with a fraction of | 157 // TODO(brianderson): Replace the hard-coded threshold with a fraction of |
| 153 // the BeginMainFrame interval. | 158 // the BeginMainFrame interval. |
| 154 // 4166us will allow 1/4 of a 60Hz interval or 1/2 of a 120Hz interval to | 159 // 4166us will allow 1/4 of a 60Hz interval or 1/2 of a 120Hz interval to |
| 155 // be spent in input hanlders before input starts getting throttled. | 160 // be spent in input hanlders before input starts getting throttled. |
| 156 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; | 161 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; |
| 157 | 162 |
| 158 } // namespace | 163 } // namespace |
| 159 | 164 |
| 160 namespace content { | 165 namespace content { |
| 161 | 166 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 is_swapped_out_(swapped_out), | 394 is_swapped_out_(swapped_out), |
| 390 input_method_is_active_(false), | 395 input_method_is_active_(false), |
| 391 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 396 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| 392 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 397 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
| 393 can_compose_inline_(true), | 398 can_compose_inline_(true), |
| 394 popup_type_(popup_type), | 399 popup_type_(popup_type), |
| 395 pending_window_rect_count_(0), | 400 pending_window_rect_count_(0), |
| 396 suppress_next_char_events_(false), | 401 suppress_next_char_events_(false), |
| 397 screen_info_(screen_info), | 402 screen_info_(screen_info), |
| 398 device_scale_factor_(screen_info_.deviceScaleFactor), | 403 device_scale_factor_(screen_info_.deviceScaleFactor), |
| 399 is_threaded_compositing_enabled_(false), | |
| 400 current_event_latency_info_(NULL), | 404 current_event_latency_info_(NULL), |
| 401 next_output_surface_id_(0), | 405 next_output_surface_id_(0), |
| 402 #if defined(OS_ANDROID) | 406 #if defined(OS_ANDROID) |
| 403 text_field_is_dirty_(false), | 407 text_field_is_dirty_(false), |
| 404 outstanding_ime_acks_(0), | 408 outstanding_ime_acks_(0), |
| 405 body_background_color_(SK_ColorWHITE), | 409 body_background_color_(SK_ColorWHITE), |
| 406 #endif | 410 #endif |
| 407 popup_origin_scale_for_emulation_(0.f), | 411 popup_origin_scale_for_emulation_(0.f), |
| 408 resizing_mode_selector_(new ResizingModeSelector()), | 412 resizing_mode_selector_(new ResizingModeSelector()), |
| 409 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { | 413 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { |
| 410 if (!swapped_out) | 414 if (!swapped_out) |
| 411 RenderProcess::current()->AddRefProcess(); | 415 RenderProcess::current()->AddRefProcess(); |
| 412 DCHECK(RenderThread::Get()); | 416 DCHECK(RenderThread::Get()); |
| 413 is_threaded_compositing_enabled_ = | |
| 414 CommandLine::ForCurrentProcess()->HasSwitch( | |
| 415 switches::kEnableThreadedCompositing); | |
| 416 device_color_profile_.push_back('0'); | 417 device_color_profile_.push_back('0'); |
| 417 } | 418 } |
| 418 | 419 |
| 419 RenderWidget::~RenderWidget() { | 420 RenderWidget::~RenderWidget() { |
| 420 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 421 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
| 421 | 422 |
| 422 // If we are swapped out, we have released already. | 423 // If we are swapped out, we have released already. |
| 423 if (!is_swapped_out_ && RenderProcess::current()) | 424 if (!is_swapped_out_ && RenderProcess::current()) |
| 424 RenderProcess::current()->ReleaseProcess(); | 425 RenderProcess::current()->ReleaseProcess(); |
| 425 } | 426 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 833 context_provider = ContextProviderCommandBuffer::Create( | 834 context_provider = ContextProviderCommandBuffer::Create( |
| 834 CreateGraphicsContext3D(), "RenderCompositor"); | 835 CreateGraphicsContext3D(), "RenderCompositor"); |
| 835 if (!context_provider.get()) { | 836 if (!context_provider.get()) { |
| 836 // Cause the compositor to wait and try again. | 837 // Cause the compositor to wait and try again. |
| 837 return scoped_ptr<cc::OutputSurface>(); | 838 return scoped_ptr<cc::OutputSurface>(); |
| 838 } | 839 } |
| 839 } | 840 } |
| 840 | 841 |
| 841 uint32 output_surface_id = next_output_surface_id_++; | 842 uint32 output_surface_id = next_output_surface_id_++; |
| 842 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { | 843 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
| 843 DCHECK(is_threaded_compositing_enabled_); | 844 DCHECK(IsThreadedCompositingEnabled()); |
| 844 return scoped_ptr<cc::OutputSurface>( | 845 return scoped_ptr<cc::OutputSurface>( |
| 845 new DelegatedCompositorOutputSurface( | 846 new DelegatedCompositorOutputSurface( |
| 846 routing_id(), | 847 routing_id(), |
| 847 output_surface_id, | 848 output_surface_id, |
| 848 context_provider)); | 849 context_provider)); |
| 849 } | 850 } |
| 850 if (!context_provider.get()) { | 851 if (!context_provider.get()) { |
| 851 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 852 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| 852 new CompositorSoftwareOutputDevice()); | 853 new CompositorSoftwareOutputDevice()); |
| 853 | 854 |
| 854 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 855 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
| 855 routing_id(), | 856 routing_id(), |
| 856 output_surface_id, | 857 output_surface_id, |
| 857 NULL, | 858 NULL, |
| 858 software_device.Pass(), | 859 software_device.Pass(), |
| 859 true)); | 860 true)); |
| 860 } | 861 } |
| 861 | 862 |
| 862 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 863 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
| 863 // Composite-to-mailbox is currently used for layout tests in order to cause | 864 // Composite-to-mailbox is currently used for layout tests in order to cause |
| 864 // them to draw inside in the renderer to do the readback there. This should | 865 // them to draw inside in the renderer to do the readback there. This should |
| 865 // no longer be the case when crbug.com/311404 is fixed. | 866 // no longer be the case when crbug.com/311404 is fixed. |
| 866 DCHECK(is_threaded_compositing_enabled_ || | 867 DCHECK(IsThreadedCompositingEnabled() || |
| 867 RenderThreadImpl::current()->layout_test_mode()); | 868 RenderThreadImpl::current()->layout_test_mode()); |
| 868 cc::ResourceFormat format = cc::RGBA_8888; | 869 cc::ResourceFormat format = cc::RGBA_8888; |
| 869 if (base::SysInfo::IsLowEndDevice()) | 870 if (base::SysInfo::IsLowEndDevice()) |
| 870 format = cc::RGB_565; | 871 format = cc::RGB_565; |
| 871 return scoped_ptr<cc::OutputSurface>( | 872 return scoped_ptr<cc::OutputSurface>( |
| 872 new MailboxOutputSurface( | 873 new MailboxOutputSurface( |
| 873 routing_id(), | 874 routing_id(), |
| 874 output_surface_id, | 875 output_surface_id, |
| 875 context_provider, | 876 context_provider, |
| 876 scoped_ptr<cc::SoftwareOutputDevice>(), | 877 scoped_ptr<cc::SoftwareOutputDevice>(), |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1165 } | 1166 } |
| 1166 | 1167 |
| 1167 void RenderWidget::AutoResizeCompositor() { | 1168 void RenderWidget::AutoResizeCompositor() { |
| 1168 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1169 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
| 1169 device_scale_factor_)); | 1170 device_scale_factor_)); |
| 1170 if (compositor_) | 1171 if (compositor_) |
| 1171 compositor_->setViewportSize(size_, physical_backing_size_); | 1172 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1172 } | 1173 } |
| 1173 | 1174 |
| 1174 void RenderWidget::initializeLayerTreeView() { | 1175 void RenderWidget::initializeLayerTreeView() { |
| 1175 compositor_ = RenderWidgetCompositor::Create( | 1176 compositor_ = |
| 1176 this, is_threaded_compositing_enabled_); | 1177 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
| 1177 compositor_->setViewportSize(size_, physical_backing_size_); | 1178 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1178 if (init_complete_) | 1179 if (init_complete_) |
| 1179 StartCompositor(); | 1180 StartCompositor(); |
| 1180 } | 1181 } |
| 1181 | 1182 |
| 1182 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1183 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1183 return compositor_.get(); | 1184 return compositor_.get(); |
| 1184 } | 1185 } |
| 1185 | 1186 |
| 1186 void RenderWidget::suppressCompositorScheduling(bool enable) { | 1187 void RenderWidget::suppressCompositorScheduling(bool enable) { |
| (...skipping 886 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2073 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2074 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2074 video_hole_frames_.AddObserver(frame); | 2075 video_hole_frames_.AddObserver(frame); |
| 2075 } | 2076 } |
| 2076 | 2077 |
| 2077 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2078 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
| 2078 video_hole_frames_.RemoveObserver(frame); | 2079 video_hole_frames_.RemoveObserver(frame); |
| 2079 } | 2080 } |
| 2080 #endif // defined(VIDEO_HOLE) | 2081 #endif // defined(VIDEO_HOLE) |
| 2081 | 2082 |
| 2082 } // namespace content | 2083 } // namespace content |
| OLD | NEW |