| Index: ui/views/background.cc
|
| diff --git a/ui/views/background.cc b/ui/views/background.cc
|
| index 56f1eb36405ad801fc649a7091a1222e3bc1f22c..f8bf1b69578fb8c35f686b21bbc02a6f096825de 100644
|
| --- a/ui/views/background.cc
|
| +++ b/ui/views/background.cc
|
| @@ -38,23 +38,19 @@ class SolidBackground : public Background {
|
|
|
| class BackgroundPainter : public Background {
|
| public:
|
| - BackgroundPainter(bool owns_painter, Painter* painter)
|
| - : owns_painter_(owns_painter), painter_(painter) {
|
| - DCHECK(painter);
|
| + explicit BackgroundPainter(std::unique_ptr<Painter> painter)
|
| + : painter_(std::move(painter)) {
|
| + DCHECK(painter_);
|
| }
|
|
|
| - ~BackgroundPainter() override {
|
| - if (owns_painter_)
|
| - delete painter_;
|
| - }
|
| + ~BackgroundPainter() override {}
|
|
|
| void Paint(gfx::Canvas* canvas, View* view) const override {
|
| - Painter::PaintPainterAt(canvas, painter_, view->GetLocalBounds());
|
| + Painter::PaintPainterAt(canvas, painter_.get(), view->GetLocalBounds());
|
| }
|
|
|
| private:
|
| - bool owns_painter_;
|
| - Painter* painter_;
|
| + std::unique_ptr<Painter> painter_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(BackgroundPainter);
|
| };
|
| @@ -85,8 +81,8 @@ Background* Background::CreateStandardPanelBackground() {
|
| // static
|
| Background* Background::CreateVerticalGradientBackground(SkColor color1,
|
| SkColor color2) {
|
| - Background* background = CreateBackgroundPainter(
|
| - true, Painter::CreateVerticalGradient(color1, color2));
|
| + Background* background =
|
| + CreateBackgroundPainter(Painter::CreateVerticalGradient(color1, color2));
|
| background->SetNativeControlColor(
|
| color_utils::AlphaBlend(color1, color2, 128));
|
|
|
| @@ -94,22 +90,9 @@ Background* Background::CreateVerticalGradientBackground(SkColor color1,
|
| }
|
|
|
| // static
|
| -Background* Background::CreateVerticalMultiColorGradientBackground(
|
| - SkColor* colors,
|
| - SkScalar* pos,
|
| - size_t count) {
|
| - Background* background = CreateBackgroundPainter(
|
| - true, Painter::CreateVerticalMultiColorGradient(colors, pos, count));
|
| - background->SetNativeControlColor(
|
| - color_utils::AlphaBlend(colors[0], colors[count-1], 128));
|
| -
|
| - return background;
|
| -}
|
| -
|
| -// static
|
| -Background* Background::CreateBackgroundPainter(bool owns_painter,
|
| - Painter* painter) {
|
| - return new BackgroundPainter(owns_painter, painter);
|
| +Background* Background::CreateBackgroundPainter(
|
| + std::unique_ptr<Painter> painter) {
|
| + return new BackgroundPainter(std::move(painter));
|
| }
|
|
|
| } // namespace views
|
|
|