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

Side by Side Diff: ash/common/drag_drop/drag_image_view.cc

Issue 2726823003: Remove WmLookup. (Closed)
Patch Set: Clean up include and modify comment. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
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/common/drag_drop/drag_image_view.h" 5 #include "ash/common/drag_drop/drag_image_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/wm_lookup.h"
10 #include "ash/common/wm_window.h" 9 #include "ash/common/wm_window.h"
11 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
12 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
13 #include "skia/ext/image_operations.h" 12 #include "skia/ext/image_operations.h"
14 #include "ui/base/resource/resource_bundle.h" 13 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/display/display.h" 14 #include "ui/display/display.h"
16 #include "ui/gfx/canvas.h" 15 #include "ui/gfx/canvas.h"
17 #include "ui/resources/grit/ui_resources.h" 16 #include "ui/resources/grit/ui_resources.h"
18 #include "ui/views/widget/widget.h" 17 #include "ui/views/widget/widget.h"
19 18
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 114
116 void DragImageView::OnPaint(gfx::Canvas* canvas) { 115 void DragImageView::OnPaint(gfx::Canvas* canvas) {
117 if (GetImage().isNull()) 116 if (GetImage().isNull())
118 return; 117 return;
119 118
120 // |drag_image_size_| is in DIP. 119 // |drag_image_size_| is in DIP.
121 // ImageSkia::size() also returns the size in DIP. 120 // ImageSkia::size() also returns the size in DIP.
122 if (GetImage().size() == drag_image_size_) { 121 if (GetImage().size() == drag_image_size_) {
123 canvas->DrawImageInt(GetImage(), 0, 0); 122 canvas->DrawImageInt(GetImage(), 0, 0);
124 } else { 123 } else {
125 WmWindow* window = WmLookup::Get()->GetWindowForWidget(widget_.get()); 124 WmWindow* window = WmWindow::Get(widget_->GetNativeWindow());
126 const float device_scale = 125 const float device_scale =
127 window->GetDisplayNearestWindow().device_scale_factor(); 126 window->GetDisplayNearestWindow().device_scale_factor();
128 // The drag image already has device scale factor applied. But 127 // The drag image already has device scale factor applied. But
129 // |drag_image_size_| is in DIP units. 128 // |drag_image_size_| is in DIP units.
130 gfx::Size drag_image_size_pixels = 129 gfx::Size drag_image_size_pixels =
131 gfx::ScaleToRoundedSize(drag_image_size_, device_scale); 130 gfx::ScaleToRoundedSize(drag_image_size_, device_scale);
132 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale); 131 gfx::ImageSkiaRep image_rep = GetImage().GetRepresentation(device_scale);
133 if (image_rep.is_null()) 132 if (image_rep.is_null())
134 return; 133 return;
135 SkBitmap scaled = skia::ImageOperations::Resize( 134 SkBitmap scaled = skia::ImageOperations::Resize(
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 // Enlarge widget if required to fit the drag hint image. 199 // Enlarge widget if required to fit the drag hint image.
201 gfx::Size widget_size = widget_->GetWindowBoundsInScreen().size(); 200 gfx::Size widget_size = widget_->GetWindowBoundsInScreen().size();
202 if (drag_hint_size.width() > widget_size.width() || 201 if (drag_hint_size.width() > widget_size.width() ||
203 drag_hint_size.height() > widget_size.height()) { 202 drag_hint_size.height() > widget_size.height()) {
204 widget_size.SetToMax(drag_hint_size); 203 widget_size.SetToMax(drag_hint_size);
205 widget_->SetSize(widget_size); 204 widget_->SetSize(widget_size);
206 } 205 }
207 } 206 }
208 207
209 } // namespace ash 208 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/devtools/ash_devtools_unittest.cc ('k') | ash/common/frame/caption_buttons/frame_size_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698