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

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

Issue 11264058: Disable force compositing mode when disabling compositing, re-enter in DoDeferredUpdate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix threaded mode Created 8 years, 1 month 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/glue/webpreferences.cc » ('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 "content/common/swapped_out_messages.h" 17 #include "content/common/swapped_out_messages.h"
18 #include "content/common/view_messages.h" 18 #include "content/common/view_messages.h"
19 #include "content/public/common/compositor_util.h"
19 #include "content/public/common/content_switches.h" 20 #include "content/public/common/content_switches.h"
20 #include "content/renderer/render_process.h" 21 #include "content/renderer/render_process.h"
21 #include "content/renderer/render_thread_impl.h" 22 #include "content/renderer/render_thread_impl.h"
22 #include "content/renderer/renderer_webkitplatformsupport_impl.h" 23 #include "content/renderer/renderer_webkitplatformsupport_impl.h"
23 #include "ipc/ipc_sync_message.h" 24 #include "ipc/ipc_sync_message.h"
24 #include "skia/ext/platform_canvas.h" 25 #include "skia/ext/platform_canvas.h"
25 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h" 26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
26 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h" 27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebHelperPlugin.h"
27 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h" 28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPagePopup.h"
28 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h" 29 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 200
200 // This is used to complete pending inits and non-pending inits. For non- 201 // This is used to complete pending inits and non-pending inits. For non-
201 // pending cases, the parent will be the same as the current parent. This 202 // pending cases, the parent will be the same as the current parent. This
202 // indicates we do not need to reparent or anything. 203 // indicates we do not need to reparent or anything.
203 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) { 204 void RenderWidget::CompleteInit(gfx::NativeViewId parent_hwnd) {
204 DCHECK(routing_id_ != MSG_ROUTING_NONE); 205 DCHECK(routing_id_ != MSG_ROUTING_NONE);
205 206
206 host_window_ = parent_hwnd; 207 host_window_ = parent_hwnd;
207 host_window_set_ = true; 208 host_window_set_ = true;
208 209
209 #if WEBWIDGET_HAS_SETCOMPOSITORSURFACEREADY 210 if (webwidget_) {
210 if (webwidget_) 211 webwidget_->setCompositorSurfaceReady();
211 webwidget_->setCompositorSurfaceReady(); 212 if (IsThreadedCompositingEnabled())
212 #endif 213 webwidget_->enterForceCompositingMode(true);
214 }
213 DoDeferredUpdate(); 215 DoDeferredUpdate();
214 216
215 Send(new ViewHostMsg_RenderViewReady(routing_id_)); 217 Send(new ViewHostMsg_RenderViewReady(routing_id_));
216 } 218 }
217 219
218 void RenderWidget::SetSwappedOut(bool is_swapped_out) { 220 void RenderWidget::SetSwappedOut(bool is_swapped_out) {
219 // We should only toggle between states. 221 // We should only toggle between states.
220 DCHECK(is_swapped_out_ != is_swapped_out); 222 DCHECK(is_swapped_out_ != is_swapped_out);
221 is_swapped_out_ = is_swapped_out; 223 is_swapped_out_ = is_swapped_out;
222 224
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 461 }
460 462
461 // Continue painting if necessary... 463 // Continue painting if necessary...
462 DoDeferredUpdateAndSendInputAck(); 464 DoDeferredUpdateAndSendInputAck();
463 } 465 }
464 466
465 bool RenderWidget::SupportsAsynchronousSwapBuffers() { 467 bool RenderWidget::SupportsAsynchronousSwapBuffers() {
466 return false; 468 return false;
467 } 469 }
468 470
471 bool RenderWidget::ForceCompositingModeEnabled() {
472 return false;
473 }
474
469 void RenderWidget::OnSwapBuffersAborted() { 475 void RenderWidget::OnSwapBuffersAborted() {
470 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted"); 476 TRACE_EVENT0("renderer", "RenderWidget::OnSwapBuffersAborted");
471 while (!updates_pending_swap_.empty()) { 477 while (!updates_pending_swap_.empty()) {
472 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front(); 478 ViewHostMsg_UpdateRect* msg = updates_pending_swap_.front();
473 updates_pending_swap_.pop_front(); 479 updates_pending_swap_.pop_front();
474 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate 480 // msg can be NULL if the swap doesn't correspond to an DoDeferredUpdate
475 // compositing pass, hence doesn't require an UpdateRect message. 481 // compositing pass, hence doesn't require an UpdateRect message.
476 if (msg) 482 if (msg)
477 Send(msg); 483 Send(msg);
478 } 484 }
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 UpdateSelectionBounds(); 902 UpdateSelectionBounds();
897 903
898 // Suppress painting if nothing is dirty. This has to be done after updating 904 // Suppress painting if nothing is dirty. This has to be done after updating
899 // animations running layout as these may generate further invalidations. 905 // animations running layout as these may generate further invalidations.
900 if (!paint_aggregator_.HasPendingUpdate()) { 906 if (!paint_aggregator_.HasPendingUpdate()) {
901 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate"); 907 TRACE_EVENT0("renderer", "EarlyOut_NoPendingUpdate");
902 webwidget_->instrumentCancelFrame(); 908 webwidget_->instrumentCancelFrame();
903 return; 909 return;
904 } 910 }
905 911
912 if (!is_accelerated_compositing_active_ &&
913 !IsThreadedCompositingEnabled() &&
914 ForceCompositingModeEnabled()) {
915 webwidget_->enterForceCompositingMode(true);
916 }
917
906 if (!last_do_deferred_update_time_.is_null()) { 918 if (!last_do_deferred_update_time_.is_null()) {
907 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_; 919 base::TimeDelta delay = frame_begin_ticks - last_do_deferred_update_time_;
908 if (is_accelerated_compositing_active_) { 920 if (is_accelerated_compositing_active_) {
909 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay", 921 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.AccelDoDeferredUpdateDelay",
910 delay, 922 delay,
911 base::TimeDelta::FromMilliseconds(1), 923 base::TimeDelta::FromMilliseconds(1),
912 base::TimeDelta::FromMilliseconds(120), 924 base::TimeDelta::FromMilliseconds(120),
913 60); 925 60);
914 } else { 926 } else {
915 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay", 927 UMA_HISTOGRAM_CUSTOM_TIMES("Renderer4.SoftwareDoDeferredUpdateDelay",
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
1055 1067
1056 // If we're software rendering then we're done initiating the paint. 1068 // If we're software rendering then we're done initiating the paint.
1057 if (!is_accelerated_compositing_active_) 1069 if (!is_accelerated_compositing_active_)
1058 DidInitiatePaint(); 1070 DidInitiatePaint();
1059 } 1071 }
1060 1072
1061 /////////////////////////////////////////////////////////////////////////////// 1073 ///////////////////////////////////////////////////////////////////////////////
1062 // WebWidgetClient 1074 // WebWidgetClient
1063 1075
1064 void RenderWidget::didInvalidateRect(const WebRect& rect) { 1076 void RenderWidget::didInvalidateRect(const WebRect& rect) {
1077 TRACE_EVENT2("renderer", "RenderWidget::didInvalidateRect",
1078 "width", rect.width, "height", rect.height);
1065 // The invalidated rect might be outside the bounds of the view. 1079 // The invalidated rect might be outside the bounds of the view.
1066 gfx::Rect view_rect(size_); 1080 gfx::Rect view_rect(size_);
1067 gfx::Rect damaged_rect = view_rect; 1081 gfx::Rect damaged_rect = view_rect;
1068 damaged_rect.Intersect(rect); 1082 damaged_rect.Intersect(rect);
1069 if (damaged_rect.IsEmpty()) 1083 if (damaged_rect.IsEmpty())
1070 return; 1084 return;
1071 1085
1072 paint_aggregator_.InvalidateRect(damaged_rect); 1086 paint_aggregator_.InvalidateRect(damaged_rect);
1073 1087
1074 // We may not need to schedule another call to DoDeferredUpdate. 1088 // We may not need to schedule another call to DoDeferredUpdate.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 1184
1171 void RenderWidget::didDeactivateCompositor() { 1185 void RenderWidget::didDeactivateCompositor() {
1172 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor"); 1186 TRACE_EVENT0("gpu", "RenderWidget::didDeactivateCompositor");
1173 1187
1174 is_accelerated_compositing_active_ = false; 1188 is_accelerated_compositing_active_ = false;
1175 Send(new ViewHostMsg_DidActivateAcceleratedCompositing( 1189 Send(new ViewHostMsg_DidActivateAcceleratedCompositing(
1176 routing_id_, is_accelerated_compositing_active_)); 1190 routing_id_, is_accelerated_compositing_active_));
1177 1191
1178 if (using_asynchronous_swapbuffers_) 1192 if (using_asynchronous_swapbuffers_)
1179 using_asynchronous_swapbuffers_ = false; 1193 using_asynchronous_swapbuffers_ = false;
1194
1195 // In single-threaded mode, we exit force compositing mode and re-enter in
1196 // DoDeferredUpdate() if appropriate. In threaded compositing mode,
1197 // DoDeferredUpdate() is bypassed and WebKit is responsible for exiting and
1198 // entering force compositing mode at the appropriate times.
1199 if (!IsThreadedCompositingEnabled())
1200 webwidget_->enterForceCompositingMode(false);
1180 } 1201 }
1181 1202
1182 void RenderWidget::willBeginCompositorFrame() { 1203 void RenderWidget::willBeginCompositorFrame() {
1183 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame"); 1204 TRACE_EVENT0("gpu", "RenderWidget::willBeginCompositorFrame");
1184 1205
1185 DCHECK(RenderThreadImpl::current()->compositor_thread()); 1206 DCHECK(RenderThreadImpl::current()->compositor_thread());
1186 1207
1187 // The following two can result in further layout and possibly 1208 // The following two can result in further layout and possibly
1188 // enable GPU acceleration so they need to be called before any painting 1209 // enable GPU acceleration so they need to be called before any painting
1189 // is done. 1210 // is done.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 params.scroll_offset = GetScrollOffset(); 1251 params.scroll_offset = GetScrollOffset();
1231 params.needs_ack = false; 1252 params.needs_ack = false;
1232 params.scale_factor = device_scale_factor_; 1253 params.scale_factor = device_scale_factor_;
1233 1254
1234 Send(new ViewHostMsg_UpdateRect(routing_id_, params)); 1255 Send(new ViewHostMsg_UpdateRect(routing_id_, params));
1235 next_paint_flags_ = 0; 1256 next_paint_flags_ = 0;
1236 need_update_rect_for_auto_resize_ = false; 1257 need_update_rect_for_auto_resize_ = false;
1237 } 1258 }
1238 1259
1239 void RenderWidget::scheduleComposite() { 1260 void RenderWidget::scheduleComposite() {
1261 TRACE_EVENT0("gpu", "RenderWidget::scheduleComposite");
1240 if (WebWidgetHandlesCompositorScheduling()) { 1262 if (WebWidgetHandlesCompositorScheduling()) {
1241 webwidget_->composite(false); 1263 webwidget_->composite(false);
1242 } else { 1264 } else {
1243 // TODO(nduca): replace with something a little less hacky. The reason this 1265 // TODO(nduca): replace with something a little less hacky. The reason this
1244 // hack is still used is because the Invalidate-DoDeferredUpdate loop 1266 // hack is still used is because the Invalidate-DoDeferredUpdate loop
1245 // contains a lot of host-renderer synchronization logic that is still 1267 // contains a lot of host-renderer synchronization logic that is still
1246 // important for the accelerated compositing case. The option of simply 1268 // important for the accelerated compositing case. The option of simply
1247 // duplicating all that code is less desirable than "faking out" the 1269 // duplicating all that code is less desirable than "faking out" the
1248 // invalidation path using a magical damage rect. 1270 // invalidation path using a magical damage rect.
1249 didInvalidateRect(WebRect(0, 0, 1, 1)); 1271 didInvalidateRect(WebRect(0, 0, 1, 1));
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
1902 1924
1903 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { 1925 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) {
1904 return false; 1926 return false;
1905 } 1927 }
1906 1928
1907 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const { 1929 bool RenderWidget::WebWidgetHandlesCompositorScheduling() const {
1908 return false; 1930 return false;
1909 } 1931 }
1910 1932
1911 } // namespace content 1933 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | webkit/glue/webpreferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698