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

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: Address review comments 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 // TODO(wez): This would be a lot simpler if we were passed an SkPath.
284 // See crbug.com/410593.
285 gfx::NativeRegion shape = native_region;
286 SkRegion device_region;
sky 2014/09/04 18:00:56 Does Skia not have a way to scale a SkRegion? Seem
Wez 2014/09/04 18:19:08 Sadly no. :( My guess is that you're really inten
287 if (gfx::IsInHighDPIMode()) {
288 shape = &device_region;
289 const float& scale = gfx::GetDPIScale();
290 std::vector<SkIRect> rects;
291 for (SkRegion::Iterator it(*native_region); !it.done(); it.next()) {
292 const SkIRect& rect = it.rect();
293 SkRect scaled_rect =
294 SkRect::MakeLTRB(rect.left() * scale, rect.top() * scale,
295 rect.right() * scale, rect.bottom() * scale);
296 SkIRect rounded_scaled_rect;
297 scaled_rect.roundOut(&rounded_scaled_rect);
298 rects.push_back(rounded_scaled_rect);
299 }
300 if (!rects.empty())
301 device_region.setRects(&rects[0], rects.size());
302 }
303
304 message_handler_->SetRegion(gfx::CreateHRGNFromSkRegion(*shape));
284 } else { 305 } else {
285 message_handler_->SetRegion(NULL); 306 message_handler_->SetRegion(NULL);
286 } 307 }
287 308
288 delete native_region; 309 delete native_region;
289 } 310 }
290 311
291 void DesktopWindowTreeHostWin::Activate() { 312 void DesktopWindowTreeHostWin::Activate() {
292 message_handler_->Activate(); 313 message_handler_->Activate();
293 } 314 }
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 960
940 // static 961 // static
941 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( 962 DesktopWindowTreeHost* DesktopWindowTreeHost::Create(
942 internal::NativeWidgetDelegate* native_widget_delegate, 963 internal::NativeWidgetDelegate* native_widget_delegate,
943 DesktopNativeWidgetAura* desktop_native_widget_aura) { 964 DesktopNativeWidgetAura* desktop_native_widget_aura) {
944 return new DesktopWindowTreeHostWin(native_widget_delegate, 965 return new DesktopWindowTreeHostWin(native_widget_delegate,
945 desktop_native_widget_aura); 966 desktop_native_widget_aura);
946 } 967 }
947 968
948 } // namespace views 969 } // 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