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 "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
11 #include "base/observer_list.h" | 11 #include "base/observer_list.h" |
12 #include "base/time.h" | 12 #include "base/time.h" |
13 #include "cc/layer_tree_host_client.h" | 13 #include "cc/layer_tree_host_client.h" |
14 #include "ui/compositor/compositor_export.h" | 14 #include "ui/compositor/compositor_export.h" |
15 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
16 #include "ui/gfx/size.h" | 16 #include "ui/gfx/size.h" |
17 #include "ui/gfx/transform.h" | 17 #include "ui/gfx/transform.h" |
18 #include "ui/gl/gl_share_group.h" | 18 #include "ui/gl/gl_share_group.h" |
19 | 19 |
20 class SkBitmap; | 20 class SkBitmap; |
21 | 21 |
22 namespace cc { | 22 namespace cc { |
| 23 class ContextProvider; |
23 class Layer; | 24 class Layer; |
24 class LayerTreeHost; | 25 class LayerTreeHost; |
25 } | 26 } |
26 | 27 |
27 namespace gfx { | 28 namespace gfx { |
28 class GLContext; | 29 class GLContext; |
29 class GLSurface; | 30 class GLSurface; |
30 class GLShareGroup; | 31 class GLShareGroup; |
31 class Point; | 32 class Point; |
32 class Rect; | 33 class Rect; |
(...skipping 27 matching lines...) Expand all Loading... |
60 // Creates an output surface for the given compositor. The factory may keep | 61 // Creates an output surface for the given compositor. The factory may keep |
61 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 62 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
62 // by calling RemoveCompositor when the compositor gets destroyed. | 63 // by calling RemoveCompositor when the compositor gets destroyed. |
63 virtual cc::OutputSurface* CreateOutputSurface( | 64 virtual cc::OutputSurface* CreateOutputSurface( |
64 Compositor* compositor) = 0; | 65 Compositor* compositor) = 0; |
65 | 66 |
66 // Creates a context used for offscreen rendering. This context can be shared | 67 // Creates a context used for offscreen rendering. This context can be shared |
67 // with all compositors. | 68 // with all compositors. |
68 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; | 69 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; |
69 | 70 |
| 71 virtual scoped_refptr<cc::ContextProvider> |
| 72 OffscreenContextProviderForMainThread() = 0; |
| 73 virtual scoped_refptr<cc::ContextProvider> |
| 74 OffscreenContextProviderForCompositorThread() = 0; |
| 75 |
70 // Destroys per-compositor data. | 76 // Destroys per-compositor data. |
71 virtual void RemoveCompositor(Compositor* compositor) = 0; | 77 virtual void RemoveCompositor(Compositor* compositor) = 0; |
72 }; | 78 }; |
73 | 79 |
74 // The default factory that creates in-process contexts. | 80 // The default factory that creates in-process contexts. |
75 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 81 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
76 public: | 82 public: |
77 DefaultContextFactory(); | 83 DefaultContextFactory(); |
78 virtual ~DefaultContextFactory(); | 84 virtual ~DefaultContextFactory(); |
79 | 85 |
80 // ContextFactory implementation | 86 // ContextFactory implementation |
81 virtual cc::OutputSurface* CreateOutputSurface( | 87 virtual cc::OutputSurface* CreateOutputSurface( |
82 Compositor* compositor) OVERRIDE; | 88 Compositor* compositor) OVERRIDE; |
83 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; | 89 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; |
| 90 virtual scoped_refptr<cc::ContextProvider> |
| 91 OffscreenContextProviderForMainThread() OVERRIDE; |
| 92 virtual scoped_refptr<cc::ContextProvider> |
| 93 OffscreenContextProviderForCompositorThread() OVERRIDE; |
84 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 94 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
85 | 95 |
86 bool Initialize(); | 96 bool Initialize(); |
87 | 97 |
88 void set_share_group(gfx::GLShareGroup* share_group) { | 98 void set_share_group(gfx::GLShareGroup* share_group) { |
89 share_group_ = share_group; | 99 share_group_ = share_group; |
90 } | 100 } |
91 | 101 |
92 private: | 102 private: |
93 WebKit::WebGraphicsContext3D* CreateContextCommon( | 103 WebKit::WebGraphicsContext3D* CreateContextCommon( |
94 Compositor* compositor, | 104 Compositor* compositor, |
95 bool offscreen); | 105 bool offscreen); |
96 | 106 |
97 scoped_refptr<gfx::GLShareGroup> share_group_; | 107 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 108 class DefaultContextProvider; |
| 109 scoped_refptr<DefaultContextProvider> offscreen_contexts_main_thread_; |
| 110 scoped_refptr<DefaultContextProvider> offscreen_contexts_compositor_thread_; |
98 | 111 |
99 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); | 112 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); |
100 }; | 113 }; |
101 | 114 |
102 // Texture provide an abstraction over the external texture that can be passed | 115 // Texture provide an abstraction over the external texture that can be passed |
103 // to a layer. | 116 // to a layer. |
104 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 117 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
105 public: | 118 public: |
106 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | 119 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); |
107 | 120 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 float pageScale) OVERRIDE; | 277 float pageScale) OVERRIDE; |
265 virtual scoped_ptr<cc::OutputSurface> | 278 virtual scoped_ptr<cc::OutputSurface> |
266 createOutputSurface() OVERRIDE; | 279 createOutputSurface() OVERRIDE; |
267 virtual void didRecreateOutputSurface(bool success) OVERRIDE; | 280 virtual void didRecreateOutputSurface(bool success) OVERRIDE; |
268 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; | 281 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; |
269 virtual void willCommit() OVERRIDE; | 282 virtual void willCommit() OVERRIDE; |
270 virtual void didCommit() OVERRIDE; | 283 virtual void didCommit() OVERRIDE; |
271 virtual void didCommitAndDrawFrame() OVERRIDE; | 284 virtual void didCommitAndDrawFrame() OVERRIDE; |
272 virtual void didCompleteSwapBuffers() OVERRIDE; | 285 virtual void didCompleteSwapBuffers() OVERRIDE; |
273 virtual void scheduleComposite() OVERRIDE; | 286 virtual void scheduleComposite() OVERRIDE; |
274 | 287 virtual scoped_refptr<cc::ContextProvider> |
| 288 OffscreenContextProviderForMainThread() OVERRIDE; |
| 289 virtual scoped_refptr<cc::ContextProvider> |
| 290 OffscreenContextProviderForCompositorThread() OVERRIDE; |
275 | 291 |
276 int last_started_frame() { return last_started_frame_; } | 292 int last_started_frame() { return last_started_frame_; } |
277 int last_ended_frame() { return last_ended_frame_; } | 293 int last_ended_frame() { return last_ended_frame_; } |
278 | 294 |
279 bool IsLocked() { return compositor_lock_ != NULL; } | 295 bool IsLocked() { return compositor_lock_ != NULL; } |
280 | 296 |
281 private: | 297 private: |
282 friend class base::RefCounted<Compositor>; | 298 friend class base::RefCounted<Compositor>; |
283 friend class CompositorLock; | 299 friend class CompositorLock; |
284 | 300 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 bool disable_schedule_composite_; | 332 bool disable_schedule_composite_; |
317 | 333 |
318 CompositorLock* compositor_lock_; | 334 CompositorLock* compositor_lock_; |
319 | 335 |
320 DISALLOW_COPY_AND_ASSIGN(Compositor); | 336 DISALLOW_COPY_AND_ASSIGN(Compositor); |
321 }; | 337 }; |
322 | 338 |
323 } // namespace ui | 339 } // namespace ui |
324 | 340 |
325 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 341 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |