summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ui/views/painter.cc17
-rw-r--r--ui/views/painter.h6
2 files changed, 13 insertions, 10 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]);
}
diff --git a/ui/views/painter.h b/ui/views/painter.h
index d4b0daa..ffbd05b 100644
--- a/ui/views/painter.h
+++ b/ui/views/painter.h
@@ -50,14 +50,14 @@ class VIEWS_EXPORT Painter {
// Creates a painter that divides |image| into nine regions. The four corners
// are rendered at the size specified in insets (eg. the upper-left corner is
- // rendered at 0 x 0 with a size of insets.left() x insets.top()). The four
- // edges are tiled and the center is stretched to fill the destination size.
+ // rendered at 0 x 0 with a size of insets.left() x insets.top()). The center
+ // image and four edge images are stretched to fill the destination size.
static Painter* CreateImagePainter(const gfx::ImageSkia& image,
const gfx::Insets& insets);
// Creates a painter that paints nine images as a scalable grid. The four
// corners are rendered in their full sizes (they are assumed to share widths
- // by column and heights by row). The four edges are tiled and the center is
+ // by column and heights by row). The center image and four edge images are
// stretched to fill the destination size.
// |image_ids| must contain nine image IDs specified in this order: Top-Left,
// Top, Top-Right, Left, Center, Right, Bottom-Left, Bottom, Bottom-Right.