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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_base.cc

Issue 1426933002: Refactor Windows DPI Point, Rect, and Size for Multiple Monitor DPI Awareness (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_base.h" 5 #include "content/browser/renderer_host/render_widget_host_view_base.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "content/browser/accessibility/browser_accessibility_manager.h" 8 #include "content/browser/accessibility/browser_accessibility_manager.h"
9 #include "content/browser/gpu/gpu_data_manager_impl.h" 9 #include "content/browser/gpu/gpu_data_manager_impl.h"
10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h" 10 #include "content/browser/renderer_host/input/synthetic_gesture_target_base.h"
(...skipping 11 matching lines...) Expand all
22 #include "base/message_loop/message_loop.h" 22 #include "base/message_loop/message_loop.h"
23 #include "base/win/wrapped_window_proc.h" 23 #include "base/win/wrapped_window_proc.h"
24 #include "content/browser/plugin_process_host.h" 24 #include "content/browser/plugin_process_host.h"
25 #include "content/browser/plugin_service_impl.h" 25 #include "content/browser/plugin_service_impl.h"
26 #include "content/common/plugin_constants_win.h" 26 #include "content/common/plugin_constants_win.h"
27 #include "content/common/webplugin_geometry.h" 27 #include "content/common/webplugin_geometry.h"
28 #include "content/public/browser/browser_thread.h" 28 #include "content/public/browser/browser_thread.h"
29 #include "content/public/browser/child_process_data.h" 29 #include "content/public/browser/child_process_data.h"
30 #include "content/public/common/content_switches.h" 30 #include "content/public/common/content_switches.h"
31 #include "ui/gfx/gdi_util.h" 31 #include "ui/gfx/gdi_util.h"
32 #include "ui/gfx/win/dpi.h" 32 #include "ui/gfx/screen_win.h"
33 #include "ui/gfx/win/hwnd_util.h" 33 #include "ui/gfx/win/hwnd_util.h"
34 #endif 34 #endif
35 35
36 namespace content { 36 namespace content {
37 37
38 #if defined(OS_WIN) 38 #if defined(OS_WIN)
39 39
40 namespace { 40 namespace {
41 41
42 // |window| is the plugin HWND, created and destroyed in the plugin process. 42 // |window| is the plugin HWND, created and destroyed in the plugin process.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, 142 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent,
143 kMaxTries)); 143 kMaxTries));
144 return new_parent; 144 return new_parent;
145 } 145 }
146 146
147 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { 147 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) {
148 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd)) 148 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd))
149 return TRUE; 149 return TRUE;
150 150
151 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); 151 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam);
152 gfx::Rect rect_in_pixels = gfx::win::DIPToScreenRect(*rect); 152 gfx::Rect rect_in_pixels = gfx::ScreenWin::DIPToScreenRect(hwnd, *rect);
153 static UINT msg = RegisterWindowMessage(kPaintMessageName); 153 static UINT msg = RegisterWindowMessage(kPaintMessageName);
154 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y()); 154 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y());
155 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height()); 155 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height());
156 156
157 // SendMessage gets the message across much quicker than PostMessage, since it 157 // SendMessage gets the message across much quicker than PostMessage, since it
158 // doesn't get queued. When the plugin thread calls PeekMessage or other 158 // doesn't get queued. When the plugin thread calls PeekMessage or other
159 // Win32 APIs, sent messages are dispatched automatically. 159 // Win32 APIs, sent messages are dispatched automatically.
160 SendNotifyMessage(hwnd, msg, wparam, lparam); 160 SendNotifyMessage(hwnd, msg, wparam, lparam);
161 161
162 return TRUE; 162 return TRUE;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 // if Windows tries to paint it synchronously inside EndDeferWindowsPos 256 // if Windows tries to paint it synchronously inside EndDeferWindowsPos
257 // then it won't have the data and it will flash white. So instead we 257 // then it won't have the data and it will flash white. So instead we
258 // manually redraw the plugin. 258 // manually redraw the plugin.
259 // Why not do this for native Windows? Not sure if there are any 259 // Why not do this for native Windows? Not sure if there are any
260 // performance issues with this. 260 // performance issues with this.
261 flags |= SWP_NOREDRAW; 261 flags |= SWP_NOREDRAW;
262 } 262 }
263 #endif 263 #endif
264 264
265 if (move.rects_valid) { 265 if (move.rects_valid) {
266 gfx::Rect clip_rect_in_pixel = gfx::win::DIPToScreenRect(move.clip_rect); 266 gfx::Rect clip_rect_in_pixel =
267 gfx::ScreenWin::DIPToScreenRect(window, move.clip_rect);
267 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(), 268 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(),
268 clip_rect_in_pixel.y(), 269 clip_rect_in_pixel.y(),
269 clip_rect_in_pixel.right(), 270 clip_rect_in_pixel.right(),
270 clip_rect_in_pixel.bottom()); 271 clip_rect_in_pixel.bottom());
271 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); 272 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
272 273
273 // Note: System will own the hrgn after we call SetWindowRgn, 274 // Note: System will own the hrgn after we call SetWindowRgn,
274 // so we don't need to call DeleteObject(hrgn) 275 // so we don't need to call DeleteObject(hrgn)
275 ::SetWindowRgn(window, hrgn, 276 ::SetWindowRgn(window, hrgn,
276 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0); 277 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0);
277 278
278 #if defined(USE_AURA) 279 #if defined(USE_AURA)
279 // When using the software compositor, if the clipping rectangle is empty 280 // When using the software compositor, if the clipping rectangle is empty
280 // then DeferWindowPos won't redraw the newly uncovered area under the 281 // then DeferWindowPos won't redraw the newly uncovered area under the
281 // plugin. 282 // plugin.
282 if (clip_rect_in_pixel.IsEmpty() && 283 if (clip_rect_in_pixel.IsEmpty() &&
283 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { 284 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
284 RECT r; 285 RECT r;
285 GetClientRect(window, &r); 286 GetClientRect(window, &r);
286 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2); 287 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2);
287 invalidate_rects.push_back(r); 288 invalidate_rects.push_back(r);
288 } 289 }
289 #endif 290 #endif
290 } else { 291 } else {
291 flags |= SWP_NOMOVE; 292 flags |= SWP_NOMOVE;
292 flags |= SWP_NOSIZE; 293 flags |= SWP_NOSIZE;
293 } 294 }
294 295
295 gfx::Rect window_rect_in_pixel = 296 gfx::Rect window_rect_in_pixel =
296 gfx::win::DIPToScreenRect(move.window_rect); 297 gfx::ScreenWin::DIPToScreenRect(window, move.window_rect);
297 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info, 298 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info,
298 window, NULL, 299 window, NULL,
299 window_rect_in_pixel.x(), 300 window_rect_in_pixel.x(),
300 window_rect_in_pixel.y(), 301 window_rect_in_pixel.y(),
301 window_rect_in_pixel.width(), 302 window_rect_in_pixel.width(),
302 window_rect_in_pixel.height(), 303 window_rect_in_pixel.height(),
303 flags); 304 flags);
304 305
305 if (!defer_window_pos_info) { 306 if (!defer_window_pos_info) {
306 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; 307 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored.";
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 } 676 }
676 677
677 uint32_t RenderWidgetHostViewBase::SurfaceIdNamespaceAtPoint( 678 uint32_t RenderWidgetHostViewBase::SurfaceIdNamespaceAtPoint(
678 const gfx::Point& point, 679 const gfx::Point& point,
679 gfx::Point* transformed_point) { 680 gfx::Point* transformed_point) {
680 NOTREACHED(); 681 NOTREACHED();
681 return 0; 682 return 0;
682 } 683 }
683 684
684 } // namespace content 685 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698