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

Unified Diff: webkit/glue/webcursor_aurax11.cc

Issue 10697082: aura: Scale custom cursors appropriately. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
« webkit/glue/webcursor_aurawin.cc ('K') | « webkit/glue/webcursor_aurawin.cc ('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..98f8d0611e256d84d2add9b9882ee12729fa07f7 100644
--- a/webkit/glue/webcursor_aurax11.cc
+++ b/webkit/glue/webcursor_aurax11.cc
@@ -9,6 +9,7 @@
#include <X11/cursorfont.h>
#include "base/logging.h"
+#include "skia/ext/image_operations.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebCursorInfo.h"
#include "ui/base/cursor/cursor.h"
#include "ui/base/x/x11_util.h"
@@ -23,13 +24,37 @@ const ui::PlatformCursor WebCursor::GetPlatformCursor() {
bitmap.allocPixels();
memcpy(bitmap.getAddr32(0, 0), custom_data_.data(), custom_data_.size());
- XcursorImage* image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_);
+ XcursorImage* image = NULL;
+ if (scale_factor_ == 1.f) {
+ image = ui::SkBitmapToXcursorImage(&bitmap, hotspot_);
+ } else {
+ gfx::Size scaled_size = custom_size_.Scale(scale_factor_);
+ SkBitmap scaled_bitmap = skia::ImageOperations::Resize(bitmap,
+ skia::ImageOperations::RESIZE_BETTER,
+ scaled_size.width(),
+ scaled_size.height());
+ image = ui::SkBitmapToXcursorImage(&scaled_bitmap,
+ hotspot_.Scale(scale_factor_));
+ }
platform_cursor_ = ui::CreateReffedCustomXCursor(image);
return platform_cursor_;
}
+void WebCursor::SetScaleFactor(float scale_factor) {
+ if (scale_factor_ == scale_factor)
+ return;
+
+ scale_factor_ = scale_factor;
+ if (platform_cursor_)
+ ui::UnrefCustomXCursor(platform_cursor_);
+ platform_cursor_ = 0;
+ // It is not necessary to recreate platform_cursor_ yet, since it will be
+ // recreated on demand when GetPlatformCursor is called.
+}
+
void WebCursor::InitPlatformData() {
platform_cursor_ = 0;
+ scale_factor_ = 1.f;
}
bool WebCursor::SerializePlatformData(Pickle* pickle) const {
@@ -57,4 +82,6 @@ void WebCursor::CopyPlatformData(const WebCursor& other) {
platform_cursor_ = other.platform_cursor_;
if (platform_cursor_)
ui::RefCustomXCursor(platform_cursor_);
+
+ scale_factor_ = other.scale_factor_;
}
« webkit/glue/webcursor_aurawin.cc ('K') | « webkit/glue/webcursor_aurawin.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698