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

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

Issue 1514743002: cc: turn on strict paint property checking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix DragImageView to not resize during paint Created 5 years 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_image_view.h ('k') | blimp/client/compositor/blimp_layer_tree_settings.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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
132 if (drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) 132 if (drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH)
133 return; 133 return;
134 134
135 gfx::Image* drag_hint = DragHint();
136 if (!drag_hint)
mfomitchev 2015/12/11 15:37:01 Shouldn't this be drag_hint->IsEmpty()?
137 return;
138
139 // Make sure drag hint image is positioned within the widget.
140 gfx::Size drag_hint_size = drag_hint->Size();
141 gfx::Point drag_hint_position = touch_drag_operation_indicator_position_;
142 drag_hint_position.Offset(-drag_hint_size.width() / 2, 0);
143 gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size);
144 drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_));
145
146 // Draw image.
147 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), drag_hint_bounds.x(),
148 drag_hint_bounds.y());
149 }
150
151 gfx::Image* DragImageView::DragHint() const {
135 // Select appropriate drag hint. 152 // Select appropriate drag hint.
136 gfx::Image* drag_hint = 153 gfx::Image* drag_hint =
137 &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 154 &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
138 IDR_TOUCH_DRAG_TIP_NODROP); 155 IDR_TOUCH_DRAG_TIP_NODROP);
139 if (touch_drag_operation_ & ui::DragDropTypes::DRAG_COPY) { 156 if (touch_drag_operation_ & ui::DragDropTypes::DRAG_COPY) {
140 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 157 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
141 IDR_TOUCH_DRAG_TIP_COPY); 158 IDR_TOUCH_DRAG_TIP_COPY);
142 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_MOVE) { 159 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_MOVE) {
143 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 160 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
144 IDR_TOUCH_DRAG_TIP_MOVE); 161 IDR_TOUCH_DRAG_TIP_MOVE);
145 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_LINK) { 162 } else if (touch_drag_operation_ & ui::DragDropTypes::DRAG_LINK) {
146 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( 163 drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed(
147 IDR_TOUCH_DRAG_TIP_LINK); 164 IDR_TOUCH_DRAG_TIP_LINK);
148 } 165 }
149 if (!drag_hint->IsEmpty()) { 166 return drag_hint;
150 gfx::Size drag_hint_size = drag_hint->Size(); 167 }
151 168
152 // Enlarge widget if required to fit the drag hint image. 169 void DragImageView::Layout() {
153 if (drag_hint_size.width() > widget_size_.width() || 170 View::Layout();
154 drag_hint_size.height() > widget_size_.height()) {
155 gfx::Size new_widget_size = widget_size_;
156 new_widget_size.SetToMax(drag_hint_size);
157 widget_->SetSize(new_widget_size);
158 }
159 171
160 // Make sure drag hint image is positioned within the widget. 172 gfx::Image* drag_hint = DragHint();
161 gfx::Point drag_hint_position = touch_drag_operation_indicator_position_; 173 if (!drag_hint)
162 drag_hint_position.Offset(-drag_hint_size.width() / 2, 0); 174 return;
163 gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size);
164 drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_));
165 175
166 // Draw image. 176 gfx::Size drag_hint_size = drag_hint->Size();
167 canvas->DrawImageInt(*(drag_hint->ToImageSkia()), 177
168 drag_hint_bounds.x(), drag_hint_bounds.y()); 178 // Enlarge widget if required to fit the drag hint image.
179 if (drag_hint_size.width() > widget_size_.width() ||
180 drag_hint_size.height() > widget_size_.height()) {
181 gfx::Size new_widget_size = widget_size_;
182 new_widget_size.SetToMax(drag_hint_size);
183 widget_->SetSize(new_widget_size);
169 } 184 }
170 } 185 }
171 186
172 } // namespace ash 187 } // namespace ash
OLDNEW
« no previous file with comments | « ash/drag_drop/drag_image_view.h ('k') | blimp/client/compositor/blimp_layer_tree_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698