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 13 matching lines...) Expand all Loading... |
24 | 24 |
25 class SkBitmap; | 25 class SkBitmap; |
26 | 26 |
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 FakeContextProvider; |
34 class Layer; | 35 class Layer; |
35 class LayerTreeDebugState; | 36 class LayerTreeDebugState; |
36 class LayerTreeHost; | 37 class LayerTreeHost; |
37 } | 38 } |
38 | 39 |
39 namespace gfx { | 40 namespace gfx { |
40 class GLContext; | 41 class GLContext; |
41 class GLSurface; | 42 class GLSurface; |
42 class GLShareGroup; | 43 class GLShareGroup; |
43 class Point; | 44 class Point; |
44 class Rect; | 45 class Rect; |
45 class Size; | 46 class Size; |
46 } | 47 } |
47 | 48 |
48 namespace WebKit { | 49 namespace WebKit { |
49 class WebGraphicsContext3D; | 50 class WebGraphicsContext3D; |
50 } | 51 } |
51 | 52 |
| 53 namespace webkit { |
| 54 namespace gpu { |
| 55 class ContextProviderInProcess; |
| 56 } |
| 57 } |
| 58 |
52 namespace ui { | 59 namespace ui { |
53 | 60 |
54 class Compositor; | 61 class Compositor; |
55 class CompositorObserver; | 62 class CompositorObserver; |
56 class ContextProviderFromContextFactory; | 63 class ContextProviderFromContextFactory; |
57 class Layer; | 64 class Layer; |
58 class PostedSwapQueue; | 65 class PostedSwapQueue; |
59 class Reflector; | 66 class Reflector; |
60 class Texture; | 67 class Texture; |
61 struct LatencyInfo; | 68 struct LatencyInfo; |
(...skipping 11 matching lines...) Expand all Loading... |
73 // If this function isn't called (for tests), a "default" factory will be | 80 // If this function isn't called (for tests), a "default" factory will be |
74 // created on the first call of GetInstance. | 81 // created on the first call of GetInstance. |
75 static void SetInstance(ContextFactory* instance); | 82 static void SetInstance(ContextFactory* instance); |
76 | 83 |
77 // Creates an output surface for the given compositor. The factory may keep | 84 // Creates an output surface for the given compositor. The factory may keep |
78 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 85 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
79 // by calling RemoveCompositor when the compositor gets destroyed. | 86 // by calling RemoveCompositor when the compositor gets destroyed. |
80 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 87 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
81 Compositor* compositor) = 0; | 88 Compositor* compositor) = 0; |
82 | 89 |
83 // Creates a context used for offscreen rendering. This context can be shared | |
84 // with all compositors. | |
85 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() = 0; | |
86 | |
87 // Creates a reflector that copies the content of the |mirrored_compositor| | 90 // Creates a reflector that copies the content of the |mirrored_compositor| |
88 // onto |mirroing_layer|. | 91 // onto |mirroing_layer|. |
89 virtual scoped_refptr<Reflector> CreateReflector( | 92 virtual scoped_refptr<Reflector> CreateReflector( |
90 Compositor* mirrored_compositor, | 93 Compositor* mirrored_compositor, |
91 Layer* mirroring_layer) = 0; | 94 Layer* mirroring_layer) = 0; |
92 // Removes the reflector, which stops the mirroring. | 95 // Removes the reflector, which stops the mirroring. |
93 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; | 96 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) = 0; |
94 | 97 |
95 virtual scoped_refptr<cc::ContextProvider> | 98 virtual scoped_refptr<cc::ContextProvider> |
96 OffscreenContextProviderForMainThread() = 0; | 99 OffscreenContextProviderForMainThread() = 0; |
(...skipping 10 matching lines...) Expand all Loading... |
107 | 110 |
108 // The default factory that creates in-process contexts. | 111 // The default factory that creates in-process contexts. |
109 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 112 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
110 public: | 113 public: |
111 DefaultContextFactory(); | 114 DefaultContextFactory(); |
112 virtual ~DefaultContextFactory(); | 115 virtual ~DefaultContextFactory(); |
113 | 116 |
114 // ContextFactory implementation | 117 // ContextFactory implementation |
115 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 118 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
116 Compositor* compositor) OVERRIDE; | 119 Compositor* compositor) OVERRIDE; |
117 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() | |
118 OVERRIDE; | |
119 | 120 |
120 virtual scoped_refptr<Reflector> CreateReflector( | 121 virtual scoped_refptr<Reflector> CreateReflector( |
121 Compositor* compositor, | 122 Compositor* compositor, |
122 Layer* layer) OVERRIDE; | 123 Layer* layer) OVERRIDE; |
123 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; | 124 virtual void RemoveReflector(scoped_refptr<Reflector> reflector) OVERRIDE; |
124 | 125 |
125 virtual scoped_refptr<cc::ContextProvider> | 126 virtual scoped_refptr<cc::ContextProvider> |
126 OffscreenContextProviderForMainThread() OVERRIDE; | 127 OffscreenContextProviderForMainThread() OVERRIDE; |
127 virtual scoped_refptr<cc::ContextProvider> | 128 virtual scoped_refptr<cc::ContextProvider> |
128 OffscreenContextProviderForCompositorThread() OVERRIDE; | 129 OffscreenContextProviderForCompositorThread() OVERRIDE; |
129 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 130 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
130 virtual bool DoesCreateTestContexts() OVERRIDE; | 131 virtual bool DoesCreateTestContexts() OVERRIDE; |
131 | 132 |
132 bool Initialize(); | 133 bool Initialize(); |
133 | 134 |
134 private: | 135 private: |
135 scoped_ptr<WebKit::WebGraphicsContext3D> CreateContextCommon( | 136 scoped_refptr<webkit::gpu::ContextProviderInProcess> |
136 Compositor* compositor, | |
137 bool offscreen); | |
138 | |
139 scoped_refptr<ContextProviderFromContextFactory> | |
140 offscreen_contexts_main_thread_; | 137 offscreen_contexts_main_thread_; |
141 scoped_refptr<ContextProviderFromContextFactory> | 138 scoped_refptr<webkit::gpu::ContextProviderInProcess> |
142 offscreen_contexts_compositor_thread_; | 139 offscreen_contexts_compositor_thread_; |
143 | 140 |
144 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); | 141 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); |
145 }; | 142 }; |
146 | 143 |
147 // The factory that creates test contexts. | 144 // The factory that creates test contexts. |
148 class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory { | 145 class COMPOSITOR_EXPORT TestContextFactory : public ContextFactory { |
149 public: | 146 public: |
150 TestContextFactory(); | 147 TestContextFactory(); |
151 virtual ~TestContextFactory(); | 148 virtual ~TestContextFactory(); |
152 | 149 |
153 // ContextFactory implementation | 150 // ContextFactory implementation |
154 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( | 151 virtual scoped_ptr<cc::OutputSurface> CreateOutputSurface( |
155 Compositor* compositor) OVERRIDE; | 152 Compositor* compositor) OVERRIDE; |
156 virtual scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext() | |
157 OVERRIDE; | |
158 | 153 |
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; | 164 virtual bool DoesCreateTestContexts() OVERRIDE; |
170 | 165 |
171 private: | 166 private: |
172 scoped_refptr<ContextProviderFromContextFactory> | 167 static scoped_ptr<WebKit::WebGraphicsContext3D> CreateOffscreenContext(); |
173 offscreen_contexts_main_thread_; | 168 |
174 scoped_refptr<ContextProviderFromContextFactory> | 169 scoped_refptr<cc::FakeContextProvider> offscreen_contexts_main_thread_; |
175 offscreen_contexts_compositor_thread_; | 170 scoped_refptr<cc::ContextProvider> offscreen_contexts_compositor_thread_; |
176 | 171 |
177 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); | 172 DISALLOW_COPY_AND_ASSIGN(TestContextFactory); |
178 }; | 173 }; |
179 | 174 |
180 // Texture provide an abstraction over the external texture that can be passed | 175 // Texture provide an abstraction over the external texture that can be passed |
181 // to a layer. | 176 // to a layer. |
182 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 177 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
183 public: | 178 public: |
184 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | 179 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); |
185 | 180 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 bool disable_schedule_composite_; | 450 bool disable_schedule_composite_; |
456 | 451 |
457 CompositorLock* compositor_lock_; | 452 CompositorLock* compositor_lock_; |
458 | 453 |
459 DISALLOW_COPY_AND_ASSIGN(Compositor); | 454 DISALLOW_COPY_AND_ASSIGN(Compositor); |
460 }; | 455 }; |
461 | 456 |
462 } // namespace ui | 457 } // namespace ui |
463 | 458 |
464 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 459 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
OLD | NEW |