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

Unified Diff: ui/views/painter.cc

Issue 14921006: Fix LabelButtonBorder image blending. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use a skia::RefPtr to free the SkXfermode after use. Created 7 years, 6 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
« ui/views/painter.h ('K') | « ui/views/painter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/painter.cc
diff --git a/ui/views/painter.cc b/ui/views/painter.cc
index ce84a58e8dbaec763a1ff5f196a19f17211be752..9adff90257332b6f2c9e919cfb52b78a5ff141b9 100644
--- a/ui/views/painter.cc
+++ b/ui/views/painter.cc
@@ -109,6 +109,9 @@ class VIEWS_EXPORT ImagePainter : public Painter {
// Painter:
virtual gfx::Size GetMinimumSize() const OVERRIDE;
virtual void Paint(gfx::Canvas* canvas, const gfx::Size& size) OVERRIDE;
+ virtual void PaintWithSkPaint(gfx::Canvas* canvas,
+ const gfx::Size& size,
+ const SkPaint& paint) OVERRIDE;
private:
// Stretches the given image over the specified canvas area.
@@ -117,7 +120,8 @@ class VIEWS_EXPORT ImagePainter : public Painter {
int x,
int y,
int w,
- int h);
+ int h,
+ const SkPaint& paint);
// Images are numbered as depicted below.
// ____________________
@@ -169,6 +173,12 @@ gfx::Size ImagePainter::GetMinimumSize() const {
}
void ImagePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
+ PaintWithSkPaint(canvas, size, SkPaint());
+}
+
+void ImagePainter::PaintWithSkPaint(gfx::Canvas* canvas,
+ const gfx::Size& size,
+ const SkPaint& paint) {
if (IsEmpty())
return;
@@ -195,15 +205,15 @@ void ImagePainter::Paint(gfx::Canvas* canvas, const gfx::Size& size) {
int i4y = std::min(std::min(i0h, i1h), i2h);
int i4h = h - i4y - std::min(std::min(i6h, i7h), i8h);
if (!images_[4].isNull())
- Fill(canvas, images_[4], i4x, i4y, i4w, i4h);
- canvas->DrawImageInt(images_[0], 0, 0);
- Fill(canvas, images_[1], i0w, 0, w - i0w - i2w, i1h);
- canvas->DrawImageInt(images_[2], w - i2w, 0);
- Fill(canvas, images_[3], 0, i0h, i3w, h - i0h - i6h);
- Fill(canvas, images_[5], w - i5w, i2h, i5w, h - i2h - i8h);
- canvas->DrawImageInt(images_[6], 0, h - i6h);
- Fill(canvas, images_[7], i6w, h - i7h, w - i6w - i8w, i7h);
- canvas->DrawImageInt(images_[8], w - i8w, h - i8h);
+ Fill(canvas, images_[4], i4x, i4y, i4w, i4h, paint);
+ canvas->DrawImageInt(images_[0], 0, 0, paint);
+ Fill(canvas, images_[1], i0w, 0, w - i0w - i2w, i1h, paint);
+ canvas->DrawImageInt(images_[2], w - i2w, 0, paint);
+ Fill(canvas, images_[3], 0, i0h, i3w, h - i0h - i6h, paint);
+ Fill(canvas, images_[5], w - i5w, i2h, i5w, h - i2h - i8h, paint);
+ canvas->DrawImageInt(images_[6], 0, h - i6h, paint);
+ Fill(canvas, images_[7], i6w, h - i7h, w - i6w - i8w, i7h, paint);
+ canvas->DrawImageInt(images_[8], w - i8w, h - i8h, paint);
}
// static
@@ -212,8 +222,9 @@ void ImagePainter::Fill(gfx::Canvas* c,
int x,
int y,
int w,
- int h) {
- c->DrawImageInt(i, 0, 0, i.width(), i.height(), x, y, w, h, false);
+ int h,
+ const SkPaint& paint) {
+ c->DrawImageInt(i, 0, 0, i.width(), i.height(), x, y, w, h, false, paint);
}
} // namespace
@@ -274,6 +285,13 @@ Painter* Painter::CreateImageGridPainter(const int image_ids[]) {
return new ImagePainter(image_ids);
}
+void Painter::PaintWithSkPaint(gfx::Canvas* canvas,
+ const gfx::Size& size,
+ const SkPaint& paint) {
+ // Ignore SkPaint options by default, applicable painters should add support.
+ Paint(canvas, size);
+}
+
// HorizontalPainter ----------------------------------------------------------
« ui/views/painter.h ('K') | « ui/views/painter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698