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 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 // Returns the size of the widget that is being drawn to. | 153 // Returns the size of the widget that is being drawn to. |
154 const gfx::Size& size() { return size_; } | 154 const gfx::Size& size() { return size_; } |
155 | 155 |
156 // Compositor does not own observers. It is the responsibility of the | 156 // Compositor does not own observers. It is the responsibility of the |
157 // observer to remove itself when it is done observing. | 157 // observer to remove itself when it is done observing. |
158 void AddObserver(CompositorObserver* observer); | 158 void AddObserver(CompositorObserver* observer); |
159 void RemoveObserver(CompositorObserver* observer); | 159 void RemoveObserver(CompositorObserver* observer); |
160 bool HasObserver(CompositorObserver* observer); | 160 bool HasObserver(CompositorObserver* observer); |
161 | 161 |
162 static void set_compositor_factory_for_testing( | |
163 ui::Compositor*(*factory)(ui::CompositorDelegate* owner)) { | |
164 compositor_factory_ = factory; | |
165 } | |
166 | |
167 static ui::Compositor* (*compositor_factory())( | |
168 ui::CompositorDelegate* owner) { | |
169 return compositor_factory_; | |
170 } | |
171 | |
172 protected: | 162 protected: |
173 Compositor(CompositorDelegate* delegate, const gfx::Size& size); | 163 Compositor(CompositorDelegate* delegate, const gfx::Size& size); |
174 virtual ~Compositor(); | 164 virtual ~Compositor(); |
175 | 165 |
176 // Notifies the compositor that compositing is about to start. | 166 // Notifies the compositor that compositing is about to start. |
177 virtual void OnNotifyStart(bool clear) = 0; | 167 virtual void OnNotifyStart(bool clear) = 0; |
178 | 168 |
179 // Notifies the compositor that compositing is complete. | 169 // Notifies the compositor that compositing is complete. |
180 virtual void OnNotifyEnd() = 0; | 170 virtual void OnNotifyEnd() = 0; |
181 | 171 |
(...skipping 17 matching lines...) Expand all Loading... |
199 void NotifyEnd(); | 189 void NotifyEnd(); |
200 | 190 |
201 CompositorDelegate* delegate_; | 191 CompositorDelegate* delegate_; |
202 gfx::Size size_; | 192 gfx::Size size_; |
203 | 193 |
204 // The root of the Layer tree drawn by this compositor. | 194 // The root of the Layer tree drawn by this compositor. |
205 Layer* root_layer_; | 195 Layer* root_layer_; |
206 | 196 |
207 ObserverList<CompositorObserver> observer_list_; | 197 ObserverList<CompositorObserver> observer_list_; |
208 | 198 |
209 // Factory used to create Compositors. Settable by tests. | |
210 // The delegate can be NULL if you don't wish to catch the ScheduleDraw() | |
211 // calls to it. | |
212 static ui::Compositor*(*compositor_factory_)( | |
213 ui::CompositorDelegate* delegate); | |
214 | |
215 friend class base::RefCounted<Compositor>; | 199 friend class base::RefCounted<Compositor>; |
216 }; | 200 }; |
217 | 201 |
218 } // namespace ui | 202 } // namespace ui |
219 | 203 |
220 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 204 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |