summaryrefslogtreecommitdiffstats
path: root/views/desktop/desktop_background.cc
blob: a6d7a64986604a1b88929f0b5e6c69d19110dd62 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "views/desktop/desktop_background.h"

#include "ui/gfx/canvas_skia.h"
#include "ui/gfx/path.h"
#include "views/view.h"

namespace views {
namespace desktop {

DesktopBackground::DesktopBackground() {
}

DesktopBackground::~DesktopBackground() {
}

void DesktopBackground::Paint(gfx::Canvas* canvas, View* view) const {
  // Paint the sky.
  canvas->FillRectInt(SK_ColorCYAN, 0, 0, view->width(), view->width());

  SkPaint paint;
  paint.setAntiAlias(true);
  paint.setStyle(SkPaint::kFill_Style);

  // Paint the rolling fields of green.
  {
    gfx::Path path;
    path.moveTo(0, view->height() / 2);
    path.cubicTo(view->height() / 4, view->height() / 4,
        view->height() / 2, view->height() / 2,
        SkIntToScalar(view->width()), view->height() / 2);
    path.lineTo(SkIntToScalar(view->width()), SkIntToScalar(view->height()));
    path.lineTo(0, SkIntToScalar(view->height()));
    path.close();

    paint.setColor(SK_ColorGREEN);
    canvas->AsCanvasSkia()->drawPath(path, paint);
  }

  // Paint the shining sun.
  {
    gfx::Path path;
    path.addCircle(view->height() / 4, view->height() / 8, view->height() / 16);
    path.close();

    paint.setColor(SK_ColorYELLOW);
    canvas->AsCanvasSkia()->drawPath(path, paint);
  }
}

}  // namespace desktop
}  // namespace views