| OLD | NEW |
| 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/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.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 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { | 297 gfx::Rect DesktopWindowTreeHostWin::GetWorkAreaBoundsInScreen() const { |
| 298 MONITORINFO monitor_info; | 298 MONITORINFO monitor_info; |
| 299 monitor_info.cbSize = sizeof(monitor_info); | 299 monitor_info.cbSize = sizeof(monitor_info); |
| 300 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), | 300 GetMonitorInfo(MonitorFromWindow(message_handler_->hwnd(), |
| 301 MONITOR_DEFAULTTONEAREST), | 301 MONITOR_DEFAULTTONEAREST), |
| 302 &monitor_info); | 302 &monitor_info); |
| 303 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); | 303 gfx::Rect pixel_bounds = gfx::Rect(monitor_info.rcWork); |
| 304 return display::win::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); | 304 return display::win::ScreenWin::ScreenToDIPRect(GetHWND(), pixel_bounds); |
| 305 } | 305 } |
| 306 | 306 |
| 307 void DesktopWindowTreeHostWin::SetShape(SkRegion* native_region) { | 307 void DesktopWindowTreeHostWin::SetShape( |
| 308 if (native_region) { | 308 std::unique_ptr<SkRegion> native_region) { |
| 309 // TODO(wez): This would be a lot simpler if we were passed an SkPath. | 309 if (!native_region) { |
| 310 // See crbug.com/410593. | 310 message_handler_->SetRegion(nullptr); |
| 311 SkRegion* shape = native_region; | 311 return; |
| 312 SkRegion device_region; | |
| 313 if (display::win::GetDPIScale() > 1.0) { | |
| 314 shape = &device_region; | |
| 315 const float& scale = display::win::GetDPIScale(); | |
| 316 std::vector<SkIRect> rects; | |
| 317 for (SkRegion::Iterator it(*native_region); !it.done(); it.next()) { | |
| 318 const SkIRect& rect = it.rect(); | |
| 319 SkRect scaled_rect = | |
| 320 SkRect::MakeLTRB(rect.left() * scale, rect.top() * scale, | |
| 321 rect.right() * scale, rect.bottom() * scale); | |
| 322 SkIRect rounded_scaled_rect; | |
| 323 scaled_rect.roundOut(&rounded_scaled_rect); | |
| 324 rects.push_back(rounded_scaled_rect); | |
| 325 } | |
| 326 if (!rects.empty()) | |
| 327 device_region.setRects(&rects[0], rects.size()); | |
| 328 } | |
| 329 | |
| 330 message_handler_->SetRegion(gfx::CreateHRGNFromSkRegion(*shape)); | |
| 331 } else { | |
| 332 message_handler_->SetRegion(NULL); | |
| 333 } | 312 } |
| 334 | 313 |
| 335 delete native_region; | 314 // TODO(wez): This would be a lot simpler if we were passed an SkPath. |
| 315 // See crbug.com/410593. |
| 316 SkRegion* shape = native_region.get(); |
| 317 SkRegion device_region; |
| 318 if (display::win::GetDPIScale() > 1.0) { |
| 319 shape = &device_region; |
| 320 const float scale = display::win::GetDPIScale(); |
| 321 std::vector<SkIRect> rects; |
| 322 for (SkRegion::Iterator it(*native_region); !it.done(); it.next()) { |
| 323 const SkIRect& rect = it.rect(); |
| 324 SkRect scaled_rect = |
| 325 SkRect::MakeLTRB(rect.left() * scale, rect.top() * scale, |
| 326 rect.right() * scale, rect.bottom() * scale); |
| 327 SkIRect rounded_scaled_rect; |
| 328 scaled_rect.roundOut(&rounded_scaled_rect); |
| 329 rects.push_back(rounded_scaled_rect); |
| 330 } |
| 331 if (!rects.empty()) |
| 332 device_region.setRects(&rects[0], rects.size()); |
| 333 } |
| 334 |
| 335 message_handler_->SetRegion(gfx::CreateHRGNFromSkRegion(*shape)); |
| 336 } | 336 } |
| 337 | 337 |
| 338 void DesktopWindowTreeHostWin::Activate() { | 338 void DesktopWindowTreeHostWin::Activate() { |
| 339 message_handler_->Activate(); | 339 message_handler_->Activate(); |
| 340 } | 340 } |
| 341 | 341 |
| 342 void DesktopWindowTreeHostWin::Deactivate() { | 342 void DesktopWindowTreeHostWin::Deactivate() { |
| 343 message_handler_->Deactivate(); | 343 message_handler_->Deactivate(); |
| 344 } | 344 } |
| 345 | 345 |
| (...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 | 997 |
| 998 // static | 998 // static |
| 999 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( | 999 DesktopWindowTreeHost* DesktopWindowTreeHost::Create( |
| 1000 internal::NativeWidgetDelegate* native_widget_delegate, | 1000 internal::NativeWidgetDelegate* native_widget_delegate, |
| 1001 DesktopNativeWidgetAura* desktop_native_widget_aura) { | 1001 DesktopNativeWidgetAura* desktop_native_widget_aura) { |
| 1002 return new DesktopWindowTreeHostWin(native_widget_delegate, | 1002 return new DesktopWindowTreeHostWin(native_widget_delegate, |
| 1003 desktop_native_widget_aura); | 1003 desktop_native_widget_aura); |
| 1004 } | 1004 } |
| 1005 | 1005 |
| 1006 } // namespace views | 1006 } // namespace views |
| OLD | NEW |