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/views/button_drag_utils.h" | 5 #include "ui/views/button_drag_utils.h" |
6 | 6 |
7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
8 #include "ui/base/dragdrop/os_exchange_data.h" | 8 #include "ui/base/dragdrop/os_exchange_data.h" |
9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/compositor/canvas_painter.h" | 10 #include "ui/compositor/canvas_painter.h" |
11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/geometry/point.h" | 12 #include "ui/gfx/geometry/point.h" |
13 #include "ui/gfx/geometry/vector2d.h" | 13 #include "ui/gfx/geometry/vector2d.h" |
14 #include "ui/gfx/image/image.h" | 14 #include "ui/gfx/image/image.h" |
15 #include "ui/resources/grit/ui_resources.h" | 15 #include "ui/resources/grit/ui_resources.h" |
16 #include "ui/views/background.h" | 16 #include "ui/views/background.h" |
17 #include "ui/views/border.h" | 17 #include "ui/views/border.h" |
18 #include "ui/views/controls/button/label_button.h" | 18 #include "ui/views/controls/button/label_button.h" |
19 #include "ui/views/controls/button/label_button_border.h" | 19 #include "ui/views/controls/button/label_button_border.h" |
20 #include "ui/views/drag_utils.h" | 20 #include "ui/views/drag_utils.h" |
| 21 #include "ui/views/paint_info.h" |
21 #include "ui/views/widget/widget.h" | 22 #include "ui/views/widget/widget.h" |
22 #include "url/gurl.h" | 23 #include "url/gurl.h" |
23 | 24 |
24 namespace button_drag_utils { | 25 namespace button_drag_utils { |
25 | 26 |
26 // Maximum width of the link drag image in pixels. | 27 // Maximum width of the link drag image in pixels. |
27 static const int kLinkDragImageMaxWidth = 150; | 28 static const int kLinkDragImageMaxWidth = 150; |
28 | 29 |
29 void SetURLAndDragImage(const GURL& url, | 30 void SetURLAndDragImage(const GURL& url, |
30 const base::string16& title, | 31 const base::string16& title, |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 77 |
77 gfx::Vector2d press_point; | 78 gfx::Vector2d press_point; |
78 if (press_pt) | 79 if (press_pt) |
79 press_point = press_pt->OffsetFromOrigin(); | 80 press_point = press_pt->OffsetFromOrigin(); |
80 else | 81 else |
81 press_point = gfx::Vector2d(size.width() / 2, size.height() / 2); | 82 press_point = gfx::Vector2d(size.width() / 2, size.height() / 2); |
82 | 83 |
83 SkBitmap bitmap; | 84 SkBitmap bitmap; |
84 float raster_scale = ScaleFactorForDragFromWidget(&widget); | 85 float raster_scale = ScaleFactorForDragFromWidget(&widget); |
85 SkColor color = SK_ColorTRANSPARENT; | 86 SkColor color = SK_ColorTRANSPARENT; |
86 button.Paint(ui::CanvasPainter(&bitmap, size, raster_scale, color).context()); | 87 button.Paint(views::PaintInfo( |
| 88 ui::CanvasPainter(&bitmap, size, raster_scale, color, |
| 89 widget.GetCompositor()->is_pixel_canvas()) |
| 90 .context(), |
| 91 size)); |
87 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, raster_scale)); | 92 gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, raster_scale)); |
88 data->provider().SetDragImage(image, press_point); | 93 data->provider().SetDragImage(image, press_point); |
89 } | 94 } |
90 | 95 |
91 } // namespace button_drag_utils | 96 } // namespace button_drag_utils |
OLD | NEW |