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

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

Issue 12226051: Clean up RenderWidget/RenderWidgetCompositor/WebKit interactions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: law of demeter Created 7 years, 9 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
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"
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded") 917 TRACE_EVENT0("renderer", "RenderWidget::AnimateIfNeeded")
918 animation_floor_time_ = now + animationInterval; 918 animation_floor_time_ = now + animationInterval;
919 // Set a timer to call us back after animationInterval before 919 // Set a timer to call us back after animationInterval before
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_->Animate(base::TimeTicks::Now());
928 base::TimeTicks::Now());
929 } else { 928 } else {
930 webwidget_->animate(0.0); 929 double frame_begin_time =
930 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
931 webwidget_->animate(frame_begin_time);
931 } 932 }
932 return; 933 return;
933 } 934 }
934 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently"); 935 TRACE_EVENT0("renderer", "EarlyOut_AnimatedTooRecently");
935 if (!animation_timer_.IsRunning()) { 936 if (!animation_timer_.IsRunning()) {
936 // This code uses base::Time::Now() to calculate the floor and next fire 937 // 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 938 // time because javascript's Date object uses base::Time::Now(). The
938 // message loop uses base::TimeTicks, which on windows can have a 939 // message loop uses base::TimeTicks, which on windows can have a
939 // different granularity than base::Time. 940 // different granularity than base::Time.
940 // The upshot of all this is that this function might be called before 941 // 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
1193 } 1194 }
1194 1195
1195 // If we're software rendering then we're done initiating the paint. 1196 // If we're software rendering then we're done initiating the paint.
1196 if (!is_accelerated_compositing_active_) 1197 if (!is_accelerated_compositing_active_)
1197 DidInitiatePaint(); 1198 DidInitiatePaint();
1198 } 1199 }
1199 1200
1200 void RenderWidget::Composite() { 1201 void RenderWidget::Composite() {
1201 DCHECK(is_accelerated_compositing_active_); 1202 DCHECK(is_accelerated_compositing_active_);
1202 if (compositor_) // TODO(jamesr): Figure out how this can be null. 1203 if (compositor_) // TODO(jamesr): Figure out how this can be null.
1203 compositor_->composite(); 1204 compositor_->Composite();
1204 } 1205 }
1205 1206
1206 /////////////////////////////////////////////////////////////////////////////// 1207 ///////////////////////////////////////////////////////////////////////////////
1207 // WebWidgetClient 1208 // WebWidgetClient
1208 1209
1209 void RenderWidget::didInvalidateRect(const WebRect& rect) { 1210 void RenderWidget::didInvalidateRect(const WebRect& rect) {
1210 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect", 1211 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
1211 "width", rect.width, "height", rect.height); 1212 "width", rect.width, "height", rect.height);
1212 // The invalidated rect might be outside the bounds of the view. 1213 // The invalidated rect might be outside the bounds of the view.
1213 gfx::Rect view_rect(size_); 1214 gfx::Rect view_rect(size_);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and 1335 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1335 // entering force compositing mode at the appropriate times. 1336 // entering force compositing mode at the appropriate times.
1336 if (!is_threaded_compositing_enabled_) 1337 if (!is_threaded_compositing_enabled_)
1337 webwidget_->enterForceCompositingMode(false); 1338 webwidget_->enterForceCompositingMode(false);
1338 } 1339 }
1339 1340
1340 void RenderWidget::initializeLayerTreeView( 1341 void RenderWidget::initializeLayerTreeView(
1341 WebKit::WebLayerTreeViewClient* client, 1342 WebKit::WebLayerTreeViewClient* client,
1342 const WebKit::WebLayer& root_layer, 1343 const WebKit::WebLayer& root_layer,
1343 const WebKit::WebLayerTreeView::Settings& settings) { 1344 const WebKit::WebLayerTreeView::Settings& settings) {
1344 compositor_ = RenderWidgetCompositor::Create(this, client, settings); 1345 compositor_ = RenderWidgetCompositor::Create(this, settings);
1345 if (!compositor_) 1346 if (!compositor_)
1346 return; 1347 return;
1347 1348
1348 compositor_->setRootLayer(root_layer); 1349 compositor_->setRootLayer(root_layer);
1349 if (init_complete_) 1350 if (init_complete_)
1350 compositor_->setSurfaceReady(); 1351 compositor_->setSurfaceReady();
1351 } 1352 }
1352 1353
1353 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() { 1354 WebKit::WebLayerTreeView* RenderWidget::layerTreeView() {
1354 return compositor_.get(); 1355 return compositor_.get();
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
2085 if (i->window == window) { 2086 if (i->window == window) {
2086 plugin_window_moves_.erase(i); 2087 plugin_window_moves_.erase(i);
2087 break; 2088 break;
2088 } 2089 }
2089 } 2090 }
2090 } 2091 }
2091 2092
2092 void RenderWidget::GetRenderingStats( 2093 void RenderWidget::GetRenderingStats(
2093 WebKit::WebRenderingStatsImpl& stats) const { 2094 WebKit::WebRenderingStatsImpl& stats) const {
2094 if (compositor_) 2095 if (compositor_)
2095 compositor_->layer_tree_host()->renderingStats(&stats.rendering_stats); 2096 compositor_->GetRenderingStats(&stats.rendering_stats);
2096 2097
2097 stats.rendering_stats.numAnimationFrames += 2098 stats.rendering_stats.numAnimationFrames +=
2098 software_stats_.numAnimationFrames; 2099 software_stats_.numAnimationFrames;
2099 stats.rendering_stats.numFramesSentToScreen += 2100 stats.rendering_stats.numFramesSentToScreen +=
2100 software_stats_.numFramesSentToScreen; 2101 software_stats_.numFramesSentToScreen;
2101 stats.rendering_stats.totalPaintTime += 2102 stats.rendering_stats.totalPaintTime +=
2102 software_stats_.totalPaintTime; 2103 software_stats_.totalPaintTime;
2103 stats.rendering_stats.totalPixelsPainted += 2104 stats.rendering_stats.totalPixelsPainted +=
2104 software_stats_.totalPixelsPainted; 2105 software_stats_.totalPixelsPainted;
2105 stats.rendering_stats.totalRasterizeTime += 2106 stats.rendering_stats.totalRasterizeTime +=
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2142 bool RenderWidget::WillHandleGestureEvent( 2143 bool RenderWidget::WillHandleGestureEvent(
2143 const WebKit::WebGestureEvent& event) { 2144 const WebKit::WebGestureEvent& event) {
2144 return false; 2145 return false;
2145 } 2146 }
2146 2147
2147 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { 2148 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const {
2148 return true; 2149 return true;
2149 } 2150 }
2150 2151
2151 } // namespace content 2152 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698