| 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 const gfx::ImageSkia& ImageView::GetImage() { | 63 const gfx::ImageSkia& ImageView::GetImage() { |
| 64 return image_; | 64 return image_; |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ImageView::SetImageSize(const gfx::Size& image_size) { | 67 void ImageView::SetImageSize(const gfx::Size& image_size) { |
| 68 image_size_set_ = true; | 68 image_size_set_ = true; |
| 69 image_size_ = image_size; | 69 image_size_ = image_size; |
| 70 PreferredSizeChanged(); | 70 PreferredSizeChanged(); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ImageView::GetImageSize(gfx::Size* image_size) { | 73 bool ImageView::GetImageSize(gfx::Size* image_size) const { |
| 74 DCHECK(image_size); | 74 DCHECK(image_size); |
| 75 if (image_size_set_) | 75 if (image_size_set_) |
| 76 *image_size = image_size_; | 76 *image_size = image_size_; |
| 77 return image_size_set_; | 77 return image_size_set_; |
| 78 } | 78 } |
| 79 | 79 |
| 80 gfx::Rect ImageView::GetImageBounds() const { | 80 gfx::Rect ImageView::GetImageBounds() const { |
| 81 gfx::Size image_size(image_size_set_ ? | 81 gfx::Size image_size(image_size_set_ ? |
| 82 image_size_ : gfx::Size(image_.width(), image_.height())); | 82 image_size_ : gfx::Size(image_.width(), image_.height())); |
| 83 return gfx::Rect(ComputeImageOrigin(image_size), image_size); | 83 return gfx::Rect(ComputeImageOrigin(image_size), image_size); |
| 84 } | 84 } |
| 85 | 85 |
| 86 void ImageView::ResetImageSize() { | 86 void ImageView::ResetImageSize() { |
| 87 image_size_set_ = false; | 87 image_size_set_ = false; |
| 88 } | 88 } |
| 89 | 89 |
| 90 void ImageView::SetFocusPainter(scoped_ptr<Painter> focus_painter) { | 90 void ImageView::SetFocusPainter(scoped_ptr<Painter> focus_painter) { |
| 91 focus_painter_ = focus_painter.Pass(); | 91 focus_painter_ = focus_painter.Pass(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 gfx::Size ImageView::GetPreferredSize() { | 94 gfx::Size ImageView::GetPreferredSize() const { |
| 95 gfx::Insets insets = GetInsets(); | 95 gfx::Insets insets = GetInsets(); |
| 96 if (image_size_set_) { | 96 if (image_size_set_) { |
| 97 gfx::Size image_size; | 97 gfx::Size image_size; |
| 98 GetImageSize(&image_size); | 98 GetImageSize(&image_size); |
| 99 image_size.Enlarge(insets.width(), insets.height()); | 99 image_size.Enlarge(insets.width(), insets.height()); |
| 100 return image_size; | 100 return image_size; |
| 101 } | 101 } |
| 102 return gfx::Size(image_.width() + insets.width(), | 102 return gfx::Size(image_.width() + insets.width(), |
| 103 image_.height() + insets.height()); | 103 image_.height() + insets.height()); |
| 104 } | 104 } |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 canvas->DrawImageInt(image_, 0, 0, image_.width(), image_.height(), | 228 canvas->DrawImageInt(image_, 0, 0, image_.width(), image_.height(), |
| 229 image_bounds.x(), image_bounds.y(), image_bounds.width(), | 229 image_bounds.x(), image_bounds.y(), image_bounds.width(), |
| 230 image_bounds.height(), true, paint); | 230 image_bounds.height(), true, paint); |
| 231 } else { | 231 } else { |
| 232 canvas->DrawImageInt(image_, image_bounds.x(), image_bounds.y()); | 232 canvas->DrawImageInt(image_, image_bounds.x(), image_bounds.y()); |
| 233 } | 233 } |
| 234 last_painted_bitmap_pixels_ = GetBitmapPixels(image_, last_paint_scale_); | 234 last_painted_bitmap_pixels_ = GetBitmapPixels(image_, last_paint_scale_); |
| 235 } | 235 } |
| 236 | 236 |
| 237 } // namespace views | 237 } // namespace views |
| OLD | NEW |