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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
141 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { | 141 ui::TextInputMode ConvertInputMode(const blink::WebString& input_mode) { |
142 static TextInputModeMapSingleton* singleton = | 142 static TextInputModeMapSingleton* singleton = |
143 TextInputModeMapSingleton::GetInstance(); | 143 TextInputModeMapSingleton::GetInstance(); |
144 TextInputModeMap::const_iterator it = | 144 TextInputModeMap::const_iterator it = |
145 singleton->map().find(input_mode.utf8()); | 145 singleton->map().find(input_mode.utf8()); |
146 if (it == singleton->map().end()) | 146 if (it == singleton->map().end()) |
147 return ui::TEXT_INPUT_MODE_DEFAULT; | 147 return ui::TEXT_INPUT_MODE_DEFAULT; |
148 return it->second; | 148 return it->second; |
149 } | 149 } |
150 | 150 |
151 bool IsThreadedCompositingEnabled() { | |
152 return !!content::RenderThreadImpl::current() | |
piman
2014/06/13 21:56:42
Oh, iirc there's a couple of tests that mock Rende
danakj
2014/06/13 21:58:54
Oh thanks, done.
| |
153 ->compositor_message_loop_proxy() | |
154 .get(); | |
155 } | |
156 | |
151 // TODO(brianderson): Replace the hard-coded threshold with a fraction of | 157 // TODO(brianderson): Replace the hard-coded threshold with a fraction of |
152 // the BeginMainFrame interval. | 158 // the BeginMainFrame interval. |
153 // 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 |
154 // be spent in input hanlders before input starts getting throttled. | 160 // be spent in input hanlders before input starts getting throttled. |
155 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; | 161 const int kInputHandlingTimeThrottlingThresholdMicroseconds = 4166; |
156 | 162 |
157 } // namespace | 163 } // namespace |
158 | 164 |
159 namespace content { | 165 namespace content { |
160 | 166 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
381 is_swapped_out_(swapped_out), | 387 is_swapped_out_(swapped_out), |
382 input_method_is_active_(false), | 388 input_method_is_active_(false), |
383 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 389 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
384 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 390 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
385 can_compose_inline_(true), | 391 can_compose_inline_(true), |
386 popup_type_(popup_type), | 392 popup_type_(popup_type), |
387 pending_window_rect_count_(0), | 393 pending_window_rect_count_(0), |
388 suppress_next_char_events_(false), | 394 suppress_next_char_events_(false), |
389 screen_info_(screen_info), | 395 screen_info_(screen_info), |
390 device_scale_factor_(screen_info_.deviceScaleFactor), | 396 device_scale_factor_(screen_info_.deviceScaleFactor), |
391 is_threaded_compositing_enabled_(false), | |
392 current_event_latency_info_(NULL), | 397 current_event_latency_info_(NULL), |
393 next_output_surface_id_(0), | 398 next_output_surface_id_(0), |
394 #if defined(OS_ANDROID) | 399 #if defined(OS_ANDROID) |
395 text_field_is_dirty_(false), | 400 text_field_is_dirty_(false), |
396 outstanding_ime_acks_(0), | 401 outstanding_ime_acks_(0), |
397 body_background_color_(SK_ColorWHITE), | 402 body_background_color_(SK_ColorWHITE), |
398 #endif | 403 #endif |
399 popup_origin_scale_for_emulation_(0.f), | 404 popup_origin_scale_for_emulation_(0.f), |
400 resizing_mode_selector_(new ResizingModeSelector()), | 405 resizing_mode_selector_(new ResizingModeSelector()), |
401 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { | 406 context_menu_source_type_(ui::MENU_SOURCE_MOUSE) { |
402 if (!swapped_out) | 407 if (!swapped_out) |
403 RenderProcess::current()->AddRefProcess(); | 408 RenderProcess::current()->AddRefProcess(); |
404 DCHECK(RenderThread::Get()); | 409 DCHECK(RenderThread::Get()); |
405 is_threaded_compositing_enabled_ = | |
406 CommandLine::ForCurrentProcess()->HasSwitch( | |
407 switches::kEnableThreadedCompositing); | |
408 } | 410 } |
409 | 411 |
410 RenderWidget::~RenderWidget() { | 412 RenderWidget::~RenderWidget() { |
411 DCHECK(!webwidget_) << "Leaking our WebWidget!"; | 413 DCHECK(!webwidget_) << "Leaking our WebWidget!"; |
412 | 414 |
413 // If we are swapped out, we have released already. | 415 // If we are swapped out, we have released already. |
414 if (!is_swapped_out_ && RenderProcess::current()) | 416 if (!is_swapped_out_ && RenderProcess::current()) |
415 RenderProcess::current()->ReleaseProcess(); | 417 RenderProcess::current()->ReleaseProcess(); |
416 } | 418 } |
417 | 419 |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
826 context_provider = ContextProviderCommandBuffer::Create( | 828 context_provider = ContextProviderCommandBuffer::Create( |
827 CreateGraphicsContext3D(), "RenderCompositor"); | 829 CreateGraphicsContext3D(), "RenderCompositor"); |
828 if (!context_provider.get()) { | 830 if (!context_provider.get()) { |
829 // Cause the compositor to wait and try again. | 831 // Cause the compositor to wait and try again. |
830 return scoped_ptr<cc::OutputSurface>(); | 832 return scoped_ptr<cc::OutputSurface>(); |
831 } | 833 } |
832 } | 834 } |
833 | 835 |
834 uint32 output_surface_id = next_output_surface_id_++; | 836 uint32 output_surface_id = next_output_surface_id_++; |
835 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { | 837 if (command_line.HasSwitch(switches::kEnableDelegatedRenderer)) { |
836 DCHECK(is_threaded_compositing_enabled_); | 838 DCHECK(IsThreadedCompositingEnabled()); |
837 return scoped_ptr<cc::OutputSurface>( | 839 return scoped_ptr<cc::OutputSurface>( |
838 new DelegatedCompositorOutputSurface( | 840 new DelegatedCompositorOutputSurface( |
839 routing_id(), | 841 routing_id(), |
840 output_surface_id, | 842 output_surface_id, |
841 context_provider)); | 843 context_provider)); |
842 } | 844 } |
843 if (!context_provider.get()) { | 845 if (!context_provider.get()) { |
844 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 846 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
845 new CompositorSoftwareOutputDevice()); | 847 new CompositorSoftwareOutputDevice()); |
846 | 848 |
847 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( | 849 return scoped_ptr<cc::OutputSurface>(new CompositorOutputSurface( |
848 routing_id(), | 850 routing_id(), |
849 output_surface_id, | 851 output_surface_id, |
850 NULL, | 852 NULL, |
851 software_device.Pass(), | 853 software_device.Pass(), |
852 true)); | 854 true)); |
853 } | 855 } |
854 | 856 |
855 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { | 857 if (command_line.HasSwitch(cc::switches::kCompositeToMailbox)) { |
856 // Composite-to-mailbox is currently used for layout tests in order to cause | 858 // Composite-to-mailbox is currently used for layout tests in order to cause |
857 // them to draw inside in the renderer to do the readback there. This should | 859 // them to draw inside in the renderer to do the readback there. This should |
858 // no longer be the case when crbug.com/311404 is fixed. | 860 // no longer be the case when crbug.com/311404 is fixed. |
859 DCHECK(is_threaded_compositing_enabled_ || | 861 DCHECK(IsThreadedCompositingEnabled() || |
860 RenderThreadImpl::current()->layout_test_mode()); | 862 RenderThreadImpl::current()->layout_test_mode()); |
861 cc::ResourceFormat format = cc::RGBA_8888; | 863 cc::ResourceFormat format = cc::RGBA_8888; |
862 #if defined(OS_ANDROID) | 864 #if defined(OS_ANDROID) |
863 if (base::android::SysUtils::IsLowEndDevice()) | 865 if (base::android::SysUtils::IsLowEndDevice()) |
864 format = cc::RGB_565; | 866 format = cc::RGB_565; |
865 #endif | 867 #endif |
866 return scoped_ptr<cc::OutputSurface>( | 868 return scoped_ptr<cc::OutputSurface>( |
867 new MailboxOutputSurface( | 869 new MailboxOutputSurface( |
868 routing_id(), | 870 routing_id(), |
869 output_surface_id, | 871 output_surface_id, |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1160 } | 1162 } |
1161 | 1163 |
1162 void RenderWidget::AutoResizeCompositor() { | 1164 void RenderWidget::AutoResizeCompositor() { |
1163 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1165 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
1164 device_scale_factor_)); | 1166 device_scale_factor_)); |
1165 if (compositor_) | 1167 if (compositor_) |
1166 compositor_->setViewportSize(size_, physical_backing_size_); | 1168 compositor_->setViewportSize(size_, physical_backing_size_); |
1167 } | 1169 } |
1168 | 1170 |
1169 void RenderWidget::initializeLayerTreeView() { | 1171 void RenderWidget::initializeLayerTreeView() { |
1170 compositor_ = RenderWidgetCompositor::Create( | 1172 compositor_ = |
1171 this, is_threaded_compositing_enabled_); | 1173 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
1172 compositor_->setViewportSize(size_, physical_backing_size_); | 1174 compositor_->setViewportSize(size_, physical_backing_size_); |
1173 if (init_complete_) | 1175 if (init_complete_) |
1174 StartCompositor(); | 1176 StartCompositor(); |
1175 } | 1177 } |
1176 | 1178 |
1177 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1179 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1178 return compositor_.get(); | 1180 return compositor_.get(); |
1179 } | 1181 } |
1180 | 1182 |
1181 void RenderWidget::suppressCompositorScheduling(bool enable) { | 1183 void RenderWidget::suppressCompositorScheduling(bool enable) { |
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2070 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2072 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2071 video_hole_frames_.AddObserver(frame); | 2073 video_hole_frames_.AddObserver(frame); |
2072 } | 2074 } |
2073 | 2075 |
2074 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2076 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2075 video_hole_frames_.RemoveObserver(frame); | 2077 video_hole_frames_.RemoveObserver(frame); |
2076 } | 2078 } |
2077 #endif // defined(VIDEO_HOLE) | 2079 #endif // defined(VIDEO_HOLE) |
2078 | 2080 |
2079 } // namespace content | 2081 } // namespace content |
OLD | NEW |