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 "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/wm/overview/window_selector_controller.h" | 9 #include "ash/common/wm/overview/window_selector_controller.h" |
11 #include "ash/common/wm_lookup.h" | 10 #include "ash/common/wm_lookup.h" |
12 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
13 #include "ash/desktop_background/desktop_background_controller.h" | 12 #include "ash/desktop_background/desktop_background_controller.h" |
14 #include "ash/desktop_background/desktop_background_widget_controller.h" | 13 #include "ash/desktop_background/desktop_background_widget_controller.h" |
15 #include "ash/desktop_background/user_wallpaper_delegate.h" | 14 #include "ash/desktop_background/user_wallpaper_delegate.h" |
16 #include "ash/root_window_controller.h" | 15 #include "ash/root_window_controller.h" |
17 #include "ash/shell.h" | 16 #include "ash/shell.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 display::Display display = window->GetDisplayNearestWindow(); | 44 display::Display display = window->GetDisplayNearestWindow(); |
45 DisplayInfo info = WmShell::Get()->GetDisplayInfo(display.id()); | 45 ui::ManagedDisplayInfo info = WmShell::Get()->GetDisplayInfo(display.id()); |
46 float ui_scale = info.GetEffectiveUIScale(); | 46 float ui_scale = info.GetEffectiveUIScale(); |
47 gfx::Size rounded_size = | 47 gfx::Size rounded_size = |
48 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); | 48 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); |
49 DCHECK_EQ(1, child_count()); | 49 DCHECK_EQ(1, child_count()); |
50 views::View* child = child_at(0); | 50 views::View* child = child_at(0); |
51 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); | 51 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); |
52 gfx::Transform transform; | 52 gfx::Transform transform; |
53 // Apply RTL transform explicitly becacuse Views layer code | 53 // Apply RTL transform explicitly becacuse Views layer code |
54 // doesn't handle RTL. crbug.com/458753. | 54 // doesn't handle RTL. crbug.com/458753. |
55 transform.Translate(-child->GetMirroredX(), 0); | 55 transform.Translate(-child->GetMirroredX(), 0); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 } else { | 229 } else { |
230 // Disable animation if transition to login screen from an empty background. | 230 // Disable animation if transition to login screen from an empty background. |
231 desktop_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); | 231 desktop_window->SetVisibilityAnimationTransition(::wm::ANIMATE_NONE); |
232 } | 232 } |
233 | 233 |
234 desktop_widget->SetBounds(params.parent->bounds()); | 234 desktop_widget->SetBounds(params.parent->bounds()); |
235 return desktop_widget; | 235 return desktop_widget; |
236 } | 236 } |
237 | 237 |
238 } // namespace ash | 238 } // namespace ash |
OLD | NEW |