| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/base/dragdrop/drag_utils.h" | 5 #include "ui/base/dragdrop/drag_utils.h" |
| 6 | 6 |
| 7 #include <objidl.h> | 7 #include <objidl.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <shobjidl.h> | 9 #include <shobjidl.h> |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 base::win::ScopedGetDC screen_dc(NULL); | 46 base::win::ScopedGetDC screen_dc(NULL); |
| 47 BITMAPINFOHEADER header; | 47 BITMAPINFOHEADER header; |
| 48 skia::CreateBitmapHeader(sk_bitmap.width(), sk_bitmap.height(), &header); | 48 skia::CreateBitmapHeader(sk_bitmap.width(), sk_bitmap.height(), &header); |
| 49 void* bits; | 49 void* bits; |
| 50 HBITMAP bitmap = | 50 HBITMAP bitmap = |
| 51 CreateDIBSection(screen_dc, reinterpret_cast<BITMAPINFO*>(&header), | 51 CreateDIBSection(screen_dc, reinterpret_cast<BITMAPINFO*>(&header), |
| 52 DIB_RGB_COLORS, &bits, NULL, 0); | 52 DIB_RGB_COLORS, &bits, NULL, 0); |
| 53 if (!bitmap || !bits) | 53 if (!bitmap || !bits) |
| 54 return NULL; | 54 return NULL; |
| 55 DCHECK_EQ(sk_bitmap.rowBytes(), static_cast<size_t>(sk_bitmap.width() * 4)); | 55 DCHECK_EQ(sk_bitmap.rowBytes(), static_cast<size_t>(sk_bitmap.width() * 4)); |
| 56 SkAutoLockPixels lock(sk_bitmap); | |
| 57 memcpy( | 56 memcpy( |
| 58 bits, sk_bitmap.getPixels(), sk_bitmap.height() * sk_bitmap.rowBytes()); | 57 bits, sk_bitmap.getPixels(), sk_bitmap.height() * sk_bitmap.rowBytes()); |
| 59 return bitmap; | 58 return bitmap; |
| 60 } | 59 } |
| 61 | 60 |
| 62 void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia, | 61 void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia, |
| 63 const gfx::Vector2d& cursor_offset, | 62 const gfx::Vector2d& cursor_offset, |
| 64 ui::OSExchangeData* data_object) { | 63 ui::OSExchangeData* data_object) { |
| 65 DCHECK(data_object && !image_skia.size().IsEmpty()); | 64 DCHECK(data_object && !image_skia.size().IsEmpty()); |
| 66 // InitializeFromBitmap() doesn't expect an alpha channel and is confused | 65 // InitializeFromBitmap() doesn't expect an alpha channel and is confused |
| (...skipping 11 matching lines...) Expand all Loading... |
| 78 } | 77 } |
| 79 | 78 |
| 80 // TODO: the above code is used in non-Ash, while below is used in Ash. If we | 79 // TODO: the above code is used in non-Ash, while below is used in Ash. If we |
| 81 // could figure this context out then we wouldn't do unnecessary work. However | 80 // could figure this context out then we wouldn't do unnecessary work. However |
| 82 // as it stands getting this information in ui/base would be a layering | 81 // as it stands getting this information in ui/base would be a layering |
| 83 // violation. | 82 // violation. |
| 84 data_object->provider().SetDragImage(image_skia, cursor_offset); | 83 data_object->provider().SetDragImage(image_skia, cursor_offset); |
| 85 } | 84 } |
| 86 | 85 |
| 87 } // namespace drag_utils | 86 } // namespace drag_utils |
| OLD | NEW |