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), | |
danakj
2014/08/13 18:30:19
This var could exist #if DCHECK_IS_ON
| |
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 788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 } | 1195 } |
1195 | 1196 |
1196 void RenderWidget::AutoResizeCompositor() { | 1197 void RenderWidget::AutoResizeCompositor() { |
1197 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, | 1198 physical_backing_size_ = gfx::ToCeiledSize(gfx::ScaleSize(size_, |
1198 device_scale_factor_)); | 1199 device_scale_factor_)); |
1199 if (compositor_) | 1200 if (compositor_) |
1200 compositor_->setViewportSize(size_, physical_backing_size_); | 1201 compositor_->setViewportSize(size_, physical_backing_size_); |
1201 } | 1202 } |
1202 | 1203 |
1203 void RenderWidget::initializeLayerTreeView() { | 1204 void RenderWidget::initializeLayerTreeView() { |
1205 DCHECK(!host_closing_); | |
1206 | |
1204 compositor_ = | 1207 compositor_ = |
1205 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); | 1208 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
1206 compositor_->setViewportSize(size_, physical_backing_size_); | 1209 compositor_->setViewportSize(size_, physical_backing_size_); |
1207 if (init_complete_) | 1210 if (init_complete_) |
1208 StartCompositor(); | 1211 StartCompositor(); |
1209 } | 1212 } |
1210 | 1213 |
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(); | |
danakj
2014/08/13 18:30:19
Ok so my super deep (ha ha haahha) understanding o
| |
1218 compositor_.reset(); | |
1219 } | |
1220 | |
1211 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1221 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1212 return compositor_.get(); | 1222 return compositor_.get(); |
1213 } | 1223 } |
1214 | 1224 |
1215 void RenderWidget::suppressCompositorScheduling(bool enable) { | |
1216 if (compositor_) | |
1217 compositor_->SetSuppressScheduleComposite(enable); | |
1218 } | |
1219 | |
1220 void RenderWidget::willBeginCompositorFrame() { | 1225 void RenderWidget::willBeginCompositorFrame() { |
1221 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1226 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1222 | 1227 |
1223 DCHECK(RenderThreadImpl::current()->compositor_message_loop_proxy().get()); | |
1224 | |
1225 // The following two can result in further layout and possibly | 1228 // The following two can result in further layout and possibly |
1226 // enable GPU acceleration so they need to be called before any painting | 1229 // enable GPU acceleration so they need to be called before any painting |
1227 // is done. | 1230 // is done. |
1228 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); | 1231 UpdateTextInputState(NO_SHOW_IME, FROM_NON_IME); |
1229 UpdateSelectionBounds(); | 1232 UpdateSelectionBounds(); |
1230 } | 1233 } |
1231 | 1234 |
1232 void RenderWidget::didBecomeReadyForAdditionalInput() { | 1235 void RenderWidget::didBecomeReadyForAdditionalInput() { |
1233 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); | 1236 TRACE_EVENT0("renderer", "RenderWidget::didBecomeReadyForAdditionalInput"); |
1234 FlushPendingInputEventAck(); | 1237 FlushPendingInputEventAck(); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1371 SetPendingWindowRect(initial_pos_); | 1374 SetPendingWindowRect(initial_pos_); |
1372 } | 1375 } |
1373 | 1376 |
1374 void RenderWidget::didFocus() { | 1377 void RenderWidget::didFocus() { |
1375 } | 1378 } |
1376 | 1379 |
1377 void RenderWidget::didBlur() { | 1380 void RenderWidget::didBlur() { |
1378 } | 1381 } |
1379 | 1382 |
1380 void RenderWidget::DoDeferredClose() { | 1383 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; | |
1381 Send(new ViewHostMsg_Close(routing_id_)); | 1390 Send(new ViewHostMsg_Close(routing_id_)); |
1382 } | 1391 } |
1383 | 1392 |
1384 void RenderWidget::closeWidgetSoon() { | 1393 void RenderWidget::closeWidgetSoon() { |
1385 if (is_swapped_out_) { | 1394 if (is_swapped_out_) { |
1386 // This widget is currently swapped out, and the active widget is in a | 1395 // This widget is currently swapped out, and the active widget is in a |
1387 // different process. Have the browser route the close request to the | 1396 // different process. Have the browser route the close request to the |
1388 // active widget instead, so that the correct unload handlers are run. | 1397 // active widget instead, so that the correct unload handlers are run. |
1389 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); | 1398 Send(new ViewHostMsg_RouteCloseEvent(routing_id_)); |
1390 return; | 1399 return; |
(...skipping 20 matching lines...) Expand all Loading... | |
1411 | 1420 |
1412 SyntheticGesturePacket gesture_packet; | 1421 SyntheticGesturePacket gesture_packet; |
1413 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1422 gesture_packet.set_gesture_params(gesture_params.Pass()); |
1414 | 1423 |
1415 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1424 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1416 } | 1425 } |
1417 | 1426 |
1418 void RenderWidget::Close() { | 1427 void RenderWidget::Close() { |
1419 screen_metrics_emulator_.reset(); | 1428 screen_metrics_emulator_.reset(); |
1420 if (webwidget_) { | 1429 if (webwidget_) { |
1421 webwidget_->willCloseLayerTreeView(); | 1430 DestroyLayerTreeView(); |
1422 compositor_.reset(); | |
1423 webwidget_->close(); | 1431 webwidget_->close(); |
1424 webwidget_ = NULL; | 1432 webwidget_ = NULL; |
1425 } | 1433 } |
1426 } | 1434 } |
1427 | 1435 |
1428 WebRect RenderWidget::windowRect() { | 1436 WebRect RenderWidget::windowRect() { |
1429 if (pending_window_rect_count_) | 1437 if (pending_window_rect_count_) |
1430 return pending_window_rect_; | 1438 return pending_window_rect_; |
1431 | 1439 |
1432 return view_screen_rect_; | 1440 return view_screen_rect_; |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2156 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2164 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2157 video_hole_frames_.AddObserver(frame); | 2165 video_hole_frames_.AddObserver(frame); |
2158 } | 2166 } |
2159 | 2167 |
2160 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2168 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2161 video_hole_frames_.RemoveObserver(frame); | 2169 video_hole_frames_.RemoveObserver(frame); |
2162 } | 2170 } |
2163 #endif // defined(VIDEO_HOLE) | 2171 #endif // defined(VIDEO_HOLE) |
2164 | 2172 |
2165 } // namespace content | 2173 } // namespace content |
OLD | NEW |