Chromium Code Reviews| 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 "ui/views/controls/image_view.h" | 5 #include "ui/views/controls/image_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "third_party/skia/include/core/SkPaint.h" | 9 #include "third_party/skia/include/core/SkPaint.h" |
| 10 #include "ui/accessibility/ax_view_state.h" | 10 #include "ui/accessibility/ax_view_state.h" |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 | 198 |
| 199 bool ImageView::GetTooltipText(const gfx::Point& p, | 199 bool ImageView::GetTooltipText(const gfx::Point& p, |
| 200 base::string16* tooltip) const { | 200 base::string16* tooltip) const { |
| 201 if (tooltip_text_.empty()) | 201 if (tooltip_text_.empty()) |
| 202 return false; | 202 return false; |
| 203 | 203 |
| 204 *tooltip = GetTooltipText(); | 204 *tooltip = GetTooltipText(); |
| 205 return true; | 205 return true; |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool ImageView::HitTestRect(const gfx::Rect& rect) const { | 208 bool ImageView::CanAcceptEvent(const ui::Event& event) { |
| 209 return interactive_ ? View::HitTestRect(rect) : false; | 209 return interactive_; |
|
sadrul
2014/05/21 15:44:03
Should this be 'interactive_ && View::CanAcceptEve
tdanderson
2014/05/21 21:07:49
Done.
| |
| 210 } | 210 } |
| 211 | 211 |
| 212 | |
| 213 void ImageView::OnPaintImage(gfx::Canvas* canvas) { | 212 void ImageView::OnPaintImage(gfx::Canvas* canvas) { |
| 214 last_paint_scale_ = canvas->image_scale(); | 213 last_paint_scale_ = canvas->image_scale(); |
| 215 last_painted_bitmap_pixels_ = NULL; | 214 last_painted_bitmap_pixels_ = NULL; |
| 216 | 215 |
| 217 if (image_.isNull()) | 216 if (image_.isNull()) |
| 218 return; | 217 return; |
| 219 | 218 |
| 220 gfx::Rect image_bounds(GetImageBounds()); | 219 gfx::Rect image_bounds(GetImageBounds()); |
| 221 if (image_bounds.IsEmpty()) | 220 if (image_bounds.IsEmpty()) |
| 222 return; | 221 return; |
| 223 | 222 |
| 224 if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { | 223 if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { |
| 225 // Resize case | 224 // Resize case |
| 226 SkPaint paint; | 225 SkPaint paint; |
| 227 paint.setFilterLevel(SkPaint::kLow_FilterLevel); | 226 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
| 228 canvas->DrawImageInt(image_, 0, 0, image_.width(), image_.height(), | 227 canvas->DrawImageInt(image_, 0, 0, image_.width(), image_.height(), |
| 229 image_bounds.x(), image_bounds.y(), image_bounds.width(), | 228 image_bounds.x(), image_bounds.y(), image_bounds.width(), |
| 230 image_bounds.height(), true, paint); | 229 image_bounds.height(), true, paint); |
| 231 } else { | 230 } else { |
| 232 canvas->DrawImageInt(image_, image_bounds.x(), image_bounds.y()); | 231 canvas->DrawImageInt(image_, image_bounds.x(), image_bounds.y()); |
| 233 } | 232 } |
| 234 last_painted_bitmap_pixels_ = GetBitmapPixels(image_, last_paint_scale_); | 233 last_painted_bitmap_pixels_ = GetBitmapPixels(image_, last_paint_scale_); |
| 235 } | 234 } |
| 236 | 235 |
| 237 } // namespace views | 236 } // namespace views |
| OLD | NEW |