| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/gfx/canvas.h" | 8 #include "ui/gfx/canvas.h" |
| 9 #include "ui/views/background.h" |
| 9 #include "ui/views/view.h" | 10 #include "ui/views/view.h" |
| 10 #include "views/background.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, background_owner_, &origin); | 24 views::View::ConvertPointToView(view, background_owner_, &origin); |
| 25 canvas->Save(); | 25 canvas->Save(); |
| 26 // Move the origin and paint as if it's paint onto the owner. | 26 // Move the origin and paint as if it's paint onto the owner. |
| 27 canvas->Translate(gfx::Point().Subtract(origin)); | 27 canvas->Translate(gfx::Point().Subtract(origin)); |
| 28 background->Paint(canvas, background_owner_); | 28 background->Paint(canvas, background_owner_); |
| 29 canvas->Restore(); | 29 canvas->Restore(); |
| 30 } | 30 } |
| 31 | 31 |
| 32 } // namespace chromeos | 32 } // namespace chromeos |
| OLD | NEW |