Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Side by Side Diff: content/renderer/render_widget.cc

Issue 11794018: Revert 175303 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/renderer/render_widget.h ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/stl_util.h" 14 #include "base/stl_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "cc/layer_tree_host.h"
18 #include "cc/thread.h"
19 #include "cc/thread_impl.h"
20 #include "content/common/swapped_out_messages.h" 17 #include "content/common/swapped_out_messages.h"
21 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
22 #include "content/public/common/content_switches.h" 19 #include "content/public/common/content_switches.h"
23 #include "content/renderer/gpu/compositor_thread.h"
24 #include "content/renderer/render_process.h" 20 #include "content/renderer/render_process.h"
25 #include "content/renderer/render_thread_impl.h" 21 #include "content/renderer/render_thread_impl.h"
26 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 22 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
27 #include "ipc/ipc_sync_message.h" 23 #include "ipc/ipc_sync_message.h"
28 #include "skia/ext/platform_canvas.h" 24 #include "skia/ext/platform_canvas.h"
29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
30 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h"
31 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h"
32 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
33 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenuInfo.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return false; 194 return false;
199 } 195 }
200 } 196 }
201 197
202 // This is used to complete pending inits and non-pending inits. 198 // This is used to complete pending inits and non-pending inits.
203 void RenderWidget::CompleteInit() { 199 void RenderWidget::CompleteInit() {
204 DCHECK(routing_id_ != MSG_ROUTING_NONE); 200 DCHECK(routing_id_ != MSG_ROUTING_NONE);
205 201
206 init_complete_ = true; 202 init_complete_ = true;
207 203
208 if (webwidget_ && is_threaded_compositing_enabled_) { 204 if (webwidget_) {
209 webwidget_->enterForceCompositingMode(true); 205 webwidget_->setCompositorSurfaceReady();
210 } 206 if (is_threaded_compositing_enabled_)
211 if (web_layer_tree_view_) { 207 webwidget_->enterForceCompositingMode(true);
212 web_layer_tree_view_->setSurfaceReady();
213 } 208 }
214 DoDeferredUpdate(); 209 DoDeferredUpdate();
215 210
216 Send(new ViewHostMsg_RenderViewReady(routing_id_)); 211 Send(new ViewHostMsg_RenderViewReady(routing_id_));
217 } 212 }
218 213
219 void RenderWidget::SetSwappedOut(bool is_swapped_out) { 214 void RenderWidget::SetSwappedOut(bool is_swapped_out) {
220 // We should only toggle between states. 215 // We should only toggle between states.
221 DCHECK(is_swapped_out_ != is_swapped_out); 216 DCHECK(is_swapped_out_ != is_swapped_out);
222 is_swapped_out_ = is_swapped_out; 217 is_swapped_out_ = is_swapped_out;
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; 593 INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS;
599 } 594 }
600 595
601 IPC::Message* response = 596 IPC::Message* response =
602 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type, 597 new ViewHostMsg_HandleInputEvent_ACK(routing_id_, input_event->type,
603 ack_result); 598 ack_result);
604 bool event_type_gets_rate_limited = 599 bool event_type_gets_rate_limited =
605 input_event->type == WebInputEvent::MouseMove || 600 input_event->type == WebInputEvent::MouseMove ||
606 input_event->type == WebInputEvent::MouseWheel || 601 input_event->type == WebInputEvent::MouseWheel ||
607 WebInputEvent::isTouchEventType(input_event->type); 602 WebInputEvent::isTouchEventType(input_event->type);
608
609 bool frame_pending = paint_aggregator_.HasPendingUpdate();
610 if (is_accelerated_compositing_active_) {
611 frame_pending = web_layer_tree_view_ &&
612 web_layer_tree_view_->commitRequested();
613 }
614
615 bool is_input_throttled = 603 bool is_input_throttled =
616 throttle_input_events_ && 604 throttle_input_events_ &&
617 frame_pending; 605 ((webwidget_ ? webwidget_->isInputThrottled() : false) ||
606 paint_aggregator_.HasPendingUpdate());
618 607
619 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) { 608 if (event_type_gets_rate_limited && is_input_throttled && !is_hidden_) {
620 // We want to rate limit the input events in this case, so we'll wait for 609 // We want to rate limit the input events in this case, so we'll wait for
621 // painting to finish before ACKing this message. 610 // painting to finish before ACKing this message.
622 if (pending_input_event_ack_.get()) { 611 if (pending_input_event_ack_.get()) {
623 // As two different kinds of events could cause us to postpone an ack 612 // As two different kinds of events could cause us to postpone an ack
624 // we send it now, if we have one pending. The Browser should never 613 // we send it now, if we have one pending. The Browser should never
625 // send us the same kind of event we are delaying the ack for. 614 // send us the same kind of event we are delaying the ack for.
626 Send(pending_input_event_ack_.release()); 615 Send(pending_input_event_ack_.release());
627 } 616 }
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) { 834 if (now >= animation_floor_time_ || num_swapbuffers_complete_pending_ > 0) {
846 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") 835 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
847 animation_floor_time_ = now + animationInterval; 836 animation_floor_time_ = now + animationInterval;
848 // Set a timer to call us back after animationInterval before 837 // Set a timer to call us back after animationInterval before
849 // running animation callbacks so that if a callback requests another 838 // running animation callbacks so that if a callback requests another
850 // we'll be sure to run it at the proper time. 839 // we'll be sure to run it at the proper time.
851 animation_timer_.Stop(); 840 animation_timer_.Stop();
852 animation_timer_.Start(FROM_HERE, animationInterval, this, 841 animation_timer_.Start(FROM_HERE, animationInterval, this,
853 &RenderWidget::AnimationCallback); 842 &RenderWidget::AnimationCallback);
854 animation_update_pending_ = false; 843 animation_update_pending_ = false;
855 if (is_accelerated_compositing_active_ && web_layer_tree_view_) { 844 webwidget_->animate(0.0);
856 web_layer_tree_view_->layer_tree_host()->updateAnimations(
857 base::TimeTicks::Now());
858 } else {
859 webwidget_->animate(0.0);
860 }
861 return; 845 return;
862 } 846 }
863 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); 847 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
864 if (!animation_timer_.IsRunning()) { 848 if (!animation_timer_.IsRunning()) {
865 // This code uses base::Time::Now() to calculate the floor and next fire 849 // This code uses base::Time::Now() to calculate the floor and next fire
866 // time because javascript's Date object uses base::Time::Now(). The 850 // time because javascript's Date object uses base::Time::Now(). The
867 // message loop uses base::TimeTicks, which on windows can have a 851 // message loop uses base::TimeTicks, which on windows can have a
868 // different granularity than base::Time. 852 // different granularity than base::Time.
869 // The upshot of all this is that this function might be called before 853 // The upshot of all this is that this function might be called before
870 // base::Time::Now() has advanced past the animation_floor_time_. To 854 // base::Time::Now() has advanced past the animation_floor_time_. To
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 using_asynchronous_swapbuffers_ = false; 1221 using_asynchronous_swapbuffers_ = false;
1238 1222
1239 // In single-threaded mode, we exit force compositing mode and re-enter in 1223 // In single-threaded mode, we exit force compositing mode and re-enter in
1240 // DoDeferredUpdate() if appropriate. In threaded compositing mode, 1224 // DoDeferredUpdate() if appropriate. In threaded compositing mode,
1241 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and 1225 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1242 // entering force compositing mode at the appropriate times. 1226 // entering force compositing mode at the appropriate times.
1243 if (!is_threaded_compositing_enabled_) 1227 if (!is_threaded_compositing_enabled_)
1244 webwidget_->enterForceCompositingMode(false); 1228 webwidget_->enterForceCompositingMode(false);
1245 } 1229 }
1246 1230
1247 void RenderWidget::initializeLayerTreeView(
1248 WebKit::WebLayerTreeViewClient* client,
1249 const WebKit::WebLayer& root_layer,
1250 const WebKit::WebLayerTreeView::Settings& settings) {
1251 DCHECK(!web_layer_tree_view_);
1252 web_layer_tree_view_.reset(new WebKit::WebLayerTreeViewImpl(client));
1253
1254 scoped_ptr<cc::Thread> impl_thread;
1255 CompositorThread* compositor_thread =
1256 RenderThreadImpl::current()->compositor_thread();
1257 if (compositor_thread)
1258 impl_thread = cc::ThreadImpl::createForDifferentThread(
1259 compositor_thread->message_loop()->message_loop_proxy());
1260 if (!web_layer_tree_view_->initialize(settings, impl_thread.Pass())) {
1261 web_layer_tree_view_.reset();
1262 return;
1263 }
1264 web_layer_tree_view_->setRootLayer(root_layer);
1265 if (init_complete_) {
1266 web_layer_tree_view_->setSurfaceReady();
1267 }
1268 }
1269
1270 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() {
1271 return web_layer_tree_view_.get();
1272 }
1273
1274 void RenderWidget::willBeginCompositorFrame() { 1231 void RenderWidget::willBeginCompositorFrame() {
1275 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1232 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1276 1233
1277 DCHECK(RenderThreadImpl::current()->compositor_thread()); 1234 DCHECK(RenderThreadImpl::current()->compositor_thread());
1278 1235
1279 // The following two can result in further layout and possibly 1236 // The following two can result in further layout and possibly
1280 // enable GPU acceleration so they need to be called before any painting 1237 // enable GPU acceleration so they need to be called before any painting
1281 // is done. 1238 // is done.
1282 UpdateTextInputState(DO_NOT_SHOW_IME); 1239 UpdateTextInputState(DO_NOT_SHOW_IME);
1283 UpdateSelectionBounds(); 1240 UpdateSelectionBounds();
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1415 // in Javascript. If we ask the RendwerWidgetHost to close now, the window 1372 // in Javascript. If we ask the RendwerWidgetHost to close now, the window
1416 // could be closed before the JS finishes executing. So instead, post a 1373 // could be closed before the JS finishes executing. So instead, post a
1417 // message back to the message loop, which won't run until the JS is 1374 // message back to the message loop, which won't run until the JS is
1418 // complete, and then the Close message can be sent. 1375 // complete, and then the Close message can be sent.
1419 MessageLoop::current()->PostTask( 1376 MessageLoop::current()->PostTask(
1420 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this)); 1377 FROM_HERE, base::Bind(&RenderWidget::DoDeferredClose, this));
1421 } 1378 }
1422 1379
1423 void RenderWidget::Close() { 1380 void RenderWidget::Close() {
1424 if (webwidget_) { 1381 if (webwidget_) {
1425 web_layer_tree_view_.reset();
1426 webwidget_->close(); 1382 webwidget_->close();
1427 webwidget_ = NULL; 1383 webwidget_ = NULL;
1428 } 1384 }
1429 } 1385 }
1430 1386
1431 WebRect RenderWidget::windowRect() { 1387 WebRect RenderWidget::windowRect() {
1432 if (pending_window_rect_count_) 1388 if (pending_window_rect_count_)
1433 return pending_window_rect_; 1389 return pending_window_rect_;
1434 1390
1435 return view_screen_rect_; 1391 return view_screen_rect_;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 1585
1630 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size())); 1586 Send(new ViewHostMsg_PaintAtSize_ACK(routing_id_, tag, bounds.size()));
1631 } 1587 }
1632 1588
1633 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) { 1589 void RenderWidget::OnRepaint(const gfx::Size& size_to_paint) {
1634 // During shutdown we can just ignore this message. 1590 // During shutdown we can just ignore this message.
1635 if (!webwidget_) 1591 if (!webwidget_)
1636 return; 1592 return;
1637 1593
1638 set_next_paint_is_repaint_ack(); 1594 set_next_paint_is_repaint_ack();
1639 if (is_accelerated_compositing_active_/* && web_layer_tree_view_*/) { 1595 if (is_accelerated_compositing_active_) {
1640 if (web_layer_tree_view_) 1596 webwidget_->setNeedsRedraw();
1641 web_layer_tree_view_->setNeedsRedraw();
1642 scheduleComposite(); 1597 scheduleComposite();
1643 } else { 1598 } else {
1644 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); 1599 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height());
1645 didInvalidateRect(repaint_rect); 1600 didInvalidateRect(repaint_rect);
1646 } 1601 }
1647 } 1602 }
1648 1603
1649 void RenderWidget::OnSmoothScrollCompleted(int gesture_id) { 1604 void RenderWidget::OnSmoothScrollCompleted(int gesture_id) {
1650 PendingSmoothScrollGestureMap::iterator it = 1605 PendingSmoothScrollGestureMap::iterator it =
1651 pending_smooth_scroll_gestures_.find(gesture_id); 1606 pending_smooth_scroll_gestures_.find(gesture_id);
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1965 i != plugin_window_moves_.end(); ++i) { 1920 i != plugin_window_moves_.end(); ++i) {
1966 if (i->window == window) { 1921 if (i->window == window) {
1967 plugin_window_moves_.erase(i); 1922 plugin_window_moves_.erase(i);
1968 break; 1923 break;
1969 } 1924 }
1970 } 1925 }
1971 } 1926 }
1972 1927
1973 void RenderWidget::GetRenderingStats( 1928 void RenderWidget::GetRenderingStats(
1974 WebKit::WebRenderingStatsImpl& stats) const { 1929 WebKit::WebRenderingStatsImpl& stats) const {
1975 if (web_layer_tree_view_) 1930 webwidget()->renderingStats(stats);
1976 web_layer_tree_view_->renderingStats(stats);
1977 1931
1978 stats.rendering_stats.numAnimationFrames += 1932 stats.rendering_stats.numAnimationFrames +=
1979 software_stats_.numAnimationFrames; 1933 software_stats_.numAnimationFrames;
1980 stats.rendering_stats.numFramesSentToScreen += 1934 stats.rendering_stats.numFramesSentToScreen +=
1981 software_stats_.numFramesSentToScreen; 1935 software_stats_.numFramesSentToScreen;
1982 stats.rendering_stats.totalPaintTimeInSeconds += 1936 stats.rendering_stats.totalPaintTimeInSeconds +=
1983 software_stats_.totalPaintTimeInSeconds; 1937 software_stats_.totalPaintTimeInSeconds;
1984 stats.rendering_stats.totalPixelsPainted += 1938 stats.rendering_stats.totalPixelsPainted +=
1985 software_stats_.totalPixelsPainted; 1939 software_stats_.totalPixelsPainted;
1986 stats.rendering_stats.totalRasterizeTimeInSeconds += 1940 stats.rendering_stats.totalRasterizeTimeInSeconds +=
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2027 1981
2028 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1982 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
2029 return false; 1983 return false;
2030 } 1984 }
2031 1985
2032 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 1986 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2033 return true; 1987 return true;
2034 } 1988 }
2035 1989
2036 } // namespace content 1990 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | webkit/compositor_bindings/web_layer_tree_view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698