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 3 // found in the LICENSE file. 4 5 #include "chrome/browser/chromeos/views/copy_background.h" 6 7 #include "base/logging.h" 8 #include "ui/gfx/canvas.h" 9 #include "views/background.h" 10 #include "views/view.h" 11 12 namespace chromeos { 13 14 CopyBackground::CopyBackground(views::View* copy_from) 15 : background_owner_(copy_from) { 16 DCHECK(background_owner_); 17 DCHECK(background_owner_->background()); 18 } 19 20 void CopyBackground::Paint(gfx::Canvas* canvas, views::View* view) const { 21 const Background* background = background_owner_->background(); 22 DCHECK(background); 23 gfx::Point origin(0, 0); 24 views::View::ConvertPointToView(view, 25 background_owner_, 26 &origin); 27 canvas->Save(); 28 // Move the origin and paint as if it's paint onto the owner. 29 canvas->TranslateInt(-origin.x(), -origin.y()); 30 background->Paint(canvas, background_owner_); 31 canvas->Restore(); 32 } 33 34 } // namespace chromeos 35