| 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 "ash/drag_drop/drag_image_view.h" | 5 #include "ash/drag_drop/drag_image_view.h" |
| 6 | 6 |
| 7 #include "skia/ext/image_operations.h" | 7 #include "skia/ext/image_operations.h" |
| 8 #include "ui/aura/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/compositor/dip_util.h" | 10 #include "ui/compositor/dip_util.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 if (GetImage().size() == widget_size_) { | 110 if (GetImage().size() == widget_size_) { |
| 111 canvas->DrawImageInt(GetImage(), 0, 0); | 111 canvas->DrawImageInt(GetImage(), 0, 0); |
| 112 } else { | 112 } else { |
| 113 float device_scale = 1; | 113 float device_scale = 1; |
| 114 if (widget_->GetNativeView() && widget_->GetNativeView()->layer()) { | 114 if (widget_->GetNativeView() && widget_->GetNativeView()->layer()) { |
| 115 device_scale = ui::GetDeviceScaleFactor( | 115 device_scale = ui::GetDeviceScaleFactor( |
| 116 widget_->GetNativeView()->layer()); | 116 widget_->GetNativeView()->layer()); |
| 117 } | 117 } |
| 118 // The drag image already has device scale factor applied. But | 118 // The drag image already has device scale factor applied. But |
| 119 // |widget_size_| is in DIP units. | 119 // |widget_size_| is in DIP units. |
| 120 gfx::Size scaled_widget_size = gfx::ToRoundedSize( | 120 gfx::Size scaled_widget_size = |
| 121 gfx::ScaleSize(widget_size_, device_scale)); | 121 gfx::ScaleToRoundedSize(widget_size_, device_scale); |
| 122 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale); | 122 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale); |
| 123 if (image_rep.is_null()) | 123 if (image_rep.is_null()) |
| 124 return; | 124 return; |
| 125 SkBitmap scaled = skia::ImageOperations::Resize( | 125 SkBitmap scaled = skia::ImageOperations::Resize( |
| 126 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, | 126 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, |
| 127 scaled_widget_size.width(), scaled_widget_size.height()); | 127 scaled_widget_size.width(), scaled_widget_size.height()); |
| 128 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale)); | 128 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale)); |
| 129 canvas->DrawImageInt(image_skia, 0, 0); | 129 canvas->DrawImageInt(image_skia, 0, 0); |
| 130 } | 130 } |
| 131 | 131 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size); | 163 gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size); |
| 164 drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_)); | 164 drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_)); |
| 165 | 165 |
| 166 // Draw image. | 166 // Draw image. |
| 167 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), | 167 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), |
| 168 drag_hint_bounds.x(), drag_hint_bounds.y()); | 168 drag_hint_bounds.x(), drag_hint_bounds.y()); |
| 169 } | 169 } |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace ash | 172 } // namespace ash |
| OLD | NEW |