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

Side by Side Diff: ui/base/dragdrop/drag_utils_gtk.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: RenderText fixup Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "ui/base/dragdrop/os_exchange_data.h" 10 #include "ui/base/dragdrop/os_exchange_data.h"
11 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h" 11 #include "ui/base/dragdrop/os_exchange_data_provider_gtk.h"
12 #include "ui/gfx/canvas.h" 12 #include "ui/gfx/canvas.h"
13 #include "ui/gfx/gtk_util.h" 13 #include "ui/gfx/gtk_util.h"
14 #include "ui/gfx/image/image_skia.h" 14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/point.h" 15 #include "ui/gfx/point.h"
16 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
17 17
18 namespace drag_utils { 18 namespace drag_utils {
19 19
20 void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia, 20 void SetDragImageOnDataObject(const gfx::ImageSkia& image_skia,
21 const gfx::Size& size, 21 const gfx::Size& size,
22 const gfx::Point& cursor_offset, 22 const gfx::Vector2d& cursor_offset,
23 ui::OSExchangeData* data_object) { 23 ui::OSExchangeData* data_object) {
24 ui::OSExchangeDataProviderGtk& provider( 24 ui::OSExchangeDataProviderGtk& provider(
25 static_cast<ui::OSExchangeDataProviderGtk&>(data_object->provider())); 25 static_cast<ui::OSExchangeDataProviderGtk&>(data_object->provider()));
26 26
27 // Convert the image into a GdkPixbuf. 27 // Convert the image into a GdkPixbuf.
28 GdkPixbuf* canvas_pixbuf = gfx::GdkPixbufFromSkBitmap(image_skia.bitmap()); 28 GdkPixbuf* canvas_pixbuf = gfx::GdkPixbufFromSkBitmap(image_skia.bitmap());
29 29
30 // Make a new pixbuf of the requested size and copy it over. 30 // Make a new pixbuf of the requested size and copy it over.
31 GdkPixbuf* pixbuf = gdk_pixbuf_new( 31 GdkPixbuf* pixbuf = gdk_pixbuf_new(
32 gdk_pixbuf_get_colorspace(canvas_pixbuf), 32 gdk_pixbuf_get_colorspace(canvas_pixbuf),
33 gdk_pixbuf_get_has_alpha(canvas_pixbuf), 33 gdk_pixbuf_get_has_alpha(canvas_pixbuf),
34 gdk_pixbuf_get_bits_per_sample(canvas_pixbuf), 34 gdk_pixbuf_get_bits_per_sample(canvas_pixbuf),
35 size.width(), 35 size.width(),
36 size.height()); 36 size.height());
37 gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, size.width(), size.height(), pixbuf, 37 gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, size.width(), size.height(), pixbuf,
38 0, 0); 38 0, 0);
39 g_object_unref(canvas_pixbuf); 39 g_object_unref(canvas_pixbuf);
40 40
41 // Set the drag data on to the provider. 41 // Set the drag data on to the provider.
42 provider.SetDragImage(pixbuf, cursor_offset); 42 provider.SetDragImage(pixbuf, cursor_offset);
43 g_object_unref(pixbuf); 43 g_object_unref(pixbuf);
44 } 44 }
45 45
46 } // namespace drag_utils 46 } // namespace drag_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698