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/containers/hash_tables.h" | 10 #include "base/containers/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/time.h" | 14 #include "base/time/time.h" |
15 #include "cc/trees/layer_tree_host_client.h" | 15 #include "cc/trees/layer_tree_host_client.h" |
| 16 #include "cc/trees/layer_tree_host_single_thread_client.h" |
16 #include "third_party/skia/include/core/SkColor.h" | 17 #include "third_party/skia/include/core/SkColor.h" |
17 #include "ui/compositor/compositor_export.h" | 18 #include "ui/compositor/compositor_export.h" |
18 #include "ui/compositor/compositor_observer.h" | 19 #include "ui/compositor/compositor_observer.h" |
19 #include "ui/gfx/native_widget_types.h" | 20 #include "ui/gfx/native_widget_types.h" |
20 #include "ui/gfx/size.h" | 21 #include "ui/gfx/size.h" |
21 #include "ui/gfx/transform.h" | 22 #include "ui/gfx/transform.h" |
22 #include "ui/gfx/vector2d.h" | 23 #include "ui/gfx/vector2d.h" |
23 #include "ui/gl/gl_share_group.h" | 24 #include "ui/gl/gl_share_group.h" |
24 | 25 |
25 class SkBitmap; | 26 class SkBitmap; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest); | 213 DISALLOW_COPY_AND_ASSIGN(DrawWaiterForTest); |
213 }; | 214 }; |
214 | 215 |
215 // Compositor object to take care of GPU painting. | 216 // Compositor object to take care of GPU painting. |
216 // A Browser compositor object is responsible for generating the final | 217 // A Browser compositor object is responsible for generating the final |
217 // displayable form of pixels comprising a single widget's contents. It draws an | 218 // displayable form of pixels comprising a single widget's contents. It draws an |
218 // appropriately transformed texture for each transformed view in the widget's | 219 // appropriately transformed texture for each transformed view in the widget's |
219 // view hierarchy. | 220 // view hierarchy. |
220 class COMPOSITOR_EXPORT Compositor | 221 class COMPOSITOR_EXPORT Compositor |
221 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 222 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
| 223 NON_EXPORTED_BASE(public cc::LayerTreeHostSingleThreadClient), |
222 public base::SupportsWeakPtr<Compositor> { | 224 public base::SupportsWeakPtr<Compositor> { |
223 public: | 225 public: |
224 explicit Compositor(gfx::AcceleratedWidget widget); | 226 explicit Compositor(gfx::AcceleratedWidget widget); |
225 virtual ~Compositor(); | 227 virtual ~Compositor(); |
226 | 228 |
227 static void Initialize(); | 229 static void Initialize(); |
228 static bool WasInitializedWithThread(); | 230 static bool WasInitializedWithThread(); |
229 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | 231 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); |
230 static void Terminate(); | 232 static void Terminate(); |
231 | 233 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 virtual void Layout() OVERRIDE; | 316 virtual void Layout() OVERRIDE; |
315 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, | 317 virtual void ApplyScrollAndScale(gfx::Vector2d scroll_delta, |
316 float page_scale) OVERRIDE {} | 318 float page_scale) OVERRIDE {} |
317 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) | 319 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface(bool fallback) |
318 OVERRIDE; | 320 OVERRIDE; |
319 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} | 321 virtual void DidInitializeOutputSurface(bool success) OVERRIDE {} |
320 virtual void WillCommit() OVERRIDE {} | 322 virtual void WillCommit() OVERRIDE {} |
321 virtual void DidCommit() OVERRIDE; | 323 virtual void DidCommit() OVERRIDE; |
322 virtual void DidCommitAndDrawFrame() OVERRIDE; | 324 virtual void DidCommitAndDrawFrame() OVERRIDE; |
323 virtual void DidCompleteSwapBuffers() OVERRIDE; | 325 virtual void DidCompleteSwapBuffers() OVERRIDE; |
324 virtual void ScheduleComposite() OVERRIDE; | |
325 virtual scoped_refptr<cc::ContextProvider> | 326 virtual scoped_refptr<cc::ContextProvider> |
326 OffscreenContextProvider() OVERRIDE; | 327 OffscreenContextProvider() OVERRIDE; |
327 | 328 |
| 329 // cc::LayerTreeHostSingleThreadClient implementation. |
| 330 virtual void ScheduleComposite() OVERRIDE; |
| 331 virtual void DidPostSwapBuffers() OVERRIDE {} |
| 332 virtual void DidAbortSwapBuffers() OVERRIDE {} |
| 333 |
328 int last_started_frame() { return last_started_frame_; } | 334 int last_started_frame() { return last_started_frame_; } |
329 int last_ended_frame() { return last_ended_frame_; } | 335 int last_ended_frame() { return last_ended_frame_; } |
330 | 336 |
331 bool IsLocked() { return compositor_lock_ != NULL; } | 337 bool IsLocked() { return compositor_lock_ != NULL; } |
332 | 338 |
333 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; | 339 const cc::LayerTreeDebugState& GetLayerTreeDebugState() const; |
334 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); | 340 void SetLayerTreeDebugState(const cc::LayerTreeDebugState& debug_state); |
335 | 341 |
336 private: | 342 private: |
337 friend class base::RefCounted<Compositor>; | 343 friend class base::RefCounted<Compositor>; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 bool draw_on_compositing_end_; | 387 bool draw_on_compositing_end_; |
382 | 388 |
383 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 389 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
384 | 390 |
385 DISALLOW_COPY_AND_ASSIGN(Compositor); | 391 DISALLOW_COPY_AND_ASSIGN(Compositor); |
386 }; | 392 }; |
387 | 393 |
388 } // namespace ui | 394 } // namespace ui |
389 | 395 |
390 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 396 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |