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 16 matching lines...) Expand all Loading... |
27 namespace base { | 27 namespace base { |
28 class MessageLoopProxy; | 28 class MessageLoopProxy; |
29 class RunLoop; | 29 class RunLoop; |
30 } | 30 } |
31 | 31 |
32 namespace cc { | 32 namespace cc { |
33 class ContextProvider; | 33 class ContextProvider; |
34 class Layer; | 34 class Layer; |
35 class LayerTreeDebugState; | 35 class LayerTreeDebugState; |
36 class LayerTreeHost; | 36 class LayerTreeHost; |
37 class TestContextProvider; | |
38 } | 37 } |
39 | 38 |
40 namespace gfx { | 39 namespace gfx { |
41 class GLContext; | 40 class GLContext; |
42 class GLSurface; | 41 class GLSurface; |
43 class GLShareGroup; | 42 class GLShareGroup; |
44 class Point; | 43 class Point; |
45 class Rect; | 44 class Rect; |
46 class Size; | 45 class Size; |
47 } | 46 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 SharedMainThreadContextProvider() = 0; | 109 SharedMainThreadContextProvider() = 0; |
111 | 110 |
112 // Destroys per-compositor data. | 111 // Destroys per-compositor data. |
113 virtual void RemoveCompositor(Compositor* compositor) = 0; | 112 virtual void RemoveCompositor(Compositor* compositor) = 0; |
114 | 113 |
115 // When true, the factory uses test contexts that do not do real GL | 114 // When true, the factory uses test contexts that do not do real GL |
116 // operations. | 115 // operations. |
117 virtual bool DoesCreateTestContexts() = 0; | 116 virtual bool DoesCreateTestContexts() = 0; |
118 }; | 117 }; |
119 | 118 |
120 // The default factory that creates in-process contexts. | |
121 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | |
122 public: | |
123 DefaultContextFactory(); | |
124 virtual ~DefaultContextFactory(); | |
125 | |
126 // ContextFactory implementation | |
127 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | |
128 Compositor* compositor) OVERRIDE; | |
129 | |
130 virtual scoped_refptr<Reflector> CreateReflector( | |
131 Compositor* compositor, | |
132 Layer* layer) OVERRIDE; | |
133 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | |
134 | |
135 virtual scoped_refptr<cc::ContextProvider> | |
136 OffscreenCompositorContextProvider() OVERRIDE; | |
137 virtual scoped_refptr<cc::ContextProvider> | |
138 SharedMainThreadContextProvider() OVERRIDE; | |
139 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | |
140 virtual bool DoesCreateTestContexts() OVERRIDE; | |
141 | |
142 bool Initialize(); | |
143 | |
144 private: | |
145 scoped_refptr<webkit::gpu::ContextProviderInProcess> | |
146 offscreen_compositor_contexts_; | |
147 scoped_refptr<webkit::gpu::ContextProviderInProcess> | |
148 shared_main_thread_contexts_; | |
149 | |
150 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); | |
151 }; | |
152 | |
153 // The factory that creates test contexts. | |
154 class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory { | |
155 public: | |
156 TestContextFactory(); | |
157 virtual ~TestContextFactory(); | |
158 | |
159 // ContextFactory implementation | |
160 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | |
161 Compositor* compositor) OVERRIDE; | |
162 | |
163 virtual scoped_refptr<Reflector> CreateReflector( | |
164 Compositor* mirrored_compositor, | |
165 Layer* mirroring_layer) OVERRIDE; | |
166 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | |
167 | |
168 virtual scoped_refptr<cc::ContextProvider> | |
169 OffscreenCompositorContextProvider() OVERRIDE; | |
170 virtual scoped_refptr<cc::ContextProvider> | |
171 SharedMainThreadContextProvider() OVERRIDE; | |
172 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | |
173 virtual bool DoesCreateTestContexts() OVERRIDE; | |
174 | |
175 private: | |
176 scoped_refptr<cc::TestContextProvider> offscreen_compositor_contexts_; | |
177 scoped_refptr<cc::TestContextProvider> shared_main_thread_contexts_; | |
178 | |
179 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); | |
180 }; | |
181 | |
182 // Texture provide an abstraction over the external texture that can be passed | 119 // Texture provide an abstraction over the external texture that can be passed |
183 // to a layer. | 120 // to a layer. |
184 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 121 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
185 public: | 122 public: |
186 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | 123 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); |
187 | 124 |
188 bool flipped() const { return flipped_; } | 125 bool flipped() const { return flipped_; } |
189 gfx::Size size() const { return size_; } | 126 gfx::Size size() const { return size_; } |
190 float device_scale_factor() const { return device_scale_factor_; } | 127 float device_scale_factor() const { return device_scale_factor_; } |
191 | 128 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 // appropriately transformed texture for each transformed view in the widget's | 218 // appropriately transformed texture for each transformed view in the widget's |
282 // view hierarchy. | 219 // view hierarchy. |
283 class COMPOSITOR_EXPORT Compositor | 220 class COMPOSITOR_EXPORT Compositor |
284 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), | 221 : NON_EXPORTED_BASE(public cc::LayerTreeHostClient), |
285 public base::SupportsWeakPtr<Compositor> { | 222 public base::SupportsWeakPtr<Compositor> { |
286 public: | 223 public: |
287 Compositor(bool use_software_renderer, | 224 Compositor(bool use_software_renderer, |
288 gfx::AcceleratedWidget widget); | 225 gfx::AcceleratedWidget widget); |
289 virtual ~Compositor(); | 226 virtual ~Compositor(); |
290 | 227 |
291 // Set up the compositor ContextFactory for a test environment. Unit tests | |
292 // that do not have a full content environment need to call this before | |
293 // initializing the Compositor. | |
294 // Some tests expect pixel output, and they should pass false for | |
295 // |allow_test_contexts|. Most unit tests should pass true. Once this has been | |
296 // called, the Initialize() and Terminate() methods should be used as normal. | |
297 static void InitializeContextFactoryForTests(bool allow_test_contexts); | |
298 | |
299 static void Initialize(); | 228 static void Initialize(); |
300 static bool WasInitializedWithThread(); | 229 static bool WasInitializedWithThread(); |
301 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | 230 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); |
302 static void Terminate(); | 231 static void Terminate(); |
303 | 232 |
304 // Schedules a redraw of the layer tree associated with this compositor. | 233 // Schedules a redraw of the layer tree associated with this compositor. |
305 void ScheduleDraw(); | 234 void ScheduleDraw(); |
306 | 235 |
307 // Sets the root of the layer tree drawn by this Compositor. The root layer | 236 // Sets the root of the layer tree drawn by this Compositor. The root layer |
308 // must have no parent. The compositor's root layer is reset if the root layer | 237 // must have no parent. The compositor's root layer is reset if the root layer |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
459 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 388 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
460 | 389 |
461 bool use_software_renderer_; | 390 bool use_software_renderer_; |
462 | 391 |
463 DISALLOW_COPY_AND_ASSIGN(Compositor); | 392 DISALLOW_COPY_AND_ASSIGN(Compositor); |
464 }; | 393 }; |
465 | 394 |
466 } // namespace ui | 395 } // namespace ui |
467 | 396 |
468 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 397 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |