| 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 13 matching lines...) Expand all Loading... |
| 24 bitmap.setConfig(SkBitmap::kARGB_8888_Config, | 24 bitmap.setConfig(SkBitmap::kARGB_8888_Config, |
| 25 custom_size_.width(), custom_size_.height()); | 25 custom_size_.width(), custom_size_.height()); |
| 26 bitmap.allocPixels(); | 26 bitmap.allocPixels(); |
| 27 memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size()); | 27 memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size()); |
| 28 | 28 |
| 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 gfx::ScaleSize(custom_size_, 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 gfx::Point hotspot_point = gfx::ToFlooredPoint( | 39 gfx::Point hotspot_point = gfx::ToFlooredPoint( |
| 40 gfx::ScalePoint(hotspot_, scale_factor_)); | 40 gfx::ScalePoint(hotspot_, scale_factor_)); |
| 41 image = ui::SkBitmapToXcursorImage(&scaled_bitmap, hotspot_point); | 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_; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |