OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
| 9 #include "base/bind.h" |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
11 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
12 #include "base/process_util.h" | 13 #include "base/process_util.h" |
13 #include "base/threading/thread.h" | 14 #include "base/threading/thread.h" |
14 #include "base/win/scoped_comptr.h" | 15 #include "base/win/scoped_comptr.h" |
15 #include "base/win/scoped_gdi_object.h" | 16 #include "base/win/scoped_gdi_object.h" |
16 #include "base/win/win_util.h" | 17 #include "base/win/win_util.h" |
17 #include "base/win/windows_version.h" | 18 #include "base/win/windows_version.h" |
18 #include "base/win/wrapped_window_proc.h" | 19 #include "base/win/wrapped_window_proc.h" |
19 #include "content/browser/accessibility/browser_accessibility_manager.h" | 20 #include "content/browser/accessibility/browser_accessibility_manager.h" |
20 #include "content/browser/accessibility/browser_accessibility_state.h" | 21 #include "content/browser/accessibility/browser_accessibility_state.h" |
21 #include "content/browser/accessibility/browser_accessibility_win.h" | 22 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 23 #include "content/browser/gpu/gpu_process_host.h" |
| 24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
22 #include "content/browser/plugin_process_host.h" | 25 #include "content/browser/plugin_process_host.h" |
23 #include "content/browser/renderer_host/backing_store.h" | 26 #include "content/browser/renderer_host/backing_store.h" |
24 #include "content/browser/renderer_host/backing_store_win.h" | 27 #include "content/browser/renderer_host/backing_store_win.h" |
25 #include "content/browser/renderer_host/render_process_host.h" | 28 #include "content/browser/renderer_host/render_process_host.h" |
26 #include "content/browser/renderer_host/render_widget_host.h" | 29 #include "content/browser/renderer_host/render_widget_host.h" |
| 30 #include "content/common/gpu/gpu_messages.h" |
27 #include "content/common/plugin_messages.h" | 31 #include "content/common/plugin_messages.h" |
28 #include "content/common/view_messages.h" | 32 #include "content/common/view_messages.h" |
29 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
30 #include "content/public/browser/content_browser_client.h" | 34 #include "content/public/browser/content_browser_client.h" |
31 #include "content/public/browser/native_web_keyboard_event.h" | 35 #include "content/public/browser/native_web_keyboard_event.h" |
32 #include "content/public/browser/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
33 #include "content/public/browser/notification_types.h" | 37 #include "content/public/browser/notification_types.h" |
34 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
35 #include "content/public/common/page_zoom.h" | 39 #include "content/public/common/page_zoom.h" |
36 #include "skia/ext/skia_utils_win.h" | 40 #include "skia/ext/skia_utils_win.h" |
(...skipping 10 matching lines...) Expand all Loading... |
47 #include "ui/gfx/canvas_skia.h" | 51 #include "ui/gfx/canvas_skia.h" |
48 #include "ui/gfx/gdi_util.h" | 52 #include "ui/gfx/gdi_util.h" |
49 #include "ui/gfx/rect.h" | 53 #include "ui/gfx/rect.h" |
50 #include "ui/gfx/screen.h" | 54 #include "ui/gfx/screen.h" |
51 #include "webkit/glue/webaccessibility.h" | 55 #include "webkit/glue/webaccessibility.h" |
52 #include "webkit/glue/webcursor.h" | 56 #include "webkit/glue/webcursor.h" |
53 #include "webkit/plugins/npapi/plugin_constants_win.h" | 57 #include "webkit/plugins/npapi/plugin_constants_win.h" |
54 #include "webkit/plugins/npapi/webplugin.h" | 58 #include "webkit/plugins/npapi/webplugin.h" |
55 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 59 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
56 | 60 |
| 61 #pragma comment(lib, "d3d9.lib") |
| 62 |
57 using base::TimeDelta; | 63 using base::TimeDelta; |
58 using base::TimeTicks; | 64 using base::TimeTicks; |
59 using content::BrowserThread; | 65 using content::BrowserThread; |
60 using ui::ViewProp; | 66 using ui::ViewProp; |
61 using WebKit::WebInputEvent; | 67 using WebKit::WebInputEvent; |
62 using WebKit::WebInputEventFactory; | 68 using WebKit::WebInputEventFactory; |
63 using WebKit::WebMouseEvent; | 69 using WebKit::WebMouseEvent; |
64 using WebKit::WebTextDirection; | 70 using WebKit::WebTextDirection; |
65 using webkit::npapi::WebPluginGeometry; | 71 using webkit::npapi::WebPluginGeometry; |
66 | 72 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 case WM_MBUTTONDOWN: | 202 case WM_MBUTTONDOWN: |
197 ::SendMessage(GetParent(window), message, wparam, lparam); | 203 ::SendMessage(GetParent(window), message, wparam, lparam); |
198 return 0; | 204 return 0; |
199 default: | 205 default: |
200 break; | 206 break; |
201 } | 207 } |
202 } | 208 } |
203 return ::DefWindowProc(window, message, wparam, lparam); | 209 return ::DefWindowProc(window, message, wparam, lparam); |
204 } | 210 } |
205 | 211 |
| 212 void SendToGpuProcessHost(int gpu_host_id, IPC::Message* message) { |
| 213 GpuProcessHost* gpu_process_host = GpuProcessHost::FromID(gpu_host_id); |
| 214 if (!gpu_process_host) { |
| 215 delete message; |
| 216 return; |
| 217 } |
| 218 |
| 219 gpu_process_host->Send(message); |
| 220 } |
| 221 |
| 222 void PostTaskOnIOThread(const tracked_objects::Location& from_here, |
| 223 base::Closure task) { |
| 224 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task); |
| 225 } |
| 226 |
206 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, | 227 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, |
207 content::PageZoom* zoom, | 228 content::PageZoom* zoom, |
208 POINT* zoom_center) { | 229 POINT* zoom_center) { |
209 static long start = 0; | 230 static long start = 0; |
210 static POINT zoom_first; | 231 static POINT zoom_first; |
211 | 232 |
212 if (gi.dwFlags == GF_BEGIN) { | 233 if (gi.dwFlags == GF_BEGIN) { |
213 start = gi.ullArguments; | 234 start = gi.ullArguments; |
214 zoom_first.x = gi.ptsLocation.x; | 235 zoom_first.x = gi.ptsLocation.x; |
215 zoom_first.y = gi.ptsLocation.y; | 236 zoom_first.y = gi.ptsLocation.y; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 last_pointer_down_location_(0) { | 338 last_pointer_down_location_(0) { |
318 render_widget_host_->SetView(this); | 339 render_widget_host_->SetView(this); |
319 registrar_.Add(this, | 340 registrar_.Add(this, |
320 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 341 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
321 content::NotificationService::AllBrowserContextsAndSources()); | 342 content::NotificationService::AllBrowserContextsAndSources()); |
322 } | 343 } |
323 | 344 |
324 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 345 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
325 UnlockMouse(); | 346 UnlockMouse(); |
326 ResetTooltip(); | 347 ResetTooltip(); |
| 348 |
| 349 if (accelerated_surface_) |
| 350 accelerated_surface_->Destroy(); |
327 } | 351 } |
328 | 352 |
329 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 353 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
330 // ATL function to create the window. | 354 // ATL function to create the window. |
331 Create(parent); | 355 Create(parent); |
332 } | 356 } |
333 | 357 |
334 /////////////////////////////////////////////////////////////////////////////// | 358 /////////////////////////////////////////////////////////////////////////////// |
335 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 359 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
336 | 360 |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1743 return 0; | 1767 return 0; |
1744 case WM_PAINT: | 1768 case WM_PAINT: |
1745 PaintCompositorHostWindow(hWnd); | 1769 PaintCompositorHostWindow(hWnd); |
1746 return 0; | 1770 return 0; |
1747 default: | 1771 default: |
1748 return DefWindowProc(hWnd, message, wParam, lParam); | 1772 return DefWindowProc(hWnd, message, wParam, lParam); |
1749 } | 1773 } |
1750 } | 1774 } |
1751 | 1775 |
1752 void RenderWidgetHostViewWin::ScheduleComposite() { | 1776 void RenderWidgetHostViewWin::ScheduleComposite() { |
1753 if (render_widget_host_) | 1777 // If we have a previous frame then present it immediately. Otherwise request |
1754 render_widget_host_->ScheduleComposite(); | 1778 // a new frame be composited. |
| 1779 if (accelerated_surface_.get()) { |
| 1780 accelerated_surface_->Present(); |
| 1781 } else { |
| 1782 if (render_widget_host_) |
| 1783 render_widget_host_->ScheduleComposite(); |
| 1784 } |
1755 } | 1785 } |
1756 | 1786 |
1757 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 1787 // Creates a HWND within the RenderWidgetHostView that will serve as a host |
1758 // for a HWND that the GPU process will create. The host window is used | 1788 // for a HWND that the GPU process will create. The host window is used |
1759 // to Z-position the GPU's window relative to other plugin windows. | 1789 // to Z-position the GPU's window relative to other plugin windows. |
1760 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 1790 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
1761 // If the window has been created, don't recreate it a second time | 1791 // If the window has been created, don't recreate it a second time |
1762 if (compositor_host_window_) | 1792 if (compositor_host_window_) |
1763 return compositor_host_window_; | 1793 return compositor_host_window_; |
1764 | 1794 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1839 else | 1869 else |
1840 next = compositor_host_window_; | 1870 next = compositor_host_window_; |
1841 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, | 1871 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, |
1842 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); | 1872 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
1843 } | 1873 } |
1844 } else { | 1874 } else { |
1845 hide_compositor_window_at_next_paint_ = true; | 1875 hide_compositor_window_at_next_paint_ = true; |
1846 } | 1876 } |
1847 } | 1877 } |
1848 | 1878 |
| 1879 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( |
| 1880 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 1881 int gpu_host_id) { |
| 1882 if (!accelerated_surface_.get() && compositor_host_window_) { |
| 1883 accelerated_surface_ = new AcceleratedSurface(compositor_host_window_); |
| 1884 accelerated_surface_->Initialize(); |
| 1885 } |
| 1886 |
| 1887 base::Closure acknowledge_task = |
| 1888 base::Bind(SendToGpuProcessHost, |
| 1889 gpu_host_id, |
| 1890 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
| 1891 |
| 1892 accelerated_surface_->AsyncPresentAndAcknowledge( |
| 1893 params.size, |
| 1894 params.surface_id, |
| 1895 base::Bind(PostTaskOnIOThread, |
| 1896 FROM_HERE, |
| 1897 acknowledge_task)); |
| 1898 } |
| 1899 |
1849 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { | 1900 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { |
1850 if (!render_widget_host_) | 1901 if (!render_widget_host_) |
1851 return; | 1902 return; |
1852 | 1903 |
1853 render_widget_host_->AccessibilitySetFocus(acc_obj_id); | 1904 render_widget_host_->AccessibilitySetFocus(acc_obj_id); |
1854 } | 1905 } |
1855 | 1906 |
1856 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { | 1907 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { |
1857 if (!render_widget_host_) | 1908 if (!render_widget_host_) |
1858 return; | 1909 return; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2222 | 2273 |
2223 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 2274 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
2224 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), | 2275 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), |
2225 selection_text_.c_str() + offset, len * sizeof(WCHAR)); | 2276 selection_text_.c_str() + offset, len * sizeof(WCHAR)); |
2226 | 2277 |
2227 // According to Microsft API document, IMR_RECONVERTSTRING and | 2278 // According to Microsft API document, IMR_RECONVERTSTRING and |
2228 // IMR_DOCUMENTFEED should return reconv, but some applications return | 2279 // IMR_DOCUMENTFEED should return reconv, but some applications return |
2229 // need_size. | 2280 // need_size. |
2230 return reinterpret_cast<LRESULT>(reconv); | 2281 return reinterpret_cast<LRESULT>(reconv); |
2231 } | 2282 } |
OLD | NEW |