summaryrefslogtreecommitdiffstats
path: root/ui/base
diff options
context:
space:
mode:
authoroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 09:03:29 +0000
committeroshima@chromium.org <oshima@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-23 09:03:29 +0000
commita7736a58c95220c405e5ff06ecddb387e3842328 (patch)
tree1ca004d883106f30def1ed3c846d6ed2bce3692e /ui/base
parent2fb3888046f9206c1c91357f36502642897ea4d6 (diff)
downloadchromium_src-a7736a58c95220c405e5ff06ecddb387e3842328.zip
chromium_src-a7736a58c95220c405e5ff06ecddb387e3842328.tar.gz
chromium_src-a7736a58c95220c405e5ff06ecddb387e3842328.tar.bz2
Use platform's device scale factor for cursor instead of gfx::Display because gfx::Display's DSF may differ from
platform's one when UI scaling is used. BUG=361672 TEST=covered by unit test Review URL: https://codereview.chromium.org/226293005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265592 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/base')
-rw-r--r--ui/base/cursor/cursor_loader.h14
-rw-r--r--ui/base/cursor/cursor_loader_ozone.cc2
-rw-r--r--ui/base/cursor/cursor_loader_x11.cc11
3 files changed, 11 insertions, 16 deletions
diff --git a/ui/base/cursor/cursor_loader.h b/ui/base/cursor/cursor_loader.h
index 8526e29..0e16237 100644
--- a/ui/base/cursor/cursor_loader.h
+++ b/ui/base/cursor/cursor_loader.h
@@ -19,14 +19,12 @@ class UI_BASE_EXPORT CursorLoader {
CursorLoader() : scale_(1.f) {}
virtual ~CursorLoader() {}
- // Returns the display the loader loads images for.
- const gfx::Display& display() const {
- return display_;
+ gfx::Display::Rotation rotation() const {
+ return rotation_;
}
- // Sets the display the loader loads images for.
- void set_display(const gfx::Display& display) {
- display_ = display;
+ void set_rotation(gfx::Display::Rotation rotation) {
+ rotation_ = rotation;
}
// Returns the current scale of the mouse cursor icon.
@@ -64,8 +62,8 @@ class UI_BASE_EXPORT CursorLoader {
static CursorLoader* Create();
private:
- // The display the loader loads images for.
- gfx::Display display_;
+ // The current rotation of the mouse cursor icon.
+ gfx::Display::Rotation rotation_;
// The current scale of the mouse cursor icon.
float scale_;
diff --git a/ui/base/cursor/cursor_loader_ozone.cc b/ui/base/cursor/cursor_loader_ozone.cc
index 19dddf5..b56648f 100644
--- a/ui/base/cursor/cursor_loader_ozone.cc
+++ b/ui/base/cursor/cursor_loader_ozone.cc
@@ -21,7 +21,7 @@ void CursorLoaderOzone::LoadImageCursor(int id,
const gfx::ImageSkia* image =
ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
const gfx::ImageSkiaRep& image_rep =
- image->GetRepresentation(display().device_scale_factor());
+ image->GetRepresentation(scale());
SkBitmap bitmap = image_rep.sk_bitmap();
cursors_[id] =
CursorFactoryOzone::GetInstance()->CreateImageCursor(bitmap, hot);
diff --git a/ui/base/cursor/cursor_loader_x11.cc b/ui/base/cursor/cursor_loader_x11.cc
index 0161da2..9c2f609 100644
--- a/ui/base/cursor/cursor_loader_x11.cc
+++ b/ui/base/cursor/cursor_loader_x11.cc
@@ -159,12 +159,11 @@ void CursorLoaderX11::LoadImageCursor(int id,
const gfx::Point& hot) {
const gfx::ImageSkia* image =
ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
- const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
- display().device_scale_factor());
+ const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(scale());
SkBitmap bitmap = image_rep.sk_bitmap();
gfx::Point hotpoint = hot;
ScaleAndRotateCursorBitmapAndHotpoint(
- scale(), display().rotation(), &bitmap, &hotpoint);
+ scale(), rotation(), &bitmap, &hotpoint);
XcursorImage* x_image = SkBitmapToXcursorImage(&bitmap, hotpoint);
cursors_[id] = CreateReffedCustomXCursor(x_image);
@@ -177,8 +176,7 @@ void CursorLoaderX11::LoadAnimatedCursor(int id,
int frame_delay_ms) {
const gfx::ImageSkia* image =
ResourceBundle::GetSharedInstance().GetImageSkiaNamed(resource_id);
- const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(
- display().device_scale_factor());
+ const gfx::ImageSkiaRep& image_rep = image->GetRepresentation(scale());
SkBitmap bitmap = image_rep.sk_bitmap();
int frame_width = bitmap.height();
int frame_height = frame_width;
@@ -233,8 +231,7 @@ void CursorLoaderX11::SetPlatformCursor(gfx::NativeCursor* cursor) {
xcursor = invisible_cursor_.get();
else if (*cursor == kCursorCustom)
xcursor = cursor->platform();
- else if (display().device_scale_factor() == 1.0f &&
- display().rotation() == gfx::Display::ROTATE_0) {
+ else if (scale() == 1.0f && rotation() == gfx::Display::ROTATE_0) {
xcursor = GetXCursor(CursorShapeFromNative(*cursor));
} else {
xcursor = ImageCursorFromNative(kCursorPointer);