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

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

Issue 271803004: Remove RenderWidget::scheduleAnimation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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') | no next file » | 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/debug/trace_event_synthetic_delay.h" 10 #include "base/debug/trace_event_synthetic_delay.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 closing_(false), 379 closing_(false),
380 is_swapped_out_(swapped_out), 380 is_swapped_out_(swapped_out),
381 input_method_is_active_(false), 381 input_method_is_active_(false),
382 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), 382 text_input_type_(ui::TEXT_INPUT_TYPE_NONE),
383 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT), 383 text_input_mode_(ui::TEXT_INPUT_MODE_DEFAULT),
384 can_compose_inline_(true), 384 can_compose_inline_(true),
385 popup_type_(popup_type), 385 popup_type_(popup_type),
386 pending_window_rect_count_(0), 386 pending_window_rect_count_(0),
387 suppress_next_char_events_(false), 387 suppress_next_char_events_(false),
388 is_accelerated_compositing_active_(false), 388 is_accelerated_compositing_active_(false),
389 animation_update_pending_(false),
390 invalidation_task_posted_(false), 389 invalidation_task_posted_(false),
391 screen_info_(screen_info), 390 screen_info_(screen_info),
392 device_scale_factor_(screen_info_.deviceScaleFactor), 391 device_scale_factor_(screen_info_.deviceScaleFactor),
393 is_threaded_compositing_enabled_(false), 392 is_threaded_compositing_enabled_(false),
394 next_output_surface_id_(0), 393 next_output_surface_id_(0),
395 #if defined(OS_ANDROID) 394 #if defined(OS_ANDROID)
396 text_field_is_dirty_(false), 395 text_field_is_dirty_(false),
397 outstanding_ime_acks_(0), 396 outstanding_ime_acks_(0),
398 body_background_color_(SK_ColorWHITE), 397 body_background_color_(SK_ColorWHITE),
399 #endif 398 #endif
(...skipping 737 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 webwidget_->setFocus(enable); 1136 webwidget_->setFocus(enable);
1138 } 1137 }
1139 1138
1140 void RenderWidget::ClearFocus() { 1139 void RenderWidget::ClearFocus() {
1141 // We may have got the focus from the browser before this gets processed, in 1140 // We may have got the focus from the browser before this gets processed, in
1142 // which case we do not want to unfocus ourself. 1141 // which case we do not want to unfocus ourself.
1143 if (!has_focus_ && webwidget_) 1142 if (!has_focus_ && webwidget_)
1144 webwidget_->setFocus(false); 1143 webwidget_->setFocus(false);
1145 } 1144 }
1146 1145
1147 void RenderWidget::AnimationCallback() {
1148 TRACE_EVENT0("renderer", "RenderWidget::AnimationCallback");
1149 if (!animation_update_pending_) {
1150 TRACE_EVENT0("renderer", "EarlyOut_NoAnimationUpdatePending");
1151 return;
1152 }
1153 FlushPendingInputEventAck();
1154 }
1155
1156 void RenderWidget::InvalidationCallback() { 1146 void RenderWidget::InvalidationCallback() {
1157 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback"); 1147 TRACE_EVENT0("renderer", "RenderWidget::InvalidationCallback");
1158 invalidation_task_posted_ = false; 1148 invalidation_task_posted_ = false;
1159 FlushPendingInputEventAck(); 1149 FlushPendingInputEventAck();
1160 } 1150 }
1161 1151
1162 void RenderWidget::FlushPendingInputEventAck() { 1152 void RenderWidget::FlushPendingInputEventAck() {
1163 if (pending_input_event_ack_) 1153 if (pending_input_event_ack_)
1164 Send(pending_input_event_ack_.release()); 1154 Send(pending_input_event_ack_.release());
1165 total_input_handling_time_this_frame_ = base::TimeDelta(); 1155 total_input_handling_time_this_frame_ = base::TimeDelta();
1166 } 1156 }
1167 1157
1168 /////////////////////////////////////////////////////////////////////////////// 1158 ///////////////////////////////////////////////////////////////////////////////
1169 // WebWidgetClient 1159 // WebWidgetClient
1170 1160
1171 void RenderWidget::didInvalidateRect(const WebRect& rect) { 1161 void RenderWidget::didInvalidateRect(const WebRect& rect) {
1172 // The invalidated rect might be outside the bounds of the view. 1162 // The invalidated rect might be outside the bounds of the view.
1173 gfx::Rect view_rect(size_); 1163 gfx::Rect view_rect(size_);
1174 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect); 1164 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, rect);
1175 if (damaged_rect.IsEmpty()) 1165 if (damaged_rect.IsEmpty())
1176 return; 1166 return;
1177 1167
1178 // We may not need to schedule another call to DoDeferredUpdate. 1168 // We may not need to schedule another call to DoDeferredUpdate.
1179 if (invalidation_task_posted_) 1169 if (invalidation_task_posted_)
1180 return; 1170 return;
1181 1171
1182 // When GPU rendering, combine pending animations and invalidations into
1183 // a single update.
1184 if (is_accelerated_compositing_active_ &&
1185 animation_update_pending_ &&
1186 animation_timer_.IsRunning())
1187 return;
1188
1189 // Perform updating asynchronously. This serves two purposes: 1172 // Perform updating asynchronously. This serves two purposes:
1190 // 1) Ensures that we call WebView::Paint without a bunch of other junk 1173 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1191 // on the call stack. 1174 // on the call stack.
1192 // 2) Allows us to collect more damage rects before painting to help coalesce 1175 // 2) Allows us to collect more damage rects before painting to help coalesce
1193 // the work that we will need to do. 1176 // the work that we will need to do.
1194 invalidation_task_posted_ = true; 1177 invalidation_task_posted_ = true;
1195 base::MessageLoop::current()->PostTask( 1178 base::MessageLoop::current()->PostTask(
1196 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); 1179 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
1197 } 1180 }
1198 1181
1199 void RenderWidget::didScrollRect(int dx, int dy, 1182 void RenderWidget::didScrollRect(int dx, int dy,
1200 const WebRect& clip_rect) { 1183 const WebRect& clip_rect) {
1201 // Drop scrolls on the floor when we are in compositing mode. 1184 // Drop scrolls on the floor when we are in compositing mode.
1202 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place. 1185 // TODO(nduca): stop WebViewImpl from sending scrolls in the first place.
1203 if (is_accelerated_compositing_active_) 1186 if (is_accelerated_compositing_active_)
1204 return; 1187 return;
1205 1188
1206 // The scrolled rect might be outside the bounds of the view. 1189 // The scrolled rect might be outside the bounds of the view.
1207 gfx::Rect view_rect(size_); 1190 gfx::Rect view_rect(size_);
1208 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect); 1191 gfx::Rect damaged_rect = gfx::IntersectRects(view_rect, clip_rect);
1209 if (damaged_rect.IsEmpty()) 1192 if (damaged_rect.IsEmpty())
1210 return; 1193 return;
1211 1194
1212 // We may not need to schedule another call to DoDeferredUpdate. 1195 // We may not need to schedule another call to DoDeferredUpdate.
1213 if (invalidation_task_posted_) 1196 if (invalidation_task_posted_)
1214 return; 1197 return;
1215 1198
1216 // When GPU rendering, combine pending animations and invalidations into
1217 // a single update.
1218 if (is_accelerated_compositing_active_ &&
1219 animation_update_pending_ &&
1220 animation_timer_.IsRunning())
1221 return;
1222
1223 // Perform updating asynchronously. This serves two purposes: 1199 // Perform updating asynchronously. This serves two purposes:
1224 // 1) Ensures that we call WebView::Paint without a bunch of other junk 1200 // 1) Ensures that we call WebView::Paint without a bunch of other junk
1225 // on the call stack. 1201 // on the call stack.
1226 // 2) Allows us to collect more damage rects before painting to help coalesce 1202 // 2) Allows us to collect more damage rects before painting to help coalesce
1227 // the work that we will need to do. 1203 // the work that we will need to do.
1228 invalidation_task_posted_ = true; 1204 invalidation_task_posted_ = true;
1229 base::MessageLoop::current()->PostTask( 1205 base::MessageLoop::current()->PostTask(
1230 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this)); 1206 FROM_HERE, base::Bind(&RenderWidget::InvalidationCallback, this));
1231 } 1207 }
1232 1208
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 // TODO(nduca): replace with something a little less hacky. The reason this 1353 // TODO(nduca): replace with something a little less hacky. The reason this
1378 // hack is still used is because the Invalidate-DoDeferredUpdate loop 1354 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1379 // contains a lot of host-renderer synchronization logic that is still 1355 // contains a lot of host-renderer synchronization logic that is still
1380 // important for the accelerated compositing case. The option of simply 1356 // important for the accelerated compositing case. The option of simply
1381 // duplicating all that code is less desirable than "faking out" the 1357 // duplicating all that code is less desirable than "faking out" the
1382 // invalidation path using a magical damage rect. 1358 // invalidation path using a magical damage rect.
1383 didInvalidateRect(WebRect(0, 0, 1, 1)); 1359 didInvalidateRect(WebRect(0, 0, 1, 1));
1384 } 1360 }
1385 } 1361 }
1386 1362
1387 void RenderWidget::scheduleAnimation() {
1388 if (animation_update_pending_)
1389 return;
1390
1391 TRACE_EVENT0("gpu", "RenderWidget::scheduleAnimation");
1392 animation_update_pending_ = true;
1393 if (!animation_timer_.IsRunning()) {
1394 animation_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(0), this,
1395 &RenderWidget::AnimationCallback);
1396 }
1397 }
1398
1399 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) { 1363 void RenderWidget::didChangeCursor(const WebCursorInfo& cursor_info) {
1400 // TODO(darin): Eliminate this temporary. 1364 // TODO(darin): Eliminate this temporary.
1401 WebCursor cursor; 1365 WebCursor cursor;
1402 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info); 1366 InitializeCursorFromWebKitCursorInfo(&cursor, cursor_info);
1403 // Only send a SetCursor message if we need to make a change. 1367 // Only send a SetCursor message if we need to make a change.
1404 if (!current_cursor_.IsEqual(cursor)) { 1368 if (!current_cursor_.IsEqual(cursor)) {
1405 current_cursor_ = cursor; 1369 current_cursor_ = cursor;
1406 Send(new ViewHostMsg_SetCursor(routing_id_, cursor)); 1370 Send(new ViewHostMsg_SetCursor(routing_id_, cursor));
1407 } 1371 }
1408 } 1372 }
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
2234 2198
2235 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2199 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2236 swapped_out_frames_.AddObserver(frame); 2200 swapped_out_frames_.AddObserver(frame);
2237 } 2201 }
2238 2202
2239 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { 2203 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) {
2240 swapped_out_frames_.RemoveObserver(frame); 2204 swapped_out_frames_.RemoveObserver(frame);
2241 } 2205 }
2242 2206
2243 } // namespace content 2207 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698