| 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/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" |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 924 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") | 924 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") |
| 925 animation_floor_time_ = now + animationInterval; | 925 animation_floor_time_ = now + animationInterval; |
| 926 // Set a timer to call us back after animationInterval before | 926 // Set a timer to call us back after animationInterval before |
| 927 // running animation callbacks so that if a callback requests another | 927 // running animation callbacks so that if a callback requests another |
| 928 // we'll be sure to run it at the proper time. | 928 // we'll be sure to run it at the proper time. |
| 929 animation_timer_.Stop(); | 929 animation_timer_.Stop(); |
| 930 animation_timer_.Start(FROM_HERE, animationInterval, this, | 930 animation_timer_.Start(FROM_HERE, animationInterval, this, |
| 931 &RenderWidget::AnimationCallback); | 931 &RenderWidget::AnimationCallback); |
| 932 animation_update_pending_ = false; | 932 animation_update_pending_ = false; |
| 933 if (is_accelerated_compositing_active_ && compositor_) { | 933 if (is_accelerated_compositing_active_ && compositor_) { |
| 934 compositor_->layer_tree_host()->updateAnimations( | 934 compositor_->Animate(base::TimeTicks::Now()); |
| 935 base::TimeTicks::Now()); | |
| 936 } else { | 935 } else { |
| 937 webwidget_->animate(0.0); | 936 double frame_begin_time = |
| 937 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 938 webwidget_->animate(frame_begin_time); |
| 938 } | 939 } |
| 939 return; | 940 return; |
| 940 } | 941 } |
| 941 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); | 942 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); |
| 942 if (!animation_timer_.IsRunning()) { | 943 if (!animation_timer_.IsRunning()) { |
| 943 // This code uses base::Time::Now() to calculate the floor and next fire | 944 // This code uses base::Time::Now() to calculate the floor and next fire |
| 944 // time because javascript's Date object uses base::Time::Now(). The | 945 // time because javascript's Date object uses base::Time::Now(). The |
| 945 // message loop uses base::TimeTicks, which on windows can have a | 946 // message loop uses base::TimeTicks, which on windows can have a |
| 946 // different granularity than base::Time. | 947 // different granularity than base::Time. |
| 947 // The upshot of all this is that this function might be called before | 948 // The upshot of all this is that this function might be called before |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1200 } | 1201 } |
| 1201 | 1202 |
| 1202 // If we're software rendering then we're done initiating the paint. | 1203 // If we're software rendering then we're done initiating the paint. |
| 1203 if (!is_accelerated_compositing_active_) | 1204 if (!is_accelerated_compositing_active_) |
| 1204 DidInitiatePaint(); | 1205 DidInitiatePaint(); |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 void RenderWidget::Composite() { | 1208 void RenderWidget::Composite() { |
| 1208 DCHECK(is_accelerated_compositing_active_); | 1209 DCHECK(is_accelerated_compositing_active_); |
| 1209 if (compositor_) // TODO(jamesr): Figure out how this can be null. | 1210 if (compositor_) // TODO(jamesr): Figure out how this can be null. |
| 1210 compositor_->composite(); | 1211 compositor_->Composite(); |
| 1211 } | 1212 } |
| 1212 | 1213 |
| 1213 /////////////////////////////////////////////////////////////////////////////// | 1214 /////////////////////////////////////////////////////////////////////////////// |
| 1214 // WebWidgetClient | 1215 // WebWidgetClient |
| 1215 | 1216 |
| 1216 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 1217 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
| 1217 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", | 1218 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", |
| 1218 "width", rect.width, "height", rect.height); | 1219 "width", rect.width, "height", rect.height); |
| 1219 // The invalidated rect might be outside the bounds of the view. | 1220 // The invalidated rect might be outside the bounds of the view. |
| 1220 gfx::Rect view_rect(size_); | 1221 gfx::Rect view_rect(size_); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1349 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and | 1350 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and |
| 1350 // entering force compositing mode at the appropriate times. | 1351 // entering force compositing mode at the appropriate times. |
| 1351 if (!is_threaded_compositing_enabled_) | 1352 if (!is_threaded_compositing_enabled_) |
| 1352 webwidget_->enterForceCompositingMode(false); | 1353 webwidget_->enterForceCompositingMode(false); |
| 1353 } | 1354 } |
| 1354 | 1355 |
| 1355 void RenderWidget::initializeLayerTreeView( | 1356 void RenderWidget::initializeLayerTreeView( |
| 1356 WebKit::WebLayerTreeViewClient* client, | 1357 WebKit::WebLayerTreeViewClient* client, |
| 1357 const WebKit::WebLayer& root_layer, | 1358 const WebKit::WebLayer& root_layer, |
| 1358 const WebKit::WebLayerTreeView::Settings& settings) { | 1359 const WebKit::WebLayerTreeView::Settings& settings) { |
| 1359 compositor_ = RenderWidgetCompositor::Create(this, client, settings); | 1360 compositor_ = RenderWidgetCompositor::Create(this, settings); |
| 1360 if (!compositor_) | 1361 if (!compositor_) |
| 1361 return; | 1362 return; |
| 1362 | 1363 |
| 1363 compositor_->setRootLayer(root_layer); | 1364 compositor_->setRootLayer(root_layer); |
| 1364 compositor_->setViewportSize(size_, physical_backing_size_); | 1365 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1365 if (init_complete_) | 1366 if (init_complete_) |
| 1366 compositor_->setSurfaceReady(); | 1367 compositor_->setSurfaceReady(); |
| 1367 } | 1368 } |
| 1368 | 1369 |
| 1369 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { | 1370 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { |
| (...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2113 if (i->window == window) { | 2114 if (i->window == window) { |
| 2114 plugin_window_moves_.erase(i); | 2115 plugin_window_moves_.erase(i); |
| 2115 break; | 2116 break; |
| 2116 } | 2117 } |
| 2117 } | 2118 } |
| 2118 } | 2119 } |
| 2119 | 2120 |
| 2120 void RenderWidget::GetRenderingStats( | 2121 void RenderWidget::GetRenderingStats( |
| 2121 WebKit::WebRenderingStatsImpl& stats) const { | 2122 WebKit::WebRenderingStatsImpl& stats) const { |
| 2122 if (compositor_) | 2123 if (compositor_) |
| 2123 compositor_->layer_tree_host()->renderingStats(&stats.rendering_stats); | 2124 compositor_->GetRenderingStats(&stats.rendering_stats); |
| 2124 | 2125 |
| 2125 stats.rendering_stats.numAnimationFrames += | 2126 stats.rendering_stats.numAnimationFrames += |
| 2126 software_stats_.numAnimationFrames; | 2127 software_stats_.numAnimationFrames; |
| 2127 stats.rendering_stats.numFramesSentToScreen += | 2128 stats.rendering_stats.numFramesSentToScreen += |
| 2128 software_stats_.numFramesSentToScreen; | 2129 software_stats_.numFramesSentToScreen; |
| 2129 stats.rendering_stats.totalPaintTime += | 2130 stats.rendering_stats.totalPaintTime += |
| 2130 software_stats_.totalPaintTime; | 2131 software_stats_.totalPaintTime; |
| 2131 stats.rendering_stats.totalPixelsPainted += | 2132 stats.rendering_stats.totalPixelsPainted += |
| 2132 software_stats_.totalPixelsPainted; | 2133 software_stats_.totalPixelsPainted; |
| 2133 stats.rendering_stats.totalRasterizeTime += | 2134 stats.rendering_stats.totalRasterizeTime += |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 bool RenderWidget::WillHandleGestureEvent( | 2171 bool RenderWidget::WillHandleGestureEvent( |
| 2171 const WebKit::WebGestureEvent& event) { | 2172 const WebKit::WebGestureEvent& event) { |
| 2172 return false; | 2173 return false; |
| 2173 } | 2174 } |
| 2174 | 2175 |
| 2175 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2176 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
| 2176 return true; | 2177 return true; |
| 2177 } | 2178 } |
| 2178 | 2179 |
| 2179 } // namespace content | 2180 } // namespace content |
| OLD | NEW |