| 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 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 // running animation callbacks so that if a callback requests another | 920 // running animation callbacks so that if a callback requests another |
| 921 // we'll be sure to run it at the proper time. | 921 // we'll be sure to run it at the proper time. |
| 922 animation_timer_.Stop(); | 922 animation_timer_.Stop(); |
| 923 animation_timer_.Start(FROM_HERE, animationInterval, this, | 923 animation_timer_.Start(FROM_HERE, animationInterval, this, |
| 924 &RenderWidget::AnimationCallback); | 924 &RenderWidget::AnimationCallback); |
| 925 animation_update_pending_ = false; | 925 animation_update_pending_ = false; |
| 926 if (is_accelerated_compositing_active_ && compositor_) { | 926 if (is_accelerated_compositing_active_ && compositor_) { |
| 927 compositor_->layer_tree_host()->updateAnimations( | 927 compositor_->layer_tree_host()->updateAnimations( |
| 928 base::TimeTicks::Now()); | 928 base::TimeTicks::Now()); |
| 929 } else { | 929 } else { |
| 930 webwidget_->animate(0.0); | 930 double frame_begin_time = |
| 931 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); |
| 932 webwidget_->animate(frame_begin_time); |
| 931 } | 933 } |
| 932 return; | 934 return; |
| 933 } | 935 } |
| 934 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); | 936 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); |
| 935 if (!animation_timer_.IsRunning()) { | 937 if (!animation_timer_.IsRunning()) { |
| 936 // This code uses base::Time::Now() to calculate the floor and next fire | 938 // This code uses base::Time::Now() to calculate the floor and next fire |
| 937 // time because javascript's Date object uses base::Time::Now(). The | 939 // time because javascript's Date object uses base::Time::Now(). The |
| 938 // message loop uses base::TimeTicks, which on windows can have a | 940 // message loop uses base::TimeTicks, which on windows can have a |
| 939 // different granularity than base::Time. | 941 // different granularity than base::Time. |
| 940 // The upshot of all this is that this function might be called before | 942 // 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... |
| 1193 } | 1195 } |
| 1194 | 1196 |
| 1195 // If we're software rendering then we're done initiating the paint. | 1197 // If we're software rendering then we're done initiating the paint. |
| 1196 if (!is_accelerated_compositing_active_) | 1198 if (!is_accelerated_compositing_active_) |
| 1197 DidInitiatePaint(); | 1199 DidInitiatePaint(); |
| 1198 } | 1200 } |
| 1199 | 1201 |
| 1200 void RenderWidget::Composite() { | 1202 void RenderWidget::Composite() { |
| 1201 DCHECK(is_accelerated_compositing_active_); | 1203 DCHECK(is_accelerated_compositing_active_); |
| 1202 if (compositor_) // TODO(jamesr): Figure out how this can be null. | 1204 if (compositor_) // TODO(jamesr): Figure out how this can be null. |
| 1203 compositor_->composite(); | 1205 compositor_->layer_tree_host()->composite(); |
| 1204 } | 1206 } |
| 1205 | 1207 |
| 1206 /////////////////////////////////////////////////////////////////////////////// | 1208 /////////////////////////////////////////////////////////////////////////////// |
| 1207 // WebWidgetClient | 1209 // WebWidgetClient |
| 1208 | 1210 |
| 1209 void RenderWidget::didInvalidateRect(const WebRect& rect) { | 1211 void RenderWidget::didInvalidateRect(const WebRect& rect) { |
| 1210 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", | 1212 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", |
| 1211 "width", rect.width, "height", rect.height); | 1213 "width", rect.width, "height", rect.height); |
| 1212 // The invalidated rect might be outside the bounds of the view. | 1214 // The invalidated rect might be outside the bounds of the view. |
| 1213 gfx::Rect view_rect(size_); | 1215 gfx::Rect view_rect(size_); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and | 1336 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and |
| 1335 // entering force compositing mode at the appropriate times. | 1337 // entering force compositing mode at the appropriate times. |
| 1336 if (!is_threaded_compositing_enabled_) | 1338 if (!is_threaded_compositing_enabled_) |
| 1337 webwidget_->enterForceCompositingMode(false); | 1339 webwidget_->enterForceCompositingMode(false); |
| 1338 } | 1340 } |
| 1339 | 1341 |
| 1340 void RenderWidget::initializeLayerTreeView( | 1342 void RenderWidget::initializeLayerTreeView( |
| 1341 WebKit::WebLayerTreeViewClient* client, | 1343 WebKit::WebLayerTreeViewClient* client, |
| 1342 const WebKit::WebLayer& root_layer, | 1344 const WebKit::WebLayer& root_layer, |
| 1343 const WebKit::WebLayerTreeView::Settings& settings) { | 1345 const WebKit::WebLayerTreeView::Settings& settings) { |
| 1344 compositor_ = RenderWidgetCompositor::Create(this, client, settings); | 1346 compositor_ = RenderWidgetCompositor::Create(this, settings); |
| 1345 if (!compositor_) | 1347 if (!compositor_) |
| 1346 return; | 1348 return; |
| 1347 | 1349 |
| 1348 compositor_->setRootLayer(root_layer); | 1350 compositor_->setRootLayer(root_layer); |
| 1349 if (init_complete_) | 1351 if (init_complete_) |
| 1350 compositor_->setSurfaceReady(); | 1352 compositor_->setSurfaceReady(); |
| 1351 } | 1353 } |
| 1352 | 1354 |
| 1353 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { | 1355 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1354 return compositor_.get(); | 1356 return compositor_.get(); |
| (...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2142 bool RenderWidget::WillHandleGestureEvent( | 2144 bool RenderWidget::WillHandleGestureEvent( |
| 2143 const WebKit::WebGestureEvent& event) { | 2145 const WebKit::WebGestureEvent& event) { |
| 2144 return false; | 2146 return false; |
| 2145 } | 2147 } |
| 2146 | 2148 |
| 2147 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2149 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
| 2148 return true; | 2150 return true; |
| 2149 } | 2151 } |
| 2150 | 2152 |
| 2151 } // namespace content | 2153 } // namespace content |
| OLD | NEW |