Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1028)

Unified Diff: ui/gfx/nine_image_painter.cc

Issue 1365503007: Make NineImagePainter stay within the bounds rect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: exclude border if not enough room for it Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/gfx/nine_image_painter_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/nine_image_painter.cc
diff --git a/ui/gfx/nine_image_painter.cc b/ui/gfx/nine_image_painter.cc
index d9cae91afab5e2b5d34985e3e7d3c2b09cd875fd..42d5cc0ab49493f8108630bf8b0a78e3fd721e78 100644
--- a/ui/gfx/nine_image_painter.cc
+++ b/ui/gfx/nine_image_painter.cc
@@ -132,9 +132,6 @@ void NineImagePainter::Paint(Canvas* canvas,
int i6w = ImageWidthInPixels(images_[6], scale_x);
int i8w = ImageWidthInPixels(images_[8], scale_x);
- int i4x = std::min(std::min(i0w, i3w), i6w);
- int i4w = width_in_pixels - i4x - std::min(std::min(i2w, i5w), i8w);
-
int i0h = ImageHeightInPixels(images_[0], scale_y);
int i1h = ImageHeightInPixels(images_[1], scale_y);
int i2h = ImageHeightInPixels(images_[2], scale_y);
@@ -142,14 +139,27 @@ void NineImagePainter::Paint(Canvas* canvas,
int i7h = ImageHeightInPixels(images_[7], scale_y);
int i8h = ImageHeightInPixels(images_[8], scale_y);
- int i4y = std::min(std::min(i0h, i1h), i2h);
- int i4h = height_in_pixels - i4y - std::min(std::min(i6h, i7h), i8h);
+ bool has_room_for_border =
+ i0w + i2w <= width_in_pixels && i3w + i5w <= width_in_pixels &&
+ i6w + i8w <= width_in_pixels && i0h + i6h <= height_in_pixels &&
+ i1h + i7h <= height_in_pixels && i2h + i8h <= height_in_pixels;
+
+ int i4x = has_room_for_border ? std::min(std::min(i0w, i3w), i6w) : 0;
+ int i4w = width_in_pixels -
+ (has_room_for_border ? i4x + std::min(std::min(i2w, i5w), i8w) : 0);
+
+ int i4y = has_room_for_border ? std::min(std::min(i0h, i1h), i2h) : 0;
+ int i4h = height_in_pixels -
+ (has_room_for_border ? i4y + std::min(std::min(i6h, i7h), i8h) : 0);
SkPaint paint;
paint.setAlpha(alpha);
Fill(canvas, images_[4], i4x, i4y, i4w, i4h, paint);
+ if (!has_room_for_border)
+ return;
+
Fill(canvas, images_[0], 0, 0, i0w, i0h, paint);
Fill(canvas, images_[1], i0w, 0, width_in_pixels - i0w - i2w, i1h, paint);
« no previous file with comments | « no previous file | ui/gfx/nine_image_painter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698