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

Unified Diff: ui/base/dragdrop/drag_utils_win.cc

Issue 1475263002: Ensure that the drag image during drag drop operations on Windows is of the correct scale. Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use GetRepresentation to find the closest match Created 5 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/dragdrop/drag_utils_win.cc
diff --git a/ui/base/dragdrop/drag_utils_win.cc b/ui/base/dragdrop/drag_utils_win.cc
index 9fedd4202a34ac8e32614fd9de5b9d15a07b8407..212ae21cd4ff48164b9f1a19cf401d3170a2d58f 100644
--- a/ui/base/dragdrop/drag_utils_win.cc
+++ b/ui/base/dragdrop/drag_utils_win.cc
@@ -18,6 +18,7 @@
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/skbitmap_operations.h"
+#include "ui/gfx/win/dpi.h"
namespace drag_utils {
@@ -61,11 +62,16 @@ void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia,
const gfx::Vector2d& cursor_offset,
sky 2015/11/25 23:38:43 I suspect you need to adjust cursor_offset too.
ananta 2015/12/01 02:42:28 Done.
ui::OSExchangeData* data_object) {
DCHECK(data_object && !image_skia.size().IsEmpty());
+
+ // Attempt to find a bitmap closely matching the current dpi scale.
+ gfx::ImageSkiaRep image_rep_for_scale = image_skia.GetRepresentation(
+ gfx::GetDPIScale());
+
// InitializeFromBitmap() doesn't expect an alpha channel and is confused
// by premultiplied colors, so unpremultiply the bitmap.
// SetDragImageOnDataObject(HBITMAP) takes ownership of the bitmap.
- HBITMAP bitmap = CreateHBITMAPFromSkBitmap(
- SkBitmapOperations::UnPreMultiply(*image_skia.bitmap()));
+ HBITMAP bitmap = CreateHBITMAPFromSkBitmap(SkBitmapOperations::UnPreMultiply(
+ image_rep_for_scale.sk_bitmap()));
if (bitmap) {
// Attach 'bitmap' to the data_object.
SetDragImageOnDataObject(
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698