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

Side by Side Diff: views/drag_utils_win.cc

Issue 2825018: Canvas refactoring part 3.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "views/drag_utils.h" 5 #include "views/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 10
11 #include "app/os_exchange_data.h" 11 #include "app/os_exchange_data.h"
12 #include "app/os_exchange_data_provider_win.h" 12 #include "app/os_exchange_data_provider_win.h"
13 #include "gfx/canvas.h" 13 #include "gfx/canvas_skia.h"
14 #include "gfx/gdi_util.h" 14 #include "gfx/gdi_util.h"
15 15
16 namespace drag_utils { 16 namespace drag_utils {
17 17
18 static void SetDragImageOnDataObject(HBITMAP hbitmap, 18 static void SetDragImageOnDataObject(HBITMAP hbitmap,
19 const gfx::Size& size, 19 const gfx::Size& size,
20 const gfx::Point& cursor_offset, 20 const gfx::Point& cursor_offset,
21 IDataObject* data_object) { 21 IDataObject* data_object) {
22 IDragSourceHelper* helper = NULL; 22 IDragSourceHelper* helper = NULL;
23 HRESULT rv = CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER, 23 HRESULT rv = CoCreateInstance(CLSID_DragDropHelper, 0, CLSCTX_INPROC_SERVER,
(...skipping 16 matching lines...) Expand all
40 HDC screen_dc = GetDC(NULL); 40 HDC screen_dc = GetDC(NULL);
41 BITMAPINFOHEADER header; 41 BITMAPINFOHEADER header;
42 gfx::CreateBitmapHeader(width, height, &header); 42 gfx::CreateBitmapHeader(width, height, &header);
43 void* bits; 43 void* bits;
44 HBITMAP bitmap = 44 HBITMAP bitmap =
45 CreateDIBSection(screen_dc, reinterpret_cast<BITMAPINFO*>(&header), 45 CreateDIBSection(screen_dc, reinterpret_cast<BITMAPINFO*>(&header),
46 DIB_RGB_COLORS, &bits, NULL, 0); 46 DIB_RGB_COLORS, &bits, NULL, 0);
47 HDC compatible_dc = CreateCompatibleDC(screen_dc); 47 HDC compatible_dc = CreateCompatibleDC(screen_dc);
48 HGDIOBJ old_object = SelectObject(compatible_dc, bitmap); 48 HGDIOBJ old_object = SelectObject(compatible_dc, bitmap);
49 BitBlt(compatible_dc, 0, 0, width, height, 49 BitBlt(compatible_dc, 0, 0, width, height,
50 canvas.getTopPlatformDevice().getBitmapDC(), 50 canvas.AsCanvasSkia()->getTopPlatformDevice().getBitmapDC(),
51 0, 0, SRCCOPY); 51 0, 0, SRCCOPY);
52 SelectObject(compatible_dc, old_object); 52 SelectObject(compatible_dc, old_object);
53 ReleaseDC(NULL, compatible_dc); 53 ReleaseDC(NULL, compatible_dc);
54 ReleaseDC(NULL, screen_dc); 54 ReleaseDC(NULL, screen_dc);
55 return bitmap; 55 return bitmap;
56 } 56 }
57 57
58 void SetDragImageOnDataObject(const gfx::Canvas& canvas, 58 void SetDragImageOnDataObject(const gfx::Canvas& canvas,
59 const gfx::Size& size, 59 const gfx::Size& size,
60 const gfx::Point& cursor_offset, 60 const gfx::Point& cursor_offset,
61 OSExchangeData* data_object) { 61 OSExchangeData* data_object) {
62 DCHECK(data_object && !size.IsEmpty()); 62 DCHECK(data_object && !size.IsEmpty());
63 // SetDragImageOnDataObject(HBITMAP) takes ownership of the bitmap. 63 // SetDragImageOnDataObject(HBITMAP) takes ownership of the bitmap.
64 HBITMAP bitmap = CreateBitmapFromCanvas(canvas, size.width(), size.height()); 64 HBITMAP bitmap = CreateBitmapFromCanvas(canvas, size.width(), size.height());
65 65
66 // Attach 'bitmap' to the data_object. 66 // Attach 'bitmap' to the data_object.
67 SetDragImageOnDataObject(bitmap, size, cursor_offset, 67 SetDragImageOnDataObject(bitmap, size, cursor_offset,
68 OSExchangeDataProviderWin::GetIDataObject(*data_object)); 68 OSExchangeDataProviderWin::GetIDataObject(*data_object));
69 } 69 }
70 70
71 } // namespace drag_utils 71 } // namespace drag_utils
OLDNEW
« gfx/canvas.h ('K') | « views/drag_utils.cc ('k') | views/painter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698