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 "webkit/glue/webcursor.h" | 5 #include "webkit/glue/webcursor.h" |
6 | 6 |
7 #include <X11/Xcursor/Xcursor.h> | 7 #include <X11/Xcursor/Xcursor.h> |
8 #include <X11/Xlib.h> | 8 #include <X11/Xlib.h> |
9 #include <X11/cursorfont.h> | 9 #include <X11/cursorfont.h> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 XcursorImage* image = NULL; | 29 XcursorImage* image = NULL; |
30 if (scale_factor_ == 1.f) { | 30 if (scale_factor_ == 1.f) { |
31 image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_); | 31 image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_); |
32 } else { | 32 } else { |
33 gfx::Size scaled_size = gfx::ToFlooredSize( | 33 gfx::Size scaled_size = gfx::ToFlooredSize( |
34 custom_size_.Scale(scale_factor_)); | 34 custom_size_.Scale(scale_factor_)); |
35 SkBitmap scaled_bitmap = skia::ImageOperations::Resize(bitmap, | 35 SkBitmap scaled_bitmap = skia::ImageOperations::Resize(bitmap, |
36 skia::ImageOperations::RESIZE_BETTER, | 36 skia::ImageOperations::RESIZE_BETTER, |
37 scaled_size.width(), | 37 scaled_size.width(), |
38 scaled_size.height()); | 38 scaled_size.height()); |
39 image = ui::SkBitmapToXcursorImage(&scaled_bitmap, | 39 gfx::Point hotspot_point = gfx::ToFlooredPoint( |
40 gfx::ToFlooredPoint( | 40 gfx::ScalePoint(hotspot_, scale_factor_)); |
41 hotspot_.Scale(scale_factor_))); | 41 image = ui::SkBitmapToXcursorImage(&scaled_bitmap, hotspot_point); |
42 } | 42 } |
43 platform_cursor_ = ui::CreateReffedCustomXCursor(image); | 43 platform_cursor_ = ui::CreateReffedCustomXCursor(image); |
44 return platform_cursor_; | 44 return platform_cursor_; |
45 } | 45 } |
46 | 46 |
47 void WebCursor::SetScaleFactor(float scale_factor) { | 47 void WebCursor::SetScaleFactor(float scale_factor) { |
48 if (scale_factor_ == scale_factor) | 48 if (scale_factor_ == scale_factor) |
49 return; | 49 return; |
50 | 50 |
51 scale_factor_ = scale_factor; | 51 scale_factor_ = scale_factor; |
(...skipping 30 matching lines...) Expand all Loading... |
82 | 82 |
83 void WebCursor::CopyPlatformData(const WebCursor& other) { | 83 void WebCursor::CopyPlatformData(const WebCursor& other) { |
84 if (platform_cursor_) | 84 if (platform_cursor_) |
85 ui::UnrefCustomXCursor(platform_cursor_); | 85 ui::UnrefCustomXCursor(platform_cursor_); |
86 platform_cursor_ = other.platform_cursor_; | 86 platform_cursor_ = other.platform_cursor_; |
87 if (platform_cursor_) | 87 if (platform_cursor_) |
88 ui::RefCustomXCursor(platform_cursor_); | 88 ui::RefCustomXCursor(platform_cursor_); |
89 | 89 |
90 scale_factor_ = other.scale_factor_; | 90 scale_factor_ = other.scale_factor_; |
91 } | 91 } |
OLD | NEW |