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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
386 did_show_(false), | 386 did_show_(false), |
387 is_hidden_(hidden), | 387 is_hidden_(hidden), |
388 never_visible_(never_visible), | 388 never_visible_(never_visible), |
389 is_fullscreen_(false), | 389 is_fullscreen_(false), |
390 has_focus_(false), | 390 has_focus_(false), |
391 handling_input_event_(false), | 391 handling_input_event_(false), |
392 handling_ime_event_(false), | 392 handling_ime_event_(false), |
393 handling_event_type_(WebInputEvent::Undefined), | 393 handling_event_type_(WebInputEvent::Undefined), |
394 ignore_ack_for_mouse_move_from_debugger_(false), | 394 ignore_ack_for_mouse_move_from_debugger_(false), |
395 closing_(false), | 395 closing_(false), |
396 host_closing_(false), | |
397 is_swapped_out_(swapped_out), | 396 is_swapped_out_(swapped_out), |
398 input_method_is_active_(false), | 397 input_method_is_active_(false), |
399 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 398 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
400 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), | 399 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), |
401 can_compose_inline_(true), | 400 can_compose_inline_(true), |
402 popup_type_(popup_type), | 401 popup_type_(popup_type), |
403 pending_window_rect_count_(0), | 402 pending_window_rect_count_(0), |
404 suppress_next_char_events_(false), | 403 suppress_next_char_events_(false), |
405 screen_info_(screen_info), | 404 screen_info_(screen_info), |
406 device_scale_factor_(screen_info_.deviceScaleFactor), | 405 device_scale_factor_(screen_info_.deviceScaleFactor), |
(...skipping 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 } | 1194 } |
1196 | 1195 |
1197 void RenderWidget::AutoResizeCompositor() { | 1196 void RenderWidget::AutoResizeCompositor() { |
1198 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1197 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
1199 device_scale_factor_)); | 1198 device_scale_factor_)); |
1200 if (compositor_) | 1199 if (compositor_) |
1201 compositor_->setViewportSize(size_, physical_backing_size_); | 1200 compositor_->setViewportSize(size_, physical_backing_size_); |
1202 } | 1201 } |
1203 | 1202 |
1204 void RenderWidget::initializeLayerTreeView() { | 1203 void RenderWidget::initializeLayerTreeView() { |
1205 DCHECK(!host_closing_); | |
1206 | |
1207 compositor_ = | 1204 compositor_ = |
1208 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); | 1205 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
1209 compositor_->setViewportSize(size_, physical_backing_size_); | 1206 compositor_->setViewportSize(size_, physical_backing_size_); |
1210 if (init_complete_) | 1207 if (init_complete_) |
1211 StartCompositor(); | 1208 StartCompositor(); |
1212 } | 1209 } |
1213 | 1210 |
1214 void RenderWidget::DestroyLayerTreeView() { | |
1215 // Always send this notification to prevent new layer tree views from | |
1216 // being created, even if one hasn't been created yet. | |
1217 webwidget_->willCloseLayerTreeView(); | |
1218 compositor_.reset(); | |
1219 } | |
1220 | |
1221 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1211 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1222 return compositor_.get(); | 1212 return compositor_.get(); |
1223 } | 1213 } |
1224 | 1214 |
| 1215 void RenderWidget::suppressCompositorScheduling(bool enable) { |
| 1216 if (compositor_) |
| 1217 compositor_->SetSuppressScheduleComposite(enable); |
| 1218 } |
| 1219 |
1225 void RenderWidget::willBeginCompositorFrame() { | 1220 void RenderWidget::willBeginCompositorFrame() { |
1226 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1221 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1227 | 1222 |
| 1223 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); |
| 1224 |
1228 // The following two can result in further layout and possibly | 1225 // The following two can result in further layout and possibly |
1229 // enable GPU acceleration so they need to be called before any painting | 1226 // enable GPU acceleration so they need to be called before any painting |
1230 // is done. | 1227 // is done. |
1231 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1228 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
1232 UpdateSelectionBounds(); | 1229 UpdateSelectionBounds(); |
1233 } | 1230 } |
1234 | 1231 |
1235 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1232 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1236 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1233 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1237 FlushPendingInputEventAck(); | 1234 FlushPendingInputEventAck(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1374 SetPendingWindowRect(initial_pos_); | 1371 SetPendingWindowRect(initial_pos_); |
1375 } | 1372 } |
1376 | 1373 |
1377 void RenderWidget::didFocus() { | 1374 void RenderWidget::didFocus() { |
1378 } | 1375 } |
1379 | 1376 |
1380 void RenderWidget::didBlur() { | 1377 void RenderWidget::didBlur() { |
1381 } | 1378 } |
1382 | 1379 |
1383 void RenderWidget::DoDeferredClose() { | 1380 void RenderWidget::DoDeferredClose() { |
1384 // No more compositing is possible. This prevents shutdown races between | |
1385 // previously posted CreateOutputSurface tasks and the host being unable to | |
1386 // create them because the close message was handled. | |
1387 DestroyLayerTreeView(); | |
1388 // Also prevent new compositors from being created. | |
1389 host_closing_ = true; | |
1390 Send(new ViewHostMsg_Close(routing_id_)); | 1381 Send(new ViewHostMsg_Close(routing_id_)); |
1391 } | 1382 } |
1392 | 1383 |
1393 void RenderWidget::closeWidgetSoon() { | 1384 void RenderWidget::closeWidgetSoon() { |
1394 if (is_swapped_out_) { | 1385 if (is_swapped_out_) { |
1395 // This widget is currently swapped out, and the active widget is in a | 1386 // This widget is currently swapped out, and the active widget is in a |
1396 // different process. Have the browser route the close request to the | 1387 // different process. Have the browser route the close request to the |
1397 // active widget instead, so that the correct unload handlers are run. | 1388 // active widget instead, so that the correct unload handlers are run. |
1398 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1389 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
1399 return; | 1390 return; |
(...skipping 20 matching lines...) Expand all Loading... |
1420 | 1411 |
1421 SyntheticGesturePacket gesture_packet; | 1412 SyntheticGesturePacket gesture_packet; |
1422 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1413 gesture_packet.set_gesture_params(gesture_params.Pass()); |
1423 | 1414 |
1424 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1415 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1425 } | 1416 } |
1426 | 1417 |
1427 void RenderWidget::Close() { | 1418 void RenderWidget::Close() { |
1428 screen_metrics_emulator_.reset(); | 1419 screen_metrics_emulator_.reset(); |
1429 if (webwidget_) { | 1420 if (webwidget_) { |
1430 DestroyLayerTreeView(); | 1421 webwidget_->willCloseLayerTreeView(); |
| 1422 compositor_.reset(); |
1431 webwidget_->close(); | 1423 webwidget_->close(); |
1432 webwidget_ = NULL; | 1424 webwidget_ = NULL; |
1433 } | 1425 } |
1434 } | 1426 } |
1435 | 1427 |
1436 WebRect RenderWidget::windowRect() { | 1428 WebRect RenderWidget::windowRect() { |
1437 if (pending_window_rect_count_) | 1429 if (pending_window_rect_count_) |
1438 return pending_window_rect_; | 1430 return pending_window_rect_; |
1439 | 1431 |
1440 return view_screen_rect_; | 1432 return view_screen_rect_; |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2164 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2156 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2165 video_hole_frames_.AddObserver(frame); | 2157 video_hole_frames_.AddObserver(frame); |
2166 } | 2158 } |
2167 | 2159 |
2168 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2160 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2169 video_hole_frames_.RemoveObserver(frame); | 2161 video_hole_frames_.RemoveObserver(frame); |
2170 } | 2162 } |
2171 #endif // defined(VIDEO_HOLE) | 2163 #endif // defined(VIDEO_HOLE) |
2172 | 2164 |
2173 } // namespace content | 2165 } // namespace content |
OLD | NEW |