summaryrefslogtreecommitdiffstats
path: root/ui/views/painter.cc
diff options
context:
space:
mode:
authormsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 22:09:30 +0000
committermsw@chromium.org <msw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-23 22:09:30 +0000
commit8c14843b5e2ee88f9d7c090618a75e557b88eef7 (patch)
tree2233232d10b35f1a33f1a289462e95a31102c61c /ui/views/painter.cc
parent1fdab0fa4670e76c505b8ac6e6eff8a180051178 (diff)
downloadchromium_src-8c14843b5e2ee88f9d7c090618a75e557b88eef7.zip
chromium_src-8c14843b5e2ee88f9d7c090618a75e557b88eef7.tar.gz
chromium_src-8c14843b5e2ee88f9d7c090618a75e557b88eef7.tar.bz2
Stretch ImagePainter edge images instead of tiling.
BUG=218968,161374 TEST=Infobar buttons look correct (no broken gradient); no button appearance regressions. R=sky@chromium.org Review URL: https://chromiumcodereview.appspot.com/13986008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/painter.cc')
-rw-r--r--ui/views/painter.cc17
1 files changed, 10 insertions, 7 deletions
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
index e461185..62026ac 100644
--- a/ui/views/painter.cc
+++ b/ui/views/painter.cc
@@ -73,6 +73,11 @@ class GradientPainter : public Painter {
DISALLOW_COPY_AND_ASSIGN(GradientPainter);
};
+// A helper fuction to stretch the given image over the specified canvas area.
+void Fill(gfx::Canvas* c, const gfx::ImageSkia& i, int x, int y, int w, int h) {
+ c->DrawImageInt(i, 0, 0, i.width(), i.height(), x, y, w, h, false);
+}
+
// ImagePainter stores and paints nine images as a scalable grid.
class VIEWS_EXPORT ImagePainter : public Painter {
public:
@@ -147,15 +152,13 @@ void ImagePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
rect.bottom() - images_[6].height(), rect.bottom() };
canvas->DrawImageInt(images_[0], x[0], y[0]);
- canvas->TileImageInt(images_[1], x[1], y[0], x[2] - x[1], y[1] - y[0]);
+ Fill(canvas, images_[1], x[1], y[0], x[2] - x[1], y[1] - y[0]);
canvas->DrawImageInt(images_[2], x[2], y[0]);
- canvas->TileImageInt(images_[3], x[0], y[1], x[1] - x[0], y[2] - y[1]);
- canvas->DrawImageInt(
- images_[4], 0, 0, images_[4].width(), images_[4].height(),
- x[1], y[1], x[2] - x[1], y[2] - y[1], false);
- canvas->TileImageInt(images_[5], x[2], y[1], x[3] - x[2], y[2] - y[1]);
+ Fill(canvas, images_[3], x[0], y[1], x[1] - x[0], y[2] - y[1]);
+ Fill(canvas, images_[4], x[1], y[1], x[2] - x[1], y[2] - y[1]);
+ Fill(canvas, images_[5], x[2], y[1], x[3] - x[2], y[2] - y[1]);
canvas->DrawImageInt(images_[6], 0, y[2]);
- canvas->TileImageInt(images_[7], x[1], y[2], x[2] - x[1], y[3] - y[2]);
+ Fill(canvas, images_[7], x[1], y[2], x[2] - x[1], y[3] - y[2]);
canvas->DrawImageInt(images_[8], x[2], y[2]);
}