diff options
-rw-r--r-- | ash/launcher/launcher.cc | 5 | ||||
-rw-r--r-- | chrome/browser/chromeos/frame/panel_controller.cc | 9 | ||||
-rw-r--r-- | chrome/browser/chromeos/login/rounded_rect_painter.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc | 7 | ||||
-rw-r--r-- | chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc | 4 | ||||
-rw-r--r-- | chrome/browser/ui/views/location_bar/location_bar_view.cc | 2 | ||||
-rw-r--r-- | ui/views/native_theme_painter.cc | 6 | ||||
-rw-r--r-- | ui/views/native_theme_painter.h | 4 | ||||
-rw-r--r-- | ui/views/painter.cc | 59 | ||||
-rw-r--r-- | ui/views/painter.h | 8 |
10 files changed, 61 insertions, 50 deletions
diff --git a/ash/launcher/launcher.cc b/ash/launcher/launcher.cc index 195fab7..4908aa1 100644 --- a/ash/launcher/launcher.cc +++ b/ash/launcher/launcher.cc @@ -31,8 +31,9 @@ class ShelfPainter : public views::Painter { image_ = *rb.GetImageNamed(IDR_AURA_LAUNCHER_BACKGROUND).ToSkBitmap(); } - virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE { - canvas->TileImageInt(image_, 0, 0, w, h); + // Overridden from views::Painter: + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { + canvas->TileImageInt(image_, 0, 0, size.width(), size.height()); } private: diff --git a/chrome/browser/chromeos/frame/panel_controller.cc b/chrome/browser/chromeos/frame/panel_controller.cc index 08a2ef9..563b28a 100644 --- a/chrome/browser/chromeos/frame/panel_controller.cc +++ b/chrome/browser/chromeos/frame/panel_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -72,8 +72,9 @@ class TitleBackgroundPainter : public views::Painter { : panel_controller_(controller) { } private: - virtual void Paint(int w, int h, gfx::Canvas* canvas) { - SkRect rect = {0, 0, w, h}; + // Overridden from views::Painter: + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { + SkRect rect = { 0, 0, size.width(), size.height() }; SkPath path; SkScalar corners[] = { kTitleCornerRadius, kTitleCornerRadius, @@ -85,7 +86,7 @@ class TitleBackgroundPainter : public views::Painter { SkPaint paint; paint.setStyle(SkPaint::kFill_Style); paint.setFlags(SkPaint::kAntiAlias_Flag); - SkPoint p[2] = { {0, 0}, {0, h} }; + SkPoint p[2] = { {0, 0}, {0, size.height()} }; SkColor colors[2] = {kTitleActiveGradientStart, kTitleActiveGradientEnd}; if (panel_controller_->urgent()) { colors[0] = kTitleUrgentGradientStart; diff --git a/chrome/browser/chromeos/login/rounded_rect_painter.cc b/chrome/browser/chromeos/login/rounded_rect_painter.cc index 2a1719d..2771112 100644 --- a/chrome/browser/chromeos/login/rounded_rect_painter.cc +++ b/chrome/browser/chromeos/login/rounded_rect_painter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -143,8 +143,9 @@ class RoundedRectPainter : public views::Painter { : border_(border) { } - virtual void Paint(int w, int h, gfx::Canvas* canvas) { - DrawRectWithBorder(w, h, border_, canvas); + // Overridden from views::Painter: + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { + DrawRectWithBorder(size.width(), size.height(), border_, canvas); } private: diff --git a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc index 6ea92ad..cdeddb9 100644 --- a/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc +++ b/chrome/browser/ui/views/autocomplete/autocomplete_popup_contents_view.cc @@ -92,7 +92,7 @@ class OptInButtonBorder : public views::Border { } else { painter = border_painter_.get(); } - painter->Paint(view.width(), view.height(), canvas); + painter->Paint(canvas, view.size()); } virtual void GetInsets(gfx::Insets* insets) const { @@ -180,8 +180,9 @@ class AutocompletePopupContentsView::InstantOptInView canvas->Save(); canvas->Translate(gfx::Point(kOptInBackgroundHInset, kOptInBackgroundVInset)); - bg_painter_->Paint(width() - kOptInBackgroundHInset * 2, - height() - kOptInBackgroundVInset * 2, canvas); + bg_painter_->Paint(canvas, + gfx::Size(width() - kOptInBackgroundHInset * 2, + height() - kOptInBackgroundVInset * 2)); canvas->DrawRect(gfx::Rect(0, 0, width() - kOptInBackgroundHInset * 2, height() - kOptInBackgroundVInset * 2), ThemeService::GetDefaultColor(ThemeService::COLOR_TOOLBAR_SEPARATOR)); diff --git a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc index 87a4563..3d98af1 100644 --- a/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc +++ b/chrome/browser/ui/views/location_bar/icon_label_bubble_view.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -51,7 +51,7 @@ void IconLabelBubbleView::SetImage(const SkBitmap& bitmap) { } void IconLabelBubbleView::OnPaint(gfx::Canvas* canvas) { - background_painter_.Paint(width(), height(), canvas); + background_painter_.Paint(canvas, size()); } gfx::Size IconLabelBubbleView::GetPreferredSize() { diff --git a/chrome/browser/ui/views/location_bar/location_bar_view.cc b/chrome/browser/ui/views/location_bar/location_bar_view.cc index 2a7fd19..e0e8831 100644 --- a/chrome/browser/ui/views/location_bar/location_bar_view.cc +++ b/chrome/browser/ui/views/location_bar/location_bar_view.cc @@ -703,7 +703,7 @@ void LocationBarView::OnPaint(gfx::Canvas* canvas) { View::OnPaint(canvas); if (painter_.get()) { - painter_->Paint(width(), height(), canvas); + painter_->Paint(canvas, size()); } else if (mode_ == POPUP) { canvas->TileImageInt(*GetThemeProvider()->GetBitmapNamed( IDR_LOCATIONBG_POPUPMODE_CENTER), 0, 0, 0, 0, width(), height()); diff --git a/ui/views/native_theme_painter.cc b/ui/views/native_theme_painter.cc index 30299ac..1c5c1a1 100644 --- a/ui/views/native_theme_painter.cc +++ b/ui/views/native_theme_painter.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -25,10 +25,10 @@ gfx::Size NativeThemePainter::GetPreferredSize() { return theme->GetPartSize(delegate_->GetThemePart(), state, extra); } -void NativeThemePainter::Paint(int w, int h, gfx::Canvas* canvas) { +void NativeThemePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { const gfx::NativeTheme* native_theme = gfx::NativeTheme::instance(); gfx::NativeTheme::Part part = delegate_->GetThemePart(); - gfx::Rect rect(0, 0, w, h); + gfx::Rect rect(size); if (delegate_->GetThemeAnimation() != NULL && delegate_->GetThemeAnimation()->is_animating()) { diff --git a/ui/views/native_theme_painter.h b/ui/views/native_theme_painter.h index f21b731..1dcb75f 100644 --- a/ui/views/native_theme_painter.h +++ b/ui/views/native_theme_painter.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -35,7 +35,7 @@ class VIEWS_EXPORT NativeThemePainter : public Painter { NativeThemeDelegate* delegate_; // Overridden from Painter: - virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE; + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; DISALLOW_COPY_AND_ASSIGN(NativeThemePainter); }; diff --git a/ui/views/painter.cc b/ui/views/painter.cc index 6b23c37..4a83cb4 100644 --- a/ui/views/painter.cc +++ b/ui/views/painter.cc @@ -29,14 +29,15 @@ class GradientPainter : public Painter { virtual ~GradientPainter() { } - void Paint(int w, int h, gfx::Canvas* canvas) { + // Overridden from Painter: + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { SkPaint paint; SkPoint p[2]; p[0].set(SkIntToScalar(0), SkIntToScalar(0)); if (horizontal_) - p[1].set(SkIntToScalar(w), SkIntToScalar(0)); + p[1].set(SkIntToScalar(size.width()), SkIntToScalar(0)); else - p[1].set(SkIntToScalar(0), SkIntToScalar(h)); + p[1].set(SkIntToScalar(0), SkIntToScalar(size.height())); SkShader* s = SkGradientShader::CreateLinear(p, colors_, NULL, 2, @@ -46,9 +47,9 @@ class GradientPainter : public Painter { // Need to unref shader, otherwise never deleted. s->unref(); - canvas->GetSkCanvas()->drawRectCoords( - SkIntToScalar(0), SkIntToScalar(0), SkIntToScalar(w), SkIntToScalar(h), - paint); + canvas->GetSkCanvas()->drawRectCoords(SkIntToScalar(0), SkIntToScalar(0), + SkIntToScalar(size.width()), + SkIntToScalar(size.height()), paint); } private: @@ -72,8 +73,8 @@ class ImagePainter : public Painter { } // Paints the images. - virtual void Paint(int w, int h, gfx::Canvas* canvas) { - if (w == image_.width() && h == image_.height()) { + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE { + if (size.width() == image_.width() && size.height() == image_.height()) { // Early out if the size we're to render at equals the size of the image. canvas->DrawBitmapInt(image_, 0, 0); return; @@ -85,44 +86,49 @@ class ImagePainter : public Painter { canvas->DrawBitmapInt( image_, insets_.left(), 0, image_.width() - insets_.width(), insets_.top(), - insets_.left(), 0, w - insets_.width(), insets_.top(), true); + insets_.left(), 0, size.width() - insets_.width(), insets_.top(), true); // Upper right. canvas->DrawBitmapInt( image_, image_.width() - insets_.right(), 0, insets_.right(), insets_.top(), - w - insets_.right(), 0, insets_.right(), insets_.top(), true); + size.width() - insets_.right(), 0, insets_.right(), insets_.top(), + true); // Right edge. canvas->DrawBitmapInt( image_, image_.width() - insets_.right(), insets_.top(), insets_.right(), image_.height() - insets_.height(), - w - insets_.right(), insets_.top(), insets_.right(), - h - insets_.height(), true); + size.width() - insets_.right(), insets_.top(), insets_.right(), + size.height() - insets_.height(), true); // Bottom right. canvas->DrawBitmapInt( image_, image_.width() - insets_.right(), image_.height() - insets_.bottom(), insets_.right(), insets_.bottom(), - w - insets_.right(), h - insets_.bottom(), insets_.right(), + size.width() - insets_.right(), + size.height() - insets_.bottom(), insets_.right(), insets_.bottom(), true); // Bottom edge. canvas->DrawBitmapInt( image_, insets_.left(), image_.height() - insets_.bottom(), image_.width() - insets_.width(), insets_.bottom(), - insets_.left(), h - insets_.bottom(), w - insets_.width(), + insets_.left(), size.height() - insets_.bottom(), + size.width() - insets_.width(), insets_.bottom(), true); // Bottom left. canvas->DrawBitmapInt( image_, 0, image_.height() - insets_.bottom(), insets_.left(), insets_.bottom(), - 0, h - insets_.bottom(), insets_.left(), insets_.bottom(), true); + 0, size.height() - insets_.bottom(), insets_.left(), insets_.bottom(), + true); // Left. canvas->DrawBitmapInt( image_, 0, insets_.top(), insets_.left(), image_.height() - insets_.height(), - 0, insets_.top(), insets_.left(), h - insets_.height(), true); + 0, insets_.top(), insets_.left(), size.height() - insets_.height(), + true); // Center. if (paint_center_) { canvas->DrawBitmapInt( @@ -130,7 +136,8 @@ class ImagePainter : public Painter { insets_.left(), insets_.top(), image_.width() - insets_.width(), image_.height() - insets_.height(), insets_.left(), insets_.top(), - w - insets_.width(), h - insets_.height(), true); + size.width() - insets_.width(), size.height() - insets_.height(), + true); } } @@ -151,7 +158,7 @@ void Painter::PaintPainterAt(gfx::Canvas* canvas, DCHECK(canvas && painter); canvas->Save(); canvas->Translate(rect.origin()); - painter->Paint(rect.width(), rect.height(), canvas); + painter->Paint(canvas, rect.size()); canvas->Restore(); } @@ -181,19 +188,17 @@ HorizontalPainter::HorizontalPainter(const int image_resource_names[]) { images_[LEFT]->height() == images_[CENTER]->height()); } -void HorizontalPainter::Paint(int w, int h, gfx::Canvas* canvas) { - if (w < (images_[LEFT]->width() + images_[CENTER]->width() + - images_[RIGHT]->width())) { +void HorizontalPainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) { + if (size.width() < (images_[LEFT]->width() + images_[CENTER]->width() + + images_[RIGHT]->width())) { // No room to paint. return; } canvas->DrawBitmapInt(*images_[LEFT], 0, 0); - canvas->DrawBitmapInt(*images_[RIGHT], w - images_[RIGHT]->width(), 0); - canvas->TileImageInt(*images_[CENTER], - images_[LEFT]->width(), - 0, - w - images_[LEFT]->width() - images_[RIGHT]->width(), - height_); + canvas->DrawBitmapInt(*images_[RIGHT], + size.width() - images_[RIGHT]->width(), 0); + canvas->TileImageInt(*images_[CENTER], images_[LEFT]->width(), 0, + size.width() - images_[LEFT]->width() - images_[RIGHT]->width(), height_); } } // namespace views diff --git a/ui/views/painter.h b/ui/views/painter.h index c782425..dcdebb2 100644 --- a/ui/views/painter.h +++ b/ui/views/painter.h @@ -11,12 +11,14 @@ #include "third_party/skia/include/core/SkColor.h" #include "ui/views/views_export.h" +class SkBitmap; + namespace gfx { class Canvas; class Insets; class Rect; +class Size; } -class SkBitmap; namespace views { @@ -48,7 +50,7 @@ class VIEWS_EXPORT Painter { virtual ~Painter() {} // Paints the painter in the specified region. - virtual void Paint(int w, int h, gfx::Canvas* canvas) = 0; + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) = 0; }; // HorizontalPainter paints 3 images into a box: left, center and right. The @@ -64,7 +66,7 @@ class VIEWS_EXPORT HorizontalPainter : public Painter { virtual ~HorizontalPainter() {} // Paints the images. - virtual void Paint(int w, int h, gfx::Canvas* canvas) OVERRIDE; + virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE; // Height of the images. int height() const { return height_; } |