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/shell.h" | 10 #include "ash/shell.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // For our scaling ratios we need to round positive numbers. | 23 // For our scaling ratios we need to round positive numbers. |
24 static int RoundPositive(double x) { | 24 static int RoundPositive(double x) { |
25 return static_cast<int>(floor(x + 0.5)); | 25 return static_cast<int>(floor(x + 0.5)); |
26 } | 26 } |
27 | 27 |
28 //////////////////////////////////////////////////////////////////////////////// | 28 //////////////////////////////////////////////////////////////////////////////// |
29 // DesktopBackgroundView, public: | 29 // DesktopBackgroundView, public: |
30 | 30 |
31 DesktopBackgroundView::DesktopBackgroundView() { | 31 DesktopBackgroundView::DesktopBackgroundView() { |
32 wallpaper_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( | 32 wallpaper_ = *ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
33 IDR_AURA_WALLPAPER).ToSkBitmap(); | 33 IDR_AURA_WALLPAPER_1).ToSkBitmap(); |
34 wallpaper_.buildMipMap(false); | 34 wallpaper_.buildMipMap(false); |
35 } | 35 } |
36 | 36 |
37 DesktopBackgroundView::~DesktopBackgroundView() { | 37 DesktopBackgroundView::~DesktopBackgroundView() { |
38 } | 38 } |
39 | 39 |
40 //////////////////////////////////////////////////////////////////////////////// | 40 //////////////////////////////////////////////////////////////////////////////// |
41 // DesktopBackgroundView, views::View overrides: | 41 // DesktopBackgroundView, views::View overrides: |
42 | 42 |
43 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { | 43 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { |
(...skipping 20 matching lines...) Expand all Loading... |
64 cropped_size = gfx::Size(wallpaper_.width(), | 64 cropped_size = gfx::Size(wallpaper_.width(), |
65 RoundPositive(static_cast<double>(height()) / horizontal_ratio)); | 65 RoundPositive(static_cast<double>(height()) / horizontal_ratio)); |
66 } | 66 } |
67 | 67 |
68 gfx::Rect wallpaper_cropped_rect = wallpaper_rect.Center(cropped_size); | 68 gfx::Rect wallpaper_cropped_rect = wallpaper_rect.Center(cropped_size); |
69 canvas->DrawBitmapInt(wallpaper_, | 69 canvas->DrawBitmapInt(wallpaper_, |
70 wallpaper_cropped_rect.x(), wallpaper_cropped_rect.y(), | 70 wallpaper_cropped_rect.x(), wallpaper_cropped_rect.y(), |
71 wallpaper_cropped_rect.width(), wallpaper_cropped_rect.height(), | 71 wallpaper_cropped_rect.width(), wallpaper_cropped_rect.height(), |
72 0, 0, width(), height(), | 72 0, 0, width(), height(), |
73 true); | 73 true); |
74 } | 74 } else { |
75 else { | |
76 // Center the wallpaper in the destination rectangle (Skia will crop | 75 // Center the wallpaper in the destination rectangle (Skia will crop |
77 // as needed). We might decide later to tile small solid color images. | 76 // as needed). We might decide later to tile small solid color images. |
78 canvas->DrawBitmapInt(wallpaper_, (width() - wallpaper_.width()) / 2, | 77 canvas->DrawBitmapInt(wallpaper_, (width() - wallpaper_.width()) / 2, |
79 (height() - wallpaper_.height()) / 2); | 78 (height() - wallpaper_.height()) / 2); |
80 } | 79 } |
81 } | 80 } |
82 | 81 |
83 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { | 82 bool DesktopBackgroundView::OnMousePressed(const views::MouseEvent& event) { |
84 return true; | 83 return true; |
85 } | 84 } |
(...skipping 14 matching lines...) Expand all Loading... |
100 ash::internal::kShellWindowId_DesktopBackgroundContainer); | 99 ash::internal::kShellWindowId_DesktopBackgroundContainer); |
101 desktop_widget->Init(params); | 100 desktop_widget->Init(params); |
102 desktop_widget->SetContentsView(view); | 101 desktop_widget->SetContentsView(view); |
103 desktop_widget->Show(); | 102 desktop_widget->Show(); |
104 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); | 103 desktop_widget->GetNativeView()->SetName("DesktopBackgroundView"); |
105 return desktop_widget; | 104 return desktop_widget; |
106 } | 105 } |
107 | 106 |
108 } // namespace internal | 107 } // namespace internal |
109 } // namespace ash | 108 } // namespace ash |
OLD | NEW |