Chromium Code Reviews| 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( |