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

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: Fixed Other Unit Tests - Moved Inner Classes Outside Created 4 years, 11 months 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 "build/build_config.h" 8 #include "build/build_config.h"
9 #include "content/browser/accessibility/browser_accessibility_manager.h" 9 #include "content/browser/accessibility/browser_accessibility_manager.h"
10 #include "content/browser/gpu/gpu_data_manager_impl.h" 10 #include "content/browser/gpu/gpu_data_manager_impl.h"
(...skipping 12 matching lines...) Expand all
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/win/wrapped_window_proc.h" 24 #include "base/win/wrapped_window_proc.h"
25 #include "content/browser/plugin_process_host.h" 25 #include "content/browser/plugin_process_host.h"
26 #include "content/browser/plugin_service_impl.h" 26 #include "content/browser/plugin_service_impl.h"
27 #include "content/common/plugin_constants_win.h" 27 #include "content/common/plugin_constants_win.h"
28 #include "content/common/webplugin_geometry.h" 28 #include "content/common/webplugin_geometry.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/child_process_data.h" 30 #include "content/public/browser/child_process_data.h"
31 #include "content/public/common/content_switches.h" 31 #include "content/public/common/content_switches.h"
32 #include "ui/gfx/gdi_util.h" 32 #include "ui/gfx/gdi_util.h"
33 #include "ui/gfx/win/dpi.h" 33 #include "ui/gfx/screen_win.h"
34 #include "ui/gfx/win/hwnd_util.h" 34 #include "ui/gfx/win/hwnd_util.h"
35 #endif 35 #endif
36 36
37 namespace content { 37 namespace content {
38 38
39 #if defined(OS_WIN) 39 #if defined(OS_WIN)
40 40
41 namespace { 41 namespace {
42 42
43 // |window| is the plugin HWND, created and destroyed in the plugin process. 43 // |window| is the plugin HWND, created and destroyed in the plugin process.
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent, 143 base::Bind(&NotifyPluginProcessHostHelper, window, new_parent,
144 kMaxTries)); 144 kMaxTries));
145 return new_parent; 145 return new_parent;
146 } 146 }
147 147
148 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) { 148 BOOL CALLBACK PaintEnumChildProc(HWND hwnd, LPARAM lparam) {
149 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd)) 149 if (!PluginServiceImpl::GetInstance()->IsPluginWindow(hwnd))
150 return TRUE; 150 return TRUE;
151 151
152 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); 152 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam);
153 gfx::Rect rect_in_pixels = gfx::win::DIPToScreenRect(*rect); 153 gfx::Rect rect_in_pixels = gfx::ScreenWin::DIPToScreenRect(hwnd, *rect);
154 static UINT msg = RegisterWindowMessage(kPaintMessageName); 154 static UINT msg = RegisterWindowMessage(kPaintMessageName);
155 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y()); 155 WPARAM wparam = MAKEWPARAM(rect_in_pixels.x(), rect_in_pixels.y());
156 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height()); 156 lparam = MAKELPARAM(rect_in_pixels.width(), rect_in_pixels.height());
157 157
158 // SendMessage gets the message across much quicker than PostMessage, since it 158 // SendMessage gets the message across much quicker than PostMessage, since it
159 // doesn't get queued. When the plugin thread calls PeekMessage or other 159 // doesn't get queued. When the plugin thread calls PeekMessage or other
160 // Win32 APIs, sent messages are dispatched automatically. 160 // Win32 APIs, sent messages are dispatched automatically.
161 SendNotifyMessage(hwnd, msg, wparam, lparam); 161 SendNotifyMessage(hwnd, msg, wparam, lparam);
162 162
163 return TRUE; 163 return TRUE;
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 // if Windows tries to paint it synchronously inside EndDeferWindowsPos 257 // if Windows tries to paint it synchronously inside EndDeferWindowsPos
258 // then it won't have the data and it will flash white. So instead we 258 // then it won't have the data and it will flash white. So instead we
259 // manually redraw the plugin. 259 // manually redraw the plugin.
260 // Why not do this for native Windows? Not sure if there are any 260 // Why not do this for native Windows? Not sure if there are any
261 // performance issues with this. 261 // performance issues with this.
262 flags |= SWP_NOREDRAW; 262 flags |= SWP_NOREDRAW;
263 } 263 }
264 #endif 264 #endif
265 265
266 if (move.rects_valid) { 266 if (move.rects_valid) {
267 gfx::Rect clip_rect_in_pixel = gfx::win::DIPToScreenRect(move.clip_rect); 267 gfx::Rect clip_rect_in_pixel =
268 gfx::ScreenWin::DIPToScreenRect(window, move.clip_rect);
268 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(), 269 HRGN hrgn = ::CreateRectRgn(clip_rect_in_pixel.x(),
269 clip_rect_in_pixel.y(), 270 clip_rect_in_pixel.y(),
270 clip_rect_in_pixel.right(), 271 clip_rect_in_pixel.right(),
271 clip_rect_in_pixel.bottom()); 272 clip_rect_in_pixel.bottom());
272 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects); 273 gfx::SubtractRectanglesFromRegion(hrgn, move.cutout_rects);
273 274
274 // Note: System will own the hrgn after we call SetWindowRgn, 275 // Note: System will own the hrgn after we call SetWindowRgn,
275 // so we don't need to call DeleteObject(hrgn) 276 // so we don't need to call DeleteObject(hrgn)
276 ::SetWindowRgn(window, hrgn, 277 ::SetWindowRgn(window, hrgn,
277 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0); 278 !move.clip_rect.IsEmpty() && (flags & SWP_NOREDRAW) == 0);
278 279
279 #if defined(USE_AURA) 280 #if defined(USE_AURA)
280 // When using the software compositor, if the clipping rectangle is empty 281 // When using the software compositor, if the clipping rectangle is empty
281 // then DeferWindowPos won't redraw the newly uncovered area under the 282 // then DeferWindowPos won't redraw the newly uncovered area under the
282 // plugin. 283 // plugin.
283 if (clip_rect_in_pixel.IsEmpty() && 284 if (clip_rect_in_pixel.IsEmpty() &&
284 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) { 285 !GpuDataManagerImpl::GetInstance()->CanUseGpuBrowserCompositor()) {
285 RECT r; 286 RECT r;
286 GetClientRect(window, &r); 287 GetClientRect(window, &r);
287 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2); 288 MapWindowPoints(window, parent, reinterpret_cast<POINT*>(&r), 2);
288 invalidate_rects.push_back(r); 289 invalidate_rects.push_back(r);
289 } 290 }
290 #endif 291 #endif
291 } else { 292 } else {
292 flags |= SWP_NOMOVE; 293 flags |= SWP_NOMOVE;
293 flags |= SWP_NOSIZE; 294 flags |= SWP_NOSIZE;
294 } 295 }
295 296
296 gfx::Rect window_rect_in_pixel = 297 gfx::Rect window_rect_in_pixel =
297 gfx::win::DIPToScreenRect(move.window_rect); 298 gfx::ScreenWin::DIPToScreenRect(window, move.window_rect);
298 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info, 299 defer_window_pos_info = ::DeferWindowPos(defer_window_pos_info,
299 window, NULL, 300 window, NULL,
300 window_rect_in_pixel.x(), 301 window_rect_in_pixel.x(),
301 window_rect_in_pixel.y(), 302 window_rect_in_pixel.y(),
302 window_rect_in_pixel.width(), 303 window_rect_in_pixel.width(),
303 window_rect_in_pixel.height(), 304 window_rect_in_pixel.height(),
304 flags); 305 flags);
305 306
306 if (!defer_window_pos_info) { 307 if (!defer_window_pos_info) {
307 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; 308 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored.";
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 } 690 }
690 691
691 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace( 692 void RenderWidgetHostViewBase::TransformPointToLocalCoordSpace(
692 const gfx::Point& point, 693 const gfx::Point& point,
693 cc::SurfaceId original_surface, 694 cc::SurfaceId original_surface,
694 gfx::Point* transformed_point) { 695 gfx::Point* transformed_point) {
695 *transformed_point = point; 696 *transformed_point = point;
696 } 697 }
697 698
698 } // namespace content 699 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698