Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: webkit/glue/webcursor_aurax11.cc

Issue 10386020: Revert r135533. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/ui.gyp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/glue/webcursor_aurax11.cc
diff --git a/webkit/glue/webcursor_aurax11.cc b/webkit/glue/webcursor_aurax11.cc
index b3f698900688279d109a280aaeb58f4c3f235a95..fe221e29f80bd7b183adad5ee8ac74b8b6fca83d 100644
--- a/webkit/glue/webcursor_aurax11.cc
+++ b/webkit/glue/webcursor_aurax11.cc
@@ -10,6 +10,7 @@
#include "base/logging.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
+#include "third_party/skia/include/core/SkUnPreMultiply.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/x/x11_util.h"
@@ -17,13 +18,35 @@ const ui::PlatformCursor WebCursor::GetPlatformCursor() {
if (platform_cursor_)
return platform_cursor_;
- SkBitmap bitmap;
- bitmap.setConfig(SkBitmap::kARGB_8888_Config,
- custom_size_.width(), custom_size_.height());
- bitmap.allocPixels();
- memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
+ XcursorImage* image =
+ XcursorImageCreate(custom_size_.width(), custom_size_.height());
+ image->xhot = hotspot_.x();
+ image->yhot = hotspot_.y();
+ uint32* pixels = image->pixels;
+
+ if (custom_size_.width() && custom_size_.height()) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config,
+ custom_size_.width(), custom_size_.height());
+ bitmap.allocPixels();
+ memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
+
+ bitmap.lockPixels();
+ int height = bitmap.height(), 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();
+ }
- XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_);
platform_cursor_ = ui::CreateReffedCustomXCursor(image);
return platform_cursor_;
}
« no previous file with comments | « ui/ui.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698