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 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1212 void RenderWidget::initializeLayerTreeView() { | 1212 void RenderWidget::initializeLayerTreeView() { |
1213 DCHECK(!host_closing_); | 1213 DCHECK(!host_closing_); |
1214 | 1214 |
1215 compositor_ = | 1215 compositor_ = |
1216 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); | 1216 RenderWidgetCompositor::Create(this, IsThreadedCompositingEnabled()); |
1217 compositor_->setViewportSize(size_, physical_backing_size_); | 1217 compositor_->setViewportSize(size_, physical_backing_size_); |
1218 if (init_complete_) | 1218 if (init_complete_) |
1219 StartCompositor(); | 1219 StartCompositor(); |
1220 } | 1220 } |
1221 | 1221 |
1222 void RenderWidget::DestroyLayerTreeView() { | |
1223 // Always send this notification to prevent new layer tree views from | |
1224 // being created, even if one hasn't been created yet. | |
1225 if (webwidget_) | |
1226 webwidget_->willCloseLayerTreeView(); | |
1227 compositor_.reset(); | |
1228 } | |
1229 | |
1230 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1222 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
1231 return compositor_.get(); | 1223 return compositor_.get(); |
1232 } | 1224 } |
1233 | 1225 |
1234 void RenderWidget::willBeginCompositorFrame() { | 1226 void RenderWidget::willBeginCompositorFrame() { |
1235 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); | 1227 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); |
1236 | 1228 |
1237 // The following two can result in further layout and possibly | 1229 // The following two can result in further layout and possibly |
1238 // enable GPU acceleration so they need to be called before any painting | 1230 // enable GPU acceleration so they need to be called before any painting |
1239 // is done. | 1231 // is done. |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 SetPendingWindowRect(initial_pos_); | 1375 SetPendingWindowRect(initial_pos_); |
1384 } | 1376 } |
1385 | 1377 |
1386 void RenderWidget::didFocus() { | 1378 void RenderWidget::didFocus() { |
1387 } | 1379 } |
1388 | 1380 |
1389 void RenderWidget::didBlur() { | 1381 void RenderWidget::didBlur() { |
1390 } | 1382 } |
1391 | 1383 |
1392 void RenderWidget::DoDeferredClose() { | 1384 void RenderWidget::DoDeferredClose() { |
1393 // No more compositing is possible. This prevents shutdown races between | 1385 StopCompositor(); |
1394 // previously posted CreateOutputSurface tasks and the host being unable to | |
1395 // create them because the close message was handled. | |
1396 DestroyLayerTreeView(); | |
1397 // Also prevent new compositors from being created. | 1386 // Also prevent new compositors from being created. |
1398 host_closing_ = true; | 1387 host_closing_ = true; |
1399 Send(new ViewHostMsg_Close(routing_id_)); | 1388 Send(new ViewHostMsg_Close(routing_id_)); |
1400 } | 1389 } |
1401 | 1390 |
1402 void RenderWidget::closeWidgetSoon() { | 1391 void RenderWidget::closeWidgetSoon() { |
1403 if (is_swapped_out_) { | 1392 if (is_swapped_out_) { |
1404 // This widget is currently swapped out, and the active widget is in a | 1393 // This widget is currently swapped out, and the active widget is in a |
1405 // different process. Have the browser route the close request to the | 1394 // different process. Have the browser route the close request to the |
1406 // active widget instead, so that the correct unload handlers are run. | 1395 // active widget instead, so that the correct unload handlers are run. |
(...skipping 21 matching lines...) Expand all Loading... |
1428 pending_synthetic_gesture_callbacks_.push(callback); | 1417 pending_synthetic_gesture_callbacks_.push(callback); |
1429 | 1418 |
1430 SyntheticGesturePacket gesture_packet; | 1419 SyntheticGesturePacket gesture_packet; |
1431 gesture_packet.set_gesture_params(gesture_params.Pass()); | 1420 gesture_packet.set_gesture_params(gesture_params.Pass()); |
1432 | 1421 |
1433 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); | 1422 Send(new InputHostMsg_QueueSyntheticGesture(routing_id_, gesture_packet)); |
1434 } | 1423 } |
1435 | 1424 |
1436 void RenderWidget::Close() { | 1425 void RenderWidget::Close() { |
1437 screen_metrics_emulator_.reset(); | 1426 screen_metrics_emulator_.reset(); |
1438 DestroyLayerTreeView(); | 1427 StopCompositor(); |
1439 if (webwidget_) { | 1428 if (webwidget_) { |
1440 webwidget_->close(); | 1429 webwidget_->close(); |
1441 webwidget_ = NULL; | 1430 webwidget_ = NULL; |
1442 } | 1431 } |
1443 } | 1432 } |
1444 | 1433 |
1445 WebRect RenderWidget::windowRect() { | 1434 WebRect RenderWidget::windowRect() { |
1446 if (pending_window_rect_count_) | 1435 if (pending_window_rect_count_) |
1447 return pending_window_rect_; | 1436 return pending_window_rect_; |
1448 | 1437 |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 } | 1986 } |
1998 | 1987 |
1999 void RenderWidget::StartCompositor() { | 1988 void RenderWidget::StartCompositor() { |
2000 // For widgets that are never visible, we don't need the compositor to run | 1989 // For widgets that are never visible, we don't need the compositor to run |
2001 // at all. | 1990 // at all. |
2002 if (never_visible_) | 1991 if (never_visible_) |
2003 return; | 1992 return; |
2004 compositor_->setSurfaceReady(); | 1993 compositor_->setSurfaceReady(); |
2005 } | 1994 } |
2006 | 1995 |
| 1996 void RenderWidget::StopCompositor() { |
| 1997 // Always send this notification to prevent new layer tree views from |
| 1998 // being created, even if one hasn't been created yet. |
| 1999 if (webwidget_) |
| 2000 webwidget_->willCloseLayerTreeView(); |
| 2001 if (compositor_) |
| 2002 compositor_->Shutdown(); |
| 2003 } |
| 2004 |
2007 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { | 2005 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { |
2008 size_t i = 0; | 2006 size_t i = 0; |
2009 for (; i < plugin_window_moves_.size(); ++i) { | 2007 for (; i < plugin_window_moves_.size(); ++i) { |
2010 if (plugin_window_moves_[i].window == move.window) { | 2008 if (plugin_window_moves_[i].window == move.window) { |
2011 if (move.rects_valid) { | 2009 if (move.rects_valid) { |
2012 plugin_window_moves_[i] = move; | 2010 plugin_window_moves_[i] = move; |
2013 } else { | 2011 } else { |
2014 plugin_window_moves_[i].visible = move.visible; | 2012 plugin_window_moves_[i].visible = move.visible; |
2015 } | 2013 } |
2016 break; | 2014 break; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { | 2176 void RenderWidget::RegisterVideoHoleFrame(RenderFrameImpl* frame) { |
2179 video_hole_frames_.AddObserver(frame); | 2177 video_hole_frames_.AddObserver(frame); |
2180 } | 2178 } |
2181 | 2179 |
2182 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { | 2180 void RenderWidget::UnregisterVideoHoleFrame(RenderFrameImpl* frame) { |
2183 video_hole_frames_.RemoveObserver(frame); | 2181 video_hole_frames_.RemoveObserver(frame); |
2184 } | 2182 } |
2185 #endif // defined(VIDEO_HOLE) | 2183 #endif // defined(VIDEO_HOLE) |
2186 | 2184 |
2187 } // namespace content | 2185 } // namespace content |
OLD | NEW |