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

Side by Side Diff: chrome/browser/renderer_host/render_widget_host.cc

Issue 4815001: Use inner HWND for accelerated rendering on windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/renderer_host/render_widget_host.h" 5 #include "chrome/browser/renderer_host/render_widget_host.h"
6 6
7 #include "app/keyboard_codes.h" 7 #include "app/keyboard_codes.h"
8 #include "base/auto_reset.h" 8 #include "base/auto_reset.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process, 70 RenderWidgetHost::RenderWidgetHost(RenderProcessHost* process,
71 int routing_id) 71 int routing_id)
72 : renderer_initialized_(false), 72 : renderer_initialized_(false),
73 renderer_accessible_(false), 73 renderer_accessible_(false),
74 view_(NULL), 74 view_(NULL),
75 process_(process), 75 process_(process),
76 painting_observer_(NULL), 76 painting_observer_(NULL),
77 routing_id_(routing_id), 77 routing_id_(routing_id),
78 is_loading_(false), 78 is_loading_(false),
79 is_hidden_(false), 79 is_hidden_(false),
80 is_gpu_rendering_active_(false), 80 is_accelerated_compositing_active_(false),
81 repaint_ack_pending_(false), 81 repaint_ack_pending_(false),
82 resize_ack_pending_(false), 82 resize_ack_pending_(false),
83 mouse_move_pending_(false), 83 mouse_move_pending_(false),
84 mouse_wheel_pending_(false), 84 mouse_wheel_pending_(false),
85 needs_repainting_on_restore_(false), 85 needs_repainting_on_restore_(false),
86 is_unresponsive_(false), 86 is_unresponsive_(false),
87 in_get_backing_store_(false), 87 in_get_backing_store_(false),
88 view_being_painted_(false), 88 view_being_painted_(false),
89 ignore_input_events_(false), 89 ignore_input_events_(false),
90 text_direction_updated_(false), 90 text_direction_updated_(false),
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck) 150 IPC_MESSAGE_HANDLER(ViewHostMsg_PaintAtSize_ACK, OnMsgPaintAtSizeAck)
151 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect) 151 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnMsgUpdateRect)
152 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck) 152 IPC_MESSAGE_HANDLER(ViewHostMsg_HandleInputEvent_ACK, OnMsgInputEventAck)
153 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus) 153 IPC_MESSAGE_HANDLER(ViewHostMsg_Focus, OnMsgFocus)
154 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur) 154 IPC_MESSAGE_HANDLER(ViewHostMsg_Blur, OnMsgBlur)
155 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor) 155 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnMsgSetCursor)
156 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateTextInputState, 156 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeUpdateTextInputState,
157 OnMsgImeUpdateTextInputState) 157 OnMsgImeUpdateTextInputState)
158 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition, 158 IPC_MESSAGE_HANDLER(ViewHostMsg_ImeCancelComposition,
159 OnMsgImeCancelComposition) 159 OnMsgImeCancelComposition)
160 IPC_MESSAGE_HANDLER(ViewHostMsg_GpuRenderingActivated, 160 IPC_MESSAGE_HANDLER(ViewHostMsg_DidActivateAcceleratedCompositing,
161 OnMsgGpuRenderingActivated) 161 OnMsgDidActivateAcceleratedCompositing)
162 #if defined(OS_MACOSX) 162 #if defined(OS_MACOSX)
163 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo) 163 IPC_MESSAGE_HANDLER(ViewHostMsg_GetScreenInfo, OnMsgGetScreenInfo)
164 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect) 164 IPC_MESSAGE_HANDLER(ViewHostMsg_GetWindowRect, OnMsgGetWindowRect)
165 IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect) 165 IPC_MESSAGE_HANDLER(ViewHostMsg_GetRootWindowRect, OnMsgGetRootWindowRect)
166 IPC_MESSAGE_HANDLER(ViewHostMsg_SetPluginImeEnabled, 166 IPC_MESSAGE_HANDLER(ViewHostMsg_SetPluginImeEnabled,
167 OnMsgSetPluginImeEnabled) 167 OnMsgSetPluginImeEnabled)
168 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateFakePluginWindowHandle, 168 IPC_MESSAGE_HANDLER(ViewHostMsg_AllocateFakePluginWindowHandle,
169 OnAllocateFakePluginWindowHandle) 169 OnAllocateFakePluginWindowHandle)
170 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyFakePluginWindowHandle, 170 IPC_MESSAGE_HANDLER(ViewHostMsg_DestroyFakePluginWindowHandle,
171 OnDestroyFakePluginWindowHandle) 171 OnDestroyFakePluginWindowHandle)
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 return; 225 return;
226 is_hidden_ = false; 226 is_hidden_ = false;
227 227
228 BackingStore* backing_store = BackingStoreManager::Lookup(this); 228 BackingStore* backing_store = BackingStoreManager::Lookup(this);
229 // If we already have a backing store for this widget, then we don't need to 229 // If we already have a backing store for this widget, then we don't need to
230 // repaint on restore _unless_ we know that our backing store is invalid. 230 // repaint on restore _unless_ we know that our backing store is invalid.
231 // When accelerated compositing is on, we must always repaint, even when 231 // When accelerated compositing is on, we must always repaint, even when
232 // the backing store exists. 232 // the backing store exists.
233 bool needs_repainting; 233 bool needs_repainting;
234 if (needs_repainting_on_restore_ || !backing_store || 234 if (needs_repainting_on_restore_ || !backing_store ||
235 is_gpu_rendering_active()) { 235 is_accelerated_compositing_active()) {
236 needs_repainting = true; 236 needs_repainting = true;
237 needs_repainting_on_restore_ = false; 237 needs_repainting_on_restore_ = false;
238 } else { 238 } else {
239 needs_repainting = false; 239 needs_repainting = false;
240 } 240 }
241 Send(new ViewMsg_WasRestored(routing_id_, needs_repainting)); 241 Send(new ViewMsg_WasRestored(routing_id_, needs_repainting));
242 242
243 process_->WidgetRestored(); 243 process_->WidgetRestored();
244 244
245 bool is_visible = true; 245 bool is_visible = true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 if (!view_) 395 if (!view_)
396 return NULL; 396 return NULL;
397 return view_->AllocBackingStore(size); 397 return view_->AllocBackingStore(size);
398 } 398 }
399 399
400 void RenderWidgetHost::DonePaintingToBackingStore() { 400 void RenderWidgetHost::DonePaintingToBackingStore() {
401 Send(new ViewMsg_UpdateRect_ACK(routing_id())); 401 Send(new ViewMsg_UpdateRect_ACK(routing_id()));
402 } 402 }
403 403
404 void RenderWidgetHost::ScheduleComposite() { 404 void RenderWidgetHost::ScheduleComposite() {
405 DCHECK(!is_hidden_ || !is_gpu_rendering_active_) << 405 if (is_hidden_ || !is_accelerated_compositing_active_) {
406 "ScheduleCompositeAndSync called while hidden!"; 406 return;
407 }
407 408
408 // Send out a request to the renderer to paint the view if required. 409 // Send out a request to the renderer to paint the view if required.
409 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) { 410 if (!repaint_ack_pending_ && !resize_ack_pending_ && !view_being_painted_) {
410 repaint_start_time_ = TimeTicks::Now(); 411 repaint_start_time_ = TimeTicks::Now();
411 repaint_ack_pending_ = true; 412 repaint_ack_pending_ = true;
412 Send(new ViewMsg_Repaint(routing_id_, current_size_)); 413 Send(new ViewMsg_Repaint(routing_id_, current_size_));
413 } 414 }
414 415
415 // When we have asked the RenderWidget to resize, and we are still waiting on 416 // When we have asked the RenderWidget to resize, and we are still waiting on
416 // a response, block for a little while to see if we can't get a response. 417 // a response, block for a little while to see if we can't get a response.
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 652
652 // Reset some fields in preparation for recovering from a crash. 653 // Reset some fields in preparation for recovering from a crash.
653 resize_ack_pending_ = false; 654 resize_ack_pending_ = false;
654 repaint_ack_pending_ = false; 655 repaint_ack_pending_ = false;
655 656
656 in_flight_size_.SetSize(0, 0); 657 in_flight_size_.SetSize(0, 0);
657 in_flight_reserved_rect_.SetRect(0, 0, 0, 0); 658 in_flight_reserved_rect_.SetRect(0, 0, 0, 0);
658 current_size_.SetSize(0, 0); 659 current_size_.SetSize(0, 0);
659 current_reserved_rect_.SetRect(0, 0, 0, 0); 660 current_reserved_rect_.SetRect(0, 0, 0, 0);
660 is_hidden_ = false; 661 is_hidden_ = false;
661 is_gpu_rendering_active_ = false; 662 is_accelerated_compositing_active_ = false;
662 663
663 if (view_) { 664 if (view_) {
664 view_->RenderViewGone(); 665 view_->RenderViewGone();
665 view_ = NULL; // The View should be deleted by RenderViewGone. 666 view_ = NULL; // The View should be deleted by RenderViewGone.
666 } 667 }
667 668
668 BackingStoreManager::RemoveBackingStore(this); 669 BackingStoreManager::RemoveBackingStore(this);
669 } 670 }
670 671
671 void RenderWidgetHost::UpdateTextDirection(WebTextDirection direction) { 672 void RenderWidgetHost::UpdateTextDirection(WebTextDirection direction) {
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); 826 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags);
826 if (is_repaint_ack) { 827 if (is_repaint_ack) {
827 repaint_ack_pending_ = false; 828 repaint_ack_pending_ = false;
828 TimeDelta delta = TimeTicks::Now() - repaint_start_time_; 829 TimeDelta delta = TimeTicks::Now() - repaint_start_time_;
829 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta); 830 UMA_HISTOGRAM_TIMES("MPArch.RWH_RepaintDelta", delta);
830 } 831 }
831 832
832 DCHECK(!params.bitmap_rect.IsEmpty()); 833 DCHECK(!params.bitmap_rect.IsEmpty());
833 DCHECK(!params.view_size.IsEmpty()); 834 DCHECK(!params.view_size.IsEmpty());
834 835
835 if (!is_gpu_rendering_active_) { 836 if (!is_accelerated_compositing_active_) {
836 const size_t size = params.bitmap_rect.height() * 837 const size_t size = params.bitmap_rect.height() *
837 params.bitmap_rect.width() * 4; 838 params.bitmap_rect.width() * 4;
838 TransportDIB* dib = process_->GetTransportDIB(params.bitmap); 839 TransportDIB* dib = process_->GetTransportDIB(params.bitmap);
839 840
840 // If gpu process does painting, scroll_rect and copy_rects are always empty 841 // If gpu process does painting, scroll_rect and copy_rects are always empty
841 // and backing store is never used. 842 // and backing store is never used.
842 if (dib) { 843 if (dib) {
843 if (dib->size() < size) { 844 if (dib->size() < size) {
844 DLOG(WARNING) << "Transport DIB too small for given rectangle"; 845 DLOG(WARNING) << "Transport DIB too small for given rectangle";
845 process()->ReceivedBadMessage(ViewHostMsg_UpdateRect__ID); 846 process()->ReceivedBadMessage(ViewHostMsg_UpdateRect__ID);
(...skipping 26 matching lines...) Expand all
872 if (is_hidden_) 873 if (is_hidden_)
873 return; 874 return;
874 875
875 // Now paint the view. Watch out: it might be destroyed already. 876 // Now paint the view. Watch out: it might be destroyed already.
876 if (view_) { 877 if (view_) {
877 view_->MovePluginWindows(params.plugin_window_moves); 878 view_->MovePluginWindows(params.plugin_window_moves);
878 // The view_ pointer could be destroyed in the context of MovePluginWindows 879 // The view_ pointer could be destroyed in the context of MovePluginWindows
879 // which attempts to move the plugin windows and in the process could 880 // which attempts to move the plugin windows and in the process could
880 // dispatch other window messages which could cause the view to be 881 // dispatch other window messages which could cause the view to be
881 // destroyed. 882 // destroyed.
882 if (view_ && !is_gpu_rendering_active_) { 883 if (view_ && !is_accelerated_compositing_active_) {
883 view_being_painted_ = true; 884 view_being_painted_ = true;
884 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy, 885 view_->DidUpdateBackingStore(params.scroll_rect, params.dx, params.dy,
885 params.copy_rects); 886 params.copy_rects);
886 view_being_painted_ = false; 887 view_being_painted_ = false;
887 } 888 }
888 } 889 }
889 890
890 if (paint_observer_.get()) 891 if (paint_observer_.get())
891 paint_observer_->RenderWidgetHostDidPaint(this); 892 paint_observer_->RenderWidgetHostDidPaint(this);
892 893
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 const gfx::Rect& caret_rect) { 971 const gfx::Rect& caret_rect) {
971 if (view_) 972 if (view_)
972 view_->ImeUpdateTextInputState(type, caret_rect); 973 view_->ImeUpdateTextInputState(type, caret_rect);
973 } 974 }
974 975
975 void RenderWidgetHost::OnMsgImeCancelComposition() { 976 void RenderWidgetHost::OnMsgImeCancelComposition() {
976 if (view_) 977 if (view_)
977 view_->ImeCancelComposition(); 978 view_->ImeCancelComposition();
978 } 979 }
979 980
980 void RenderWidgetHost::OnMsgGpuRenderingActivated(bool activated) { 981 void RenderWidgetHost::OnMsgDidActivateAcceleratedCompositing(bool activated) {
981 #if defined(OS_MACOSX) 982 #if defined(OS_MACOSX)
982 bool old_state = is_gpu_rendering_active_; 983 bool old_state = is_accelerated_compositing_active_;
983 #endif 984 #endif
984 is_gpu_rendering_active_ = activated; 985 is_accelerated_compositing_active_ = activated;
985 #if defined(OS_MACOSX) 986 #if defined(OS_MACOSX)
986 if (old_state != is_gpu_rendering_active_ && view_) 987 if (old_state != is_accelerated_compositing_active_ && view_)
987 view_->GpuRenderingStateDidChange(); 988 view_->GpuRenderingStateDidChange();
989 #elif defined(OS_WIN)
990 view_->ShowCompositorHostWindow(is_accelerated_compositing_active_);
988 #elif defined(TOOLKIT_USES_GTK) 991 #elif defined(TOOLKIT_USES_GTK)
989 view_->AcceleratedCompositingActivated(activated); 992 view_->AcceleratedCompositingActivated(activated);
990 #endif 993 #endif
991 } 994 }
992 995
993 #if defined(OS_MACOSX) 996 #if defined(OS_MACOSX)
994 997
995 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view, 998 void RenderWidgetHost::OnMsgGetScreenInfo(gfx::NativeViewId view,
996 WebScreenInfo* results) { 999 WebScreenInfo* results) {
997 gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL; 1000 gfx::NativeView native_view = view_ ? view_->GetNativeView() : NULL;
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 } 1085 }
1083 } 1086 }
1084 1087
1085 void RenderWidgetHost::OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id) { 1088 void RenderWidgetHost::OnMsgDestroyPluginContainer(gfx::PluginWindowHandle id) {
1086 if (view_) { 1089 if (view_) {
1087 view_->DestroyPluginContainer(id); 1090 view_->DestroyPluginContainer(id);
1088 } else { 1091 } else {
1089 NOTIMPLEMENTED(); 1092 NOTIMPLEMENTED();
1090 } 1093 }
1091 } 1094 }
1092
1093 #endif 1095 #endif
1094 1096
1095 void RenderWidgetHost::PaintBackingStoreRect( 1097 void RenderWidgetHost::PaintBackingStoreRect(
1096 TransportDIB::Id bitmap, 1098 TransportDIB::Id bitmap,
1097 const gfx::Rect& bitmap_rect, 1099 const gfx::Rect& bitmap_rect,
1098 const std::vector<gfx::Rect>& copy_rects, 1100 const std::vector<gfx::Rect>& copy_rects,
1099 const gfx::Size& view_size) { 1101 const gfx::Size& view_size) {
1100 // The view may be destroyed already. 1102 // The view may be destroyed already.
1101 if (!view_) 1103 if (!view_)
1102 return; 1104 return;
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1207 // of this key event. 1209 // of this key event.
1208 if (!processed && !is_hidden_ && !front_item.skip_in_browser) { 1210 if (!processed && !is_hidden_ && !front_item.skip_in_browser) {
1209 UnhandledKeyboardEvent(front_item); 1211 UnhandledKeyboardEvent(front_item);
1210 1212
1211 // WARNING: This RenderWidgetHost can be deallocated at this point 1213 // WARNING: This RenderWidgetHost can be deallocated at this point
1212 // (i.e. in the case of Ctrl+W, where the call to 1214 // (i.e. in the case of Ctrl+W, where the call to
1213 // UnhandledKeyboardEvent destroys this RenderWidgetHost). 1215 // UnhandledKeyboardEvent destroys this RenderWidgetHost).
1214 } 1216 }
1215 } 1217 }
1216 } 1218 }
OLDNEW
« no previous file with comments | « chrome/browser/renderer_host/render_widget_host.h ('k') | chrome/browser/renderer_host/render_widget_host_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698