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

Side by Side Diff: ui/views/widget/desktop_aura/desktop_window_tree_host_win.cc

Issue 532913003: Account for device scale factor in AppWindow.setShape(), under Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h" 5 #include "ui/views/widget/desktop_aura/desktop_window_tree_host_win.h"
6 6
7 #include "base/win/metro.h" 7 #include "base/win/metro.h"
8 #include "third_party/skia/include/core/SkPath.h" 8 #include "third_party/skia/include/core/SkPath.h"
9 #include "third_party/skia/include/core/SkRegion.h" 9 #include "third_party/skia/include/core/SkRegion.h"
10 #include "ui/aura/client/aura_constants.h" 10 #include "ui/aura/client/aura_constants.h"
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 monitor_info.cbSize = sizeof(monitor_info); 273 monitor_info.cbSize = sizeof(monitor_info);
274 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), 274 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(),
275 MONITOR_DEFAULTTONEAREST), 275 MONITOR_DEFAULTTONEAREST),
276 &monitor_info); 276 &monitor_info);
277 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); 277 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork);
278 return gfx::win::ScreenToDIPRect(pixel_bounds); 278 return gfx::win::ScreenToDIPRect(pixel_bounds);
279 } 279 }
280 280
281 void DesktopWindowTreeHostWin::SetShape(gfx::NativeRegion native_region) { 281 void DesktopWindowTreeHostWin::SetShape(gfx::NativeRegion native_region) {
282 if (native_region) { 282 if (native_region) {
283 message_handler_->SetRegion(gfx::CreateHRGNFromSkRegion(*native_region)); 283
sky 2014/09/04 13:23:05 nit: no newline here.
Wez 2014/09/04 17:50:50 Done.
284 // TODO(wez): This would be a lot simpler if we were passed an SkPath.
285 // See crbug.com/410593.
286 gfx::NativeRegion shape = native_region;
287 SkRegion device_region;
288 if (gfx::IsInHighDPIMode()) {
289 shape = &device_region;
290 const float& scale = gfx::win::GetDeviceScaleFactor();
sky 2014/09/04 13:23:05 I think you want GetDPIScale() and no &, just cons
sky 2014/09/04 17:40:09 Actually, both are the same, so it shouldn't matte
Wez 2014/09/04 17:50:50 Re GetDPIScale: Done. Re const float&: We want to
291 std::vector<SkIRect> rects;
292 for (SkRegion::Iterator it(*native_region); !it.done(); it.next()) {
293 const SkIRect& rect = it.rect();
294 SkRect scaled_rect =
295 SkRect::MakeLTRB(rect.left() * scale, rect.top() * scale,
296 rect.right() * scale, rect.bottom() * scale);
297 SkIRect rounded_scaled_rect;
298 scaled_rect.roundOut(&rounded_scaled_rect);
299 rects.push_back(rounded_scaled_rect);
300 }
301 if (!rects.empty()) {
sky 2014/09/04 13:23:05 nit: no {}
Wez 2014/09/04 17:50:50 Done.
302 device_region.setRects(&rects[0], rects.size());
303 }
304 }
305
306 message_handler_->SetRegion(gfx::CreateHRGNFromSkRegion(*shape));
284 } else { 307 } else {
285 message_handler_->SetRegion(NULL); 308 message_handler_->SetRegion(NULL);
286 } 309 }
287 310
288 delete native_region; 311 delete native_region;
289 } 312 }
290 313
291 void DesktopWindowTreeHostWin::Activate() { 314 void DesktopWindowTreeHostWin::Activate() {
292 message_handler_->Activate(); 315 message_handler_->Activate();
293 } 316 }
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 962
940 // static 963 // static
941 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 964 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
942 internal::NativeWidgetDelegate* native_widget_delegate, 965 internal::NativeWidgetDelegate* native_widget_delegate,
943 DesktopNativeWidgetAura* desktop_native_widget_aura) { 966 DesktopNativeWidgetAura* desktop_native_widget_aura) {
944 return new DesktopWindowTreeHostWin(native_widget_delegate, 967 return new DesktopWindowTreeHostWin(native_widget_delegate,
945 desktop_native_widget_aura); 968 desktop_native_widget_aura);
946 } 969 }
947 970
948 } // namespace views 971 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698