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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 case WM_MBUTTONDOWN: | 200 case WM_MBUTTONDOWN: |
197 ::SendMessage(GetParent(window), message, wparam, lparam); | 201 ::SendMessage(GetParent(window), message, wparam, lparam); |
198 return 0; | 202 return 0; |
199 default: | 203 default: |
200 break; | 204 break; |
201 } | 205 } |
202 } | 206 } |
203 return ::DefWindowProc(window, message, wparam, lparam); | 207 return ::DefWindowProc(window, message, wparam, lparam); |
204 } | 208 } |
205 | 209 |
| 210 void SendToGpuProcessHost(int gpu_host_id, IPC::Message* message) { |
| 211 GpuProcessHost* gpu_process_host = GpuProcessHost::FromID(gpu_host_id); |
| 212 if (!gpu_process_host) { |
| 213 delete message; |
| 214 return; |
| 215 } |
| 216 |
| 217 gpu_process_host->Send(message); |
| 218 } |
| 219 |
| 220 void PostTaskOnIOThread(const tracked_objects::Location& from_here, |
| 221 base::Closure task) { |
| 222 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task); |
| 223 } |
| 224 |
206 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, | 225 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, |
207 content::PageZoom* zoom, | 226 content::PageZoom* zoom, |
208 POINT* zoom_center) { | 227 POINT* zoom_center) { |
209 static long start = 0; | 228 static long start = 0; |
210 static POINT zoom_first; | 229 static POINT zoom_first; |
211 | 230 |
212 if (gi.dwFlags == GF_BEGIN) { | 231 if (gi.dwFlags == GF_BEGIN) { |
213 start = gi.ullArguments; | 232 start = gi.ullArguments; |
214 zoom_first.x = gi.ptsLocation.x; | 233 zoom_first.x = gi.ptsLocation.x; |
215 zoom_first.y = gi.ptsLocation.y; | 234 zoom_first.y = gi.ptsLocation.y; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 touch_state_(this) { | 350 touch_state_(this) { |
332 render_widget_host_->SetView(this); | 351 render_widget_host_->SetView(this); |
333 registrar_.Add(this, | 352 registrar_.Add(this, |
334 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 353 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
335 content::NotificationService::AllBrowserContextsAndSources()); | 354 content::NotificationService::AllBrowserContextsAndSources()); |
336 } | 355 } |
337 | 356 |
338 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 357 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
339 UnlockMouse(); | 358 UnlockMouse(); |
340 ResetTooltip(); | 359 ResetTooltip(); |
| 360 |
| 361 if (accelerated_surface_) |
| 362 accelerated_surface_->Destroy(); |
341 } | 363 } |
342 | 364 |
343 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 365 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
344 // ATL function to create the window. | 366 // ATL function to create the window. |
345 Create(parent); | 367 Create(parent); |
346 } | 368 } |
347 | 369 |
348 /////////////////////////////////////////////////////////////////////////////// | 370 /////////////////////////////////////////////////////////////////////////////// |
349 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 371 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
350 | 372 |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1949 return 0; | 1971 return 0; |
1950 case WM_PAINT: | 1972 case WM_PAINT: |
1951 PaintCompositorHostWindow(hWnd); | 1973 PaintCompositorHostWindow(hWnd); |
1952 return 0; | 1974 return 0; |
1953 default: | 1975 default: |
1954 return DefWindowProc(hWnd, message, wParam, lParam); | 1976 return DefWindowProc(hWnd, message, wParam, lParam); |
1955 } | 1977 } |
1956 } | 1978 } |
1957 | 1979 |
1958 void RenderWidgetHostViewWin::ScheduleComposite() { | 1980 void RenderWidgetHostViewWin::ScheduleComposite() { |
1959 if (render_widget_host_) | 1981 // If we have a previous frame then present it immediately. Otherwise request |
1960 render_widget_host_->ScheduleComposite(); | 1982 // a new frame be composited. |
| 1983 if (accelerated_surface_.get()) { |
| 1984 accelerated_surface_->Present(); |
| 1985 } else { |
| 1986 if (render_widget_host_) |
| 1987 render_widget_host_->ScheduleComposite(); |
| 1988 } |
1961 } | 1989 } |
1962 | 1990 |
1963 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 1991 // 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 | 1992 // 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. | 1993 // to Z-position the GPU's window relative to other plugin windows. |
1966 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 1994 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
1967 // If the window has been created, don't recreate it a second time | 1995 // If the window has been created, don't recreate it a second time |
1968 if (compositor_host_window_) | 1996 if (compositor_host_window_) |
1969 return compositor_host_window_; | 1997 return compositor_host_window_; |
1970 | 1998 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 else | 2074 else |
2047 next = compositor_host_window_; | 2075 next = compositor_host_window_; |
2048 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, | 2076 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, |
2049 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); | 2077 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
2050 } | 2078 } |
2051 } else { | 2079 } else { |
2052 hide_compositor_window_at_next_paint_ = true; | 2080 hide_compositor_window_at_next_paint_ = true; |
2053 } | 2081 } |
2054 } | 2082 } |
2055 | 2083 |
| 2084 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( |
| 2085 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, |
| 2086 int gpu_host_id) { |
| 2087 if (!accelerated_surface_.get() && compositor_host_window_) { |
| 2088 accelerated_surface_ = new AcceleratedSurface(compositor_host_window_); |
| 2089 accelerated_surface_->Initialize(); |
| 2090 } |
| 2091 |
| 2092 base::Closure acknowledge_task = |
| 2093 base::Bind(SendToGpuProcessHost, |
| 2094 gpu_host_id, |
| 2095 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); |
| 2096 |
| 2097 accelerated_surface_->AsyncPresentAndAcknowledge( |
| 2098 params.size, |
| 2099 params.surface_id, |
| 2100 base::Bind(PostTaskOnIOThread, |
| 2101 FROM_HERE, |
| 2102 acknowledge_task)); |
| 2103 } |
| 2104 |
2056 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { | 2105 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { |
2057 if (!render_widget_host_) | 2106 if (!render_widget_host_) |
2058 return; | 2107 return; |
2059 | 2108 |
2060 render_widget_host_->AccessibilitySetFocus(acc_obj_id); | 2109 render_widget_host_->AccessibilitySetFocus(acc_obj_id); |
2061 } | 2110 } |
2062 | 2111 |
2063 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { | 2112 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { |
2064 if (!render_widget_host_) | 2113 if (!render_widget_host_) |
2065 return; | 2114 return; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 | 2478 |
2430 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 2479 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
2431 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), | 2480 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), |
2432 selection_text_.c_str() + offset, len * sizeof(WCHAR)); | 2481 selection_text_.c_str() + offset, len * sizeof(WCHAR)); |
2433 | 2482 |
2434 // According to Microsft API document, IMR_RECONVERTSTRING and | 2483 // According to Microsft API document, IMR_RECONVERTSTRING and |
2435 // IMR_DOCUMENTFEED should return reconv, but some applications return | 2484 // IMR_DOCUMENTFEED should return reconv, but some applications return |
2436 // need_size. | 2485 // need_size. |
2437 return reinterpret_cast<LRESULT>(reconv); | 2486 return reinterpret_cast<LRESULT>(reconv); |
2438 } | 2487 } |
OLD | NEW |