Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / ui / base / cursor / cursor_loader_x11.cc
index 0161da2..e0bb9ea 100644 (file)
@@ -159,12 +159,13 @@ 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;
+  // TODO(oshima): The cursor should use resource scale factor when
+  // fractional scale factor is enabled. crbug.com/372212
   ScaleAndRotateCursorBitmapAndHotpoint(
-      scale(), display().rotation(), &bitmap, &hotpoint);
+      scale() / image_rep.scale(), rotation(), &bitmap, &hotpoint);
 
   XcursorImage* x_image = SkBitmapToXcursorImage(&bitmap, hotpoint);
   cursors_[id] = CreateReffedCustomXCursor(x_image);
@@ -175,10 +176,10 @@ void CursorLoaderX11::LoadAnimatedCursor(int id,
                                          int resource_id,
                                          const gfx::Point& hot,
                                          int frame_delay_ms) {
+  // TODO(oshima|tdanderson): Support rotation and fractional scale factor.
   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 +234,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);
@@ -243,6 +243,10 @@ void CursorLoaderX11::SetPlatformCursor(gfx::NativeCursor* cursor) {
   cursor->SetPlatformCursor(xcursor);
 }
 
+const XcursorImage* CursorLoaderX11::GetXcursorImageForTest(int id) {
+  return test::GetCachedXcursorImage(cursors_[id]);
+}
+
 bool CursorLoaderX11::IsImageCursor(gfx::NativeCursor native_cursor) {
   int type = native_cursor.native_type();
   return cursors_.count(type) || animated_cursors_.count(type);