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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 void DragImageView::OnPaint(gfx::Canvas* canvas) { 105 void DragImageView::OnPaint(gfx::Canvas* canvas) {
106 if (GetImage().isNull()) 106 if (GetImage().isNull())
107 return; 107 return;
108 108
109 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP. 109 // |widget_size_| is in DIP. ImageSkia::size() also returns the size in DIP.
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 =
116 widget_->GetNativeView()->layer()); 116 ui::GetDeviceScaleFactor(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 = 120 gfx::Size scaled_widget_size =
121 gfx::ScaleToRoundedSize(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,
(...skipping 18 matching lines...) Expand all
145 145
146 // Draw image. 146 // Draw image.
147 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), drag_hint_bounds.x(), 147 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), drag_hint_bounds.x(),
148 drag_hint_bounds.y()); 148 drag_hint_bounds.y());
149 } 149 }
150 150
151 gfx::Image* DragImageView::DragHint() const { 151 gfx::Image* DragImageView::DragHint() const {
152 // Select appropriate drag hint. 152 // Select appropriate drag hint.
153 gfx::Image* drag_hint = 153 gfx::Image* drag_hint =
154 &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 154 &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
155 IDR_TOUCH_DRAG_TIP_NODROP); 155 IDR_TOUCH_DRAG_TIP_NODROP);
156 if (touch_drag_operation_ & ui::DragDropTypes::DRAG_COPY) { 156 if (touch_drag_operation_ & ui::DragDropTypes::DRAG_COPY) {
157 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 157 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
158 IDR_TOUCH_DRAG_TIP_COPY); 158 IDR_TOUCH_DRAG_TIP_COPY);
159 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_MOVE) { 159 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_MOVE) {
160 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 160 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
161 IDR_TOUCH_DRAG_TIP_MOVE); 161 IDR_TOUCH_DRAG_TIP_MOVE);
162 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_LINK) { 162 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_LINK) {
163 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 163 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
164 IDR_TOUCH_DRAG_TIP_LINK); 164 IDR_TOUCH_DRAG_TIP_LINK);
165 } 165 }
(...skipping 12 matching lines...) Expand all
178 // Enlarge widget if required to fit the drag hint image. 178 // Enlarge widget if required to fit the drag hint image.
179 if (drag_hint_size.width() > widget_size_.width() || 179 if (drag_hint_size.width() > widget_size_.width() ||
180 drag_hint_size.height() > widget_size_.height()) { 180 drag_hint_size.height() > widget_size_.height()) {
181 gfx::Size new_widget_size = widget_size_; 181 gfx::Size new_widget_size = widget_size_;
182 new_widget_size.SetToMax(drag_hint_size); 182 new_widget_size.SetToMax(drag_hint_size);
183 widget_->SetSize(new_widget_size); 183 widget_->SetSize(new_widget_size);
184 } 184 }
185 } 185 }
186 186
187 } // namespace ash 187 } // namespace ash
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_drop_tracker_unittest.cc ('k') | ash/extended_desktop_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698