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

Unified Diff: ash/wm/image_cursors.cc

Issue 249303002: Revert of Use platform's device scale factor for cursor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/wm/image_cursors.h ('k') | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/image_cursors.cc
diff --git a/ash/wm/image_cursors.cc b/ash/wm/image_cursors.cc
index 2a41375d19658c8ea9a437a775cf96f8391da808..e63bece7ffd9389cba0e9d074d345ea4ae8aaa82 100644
--- a/ash/wm/image_cursors.cc
+++ b/ash/wm/image_cursors.cc
@@ -6,9 +6,6 @@
#include <float.h>
-#include "ash/display/display_info.h"
-#include "ash/display/display_manager.h"
-#include "ash/shell.h"
#include "base/logging.h"
#include "base/strings/string16.h"
#include "ui/base/cursor/cursor.h"
@@ -59,54 +56,41 @@
ui::kCursorProgress
};
-ImageCursors::ImageCursors() : cursor_set_(ui::CURSOR_SET_NORMAL) {
+ImageCursors::ImageCursors() : scale_(1.f), cursor_set_(ui::CURSOR_SET_NORMAL) {
}
ImageCursors::~ImageCursors() {
}
-float ImageCursors::GetScale() const {
+gfx::Display ImageCursors::GetDisplay() const {
if (!cursor_loader_) {
NOTREACHED();
// Returning default on release build as it's not serious enough to crash
// even if this ever happens.
- return 1.0f;
+ return gfx::Display();
}
- return cursor_loader_->scale();
-}
-
-gfx::Display::Rotation ImageCursors::GetRotation() const {
- if (!cursor_loader_) {
- NOTREACHED();
- // Returning default on release build as it's not serious enough to crash
- // even if this ever happens.
- return gfx::Display::ROTATE_0;
- }
- return cursor_loader_->rotation();
+ return cursor_loader_->display();
}
bool ImageCursors::SetDisplay(const gfx::Display& display) {
- DCHECK(display.is_valid());
- // Use the platform's device scale factor instead of display's
- // that might have been adjusted for UI scale.
- float scale_factor = Shell::GetInstance()->display_manager()->
- GetDisplayInfo(display.id()).device_scale_factor();
-
+ float device_scale_factor = display.device_scale_factor();
if (!cursor_loader_) {
cursor_loader_.reset(ui::CursorLoader::Create());
- } else if (cursor_loader_->rotation() == display.rotation() &&
- cursor_loader_->scale() == scale_factor) {
+ cursor_loader_->set_scale(scale_);
+ } else if (cursor_loader_->display().rotation() == display.rotation() &&
+ cursor_loader_->display().device_scale_factor() ==
+ device_scale_factor) {
return false;
}
- cursor_loader_->set_rotation(display.rotation());
- cursor_loader_->set_scale(scale_factor);
+ cursor_loader_->set_display(display);
ReloadCursors();
return true;
}
void ImageCursors::ReloadCursors() {
- float device_scale_factor = cursor_loader_->scale();
+ const gfx::Display& display = cursor_loader_->display();
+ float device_scale_factor = display.device_scale_factor();
cursor_loader_->UnloadAll();
@@ -137,6 +121,20 @@
}
}
+void ImageCursors::SetScale(float scale) {
+ if (scale < FLT_EPSILON) {
+ NOTREACHED() << "Scale must be bigger than 0.";
+ scale = 1.0f;
+ }
+
+ scale_ = scale;
+
+ if (cursor_loader_.get()) {
+ cursor_loader_->set_scale(scale);
+ ReloadCursors();
+ }
+}
+
void ImageCursors::SetCursorSet(ui::CursorSetType cursor_set) {
if (cursor_set_ == cursor_set)
return;
« no previous file with comments | « ash/wm/image_cursors.h ('k') | chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698