OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/chromeos/views/copy_background.h" | 5 #include "chrome/browser/chromeos/views/copy_background.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
9 #include "views/background.h" | 9 #include "views/background.h" |
10 #include "views/view.h" | 10 #include "views/view.h" |
11 | 11 |
12 namespace chromeos { | 12 namespace chromeos { |
13 | 13 |
14 CopyBackground::CopyBackground(views::View* copy_from) | 14 CopyBackground::CopyBackground(views::View* copy_from) |
15 : background_owner_(copy_from) { | 15 : background_owner_(copy_from) { |
16 DCHECK(background_owner_); | 16 DCHECK(background_owner_); |
17 DCHECK(background_owner_->background()); | 17 DCHECK(background_owner_->background()); |
18 } | 18 } |
19 | 19 |
20 void CopyBackground::Paint(gfx::Canvas* canvas, views::View* view) const { | 20 void CopyBackground::Paint(gfx::Canvas* canvas, views::View* view) const { |
21 const Background* background = background_owner_->background(); | 21 const Background* background = background_owner_->background(); |
22 DCHECK(background); | 22 DCHECK(background); |
23 gfx::Point origin(0, 0); | 23 gfx::Point origin(0, 0); |
24 views::View::ConvertPointToView(view, | 24 views::View::ConvertPointToView(view, |
25 background_owner_, | 25 background_owner_, |
26 &origin); | 26 &origin); |
27 canvas->Save(); | 27 canvas->Save(); |
28 // Move the origin and paint as if it's paint onto the owner. | 28 // Move the origin and paint as if it's paint onto the owner. |
29 canvas->TranslateInt(-origin.x(), -origin.y()); | 29 canvas->TranslateInt(-origin.x(), -origin.y()); |
30 background->Paint(canvas, background_owner_); | 30 background->Paint(canvas, background_owner_); |
31 canvas->Restore(); | 31 canvas->Restore(); |
32 } | 32 } |
33 | 33 |
34 } // namespace chromeos | 34 } // namespace chromeos |
OLD | NEW |