Index: ui/base/x/x11_util.cc |
diff --git a/ui/base/x/x11_util.cc b/ui/base/x/x11_util.cc |
index 5df42c04eb09c35354edd93887f881021781dbd3..e90a303f9b6cab8ee5b7fcc45cca5bab0cc1556a 100644 |
--- a/ui/base/x/x11_util.cc |
+++ b/ui/base/x/x11_util.cc |
@@ -37,6 +37,8 @@ |
#if defined(USE_AURA) |
#include <X11/Xcursor/Xcursor.h> |
+#include "third_party/skia/include/core/SkBitmap.h" |
+#include "third_party/skia/include/core/SkUnPreMultiply.h" |
#endif |
#if defined(TOOLKIT_GTK) |
@@ -411,6 +413,34 @@ void RefCustomXCursor(::Cursor cursor) { |
void UnrefCustomXCursor(::Cursor cursor) { |
XCustomCursorCache::GetInstance()->Unref(cursor); |
} |
+ |
+XcursorImage* SkBitmapToXcursorImage(const SkBitmap* bitmap, |
+ const gfx::Point& hotspot) { |
+ DCHECK(bitmap->config() == SkBitmap::kARGB_8888_Config); |
+ XcursorImage* image = XcursorImageCreate(bitmap->width(), bitmap->height()); |
sky
2012/05/03 21:09:44
Can you move ConvertSkiatoRGBA to a common place?
varunjain
2012/05/03 22:12:20
Done.
|
+ image->xhot = hotspot.x(); |
+ image->yhot = hotspot.y(); |
+ uint32* pixels = image->pixels; |
+ |
+ if (bitmap->width() && bitmap->height()) { |
+ bitmap->lockPixels(); |
+ int height = bitmap->height(); |
+ int width = bitmap->width(); |
+ for (int y = 0, i = 0; y < height; y++) { |
+ for (int x = 0; x < width; x++) { |
+ uint32 pixel = bitmap->getAddr32(0, y)[x]; |
+ int alpha = SkColorGetA(pixel); |
+ if (alpha != 0 && alpha != 255) |
+ pixels[i] = SkUnPreMultiply::PMColorToColor(pixel); |
+ else |
+ pixels[i] = pixel; |
+ ++i; |
+ } |
+ } |
+ bitmap->unlockPixels(); |
+ } |
+ return image; |
+} |
#endif |
XID GetX11RootWindow() { |