summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/views/copy_background.cc
blob: a6dd3ede340bdb788a150e06e0df4cd57358a7fe (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
// 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 "chrome/browser/chromeos/views/copy_background.h"

#include "base/logging.h"
#include "ui/gfx/canvas.h"
#include "ui/views/view.h"
#include "views/background.h"

namespace chromeos {

CopyBackground::CopyBackground(views::View* copy_from)
    : background_owner_(copy_from) {
  DCHECK(background_owner_);
  DCHECK(background_owner_->background());
}

void CopyBackground::Paint(gfx::Canvas* canvas, views::View* view) const {
  const Background* background = background_owner_->background();
  DCHECK(background);
  gfx::Point origin(0, 0);
  views::View::ConvertPointToView(view, background_owner_, &origin);
  canvas->Save();
  // Move the origin and paint as if it's paint onto the owner.
  canvas->Translate(gfx::Point().Subtract(origin));
  background->Paint(canvas, background_owner_);
  canvas->Restore();
}

}  // namespace chromeos