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 UsesTestContexts() = 0; | |
sky
2013/08/05 16:50:58
nit: IMO a better name for this is IsUsingTestCont
danakj
2013/08/05 16:53:34
That name sounds like it could change, whereas I w
| |
102 }; | 106 }; |
103 | 107 |
104 // The default factory that creates in-process contexts. | 108 // The default factory that creates in-process contexts. |
105 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 109 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
106 public: | 110 public: |
107 DefaultContextFactory(); | 111 DefaultContextFactory(); |
108 virtual ~DefaultContextFactory(); | 112 virtual ~DefaultContextFactory(); |
109 | 113 |
110 // ContextFactory implementation | 114 // ContextFactory implementation |
111 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 115 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
112 Compositor* compositor) OVERRIDE; | 116 Compositor* compositor) OVERRIDE; |
113 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() | 117 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() |
114 OVERRIDE; | 118 OVERRIDE; |
115 | 119 |
116 virtual scoped_refptr<Reflector> CreateReflector( | 120 virtual scoped_refptr<Reflector> CreateReflector( |
117 Compositor* compositor, | 121 Compositor* compositor, |
118 Layer* layer) OVERRIDE; | 122 Layer* layer) OVERRIDE; |
119 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | 123 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; |
120 | 124 |
121 virtual scoped_refptr<cc::ContextProvider> | 125 virtual scoped_refptr<cc::ContextProvider> |
122 OffscreenContextProviderForMainThread() OVERRIDE; | 126 OffscreenContextProviderForMainThread() OVERRIDE; |
123 virtual scoped_refptr<cc::ContextProvider> | 127 virtual scoped_refptr<cc::ContextProvider> |
124 OffscreenContextProviderForCompositorThread() OVERRIDE; | 128 OffscreenContextProviderForCompositorThread() OVERRIDE; |
125 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 129 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
130 virtual bool UsesTestContexts() OVERRIDE; | |
126 | 131 |
127 bool Initialize(); | 132 bool Initialize(); |
128 | 133 |
129 private: | 134 private: |
130 scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon( | 135 scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon( |
131 Compositor* compositor, | 136 Compositor* compositor, |
132 bool offscreen); | 137 bool offscreen); |
133 | 138 |
134 scoped_refptr<ContextProviderFromContextFactory> | 139 scoped_refptr<ContextProviderFromContextFactory> |
135 offscreen_contexts_main_thread_; | 140 offscreen_contexts_main_thread_; |
(...skipping 18 matching lines...) Expand all Loading... | |
154 virtual scoped_refptr<Reflector> CreateReflector( | 159 virtual scoped_refptr<Reflector> CreateReflector( |
155 Compositor* mirrored_compositor, | 160 Compositor* mirrored_compositor, |
156 Layer* mirroring_layer) OVERRIDE; | 161 Layer* mirroring_layer) OVERRIDE; |
157 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | 162 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; |
158 | 163 |
159 virtual scoped_refptr<cc::ContextProvider> | 164 virtual scoped_refptr<cc::ContextProvider> |
160 OffscreenContextProviderForMainThread() OVERRIDE; | 165 OffscreenContextProviderForMainThread() OVERRIDE; |
161 virtual scoped_refptr<cc::ContextProvider> | 166 virtual scoped_refptr<cc::ContextProvider> |
162 OffscreenContextProviderForCompositorThread() OVERRIDE; | 167 OffscreenContextProviderForCompositorThread() OVERRIDE; |
163 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 168 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
169 virtual bool UsesTestContexts() OVERRIDE; | |
164 | 170 |
165 private: | 171 private: |
166 scoped_refptr<ContextProviderFromContextFactory> | 172 scoped_refptr<ContextProviderFromContextFactory> |
167 offscreen_contexts_main_thread_; | 173 offscreen_contexts_main_thread_; |
168 scoped_refptr<ContextProviderFromContextFactory> | 174 scoped_refptr<ContextProviderFromContextFactory> |
169 offscreen_contexts_compositor_thread_; | 175 offscreen_contexts_compositor_thread_; |
170 | 176 |
171 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); | 177 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); |
172 }; | 178 }; |
173 | 179 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
283 // appropriately transformed texture for each transformed view in the widget's | 289 // appropriately transformed texture for each transformed view in the widget's |
284 // view hierarchy. | 290 // view hierarchy. |
285 class COMPOSITOR_EXPORT Compositor | 291 class COMPOSITOR_EXPORT Compositor |
286 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 292 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
287 public base::SupportsWeakPtr<Compositor> { | 293 public base::SupportsWeakPtr<Compositor> { |
288 public: | 294 public: |
289 Compositor(CompositorDelegate* delegate, | 295 Compositor(CompositorDelegate* delegate, |
290 gfx::AcceleratedWidget widget); | 296 gfx::AcceleratedWidget widget); |
291 virtual ~Compositor(); | 297 virtual ~Compositor(); |
292 | 298 |
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 | |
293 static void Initialize(); | 307 static void Initialize(); |
294 static bool WasInitializedWithThread(); | 308 static bool WasInitializedWithThread(); |
295 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | 309 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); |
296 static void Terminate(); | 310 static void Terminate(); |
297 | 311 |
298 // Schedules a redraw of the layer tree associated with this compositor. | 312 // Schedules a redraw of the layer tree associated with this compositor. |
299 void ScheduleDraw(); | 313 void ScheduleDraw(); |
300 | 314 |
301 // Sets the root of the layer tree drawn by this Compositor. The root layer | 315 // Sets the root of the layer tree drawn by this Compositor. The root layer |
302 // must have no parent. The compositor's root layer is reset if the root layer | 316 // 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... | |
441 bool disable_schedule_composite_; | 455 bool disable_schedule_composite_; |
442 | 456 |
443 CompositorLock* compositor_lock_; | 457 CompositorLock* compositor_lock_; |
444 | 458 |
445 DISALLOW_COPY_AND_ASSIGN(Compositor); | 459 DISALLOW_COPY_AND_ASSIGN(Compositor); |
446 }; | 460 }; |
447 | 461 |
448 } // namespace ui | 462 } // namespace ui |
449 | 463 |
450 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 464 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |