| 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/utf_string_conversions.h" | 8 #include "base/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" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 case CENTER: y = (height() - image_size.height()) / 2; break; | 103 case CENTER: y = (height() - image_size.height()) / 2; break; |
| 104 default: NOTREACHED(); y = 0; break; | 104 default: NOTREACHED(); y = 0; break; |
| 105 } | 105 } |
| 106 | 106 |
| 107 return gfx::Point(x, y); | 107 return gfx::Point(x, y); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void ImageView::OnPaint(gfx::Canvas* canvas) { | 110 void ImageView::OnPaint(gfx::Canvas* canvas) { |
| 111 View::OnPaint(canvas); | 111 View::OnPaint(canvas); |
| 112 | 112 |
| 113 if (image_.empty()) | 113 if (image_.isNull()) |
| 114 return; | 114 return; |
| 115 | 115 |
| 116 gfx::Rect image_bounds(GetImageBounds()); | 116 gfx::Rect image_bounds(GetImageBounds()); |
| 117 if (image_bounds.IsEmpty()) | 117 if (image_bounds.IsEmpty()) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { | 120 if (image_bounds.size() != gfx::Size(image_.width(), image_.height())) { |
| 121 // Resize case | 121 // Resize case |
| 122 SkPaint paint; | 122 SkPaint paint; |
| 123 paint.setFilterBitmap(true); | 123 paint.setFilterBitmap(true); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 166 |
| 167 bool ImageView::GetTooltipText(const gfx::Point& p, string16* tooltip) const { | 167 bool ImageView::GetTooltipText(const gfx::Point& p, string16* tooltip) const { |
| 168 if (tooltip_text_.empty()) | 168 if (tooltip_text_.empty()) |
| 169 return false; | 169 return false; |
| 170 | 170 |
| 171 *tooltip = GetTooltipText(); | 171 *tooltip = GetTooltipText(); |
| 172 return true; | 172 return true; |
| 173 } | 173 } |
| 174 | 174 |
| 175 } // namespace views | 175 } // namespace views |
| OLD | NEW |