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

Side by Side Diff: ash/desktop_background/desktop_background_view.cc

Issue 1924703002: Rename gfx::Display/Screen to display::Display/Screen in ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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 | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/dip_unittest.cc » ('j') | 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 "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/display/screen.h"
24 #include "ui/gfx/canvas.h" 25 #include "ui/gfx/canvas.h"
25 #include "ui/gfx/geometry/safe_integer_conversions.h" 26 #include "ui/gfx/geometry/safe_integer_conversions.h"
26 #include "ui/gfx/geometry/size_conversions.h" 27 #include "ui/gfx/geometry/size_conversions.h"
27 #include "ui/gfx/image/image.h" 28 #include "ui/gfx/image/image.h"
28 #include "ui/gfx/screen.h"
29 #include "ui/gfx/transform.h" 29 #include "ui/gfx/transform.h"
30 #include "ui/views/widget/widget.h" 30 #include "ui/views/widget/widget.h"
31 31
32 using wallpaper::WallpaperLayout; 32 using wallpaper::WallpaperLayout;
33 using wallpaper::WALLPAPER_LAYOUT_CENTER; 33 using wallpaper::WALLPAPER_LAYOUT_CENTER;
34 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED; 34 using wallpaper::WALLPAPER_LAYOUT_CENTER_CROPPED;
35 using wallpaper::WALLPAPER_LAYOUT_STRETCH; 35 using wallpaper::WALLPAPER_LAYOUT_STRETCH;
36 using wallpaper::WALLPAPER_LAYOUT_TILE; 36 using wallpaper::WALLPAPER_LAYOUT_TILE;
37 37
38 namespace ash { 38 namespace ash {
39 namespace { 39 namespace {
40 40
41 // 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
42 // 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
43 // 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
44 // size when laid-out. 44 // size when laid-out.
45 // 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
46 // it back to the screen size in the compositor. 46 // it back to the screen size in the compositor.
47 class LayerControlView : public views::View { 47 class LayerControlView : public views::View {
48 public: 48 public:
49 explicit LayerControlView(views::View* view) { 49 explicit LayerControlView(views::View* view) {
50 AddChildView(view); 50 AddChildView(view);
51 view->SetPaintToLayer(true); 51 view->SetPaintToLayer(true);
52 } 52 }
53 53
54 // Overrides views::View. 54 // Overrides views::View.
55 void Layout() override { 55 void Layout() override {
56 gfx::Display display = gfx::Screen::GetScreen()->GetDisplayNearestWindow( 56 display::Display display =
57 GetWidget()->GetNativeView()); 57 display::Screen::GetScreen()->GetDisplayNearestWindow(
58 GetWidget()->GetNativeView());
58 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); 59 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
59 DisplayInfo info = display_manager->GetDisplayInfo(display.id()); 60 DisplayInfo info = display_manager->GetDisplayInfo(display.id());
60 float ui_scale = info.GetEffectiveUIScale(); 61 float ui_scale = info.GetEffectiveUIScale();
61 gfx::Size rounded_size = 62 gfx::Size rounded_size =
62 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale); 63 gfx::ScaleToFlooredSize(display.size(), 1.f / ui_scale);
63 DCHECK_EQ(1, child_count()); 64 DCHECK_EQ(1, child_count());
64 views::View* child = child_at(0); 65 views::View* child = child_at(0);
65 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height()); 66 child->SetBounds(0, 0, rounded_size.width(), rounded_size.height());
66 gfx::Transform transform; 67 gfx::Transform transform;
67 // Apply RTL transform explicitly becacuse Views layer code 68 // Apply RTL transform explicitly becacuse Views layer code
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 // Disable animation if transition to login screen from an empty background. 248 // Disable animation if transition to login screen from an empty background.
248 ::wm::SetWindowVisibilityAnimationTransition( 249 ::wm::SetWindowVisibilityAnimationTransition(
249 desktop_widget->GetNativeView(), ::wm::ANIMATE_NONE); 250 desktop_widget->GetNativeView(), ::wm::ANIMATE_NONE);
250 } 251 }
251 252
252 desktop_widget->SetBounds(params.parent->bounds()); 253 desktop_widget->SetBounds(params.parent->bounds());
253 return desktop_widget; 254 return desktop_widget;
254 } 255 }
255 256
256 } // namespace ash 257 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_controller.cc ('k') | ash/dip_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698