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_COMPOSITOR_COMPOSITOR_H_ | 5 #ifndef UI_COMPOSITOR_COMPOSITOR_H_ |
6 #define UI_COMPOSITOR_COMPOSITOR_H_ | 6 #define UI_COMPOSITOR_COMPOSITOR_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/hash_tables.h" | 10 #include "base/hash_tables.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
14 #include "base/time.h" | 14 #include "base/time.h" |
15 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 16 #include "third_party/skia/include/core/SkColor.h" |
17 #include "ui/compositor/compositor_export.h" | 17 #include "ui/compositor/compositor_export.h" |
| 18 #include "ui/compositor/compositor_observer.h" |
18 #include "ui/gfx/native_widget_types.h" | 19 #include "ui/gfx/native_widget_types.h" |
19 #include "ui/gfx/size.h" | 20 #include "ui/gfx/size.h" |
20 #include "ui/gfx/transform.h" | 21 #include "ui/gfx/transform.h" |
21 #include "ui/gfx/vector2d.h" | 22 #include "ui/gfx/vector2d.h" |
22 #include "ui/gl/gl_share_group.h" | 23 #include "ui/gl/gl_share_group.h" |
23 | 24 |
24 class SkBitmap; | 25 class SkBitmap; |
25 | 26 |
| 27 namespace base { |
| 28 class RunLoop; |
| 29 } |
| 30 |
26 namespace cc { | 31 namespace cc { |
27 class ContextProvider; | 32 class ContextProvider; |
28 class Layer; | 33 class Layer; |
29 class LayerTreeHost; | 34 class LayerTreeHost; |
30 } | 35 } |
31 | 36 |
32 namespace gfx { | 37 namespace gfx { |
33 class GLContext; | 38 class GLContext; |
34 class GLSurface; | 39 class GLSurface; |
35 class GLShareGroup; | 40 class GLShareGroup; |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 205 |
201 explicit CompositorLock(Compositor* compositor); | 206 explicit CompositorLock(Compositor* compositor); |
202 ~CompositorLock(); | 207 ~CompositorLock(); |
203 | 208 |
204 void CancelLock(); | 209 void CancelLock(); |
205 | 210 |
206 Compositor* compositor_; | 211 Compositor* compositor_; |
207 DISALLOW_COPY_AND_ASSIGN(CompositorLock); | 212 DISALLOW_COPY_AND_ASSIGN(CompositorLock); |
208 }; | 213 }; |
209 | 214 |
| 215 class COMPOSITOR_EXPORT DrawWaiterForTest : public ui::CompositorObserver { |
| 216 public: |
| 217 // Waits at most |kDrawWaitTimeOutMs| milliseconds for a draw to be issued. |
| 218 // If a draw is issued in that timeframe, it will complete. Returns true if |
| 219 // a draw completed, false otherwise. |
| 220 static bool Wait(Compositor* compositor); |
| 221 |
| 222 private: |
| 223 DrawWaiterForTest(); |
| 224 virtual ~DrawWaiterForTest(); |
| 225 |
| 226 bool WaitImpl(Compositor* compositor); |
| 227 void TimedOutWhileWaiting(); |
| 228 |
| 229 // CompositorObserver implementation. |
| 230 virtual void OnCompositingDidCommit(Compositor* compositor) OVERRIDE; |
| 231 virtual void OnCompositingStarted(Compositor* compositor, |
| 232 base::TimeTicks start_time) OVERRIDE; |
| 233 virtual void OnCompositingEnded(Compositor* compositor) OVERRIDE; |
| 234 virtual void OnCompositingAborted(Compositor* compositor) OVERRIDE; |
| 235 virtual void OnCompositingLockStateChanged(Compositor* compositor) OVERRIDE; |
| 236 virtual void OnUpdateVSyncParameters(Compositor* compositor, |
| 237 base::TimeTicks timebase, |
| 238 base::TimeDelta interval) OVERRIDE; |
| 239 |
| 240 const int kDrawWaitTimeOutMs; |
| 241 |
| 242 scoped_ptr<base::RunLoop> wait_run_loop_; |
| 243 bool did_draw_; |
| 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest); |
| 246 }; |
210 | 247 |
211 // Compositor object to take care of GPU painting. | 248 // Compositor object to take care of GPU painting. |
212 // A Browser compositor object is responsible for generating the final | 249 // A Browser compositor object is responsible for generating the final |
213 // displayable form of pixels comprising a single widget's contents. It draws an | 250 // displayable form of pixels comprising a single widget's contents. It draws an |
214 // appropriately transformed texture for each transformed view in the widget's | 251 // appropriately transformed texture for each transformed view in the widget's |
215 // view hierarchy. | 252 // view hierarchy. |
216 class COMPOSITOR_EXPORT Compositor | 253 class COMPOSITOR_EXPORT Compositor |
217 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 254 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
218 public base::SupportsWeakPtr<Compositor> { | 255 public base::SupportsWeakPtr<Compositor> { |
219 public: | 256 public: |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 bool disable_schedule_composite_; | 402 bool disable_schedule_composite_; |
366 | 403 |
367 CompositorLock* compositor_lock_; | 404 CompositorLock* compositor_lock_; |
368 | 405 |
369 DISALLOW_COPY_AND_ASSIGN(Compositor); | 406 DISALLOW_COPY_AND_ASSIGN(Compositor); |
370 }; | 407 }; |
371 | 408 |
372 } // namespace ui | 409 } // namespace ui |
373 | 410 |
374 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 411 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |