OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/compositor/test/test_compositor_host.h" | 5 #include "ui/gfx/compositor/test/test_compositor_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 | 31 |
32 private: | 32 private: |
33 // Overridden from TestCompositorHost: | 33 // Overridden from TestCompositorHost: |
34 virtual void Show() OVERRIDE; | 34 virtual void Show() OVERRIDE; |
35 virtual ui::Compositor* GetCompositor() OVERRIDE; | 35 virtual ui::Compositor* GetCompositor() OVERRIDE; |
36 | 36 |
37 // Overridden from CompositorDelegate: | 37 // Overridden from CompositorDelegate: |
38 virtual void ScheduleDraw() OVERRIDE; | 38 virtual void ScheduleDraw() OVERRIDE; |
39 | 39 |
40 // Overridden from MessagePumpDispatcher: | 40 // Overridden from MessagePumpDispatcher: |
41 #if defined(USE_AURA) | 41 virtual bool Dispatch(const base::NativeEvent& event) OVERRIDE; |
42 virtual base::MessagePumpDispatcher::DispatchStatus | |
43 Dispatch(XEvent* xev) OVERRIDE; | |
44 #elif defined(TOOLKIT_GTK) | |
45 virtual bool Dispatch(GdkEvent* event) OVERRIDE; | |
46 #endif | |
47 | 42 |
48 void Draw(); | 43 void Draw(); |
49 | 44 |
50 gfx::Rect bounds_; | 45 gfx::Rect bounds_; |
51 | 46 |
52 scoped_ptr<ui::Compositor> compositor_; | 47 scoped_ptr<ui::Compositor> compositor_; |
53 | 48 |
54 XID window_; | 49 XID window_; |
55 | 50 |
56 base::WeakPtrFactory<TestCompositorHostLinux> method_factory_; | 51 base::WeakPtrFactory<TestCompositorHostLinux> method_factory_; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 92 |
98 void TestCompositorHostLinux::ScheduleDraw() { | 93 void TestCompositorHostLinux::ScheduleDraw() { |
99 if (!method_factory_.HasWeakPtrs()) { | 94 if (!method_factory_.HasWeakPtrs()) { |
100 MessageLoopForUI::current()->PostTask( | 95 MessageLoopForUI::current()->PostTask( |
101 FROM_HERE, | 96 FROM_HERE, |
102 base::Bind(&TestCompositorHostLinux::Draw, | 97 base::Bind(&TestCompositorHostLinux::Draw, |
103 method_factory_.GetWeakPtr())); | 98 method_factory_.GetWeakPtr())); |
104 } | 99 } |
105 } | 100 } |
106 | 101 |
107 #if defined(USE_AURA) | 102 bool TestCompositorHostLinux::Dispatch(const base::NativeEvent& event) { |
108 base::MessagePumpDispatcher::DispatchStatus TestCompositorHostLinux::Dispatch( | 103 return true; |
109 XEvent* xev) { | |
110 return MessagePumpDispatcher::EVENT_IGNORED; | |
111 } | 104 } |
112 #elif defined(TOOLKIT_GTK) | |
113 bool TestCompositorHostLinux::Dispatch(GdkEvent*) { | |
114 return false; | |
115 } | |
116 #endif | |
117 | 105 |
118 void TestCompositorHostLinux::Draw() { | 106 void TestCompositorHostLinux::Draw() { |
119 if (compositor_.get()) | 107 if (compositor_.get()) |
120 compositor_->Draw(false); | 108 compositor_->Draw(false); |
121 } | 109 } |
122 | 110 |
123 // static | 111 // static |
124 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { | 112 TestCompositorHost* TestCompositorHost::Create(const gfx::Rect& bounds) { |
125 return new TestCompositorHostLinux(bounds); | 113 return new TestCompositorHostLinux(bounds); |
126 } | 114 } |
127 | 115 |
128 } // namespace ui | 116 } // namespace ui |
OLD | NEW |