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

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: 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..a030a5506c26baf1a7169dd7556e518bf1f0f258 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,23 @@ void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia,
const gfx::Vector2d& cursor_offset,
ui::OSExchangeData* data_object) {
DCHECK(data_object && !image_skia.size().IsEmpty());
+
+ // Attempt to find a bitmap matching the current dpi scale, failing which we
+ // fallback to the 1x bitmap.
+ SkBitmap skia_bitmap;
+ if (image_skia.HasRepresentation(gfx::GetDPIScale())) {
sky 2015/11/25 23:32:54 If it doesn't have a rep for the specified dpi, sh
ananta 2015/11/25 23:37:14 My bad. We should just use GetRepresentation which
+ gfx::ImageSkiaRep image_rep_for_scale = image_skia.GetRepresentation(
+ gfx::GetDPIScale());
+ skia_bitmap = image_rep_for_scale.sk_bitmap();
+ } else {
+ skia_bitmap = *image_skia.bitmap();
+ }
+
// 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(
+ skia_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