| 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 "aura/desktop.h" | 5 #include "aura/desktop.h" |
| 6 | 6 |
| 7 #include "aura/desktop_host.h" | 7 #include "aura/desktop_host.h" |
| 8 #include "aura/root_window.h" | |
| 9 #include "aura/window.h" | 8 #include "aura/window.h" |
| 10 #include "base/logging.h" | 9 #include "base/logging.h" |
| 11 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 12 #include "ui/gfx/compositor/compositor.h" | 11 #include "ui/gfx/compositor/compositor.h" |
| 13 | 12 |
| 14 namespace aura { | 13 namespace aura { |
| 15 | 14 |
| 16 // static | 15 // static |
| 17 Desktop* Desktop::instance_ = NULL; | 16 Desktop* Desktop::instance_ = NULL; |
| 18 | 17 |
| 19 Desktop::Desktop() | 18 Desktop::Desktop() |
| 20 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))) { | 19 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))) { |
| 21 compositor_ = ui::Compositor::Create(host_->GetAcceleratedWidget(), | 20 compositor_ = ui::Compositor::Create(host_->GetAcceleratedWidget(), |
| 22 host_->GetSize()); | 21 host_->GetSize()); |
| 23 host_->SetDesktop(this); | 22 host_->SetDesktop(this); |
| 24 DCHECK(compositor_.get()); | 23 DCHECK(compositor_.get()); |
| 25 window_.reset(new internal::RootWindow); | 24 window_.reset(new Window(NULL)); |
| 26 } | 25 } |
| 27 | 26 |
| 28 Desktop::~Desktop() { | 27 Desktop::~Desktop() { |
| 29 } | 28 } |
| 30 | 29 |
| 31 void Desktop::Show() { | 30 void Desktop::Run() { |
| 32 host_->Show(); | 31 host_->Show(); |
| 33 } | |
| 34 | |
| 35 void Desktop::SetSize(const gfx::Size& size) { | |
| 36 host_->SetSize(size); | |
| 37 } | |
| 38 | |
| 39 void Desktop::Run() { | |
| 40 Show(); | |
| 41 MessageLoop main_message_loop(MessageLoop::TYPE_UI); | 32 MessageLoop main_message_loop(MessageLoop::TYPE_UI); |
| 42 MessageLoopForUI::current()->Run(host_); | 33 MessageLoopForUI::current()->Run(host_); |
| 43 } | 34 } |
| 44 | 35 |
| 45 void Desktop::Draw() { | 36 void Desktop::Draw() { |
| 37 // Second pass renders the layers. |
| 46 compositor_->NotifyStart(); | 38 compositor_->NotifyStart(); |
| 47 window_->DrawTree(); | 39 window_->DrawTree(); |
| 48 compositor_->NotifyEnd(); | 40 compositor_->NotifyEnd(); |
| 49 } | 41 } |
| 50 | 42 |
| 51 bool Desktop::OnMouseEvent(const MouseEvent& event) { | 43 bool Desktop::OnMouseEvent(const MouseEvent& event) { |
| 52 return window_->HandleMouseEvent(event); | 44 return window_->OnMouseEvent(event); |
| 53 } | 45 } |
| 54 | 46 |
| 55 // static | 47 // static |
| 56 Desktop* Desktop::GetInstance() { | 48 Desktop* Desktop::GetInstance() { |
| 57 if (!instance_) { | 49 if (!instance_) { |
| 58 instance_ = new Desktop; | 50 instance_ = new Desktop; |
| 59 instance_->window_->Init(); | 51 instance_->window_->Init(); |
| 60 } | 52 } |
| 61 return instance_; | 53 return instance_; |
| 62 } | 54 } |
| 63 | 55 |
| 64 } // namespace aura | 56 } // namespace aura |
| OLD | NEW |