| 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/base/accessibility/accessible_view_state.h" | 10 #include "ui/base/accessibility/accessible_view_state.h" |
| 11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
| 12 #include "ui/gfx/insets.h" | 12 #include "ui/gfx/insets.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 ImageView::ImageView() | 16 ImageView::ImageView() |
| 17 : image_size_set_(false), | 17 : image_size_set_(false), |
| 18 horiz_alignment_(CENTER), | 18 horiz_alignment_(CENTER), |
| 19 vert_alignment_(CENTER), | 19 vert_alignment_(CENTER), |
| 20 interactive_(true) { | 20 interactive_(true) { |
| 21 } | 21 } |
| 22 | 22 |
| 23 ImageView::~ImageView() { | 23 ImageView::~ImageView() { |
| 24 } | 24 } |
| 25 | 25 |
| 26 void ImageView::SetImage(const gfx::ImageSkia& img) { | 26 void ImageView::SetImage(const gfx::ImageSkia& img) { |
| 27 if (image_.BackedBySameObjectAs(img)) |
| 28 return; |
| 29 |
| 27 gfx::Size pref_size(GetPreferredSize()); | 30 gfx::Size pref_size(GetPreferredSize()); |
| 28 image_ = img; | 31 image_ = img; |
| 29 if (pref_size != GetPreferredSize()) | 32 if (pref_size != GetPreferredSize()) |
| 30 PreferredSizeChanged(); | 33 PreferredSizeChanged(); |
| 31 SchedulePaint(); | 34 SchedulePaint(); |
| 32 } | 35 } |
| 33 | 36 |
| 34 void ImageView::SetImage(const gfx::ImageSkia* image_skia) { | 37 void ImageView::SetImage(const gfx::ImageSkia* image_skia) { |
| 35 if (image_skia) { | 38 if (image_skia) { |
| 36 SetImage(*image_skia); | 39 SetImage(*image_skia); |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 | 174 |
| 172 *tooltip = GetTooltipText(); | 175 *tooltip = GetTooltipText(); |
| 173 return true; | 176 return true; |
| 174 } | 177 } |
| 175 | 178 |
| 176 bool ImageView::HitTestRect(const gfx::Rect& rect) const { | 179 bool ImageView::HitTestRect(const gfx::Rect& rect) const { |
| 177 return interactive_ ? View::HitTestRect(rect) : false; | 180 return interactive_ ? View::HitTestRect(rect) : false; |
| 178 } | 181 } |
| 179 | 182 |
| 180 } // namespace views | 183 } // namespace views |
| OLD | NEW |