Remove unused parameter.
[chromium-blink-merge.git] / ui / message_center / views / proportional_image_view.cc
blobc944e64fba95cebe838239035a89d48e686f6254
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
3 // found in the LICENSE file.
5 #include "ui/message_center/views/proportional_image_view.h"
7 #include "ui/gfx/canvas.h"
8 #include "ui/message_center/message_center_style.h"
10 namespace message_center {
12 ProportionalImageView::ProportionalImageView(const gfx::ImageSkia& image,
13 const gfx::Size& max_size)
14 : image_(image), max_size_(max_size) {}
16 ProportionalImageView::~ProportionalImageView() {}
18 gfx::Size ProportionalImageView::GetPreferredSize() const { return max_size_; }
20 int ProportionalImageView::GetHeightForWidth(int width) const {
21 return max_size_.height();
24 void ProportionalImageView::OnPaint(gfx::Canvas* canvas) {
25 views::View::OnPaint(canvas);
27 gfx::Size draw_size = GetImageDrawingSize();
29 if (draw_size.IsEmpty())
30 return;
32 gfx::Rect draw_bounds = GetContentsBounds();
33 draw_bounds.ClampToCenteredSize(draw_size);
35 gfx::Size image_size(image_.size());
37 if (image_size == draw_size) {
38 canvas->DrawImageInt(image_, draw_bounds.x(), draw_bounds.y());
39 } else {
40 SkPaint paint;
41 paint.setFilterQuality(kLow_SkFilterQuality);
43 // This call resizes the image while drawing into the canvas.
44 canvas->DrawImageInt(
45 image_,
46 0, 0, image_size.width(), image_size.height(),
47 draw_bounds.x(), draw_bounds.y(), draw_size.width(), draw_size.height(),
48 true,
49 paint);
53 gfx::Size ProportionalImageView::GetImageDrawingSize() {
54 if (!visible())
55 return gfx::Size();
56 return message_center::GetImageSizeForContainerSize(
57 GetContentsBounds().size(), image_.size());
60 } // namespace message_center