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/wm/image_cursors.h" | 5 #include "ash/wm/image_cursors.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "ui/base/cursor/cursor.h" | 9 #include "ui/base/cursor/cursor.h" |
10 #include "ui/base/cursor/cursor_loader.h" | 10 #include "ui/base/cursor/cursor_loader.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 ui::kCursorProgress | 54 ui::kCursorProgress |
55 }; | 55 }; |
56 | 56 |
57 ImageCursors::ImageCursors() { | 57 ImageCursors::ImageCursors() { |
58 } | 58 } |
59 | 59 |
60 ImageCursors::~ImageCursors() { | 60 ImageCursors::~ImageCursors() { |
61 } | 61 } |
62 | 62 |
63 gfx::Display ImageCursors::GetDisplay() const { | 63 gfx::Display ImageCursors::GetDisplay() const { |
64 if (!cursor_loader_.get()) { | 64 if (!cursor_loader_) { |
65 NOTREACHED(); | 65 NOTREACHED(); |
66 // Returning default on release build as it's not serious enough to crash | 66 // Returning default on release build as it's not serious enough to crash |
67 // even if this ever happens. | 67 // even if this ever happens. |
68 return gfx::Display(); | 68 return gfx::Display(); |
69 } | 69 } |
70 return cursor_loader_->display(); | 70 return cursor_loader_->display(); |
71 } | 71 } |
72 | 72 |
73 bool ImageCursors::SetDisplay(const gfx::Display& display) { | 73 bool ImageCursors::SetDisplay(const gfx::Display& display) { |
74 float device_scale_factor = display.device_scale_factor(); | 74 float device_scale_factor = display.device_scale_factor(); |
75 if (!cursor_loader_.get()) { | 75 if (!cursor_loader_) { |
76 cursor_loader_.reset(ui::CursorLoader::Create()); | 76 cursor_loader_.reset(ui::CursorLoader::Create()); |
77 } else if (cursor_loader_->display().rotation() == display.rotation() && | 77 } else if (cursor_loader_->display().rotation() == display.rotation() && |
78 cursor_loader_->display().device_scale_factor() == | 78 cursor_loader_->display().device_scale_factor() == |
79 device_scale_factor) { | 79 device_scale_factor) { |
80 return false; | 80 return false; |
81 } | 81 } |
82 | 82 |
83 cursor_loader_->UnloadAll(); | 83 cursor_loader_->UnloadAll(); |
84 cursor_loader_->set_display(display); | 84 cursor_loader_->set_display(display); |
85 | 85 |
(...skipping 25 matching lines...) Expand all Loading... |
111 | 111 |
112 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { | 112 void ImageCursors::SetPlatformCursor(gfx::NativeCursor* cursor) { |
113 cursor_loader_->SetPlatformCursor(cursor); | 113 cursor_loader_->SetPlatformCursor(cursor); |
114 } | 114 } |
115 | 115 |
116 void ImageCursors::SetCursorResourceModule(const base::string16& module_name) { | 116 void ImageCursors::SetCursorResourceModule(const base::string16& module_name) { |
117 cursor_loader_->SetCursorResourceModule(module_name); | 117 cursor_loader_->SetCursorResourceModule(module_name); |
118 } | 118 } |
119 | 119 |
120 } // namespace ash | 120 } // namespace ash |
OLD | NEW |