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" |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 // Removes the reflector, which stops the mirroring. | 92 // Removes the reflector, which stops the mirroring. |
93 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; | 93 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; |
94 | 94 |
95 virtual scoped_refptr<cc::ContextProvider> | 95 virtual scoped_refptr<cc::ContextProvider> |
96 OffscreenContextProviderForMainThread() = 0; | 96 OffscreenContextProviderForMainThread() = 0; |
97 virtual scoped_refptr<cc::ContextProvider> | 97 virtual scoped_refptr<cc::ContextProvider> |
98 OffscreenContextProviderForCompositorThread() = 0; | 98 OffscreenContextProviderForCompositorThread() = 0; |
99 | 99 |
100 // Destroys per-compositor data. | 100 // Destroys per-compositor data. |
101 virtual void RemoveCompositor(Compositor* compositor) = 0; | 101 virtual void RemoveCompositor(Compositor* compositor) = 0; |
102 | |
103 // When true, the factory uses test contexts that do not do real GL | |
104 // operations. | |
105 virtual bool DoesCreateTestContexts() = 0; | |
106 }; | 102 }; |
107 | 103 |
108 // The default factory that creates in-process contexts. | 104 // The default factory that creates in-process contexts. |
109 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 105 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
110 public: | 106 public: |
111 DefaultContextFactory(); | 107 DefaultContextFactory(); |
112 virtual ~DefaultContextFactory(); | 108 virtual ~DefaultContextFactory(); |
113 | 109 |
114 // ContextFactory implementation | 110 // ContextFactory implementation |
115 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 111 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
116 Compositor* compositor) OVERRIDE; | 112 Compositor* compositor) OVERRIDE; |
117 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() | 113 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() |
118 OVERRIDE; | 114 OVERRIDE; |
119 | 115 |
120 virtual scoped_refptr<Reflector> CreateReflector( | 116 virtual scoped_refptr<Reflector> CreateReflector( |
121 Compositor* compositor, | 117 Compositor* compositor, |
122 Layer* layer) OVERRIDE; | 118 Layer* layer) OVERRIDE; |
123 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | 119 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; |
124 | 120 |
125 virtual scoped_refptr<cc::ContextProvider> | 121 virtual scoped_refptr<cc::ContextProvider> |
126 OffscreenContextProviderForMainThread() OVERRIDE; | 122 OffscreenContextProviderForMainThread() OVERRIDE; |
127 virtual scoped_refptr<cc::ContextProvider> | 123 virtual scoped_refptr<cc::ContextProvider> |
128 OffscreenContextProviderForCompositorThread() OVERRIDE; | 124 OffscreenContextProviderForCompositorThread() OVERRIDE; |
129 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 125 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
130 virtual bool DoesCreateTestContexts() OVERRIDE; | |
131 | 126 |
132 bool Initialize(); | 127 bool Initialize(); |
133 | 128 |
134 private: | 129 private: |
135 scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon( | 130 scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon( |
136 Compositor* compositor, | 131 Compositor* compositor, |
137 bool offscreen); | 132 bool offscreen); |
138 | 133 |
139 scoped_refptr<ContextProviderFromContextFactory> | 134 scoped_refptr<ContextProviderFromContextFactory> |
140 offscreen_contexts_main_thread_; | 135 offscreen_contexts_main_thread_; |
(...skipping 18 matching lines...) Expand all Loading... |
159 virtual scoped_refptr<Reflector> CreateReflector( | 154 virtual scoped_refptr<Reflector> CreateReflector( |
160 Compositor* mirrored_compositor, | 155 Compositor* mirrored_compositor, |
161 Layer* mirroring_layer) OVERRIDE; | 156 Layer* mirroring_layer) OVERRIDE; |
162 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | 157 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; |
163 | 158 |
164 virtual scoped_refptr<cc::ContextProvider> | 159 virtual scoped_refptr<cc::ContextProvider> |
165 OffscreenContextProviderForMainThread() OVERRIDE; | 160 OffscreenContextProviderForMainThread() OVERRIDE; |
166 virtual scoped_refptr<cc::ContextProvider> | 161 virtual scoped_refptr<cc::ContextProvider> |
167 OffscreenContextProviderForCompositorThread() OVERRIDE; | 162 OffscreenContextProviderForCompositorThread() OVERRIDE; |
168 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 163 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
169 virtual bool DoesCreateTestContexts() OVERRIDE; | |
170 | 164 |
171 private: | 165 private: |
172 scoped_refptr<ContextProviderFromContextFactory> | 166 scoped_refptr<ContextProviderFromContextFactory> |
173 offscreen_contexts_main_thread_; | 167 offscreen_contexts_main_thread_; |
174 scoped_refptr<ContextProviderFromContextFactory> | 168 scoped_refptr<ContextProviderFromContextFactory> |
175 offscreen_contexts_compositor_thread_; | 169 offscreen_contexts_compositor_thread_; |
176 | 170 |
177 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); | 171 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); |
178 }; | 172 }; |
179 | 173 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // appropriately transformed texture for each transformed view in the widget's | 283 // appropriately transformed texture for each transformed view in the widget's |
290 // view hierarchy. | 284 // view hierarchy. |
291 class COMPOSITOR_EXPORT Compositor | 285 class COMPOSITOR_EXPORT Compositor |
292 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 286 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
293 public base::SupportsWeakPtr<Compositor> { | 287 public base::SupportsWeakPtr<Compositor> { |
294 public: | 288 public: |
295 Compositor(CompositorDelegate* delegate, | 289 Compositor(CompositorDelegate* delegate, |
296 gfx::AcceleratedWidget widget); | 290 gfx::AcceleratedWidget widget); |
297 virtual ~Compositor(); | 291 virtual ~Compositor(); |
298 | 292 |
299 // Set up the compositor ContextFactory for a test environment. Unit tests | |
300 // that do not have a full content environment need to call this before | |
301 // initializing the Compositor. | |
302 // Some tests expect pixel output, and they should pass false for | |
303 // |allow_test_contexts|. Most unit tests should pass true. Once this has been | |
304 // called, the Initialize() and Terminate() methods should be used as normal. | |
305 static void InitializeContextFactoryForTests(bool allow_test_contexts); | |
306 | |
307 static void Initialize(); | 293 static void Initialize(); |
308 static bool WasInitializedWithThread(); | 294 static bool WasInitializedWithThread(); |
309 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | 295 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); |
310 static void Terminate(); | 296 static void Terminate(); |
311 | 297 |
312 // Schedules a redraw of the layer tree associated with this compositor. | 298 // Schedules a redraw of the layer tree associated with this compositor. |
313 void ScheduleDraw(); | 299 void ScheduleDraw(); |
314 | 300 |
315 // Sets the root of the layer tree drawn by this Compositor. The root layer | 301 // Sets the root of the layer tree drawn by this Compositor. The root layer |
316 // must have no parent. The compositor's root layer is reset if the root layer | 302 // must have no parent. The compositor's root layer is reset if the root layer |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool disable_schedule_composite_; | 441 bool disable_schedule_composite_; |
456 | 442 |
457 CompositorLock* compositor_lock_; | 443 CompositorLock* compositor_lock_; |
458 | 444 |
459 DISALLOW_COPY_AND_ASSIGN(Compositor); | 445 DISALLOW_COPY_AND_ASSIGN(Compositor); |
460 }; | 446 }; |
461 | 447 |
462 } // namespace ui | 448 } // namespace ui |
463 | 449 |
464 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 450 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |