| OLD | NEW | 
|   1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |   1 // Copyright (c) 2009 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 <gtk/gtk.h> | 
 |   8  | 
|   7 #include "app/gfx/canvas.h" |   9 #include "app/gfx/canvas.h" | 
 |  10 #include "app/gfx/gtk_util.h" | 
|   8 #include "base/logging.h" |  11 #include "base/logging.h" | 
|   9 #include "app/os_exchange_data.h" |  12 #include "app/os_exchange_data.h" | 
 |  13 #include "app/os_exchange_data_provider_gtk.h" | 
|  10  |  14  | 
|  11 namespace drag_utils { |  15 namespace drag_utils { | 
|  12  |  16  | 
|  13 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |  17 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 
|  14                               int width, |  18                               int width, | 
|  15                               int height, |  19                               int height, | 
|  16                               int cursor_x_offset, |  20                               int cursor_x_offset, | 
|  17                               int cursor_y_offset, |  21                               int cursor_y_offset, | 
|  18                               OSExchangeData* data_object) { |  22                               OSExchangeData* data_object) { | 
|  19   NOTIMPLEMENTED(); |  23   OSExchangeDataProviderGtk& provider( | 
 |  24       static_cast<OSExchangeDataProviderGtk&>(data_object->provider())); | 
 |  25  | 
 |  26   // Convert the canvas into a GdkPixbuf. | 
 |  27   SkBitmap bitmap = canvas.ExtractBitmap(); | 
 |  28   GdkPixbuf* canvas_pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); | 
 |  29  | 
 |  30   // Make a new pixbuf of the requested size and copy it over. | 
 |  31   GdkPixbuf* pixbuf = gdk_pixbuf_new( | 
 |  32       gdk_pixbuf_get_colorspace(canvas_pixbuf), | 
 |  33       gdk_pixbuf_get_has_alpha(canvas_pixbuf), | 
 |  34       gdk_pixbuf_get_bits_per_sample(canvas_pixbuf), | 
 |  35       width, | 
 |  36       height); | 
 |  37   gdk_pixbuf_copy_area(canvas_pixbuf, 0, 0, width, height, pixbuf, 0, 0); | 
 |  38   g_object_unref(canvas_pixbuf); | 
 |  39  | 
 |  40   // Set the drag data on to the provider. | 
 |  41   provider.SetDragImage(pixbuf, cursor_x_offset, cursor_y_offset); | 
 |  42   g_object_unref(pixbuf); | 
|  20 } |  43 } | 
|  21  |  44  | 
|  22 } // namespace drag_utils |  45 } // namespace drag_utils | 
| OLD | NEW |