OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/message_center/views/proportional_image_view.h" | 5 #include "ui/message_center/views/proportional_image_view.h" |
6 | 6 |
7 #include "ui/gfx/canvas.h" | 7 #include "ui/gfx/canvas.h" |
8 #include "ui/message_center/message_center_style.h" | 8 #include "ui/message_center/message_center_style.h" |
9 | 9 |
10 namespace message_center { | 10 namespace message_center { |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 gfx::Rect draw_bounds = GetContentsBounds(); | 32 gfx::Rect draw_bounds = GetContentsBounds(); |
33 draw_bounds.ClampToCenteredSize(draw_size); | 33 draw_bounds.ClampToCenteredSize(draw_size); |
34 | 34 |
35 gfx::Size image_size(image_.size()); | 35 gfx::Size image_size(image_.size()); |
36 | 36 |
37 if (image_size == draw_size) { | 37 if (image_size == draw_size) { |
38 canvas->DrawImageInt(image_, draw_bounds.x(), draw_bounds.y()); | 38 canvas->DrawImageInt(image_, draw_bounds.x(), draw_bounds.y()); |
39 } else { | 39 } else { |
40 SkPaint paint; | 40 SkPaint paint; |
41 paint.setFilterBitmap(true); | 41 paint.setFilterLevel(SkPaint::kLow_FilterLevel); |
42 | 42 |
43 // This call resizes the image while drawing into the canvas. | 43 // This call resizes the image while drawing into the canvas. |
44 canvas->DrawImageInt( | 44 canvas->DrawImageInt( |
45 image_, | 45 image_, |
46 0, 0, image_size.width(), image_size.height(), | 46 0, 0, image_size.width(), image_size.height(), |
47 draw_bounds.x(), draw_bounds.y(), draw_size.width(), draw_size.height(), | 47 draw_bounds.x(), draw_bounds.y(), draw_size.width(), draw_size.height(), |
48 true, | 48 true, |
49 paint); | 49 paint); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 gfx::Size ProportionalImageView::GetImageDrawingSize() { | 53 gfx::Size ProportionalImageView::GetImageDrawingSize() { |
54 if (!visible()) | 54 if (!visible()) |
55 return gfx::Size(); | 55 return gfx::Size(); |
56 return message_center::GetImageSizeForContainerSize( | 56 return message_center::GetImageSizeForContainerSize( |
57 GetContentsBounds().size(), image_.size()); | 57 GetContentsBounds().size(), image_.size()); |
58 } | 58 } |
59 | 59 |
60 } // namespace message_center | 60 } // namespace message_center |
OLD | NEW |