Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Side by Side Diff: aura/desktop.cc

Issue 7770002: gfx::Compositor: SchedulePaint. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « aura/desktop.h ('k') | aura/window_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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" 8 #include "aura/root_window.h"
9 #include "aura/window.h" 9 #include "aura/window.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "ui/gfx/compositor/compositor.h" 12 #include "ui/gfx/compositor/compositor.h"
13 13
14 namespace aura { 14 namespace aura {
15 15
16 // static 16 // static
17 Desktop* Desktop::instance_ = NULL; 17 Desktop* Desktop::instance_ = NULL;
18 18
19 Desktop::Desktop() 19 Desktop::Desktop()
20 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))) { 20 : host_(aura::DesktopHost::Create(gfx::Rect(200, 200, 1024, 768))),
21 compositor_ = ui::Compositor::Create(host_->GetAcceleratedWidget(), 21 ALLOW_THIS_IN_INITIALIZER_LIST(schedule_paint_(this)) {
22 DCHECK(MessageLoopForUI::current())
23 << "The UI message loop must be initialized first.";
24 compositor_ = ui::Compositor::Create(this, host_->GetAcceleratedWidget(),
22 host_->GetSize()); 25 host_->GetSize());
23 host_->SetDesktop(this); 26 host_->SetDesktop(this);
24 DCHECK(compositor_.get()); 27 DCHECK(compositor_.get());
25 window_.reset(new internal::RootWindow); 28 window_.reset(new internal::RootWindow);
26 } 29 }
27 30
28 Desktop::~Desktop() { 31 Desktop::~Desktop() {
29 } 32 }
30 33
31 void Desktop::Show() { 34 void Desktop::Show() {
32 host_->Show(); 35 host_->Show();
33 } 36 }
34 37
35 void Desktop::SetSize(const gfx::Size& size) { 38 void Desktop::SetSize(const gfx::Size& size) {
36 host_->SetSize(size); 39 host_->SetSize(size);
37 } 40 }
38 41
39 void Desktop::Run() { 42 void Desktop::Run() {
40 Show(); 43 Show();
41 MessageLoop main_message_loop(MessageLoop::TYPE_UI);
42 MessageLoopForUI::current()->Run(host_); 44 MessageLoopForUI::current()->Run(host_);
43 } 45 }
44 46
45 void Desktop::Draw() { 47 void Desktop::Draw() {
46 compositor_->NotifyStart(); 48 compositor_->NotifyStart();
47 window_->DrawTree(); 49 window_->DrawTree();
48 compositor_->NotifyEnd(); 50 compositor_->NotifyEnd();
49 } 51 }
50 52
51 bool Desktop::OnMouseEvent(const MouseEvent& event) { 53 bool Desktop::OnMouseEvent(const MouseEvent& event) {
52 return window_->HandleMouseEvent(event); 54 return window_->HandleMouseEvent(event);
53 } 55 }
54 56
55 bool Desktop::OnKeyEvent(const KeyEvent& event) { 57 bool Desktop::OnKeyEvent(const KeyEvent& event) {
56 return window_->HandleKeyEvent(event); 58 return window_->HandleKeyEvent(event);
57 } 59 }
58 60
61 void Desktop::ScheduleCompositorPaint() {
62 if (schedule_paint_.empty()) {
63 MessageLoop::current()->PostTask(FROM_HERE,
64 schedule_paint_.NewRunnableMethod(&Desktop::Draw));
65 }
66 }
67
59 // static 68 // static
60 Desktop* Desktop::GetInstance() { 69 Desktop* Desktop::GetInstance() {
61 if (!instance_) { 70 if (!instance_) {
62 instance_ = new Desktop; 71 instance_ = new Desktop;
63 instance_->window_->Init(); 72 instance_->window_->Init();
64 } 73 }
65 return instance_; 74 return instance_;
66 } 75 }
67 76
68 } // namespace aura 77 } // namespace aura
OLDNEW
« no previous file with comments | « aura/desktop.h ('k') | aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698