| 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/layout.h" |
| 9 #include "ui/compositor/dip_util.h" | 10 #include "ui/compositor/dip_util.h" |
| 10 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 11 #include "ui/gfx/size_conversions.h" | 12 #include "ui/gfx/size_conversions.h" |
| 12 #include "ui/views/corewm/shadow_types.h" | 13 #include "ui/views/corewm/shadow_types.h" |
| 13 #include "ui/views/widget/widget.h" | 14 #include "ui/views/widget/widget.h" |
| 14 | 15 |
| 15 namespace ash { | 16 namespace ash { |
| 16 namespace internal { | 17 namespace internal { |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 84 |
| 84 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP. | 85 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP. |
| 85 if (GetImage().size() == widget_size_) { | 86 if (GetImage().size() == widget_size_) { |
| 86 canvas->DrawImageInt(GetImage(), 0, 0); | 87 canvas->DrawImageInt(GetImage(), 0, 0); |
| 87 } else { | 88 } else { |
| 88 float device_scale = 1; | 89 float device_scale = 1; |
| 89 if (widget_->GetNativeView() && widget_->GetNativeView()->layer()) { | 90 if (widget_->GetNativeView() && widget_->GetNativeView()->layer()) { |
| 90 device_scale = ui::GetDeviceScaleFactor( | 91 device_scale = ui::GetDeviceScaleFactor( |
| 91 widget_->GetNativeView()->layer()); | 92 widget_->GetNativeView()->layer()); |
| 92 } | 93 } |
| 93 ui::ScaleFactor device_scale_factor = | |
| 94 ui::GetScaleFactorFromScale(device_scale); | |
| 95 | |
| 96 // The drag image already has device scale factor applied. But | 94 // The drag image already has device scale factor applied. But |
| 97 // |widget_size_| is in DIP units. | 95 // |widget_size_| is in DIP units. |
| 98 gfx::Size scaled_widget_size = gfx::ToRoundedSize( | 96 gfx::Size scaled_widget_size = gfx::ToRoundedSize( |
| 99 gfx::ScaleSize(widget_size_, device_scale)); | 97 gfx::ScaleSize(widget_size_, device_scale)); |
| 100 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation( | 98 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale); |
| 101 device_scale_factor); | |
| 102 if (image_rep.is_null()) | 99 if (image_rep.is_null()) |
| 103 return; | 100 return; |
| 104 SkBitmap scaled = skia::ImageOperations::Resize( | 101 SkBitmap scaled = skia::ImageOperations::Resize( |
| 105 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, | 102 image_rep.sk_bitmap(), skia::ImageOperations::RESIZE_LANCZOS3, |
| 106 scaled_widget_size.width(), scaled_widget_size.height()); | 103 scaled_widget_size.width(), scaled_widget_size.height()); |
| 107 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale_factor)); | 104 gfx::ImageSkia image_skia(gfx::ImageSkiaRep(scaled, device_scale)); |
| 108 canvas->DrawImageInt(image_skia, 0, 0); | 105 canvas->DrawImageInt(image_skia, 0, 0); |
| 109 } | 106 } |
| 110 } | 107 } |
| 111 | 108 |
| 112 } // namespace internal | 109 } // namespace internal |
| 113 } // namespace ash | 110 } // namespace ash |
| OLD | NEW |