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

Unified Diff: ui/views/button_drag_utils.cc

Issue 2694023003: Make CanvasPainter raster directly to an SkBitmap (Closed)
Patch Set: tapted review Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/compositor/canvas_painter.cc ('k') | ui/views/cocoa/bridged_content_view.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/button_drag_utils.cc
diff --git a/ui/views/button_drag_utils.cc b/ui/views/button_drag_utils.cc
index 084ed5b8f40029c029e14e3baea3037103a3eb71..5eaf6db6720bd5996bd65043c7143510cc879855 100644
--- a/ui/views/button_drag_utils.cc
+++ b/ui/views/button_drag_utils.cc
@@ -71,20 +71,22 @@ void SetDragImage(const GURL& url,
} else {
button.SetImage(views::Button::STATE_NORMAL, icon);
}
- gfx::Size prefsize = button.GetPreferredSize();
- button.SetBounds(0, 0, prefsize.width(), prefsize.height());
+
+ gfx::Size size(button.GetPreferredSize());
+ button.SetBoundsRect(gfx::Rect(size));
gfx::Vector2d press_point;
if (press_pt)
press_point = press_pt->OffsetFromOrigin();
else
- press_point = gfx::Vector2d(prefsize.width() / 2, prefsize.height() / 2);
+ press_point = gfx::Vector2d(size.width() / 2, size.height() / 2);
- // Render the image.
- std::unique_ptr<gfx::Canvas> canvas(
- views::GetCanvasForDragImage(widget, prefsize));
- button.Paint(ui::CanvasPainter(canvas.get(), 1.f).context());
- drag_utils::SetDragImageOnDataObject(*canvas, press_point, data);
+ SkBitmap bitmap;
+ float raster_scale = ScaleFactorForDragFromWidget(widget);
+ SkColor color = SK_ColorTRANSPARENT;
+ button.Paint(ui::CanvasPainter(&bitmap, size, raster_scale, color).context());
+ gfx::ImageSkia image(gfx::ImageSkiaRep(bitmap, raster_scale));
+ drag_utils::SetDragImageOnDataObject(image, press_point, data);
}
} // namespace button_drag_utils
« no previous file with comments | « ui/compositor/canvas_painter.cc ('k') | ui/views/cocoa/bridged_content_view.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698