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

Unified Diff: content/common/cursors/webcursor_aura.cc

Issue 1525263004: hidpi support for custom cursors in windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 5 years 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
Index: content/common/cursors/webcursor_aura.cc
diff --git a/content/common/cursors/webcursor_aura.cc b/content/common/cursors/webcursor_aura.cc
index 584ebdfb600f26b2b030284eb189a7648a2a71be..34868704001a86759e50ea6fd1ded0b174eeb2cb 100644
--- a/content/common/cursors/webcursor_aura.cc
+++ b/content/common/cursors/webcursor_aura.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "third_party/WebKit/public/platform/WebCursorInfo.h"
#include "ui/base/cursor/cursor.h"
+#include "ui/base/cursor/cursor_util.h"
using blink::WebCursorInfo;
@@ -111,4 +112,31 @@ gfx::NativeCursor WebCursor::GetNativeCursor() {
}
}
+float WebCursor::GetCursorScaleFactor() {
+ DCHECK(custom_scale_ != 0);
+ return device_scale_factor_ / custom_scale_;
+}
+
+void WebCursor::CreateScaledBitmapAndHotspotFromCustomData(
+ SkBitmap* bitmap,
+ gfx::Point* hotspot) {
+ DCHECK(custom_data_.size() > 0);
+ *hotspot = hotspot_;
+ bitmap->allocN32Pixels(custom_size_.width(), custom_size_.height());
+ memcpy(bitmap->getAddr32(0, 0), custom_data_.data(), custom_data_.size());
+ ui::ScaleAndRotateCursorBitmapAndHotpoint(
+ GetCursorScaleFactor(), gfx::Display::ROTATE_0, bitmap, hotspot);
+}
+
+// ozone has its own SetDisplayInfo that takes rotation into account
+#if !defined(USE_OZONE)
+void WebCursor::SetDisplayInfo(const gfx::Display& display) {
+ if (device_scale_factor_ == display.device_scale_factor())
+ return;
+
+ device_scale_factor_ = display.device_scale_factor();
+ CleanupPlatformData();
+}
+#endif
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698