Commit a558100b authored by oshima's avatar oshima Committed by Commit bot

Use the resource scale factor for cursor.

BUG=411415
TEST=covered by unit tests.

Review URL: https://codereview.chromium.org/562003002

Cr-Commit-Position: refs/heads/master@{#294328}
parent 5252b822
......@@ -13,6 +13,7 @@
#include "ui/aura/window_tree_host.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/cursor/image_cursors.h"
#include "ui/base/layout.h"
namespace ash {
namespace {
......@@ -75,9 +76,17 @@ void AshNativeCursorManager::SetDisplay(
DCHECK(display.is_valid());
// Use the platform's device scale factor instead of the display's, which
// might have been adjusted for the UI scale.
const float scale_factor = Shell::GetInstance()->display_manager()->
const float original_scale = Shell::GetInstance()->display_manager()->
GetDisplayInfo(display.id()).device_scale_factor();
if (image_cursors_->SetDisplay(display, scale_factor))
#if defined(OS_CHROMEOS)
// And use the nearest resource scale factor.
const float cursor_scale = ui::GetScaleForScaleFactor(
ui::GetSupportedScaleFactor(original_scale));
#else
// TODO(oshima): crbug.com/143619
const float cursor_scale = original_scale;
#endif
if (image_cursors_->SetDisplay(display, cursor_scale))
SetCursor(delegate->GetCursor(), delegate);
#if defined(OS_CHROMEOS)
Shell::GetInstance()->display_controller()->cursor_window_controller()->
......
......@@ -146,6 +146,17 @@ TEST_F(AshNativeCursorManagerTest, SetDeviceScaleFactorAndRotation) {
EXPECT_EQ(gfx::Display::ROTATE_270, test_api.GetCurrentCursorRotation());
}
#if defined(OS_CHROMEOS)
// TODO(oshima): crbug.com/143619
TEST_F(AshNativeCursorManagerTest, FractionalScale) {
::wm::CursorManager* cursor_manager = Shell::GetInstance()->cursor_manager();
CursorManagerTestApi test_api(cursor_manager);
// Cursor should use the resource scale factor.
UpdateDisplay("800x100*1.25");
EXPECT_EQ(1.0f, test_api.GetCurrentCursor().device_scale_factor());
}
#endif
TEST_F(AshNativeCursorManagerTest, UIScaleShouldNotChangeCursor) {
int64 display_id = Shell::GetScreen()->GetPrimaryDisplay().id();
gfx::Display::SetInternalDisplayId(display_id);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment