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

Unified Diff: ui/gfx/nine_image_painter.cc

Issue 798163003: Use nine image painter to draw tray background (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
Index: ui/gfx/nine_image_painter.cc
diff --git a/ui/gfx/nine_image_painter.cc b/ui/gfx/nine_image_painter.cc
index 500c536beeaab9d17612a9864e35ef3865ef11d5..b94ab92d5987cd4d3f31157d5066621d16a9dfd1 100644
--- a/ui/gfx/nine_image_painter.cc
+++ b/ui/gfx/nine_image_painter.cc
@@ -25,10 +25,14 @@ namespace {
// The following functions width and height of the image in pixels for the
// scale factor in the Canvas.
int ImageWidthInPixels(const ImageSkia& i, Canvas* c) {
+ if (i.isNull())
+ return 0;
return i.GetRepresentation(c->image_scale()).pixel_width();
}
int ImageHeightInPixels(const ImageSkia& i, Canvas* c) {
+ if (i.isNull())
+ return 0;
return i.GetRepresentation(c->image_scale()).pixel_height();
}
@@ -146,22 +150,44 @@ void NineImagePainter::Paint(Canvas* canvas,
SkPaint paint;
paint.setAlpha(alpha);
- if (!images_[4].isNull())
- Fill(canvas, images_[4], i4x, i4y, i4w, i4h, paint);
canvas->DrawImageIntInPixel(images_[0], 0, 0, i0w, i0h,
0, 0, i0w, i0h, false, paint);
- Fill(canvas, images_[1], i0w, 0, width_in_pixels - i0w - i2w, i1h, paint);
- canvas->DrawImageIntInPixel(images_[2], 0, 0, i2w, i2h, width_in_pixels - i2w,
- 0, i2w, i2h, false, paint);
- Fill(canvas, images_[3], 0, i0h, i3w, height_in_pixels - i0h - i6h, paint);
- Fill(canvas, images_[5], width_in_pixels - i5w, i2h, i5w,
- height_in_pixels - i2h - i8h, paint);
- canvas->DrawImageIntInPixel(images_[6], 0, 0, i6w, i6h, 0,
- height_in_pixels - i6h, i6w, i6h, false, paint);
- Fill(canvas, images_[7], i6w, height_in_pixels - i7h,
- width_in_pixels - i6w - i8w, i7h, paint);
- canvas->DrawImageIntInPixel(images_[8], 0, 0, i8w, i8h, width_in_pixels - i8w,
- height_in_pixels - i8h, i8w, i8h, false, paint);
+
+ if (!images_[1].isNull())
+ Fill(canvas, images_[1], i0w, 0, width_in_pixels - i0w - i2w, i1h, paint);
+
+ if (!images_[2].isNull()) {
+ canvas->DrawImageIntInPixel(
+ images_[2], 0, 0, i2w, i2h, width_in_pixels - i2w,
+ 0, i2w, i2h, false, paint);
+ }
+
+ if (!images_[4].isNull())
+ Fill(canvas, images_[4], i4x, i4y, i4w, i4h, paint);
+
+ if (!images_[3].isNull())
+ Fill(canvas, images_[3], 0, i0h, i3w, height_in_pixels - i0h - i6h, paint);
+
+ if (!images_[5].isNull()) {
+ Fill(canvas, images_[5], width_in_pixels - i5w, i2h, i5w,
+ height_in_pixels - i2h - i8h, paint);
+ }
+
+ if (!images_[6].isNull()) {
+ canvas->DrawImageIntInPixel(images_[6], 0, 0, i6w, i6h, 0,
+ height_in_pixels - i6h, i6w, i6h, false, paint);
+ }
+
+ if (!images_[7].isNull()) {
+ Fill(canvas, images_[7], i6w, height_in_pixels - i7h,
+ width_in_pixels - i6w - i8w, i7h, paint);
+ }
+
+ if (!images_[8].isNull()) {
+ canvas->DrawImageIntInPixel(
+ images_[8], 0, 0, i8w, i8h, width_in_pixels - i8w,
+ height_in_pixels - i8h, i8w, i8h, false, paint);
+ }
}
} // namespace gfx
« ash/system/tray/tray_background_view.cc ('K') | « ui/base/nine_image_painter_factory.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698