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_impl.h" | 28 #include "content/browser/renderer_host/render_process_host_impl.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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 touch_state_(this) { | 352 touch_state_(this) { |
332 render_widget_host_->SetView(this); | 353 render_widget_host_->SetView(this); |
333 registrar_.Add(this, | 354 registrar_.Add(this, |
334 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 355 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
335 content::NotificationService::AllBrowserContextsAndSources()); | 356 content::NotificationService::AllBrowserContextsAndSources()); |
336 } | 357 } |
337 | 358 |
338 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 359 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
339 UnlockMouse(); | 360 UnlockMouse(); |
340 ResetTooltip(); | 361 ResetTooltip(); |
| 362 |
| 363 if (accelerated_surface_) |
| 364 accelerated_surface_->Destroy(); |
341 } | 365 } |
342 | 366 |
343 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 367 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
344 // ATL function to create the window. | 368 // ATL function to create the window. |
345 Create(parent); | 369 Create(parent); |
346 } | 370 } |
347 | 371 |
348 /////////////////////////////////////////////////////////////////////////////// | 372 /////////////////////////////////////////////////////////////////////////////// |
349 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 373 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
350 | 374 |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 return 0; | 1973 return 0; |
1950 case WM_PAINT: | 1974 case WM_PAINT: |
1951 PaintCompositorHostWindow(hWnd); | 1975 PaintCompositorHostWindow(hWnd); |
1952 return 0; | 1976 return 0; |
1953 default: | 1977 default: |
1954 return DefWindowProc(hWnd, message, wParam, lParam); | 1978 return DefWindowProc(hWnd, message, wParam, lParam); |
1955 } | 1979 } |
1956 } | 1980 } |
1957 | 1981 |
1958 void RenderWidgetHostViewWin::ScheduleComposite() { | 1982 void RenderWidgetHostViewWin::ScheduleComposite() { |
1959 if (render_widget_host_) | 1983 // If we have a previous frame then present it immediately. Otherwise request |
1960 render_widget_host_->ScheduleComposite(); | 1984 // a new frame be composited. |
| 1985 if (accelerated_surface_.get()) { |
| 1986 accelerated_surface_->Present(); |
| 1987 } else { |
| 1988 if (render_widget_host_) |
| 1989 render_widget_host_->ScheduleComposite(); |
| 1990 } |
1961 } | 1991 } |
1962 | 1992 |
1963 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 1993 // Creates a HWND within the RenderWidgetHostView that will serve as a host |
1964 // for a HWND that the GPU process will create. The host window is used | 1994 // for a HWND that the GPU process will create. The host window is used |
1965 // to Z-position the GPU's window relative to other plugin windows. | 1995 // to Z-position the GPU's window relative to other plugin windows. |
1966 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 1996 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
1967 // If the window has been created, don't recreate it a second time | 1997 // If the window has been created, don't recreate it a second time |
1968 if (compositor_host_window_) | 1998 if (compositor_host_window_) |
1969 return compositor_host_window_; | 1999 return compositor_host_window_; |
1970 | 2000 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 else | 2076 else |
2047 next = compositor_host_window_; | 2077 next = compositor_host_window_; |
2048 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, | 2078 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, |
2049 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); | 2079 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
2050 } | 2080 } |
2051 } else { | 2081 } else { |
2052 hide_compositor_window_at_next_paint_ = true; | 2082 hide_compositor_window_at_next_paint_ = true; |
2053 } | 2083 } |
2054 } | 2084 } |
2055 | 2085 |
| 2086 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( |
| 2087 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 2088 int gpu_host_id) { |
| 2089 if (!accelerated_surface_.get() && compositor_host_window_) { |
| 2090 accelerated_surface_ = new AcceleratedSurface(compositor_host_window_); |
| 2091 accelerated_surface_->Initialize(); |
| 2092 } |
| 2093 |
| 2094 base::Closure acknowledge_task = |
| 2095 base::Bind(SendToGpuProcessHost, |
| 2096 gpu_host_id, |
| 2097 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
| 2098 |
| 2099 accelerated_surface_->AsyncPresentAndAcknowledge( |
| 2100 params.size, |
| 2101 params.surface_id, |
| 2102 base::Bind(PostTaskOnIOThread, |
| 2103 FROM_HERE, |
| 2104 acknowledge_task)); |
| 2105 } |
| 2106 |
2056 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { | 2107 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { |
2057 if (!render_widget_host_) | 2108 if (!render_widget_host_) |
2058 return; | 2109 return; |
2059 | 2110 |
2060 render_widget_host_->AccessibilitySetFocus(acc_obj_id); | 2111 render_widget_host_->AccessibilitySetFocus(acc_obj_id); |
2061 } | 2112 } |
2062 | 2113 |
2063 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { | 2114 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { |
2064 if (!render_widget_host_) | 2115 if (!render_widget_host_) |
2065 return; | 2116 return; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 | 2480 |
2430 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 2481 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
2431 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), | 2482 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), |
2432 selection_text_.c_str() + offset, len * sizeof(WCHAR)); | 2483 selection_text_.c_str() + offset, len * sizeof(WCHAR)); |
2433 | 2484 |
2434 // According to Microsft API document, IMR_RECONVERTSTRING and | 2485 // According to Microsft API document, IMR_RECONVERTSTRING and |
2435 // IMR_DOCUMENTFEED should return reconv, but some applications return | 2486 // IMR_DOCUMENTFEED should return reconv, but some applications return |
2436 // need_size. | 2487 // need_size. |
2437 return reinterpret_cast<LRESULT>(reconv); | 2488 return reinterpret_cast<LRESULT>(reconv); |
2438 } | 2489 } |
OLD | NEW |