diff options
author | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 22:53:07 +0000 |
---|---|---|
committer | johnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 22:53:07 +0000 |
commit | ebc3c8bdb77ce5926e0bb6961851d9e3546f7274 (patch) | |
tree | cc79ff43b5cfaaff764187948da4026dc309f70b /views | |
parent | 698601ed9a0a452c6cc7761d74c06afb1226ac86 (diff) | |
download | chromium_src-ebc3c8bdb77ce5926e0bb6961851d9e3546f7274.zip chromium_src-ebc3c8bdb77ce5926e0bb6961851d9e3546f7274.tar.gz chromium_src-ebc3c8bdb77ce5926e0bb6961851d9e3546f7274.tar.bz2 |
Re-enable the paint_center option in ImagePainter.
This was lost when ImagePainter was refactored as part of the fix to http://crbug.com/23261.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/300019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29725 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r-- | views/painter.cc | 22 | ||||
-rw-r--r-- | views/painter.h | 3 |
2 files changed, 20 insertions, 5 deletions
diff --git a/views/painter.cc b/views/painter.cc index c710158..bcc65cd 100644 --- a/views/painter.cc +++ b/views/painter.cc @@ -57,9 +57,12 @@ class GradientPainter : public Painter { class ImagePainter : public Painter { public: - ImagePainter(const SkBitmap& image, const gfx::Insets& insets) + ImagePainter(const SkBitmap& image, + const gfx::Insets& insets, + bool paint_center) : image_(image), - insets_(insets) { + insets_(insets), + paint_center_(paint_center) { DCHECK(image.width() > insets.width() && image.height() > insets.height()); } @@ -116,11 +119,21 @@ class ImagePainter : public Painter { image_, 0, insets_.top(), insets_.left(), image_.height() - insets_.height(), 0, insets_.top(), insets_.left(), h - insets_.height(), true); + // Center. + if (paint_center_) { + canvas->DrawBitmapInt( + image_, + insets_.top(), insets_.left(), + image_.width() - insets_.width(), image_.height() - insets_.height(), + insets_.left(), insets_.top(), + w - insets_.width(), h - insets_.height(), true); + } } private: const SkBitmap image_; const gfx::Insets insets_; + bool paint_center_; DISALLOW_COPY_AND_ASSIGN(ImagePainter); }; @@ -151,8 +164,9 @@ Painter* Painter::CreateVerticalGradient(SkColor c1, SkColor c2) { // static Painter* Painter::CreateImagePainter(const SkBitmap& image, - const gfx::Insets& insets) { - return new ImagePainter(image, insets); + const gfx::Insets& insets, + bool paint_center) { + return new ImagePainter(image, insets, paint_center); } HorizontalPainter::HorizontalPainter(const int image_resource_names[]) { diff --git a/views/painter.h b/views/painter.h index 40e5db3..a237461 100644 --- a/views/painter.h +++ b/views/painter.h @@ -37,7 +37,8 @@ class Painter { // destination size. // Ownership is passed to the caller. static Painter* CreateImagePainter(const SkBitmap& image, - const gfx::Insets& insets); + const gfx::Insets& insets, + bool paint_center); virtual ~Painter() {} |