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