Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "aura/desktop.h" | |
| 6 #include "aura/desktop_host.h" | |
| 7 #include "aura/window.h" | |
| 8 #include "aura/window_delegate.h" | |
| 9 #include "base/at_exit.h" | |
| 10 #include "base/command_line.h" | |
| 11 #include "base/i18n/icu_util.h" | |
| 12 #include "base/memory/scoped_ptr.h" | |
| 13 #include "base/message_loop.h" | |
| 14 #include "third_party/skia/include/core/SkXfermode.h" | |
| 15 #include "ui/base/resource/resource_bundle.h" | |
| 16 #include "ui/gfx/canvas.h" | |
| 17 #include "ui/gfx/canvas_skia.h" | |
| 18 #include "ui/gfx/rect.h" | |
| 19 #include "ui/base/ui_base_paths.h" | |
| 20 | |
| 21 namespace { | |
| 22 | |
| 23 // Trivial WindowDelegate implementation that draws a red background. | |
|
Daniel Erat
2011/07/28 23:00:37
s/red/blue/
| |
| 24 class DemoWindowDelegate : public aura::WindowDelegate { | |
| 25 public: | |
| 26 explicit DemoWindowDelegate(aura::Window* window); | |
| 27 | |
| 28 virtual void OnPaint(const gfx::Rect& bounds) OVERRIDE; | |
| 29 | |
| 30 private: | |
| 31 aura::Window* window_; | |
| 32 | |
| 33 DISALLOW_COPY_AND_ASSIGN(DemoWindowDelegate); | |
| 34 }; | |
| 35 | |
| 36 DemoWindowDelegate::DemoWindowDelegate(aura::Window* window) | |
| 37 : window_(window) { | |
| 38 } | |
| 39 | |
| 40 void DemoWindowDelegate::OnPaint(const gfx::Rect& bounds) { | |
| 41 scoped_ptr<gfx::Canvas> canvas( | |
| 42 gfx::Canvas::CreateCanvas(bounds.width(), bounds.height(), false)); | |
| 43 canvas->AsCanvasSkia()->drawColor( | |
| 44 SK_ColorBLUE, SkXfermode::kSrc_Mode); | |
| 45 window_->SetCanvas(*canvas->AsCanvasSkia(), bounds.origin()); | |
| 46 } | |
| 47 | |
| 48 } // namespace | |
| 49 | |
| 50 int main(int argc, char** argv) { | |
| 51 CommandLine::Init(argc, argv); | |
| 52 | |
| 53 // The exit manager is in charge of calling the dtors of singleton objects. | |
| 54 base::AtExitManager exit_manager; | |
| 55 | |
| 56 ui::RegisterPathProvider(); | |
| 57 icu_util::Initialize(); | |
| 58 ResourceBundle::InitSharedInstance("en-US"); | |
| 59 | |
| 60 // Create the DesktopHost and Desktop. | |
| 61 scoped_ptr<aura::DesktopHost> host( | |
| 62 aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))); | |
| 63 aura::Desktop desktop(host->GetAcceleratedWidget(), host->GetSize()); | |
| 64 host->SetDesktop(&desktop); | |
| 65 | |
| 66 // Create a test window and give it a size. | |
| 67 aura::Window window(&desktop); | |
| 68 window.SetBounds(gfx::Rect(100, 100, 400, 400), 0); | |
| 69 window.SetVisibility(aura::Window::VISIBILITY_SHOWN); | |
| 70 DemoWindowDelegate window_delegate(&window); | |
| 71 window.set_delegate(&window_delegate); | |
| 72 | |
| 73 host->Show(); | |
| 74 | |
| 75 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | |
| 76 MessageLoopForUI::current()->Run(NULL); | |
| 77 return 0; | |
| 78 } | |
| OLD | NEW |