OLD | NEW |
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_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/l10n_util_win.h" | 8 #include "app/l10n_util_win.h" |
9 #include "app/resource_bundle.h" | 9 #include "app/resource_bundle.h" |
10 #include "app/win/scoped_prop.h" | 10 #include "app/win/scoped_prop.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/i18n/rtl.h" | 12 #include "base/i18n/rtl.h" |
13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
14 #include "base/process_util.h" | 14 #include "base/process_util.h" |
15 #include "base/scoped_comptr_win.h" | 15 #include "base/scoped_comptr_win.h" |
16 #include "base/thread.h" | 16 #include "base/thread.h" |
17 #include "base/win_util.h" | 17 #include "base/win_util.h" |
18 #include "chrome/browser/accessibility/browser_accessibility_win.h" | 18 #include "chrome/browser/accessibility/browser_accessibility_win.h" |
19 #include "chrome/browser/accessibility/browser_accessibility_manager.h" | 19 #include "chrome/browser/accessibility/browser_accessibility_manager.h" |
20 #include "chrome/browser/accessibility/browser_accessibility_state.h" | 20 #include "chrome/browser/accessibility/browser_accessibility_state.h" |
21 #include "chrome/browser/browser_process.h" | 21 #include "chrome/browser/browser_process.h" |
22 #include "chrome/browser/browser_thread.h" | 22 #include "chrome/browser/browser_thread.h" |
23 #include "chrome/browser/browser_trial.h" | 23 #include "chrome/browser/browser_trial.h" |
24 #include "chrome/browser/plugin_process_host.h" | 24 #include "chrome/browser/plugin_process_host.h" |
25 #include "chrome/browser/renderer_host/backing_store.h" | 25 #include "chrome/browser/renderer_host/backing_store.h" |
26 #include "chrome/browser/renderer_host/backing_store_win.h" | 26 #include "chrome/browser/renderer_host/backing_store_win.h" |
27 #include "chrome/browser/renderer_host/gpu_view_host.h" | |
28 #include "chrome/browser/renderer_host/render_process_host.h" | 27 #include "chrome/browser/renderer_host/render_process_host.h" |
29 #include "chrome/browser/renderer_host/render_widget_host.h" | 28 #include "chrome/browser/renderer_host/render_widget_host.h" |
30 #include "chrome/common/chrome_constants.h" | 29 #include "chrome/common/chrome_constants.h" |
31 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/native_web_keyboard_event.h" | 31 #include "chrome/common/native_web_keyboard_event.h" |
33 #include "chrome/common/notification_service.h" | 32 #include "chrome/common/notification_service.h" |
34 #include "chrome/common/plugin_messages.h" | 33 #include "chrome/common/plugin_messages.h" |
35 #include "chrome/common/render_messages.h" | 34 #include "chrome/common/render_messages.h" |
36 #include "gfx/canvas.h" | 35 #include "gfx/canvas.h" |
37 #include "gfx/canvas_skia.h" | 36 #include "gfx/canvas_skia.h" |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 Create(parent); // ATL function to create the window. | 307 Create(parent); // ATL function to create the window. |
309 | 308 |
310 // Add a property indicating that a particular renderer is associated with | 309 // Add a property indicating that a particular renderer is associated with |
311 // this window. Used by the GPU process to validate window handles it | 310 // this window. Used by the GPU process to validate window handles it |
312 // receives from renderer processes. | 311 // receives from renderer processes. |
313 int renderer_id = render_widget_host_->process()->id(); | 312 int renderer_id = render_widget_host_->process()->id(); |
314 props_.push_back( | 313 props_.push_back( |
315 new app::win::ScopedProp(m_hWnd, | 314 new app::win::ScopedProp(m_hWnd, |
316 chrome::kChromiumRendererIdProperty, | 315 chrome::kChromiumRendererIdProperty, |
317 reinterpret_cast<HANDLE>(renderer_id))); | 316 reinterpret_cast<HANDLE>(renderer_id))); |
318 | |
319 // Uncommenting this will enable experimental out-of-process painting. | |
320 // Contact brettw for more, | |
321 // gpu_view_host_.reset(new GpuViewHost(render_widget_host_, m_hWnd)); | |
322 } | 317 } |
323 | 318 |
324 /////////////////////////////////////////////////////////////////////////////// | 319 /////////////////////////////////////////////////////////////////////////////// |
325 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 320 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
326 | 321 |
327 void RenderWidgetHostViewWin::InitAsPopup( | 322 void RenderWidgetHostViewWin::InitAsPopup( |
328 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 323 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
329 parent_hwnd_ = parent_host_view->GetNativeView(); | 324 parent_hwnd_ = parent_host_view->GetNativeView(); |
330 close_on_deactivate_ = true; | 325 close_on_deactivate_ = true; |
331 Create(parent_hwnd_, NULL, NULL, WS_POPUP, WS_EX_TOOLWINDOW); | 326 Create(parent_hwnd_, NULL, NULL, WS_POPUP, WS_EX_TOOLWINDOW); |
(...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 // within the same link/image/etc doesn't cause the tooltip to re-appear. | 779 // within the same link/image/etc doesn't cause the tooltip to re-appear. |
785 if (!tooltip_showing_) { | 780 if (!tooltip_showing_) { |
786 if (::IsWindow(tooltip_hwnd_)) | 781 if (::IsWindow(tooltip_hwnd_)) |
787 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); | 782 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); |
788 } | 783 } |
789 } | 784 } |
790 } | 785 } |
791 | 786 |
792 BackingStore* RenderWidgetHostViewWin::AllocBackingStore( | 787 BackingStore* RenderWidgetHostViewWin::AllocBackingStore( |
793 const gfx::Size& size) { | 788 const gfx::Size& size) { |
794 if (gpu_view_host_.get()) | |
795 return gpu_view_host_->CreateBackingStore(size); | |
796 return new BackingStoreWin(render_widget_host_, size); | 789 return new BackingStoreWin(render_widget_host_, size); |
797 } | 790 } |
798 | 791 |
799 VideoLayer* RenderWidgetHostViewWin::AllocVideoLayer( | |
800 const gfx::Size& size) { | |
801 NOTIMPLEMENTED(); | |
802 return NULL; | |
803 } | |
804 | |
805 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { | 792 void RenderWidgetHostViewWin::SetBackground(const SkBitmap& background) { |
806 RenderWidgetHostView::SetBackground(background); | 793 RenderWidgetHostView::SetBackground(background); |
807 Send(new ViewMsg_SetBackground(render_widget_host_->routing_id(), | 794 Send(new ViewMsg_SetBackground(render_widget_host_->routing_id(), |
808 background)); | 795 background)); |
809 } | 796 } |
810 | 797 |
811 bool RenderWidgetHostViewWin::ContainsNativeView( | 798 bool RenderWidgetHostViewWin::ContainsNativeView( |
812 gfx::NativeView native_view) const { | 799 gfx::NativeView native_view) const { |
813 if (m_hWnd == native_view) | 800 if (m_hWnd == native_view) |
814 return true; | 801 return true; |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
883 | 870 |
884 props_.reset(); | 871 props_.reset(); |
885 | 872 |
886 ResetTooltip(); | 873 ResetTooltip(); |
887 TrackMouseLeave(false); | 874 TrackMouseLeave(false); |
888 } | 875 } |
889 | 876 |
890 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { | 877 void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
891 DCHECK(render_widget_host_->process()->HasConnection()); | 878 DCHECK(render_widget_host_->process()->HasConnection()); |
892 | 879 |
893 if (gpu_view_host_.get()) { | |
894 // When we're proxying painting, we don't actually display the web page | |
895 // ourselves. We clear it white in case the proxy window isn't visible | |
896 // yet we won't show gibberish. | |
897 CPaintDC paint_dc(m_hWnd); | |
898 FillRect(paint_dc.m_hDC, &paint_dc.m_ps.rcPaint, | |
899 static_cast<HBRUSH>(GetStockObject(WHITE_BRUSH))); | |
900 return; | |
901 } | |
902 | |
903 // If the GPU process is rendering directly into the View, | 880 // If the GPU process is rendering directly into the View, |
904 // call the compositor directly. | 881 // call the compositor directly. |
905 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); | 882 RenderWidgetHost* render_widget_host = GetRenderWidgetHost(); |
906 if (render_widget_host->is_gpu_rendering_active()) { | 883 if (render_widget_host->is_gpu_rendering_active()) { |
907 // We initialize paint_dc here so that BeginPaint()/EndPaint() | 884 // We initialize paint_dc here so that BeginPaint()/EndPaint() |
908 // get called to validate the region. | 885 // get called to validate the region. |
909 CPaintDC paint_dc(m_hWnd); | 886 CPaintDC paint_dc(m_hWnd); |
910 render_widget_host_->ScheduleComposite(); | 887 render_widget_host_->ScheduleComposite(); |
911 return; | 888 return; |
912 } | 889 } |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1709 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( | 1686 RenderWidgetHostView::GetRenderWidgetHostViewFromNativeView( |
1710 gfx::NativeView native_view) { | 1687 gfx::NativeView native_view) { |
1711 if (::IsWindow(native_view)) { | 1688 if (::IsWindow(native_view)) { |
1712 HANDLE raw_render_host_view = ::GetProp(native_view, | 1689 HANDLE raw_render_host_view = ::GetProp(native_view, |
1713 kRenderWidgetHostViewKey); | 1690 kRenderWidgetHostViewKey); |
1714 if (raw_render_host_view) | 1691 if (raw_render_host_view) |
1715 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); | 1692 return reinterpret_cast<RenderWidgetHostView*>(raw_render_host_view); |
1716 } | 1693 } |
1717 return NULL; | 1694 return NULL; |
1718 } | 1695 } |
OLD | NEW |