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 "ash/desktop_background/desktop_background_view.h" | 5 #include "ash/desktop_background/desktop_background_view.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
11 #include "ash/desktop_background/desktop_background_widget_controller.h" | 11 #include "ash/desktop_background/desktop_background_widget_controller.h" |
12 #include "ash/desktop_background/user_wallpaper_delegate.h" | 12 #include "ash/desktop_background/user_wallpaper_delegate.h" |
13 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
15 #include "ash/session/session_state_delegate.h" | 15 #include "ash/session/session_state_delegate.h" |
16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
18 #include "ash/wm/overview/window_selector_controller.h" | 18 #include "ash/wm/overview/window_selector_controller.h" |
19 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
21 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
22 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
23 #include "ui/compositor/layer.h" | 23 #include "ui/compositor/layer.h" |
24 #include "ui/gfx/canvas.h" | 24 #include "ui/gfx/canvas.h" |
25 #include "ui/gfx/geometry/safe_integer_conversions.h" | 25 #include "ui/gfx/geometry/safe_integer_conversions.h" |
26 #include "ui/gfx/geometry/size_conversions.h" | 26 #include "ui/gfx/geometry/size_conversions.h" |
27 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
| 28 #include "ui/gfx/screen.h" |
28 #include "ui/gfx/transform.h" | 29 #include "ui/gfx/transform.h" |
29 #include "ui/views/widget/widget.h" | 30 #include "ui/views/widget/widget.h" |
30 | 31 |
31 using wallpaper::WallpaperLayout; | 32 using wallpaper::WallpaperLayout; |
32 using wallpaper::WALLPAPER_LAYOUT_CENTER; | 33 using wallpaper::WALLPAPER_LAYOUT_CENTER; |
33 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; | 34 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; |
34 using wallpaper::WALLPAPER_LAYOUT_STRETCH; | 35 using wallpaper::WALLPAPER_LAYOUT_STRETCH; |
35 using wallpaper::WALLPAPER_LAYOUT_TILE; | 36 using wallpaper::WALLPAPER_LAYOUT_TILE; |
36 | 37 |
37 namespace ash { | 38 namespace ash { |
38 namespace { | 39 namespace { |
39 | 40 |
40 // A view that controls the child view's layer so that the layer | 41 // A view that controls the child view's layer so that the layer |
41 // always has the same size as the display's original, un-scaled size | 42 // always has the same size as the display's original, un-scaled size |
42 // in DIP. The layer then transformed to fit to the virtual screen | 43 // in DIP. The layer then transformed to fit to the virtual screen |
43 // size when laid-out. | 44 // size when laid-out. |
44 // This is to avoid scaling the image at painting time, then scaling | 45 // This is to avoid scaling the image at painting time, then scaling |
45 // it back to the screen size in the compositor. | 46 // it back to the screen size in the compositor. |
46 class LayerControlView : public views::View { | 47 class LayerControlView : public views::View { |
47 public: | 48 public: |
48 explicit LayerControlView(views::View* view) { | 49 explicit LayerControlView(views::View* view) { |
49 AddChildView(view); | 50 AddChildView(view); |
50 view->SetPaintToLayer(true); | 51 view->SetPaintToLayer(true); |
51 } | 52 } |
52 | 53 |
53 // Overrides views::View. | 54 // Overrides views::View. |
54 void Layout() override { | 55 void Layout() override { |
55 gfx::Display display = Shell::GetScreen()->GetDisplayNearestWindow( | 56 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayNearestWindow( |
56 GetWidget()->GetNativeView()); | 57 GetWidget()->GetNativeView()); |
57 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 58 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
58 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); | 59 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); |
59 float ui_scale = info.GetEffectiveUIScale(); | 60 float ui_scale = info.GetEffectiveUIScale(); |
60 gfx::Size rounded_size = | 61 gfx::Size rounded_size = |
61 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); | 62 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); |
62 DCHECK_EQ(1, child_count()); | 63 DCHECK_EQ(1, child_count()); |
63 views::View* child = child_at(0); | 64 views::View* child = child_at(0); |
64 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); | 65 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); |
65 gfx::Transform transform; | 66 gfx::Transform transform; |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 // Disable animation if transition to login screen from an empty background. | 247 // Disable animation if transition to login screen from an empty background. |
247 wm::SetWindowVisibilityAnimationTransition( | 248 wm::SetWindowVisibilityAnimationTransition( |
248 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); | 249 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); |
249 } | 250 } |
250 | 251 |
251 desktop_widget->SetBounds(params.parent->bounds()); | 252 desktop_widget->SetBounds(params.parent->bounds()); |
252 return desktop_widget; | 253 return desktop_widget; |
253 } | 254 } |
254 | 255 |
255 } // namespace ash | 256 } // namespace ash |
OLD | NEW |