| 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 #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 18 matching lines...) Expand all Loading... |
| 200 void NotifyStart(bool force_clear); | 190 void NotifyStart(bool force_clear); |
| 201 | 191 |
| 202 CompositorDelegate* delegate_; | 192 CompositorDelegate* delegate_; |
| 203 gfx::Size size_; | 193 gfx::Size size_; |
| 204 | 194 |
| 205 // The root of the Layer tree drawn by this compositor. | 195 // The root of the Layer tree drawn by this compositor. |
| 206 Layer* root_layer_; | 196 Layer* root_layer_; |
| 207 | 197 |
| 208 ObserverList<CompositorObserver> observer_list_; | 198 ObserverList<CompositorObserver> observer_list_; |
| 209 | 199 |
| 210 // Factory used to create Compositors. Settable by tests. | |
| 211 // The delegate can be NULL if you don't wish to catch the ScheduleDraw() | |
| 212 // calls to it. | |
| 213 static ui::Compositor*(*compositor_factory_)( | |
| 214 ui::CompositorDelegate* delegate); | |
| 215 | |
| 216 friend class base::RefCounted<Compositor>; | 200 friend class base::RefCounted<Compositor>; |
| 217 }; | 201 }; |
| 218 | 202 |
| 219 } // namespace ui | 203 } // namespace ui |
| 220 | 204 |
| 221 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ | 205 #endif // UI_GFX_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |