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/wallpaper/wallpaper_view.h" | 5 #include "ash/wallpaper/wallpaper_view.h" |
6 | 6 |
7 #include "ash/aura/wm_window_aura.h" | 7 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/display/display_info.h" | |
9 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
10 #include "ash/common/wallpaper/wallpaper_delegate.h" | 9 #include "ash/common/wallpaper/wallpaper_delegate.h" |
11 #include "ash/common/wm/overview/window_selector_controller.h" | 10 #include "ash/common/wm/overview/window_selector_controller.h" |
12 #include "ash/common/wm_lookup.h" | 11 #include "ash/common/wm_lookup.h" |
13 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
14 #include "ash/root_window_controller.h" | 13 #include "ash/root_window_controller.h" |
15 #include "ash/shell.h" | 14 #include "ash/shell.h" |
16 #include "ash/wallpaper/wallpaper_controller.h" | 15 #include "ash/wallpaper/wallpaper_controller.h" |
17 #include "ash/wallpaper/wallpaper_widget_controller.h" | 16 #include "ash/wallpaper/wallpaper_widget_controller.h" |
18 #include "ui/display/display.h" | 17 #include "ui/display/display.h" |
| 18 #include "ui/display/manager/managed_display_info.h" |
19 #include "ui/display/screen.h" | 19 #include "ui/display/screen.h" |
20 #include "ui/gfx/canvas.h" | 20 #include "ui/gfx/canvas.h" |
21 #include "ui/gfx/geometry/safe_integer_conversions.h" | 21 #include "ui/gfx/geometry/safe_integer_conversions.h" |
22 #include "ui/gfx/geometry/size_conversions.h" | 22 #include "ui/gfx/geometry/size_conversions.h" |
23 #include "ui/gfx/transform.h" | 23 #include "ui/gfx/transform.h" |
24 #include "ui/views/widget/widget.h" | 24 #include "ui/views/widget/widget.h" |
25 | 25 |
26 namespace ash { | 26 namespace ash { |
27 namespace { | 27 namespace { |
28 | 28 |
29 // A view that controls the child view's layer so that the layer always has the | 29 // A view that controls the child view's layer so that the layer always has the |
30 // same size as the display's original, un-scaled size in DIP. The layer is then | 30 // same size as the display's original, un-scaled size in DIP. The layer is then |
31 // transformed to fit to the virtual screen size when laid-out. This is to avoid | 31 // transformed to fit to the virtual screen size when laid-out. This is to avoid |
32 // scaling the image at painting time, then scaling it back to the screen size | 32 // scaling the image at painting time, then scaling it back to the screen size |
33 // in the compositor. | 33 // in the compositor. |
34 class LayerControlView : public views::View { | 34 class LayerControlView : public views::View { |
35 public: | 35 public: |
36 explicit LayerControlView(views::View* view) { | 36 explicit LayerControlView(views::View* view) { |
37 AddChildView(view); | 37 AddChildView(view); |
38 view->SetPaintToLayer(true); | 38 view->SetPaintToLayer(true); |
39 } | 39 } |
40 | 40 |
41 // Overrides views::View. | 41 // Overrides views::View. |
42 void Layout() override { | 42 void Layout() override { |
43 WmWindow* window = WmLookup::Get()->GetWindowForWidget(GetWidget()); | 43 WmWindow* window = WmLookup::Get()->GetWindowForWidget(GetWidget()); |
44 // Keep |this| at the bottom since there may be other windows on top of the | 44 // Keep |this| at the bottom since there may be other windows on top of the |
45 // wallpaper view such as an overview mode shield. | 45 // wallpaper view such as an overview mode shield. |
46 window->GetParent()->StackChildAtBottom(window); | 46 window->GetParent()->StackChildAtBottom(window); |
47 display::Display display = window->GetDisplayNearestWindow(); | 47 display::Display display = window->GetDisplayNearestWindow(); |
48 DisplayInfo info = WmShell::Get()->GetDisplayInfo(display.id()); | 48 display::ManagedDisplayInfo info = |
| 49 WmShell::Get()->GetDisplayInfo(display.id()); |
49 float ui_scale = info.GetEffectiveUIScale(); | 50 float ui_scale = info.GetEffectiveUIScale(); |
50 gfx::Size rounded_size = | 51 gfx::Size rounded_size = |
51 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); | 52 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); |
52 DCHECK_EQ(1, child_count()); | 53 DCHECK_EQ(1, child_count()); |
53 views::View* child = child_at(0); | 54 views::View* child = child_at(0); |
54 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); | 55 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); |
55 gfx::Transform transform; | 56 gfx::Transform transform; |
56 // Apply RTL transform explicitly becacuse Views layer code | 57 // Apply RTL transform explicitly becacuse Views layer code |
57 // doesn't handle RTL. crbug.com/458753. | 58 // doesn't handle RTL. crbug.com/458753. |
58 transform.Translate(-child->GetMirroredX(), 0); | 59 transform.Translate(-child->GetMirroredX(), 0); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } else { | 228 } else { |
228 // Disable animation if transition to login screen from an empty background. | 229 // Disable animation if transition to login screen from an empty background. |
229 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 230 wallpaper_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
230 } | 231 } |
231 | 232 |
232 wallpaper_widget->SetBounds(params.parent->bounds()); | 233 wallpaper_widget->SetBounds(params.parent->bounds()); |
233 return wallpaper_widget; | 234 return wallpaper_widget; |
234 } | 235 } |
235 | 236 |
236 } // namespace ash | 237 } // namespace ash |
OLD | NEW |