| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 // displayable form of pixels comprising a single widget's contents. It draws an | 217 // displayable form of pixels comprising a single widget's contents. It draws an |
| 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 explicit Compositor(gfx::AcceleratedWidget widget); | 224 explicit Compositor(gfx::AcceleratedWidget widget); |
| 288 virtual ~Compositor(); | 225 virtual ~Compositor(); |
| 289 | 226 |
| 290 // Set up the compositor ContextFactory for a test environment. Unit tests | |
| 291 // that do not have a full content environment need to call this before | |
| 292 // initializing the Compositor. | |
| 293 // Some tests expect pixel output, and they should pass false for | |
| 294 // |allow_test_contexts|. Most unit tests should pass true. Once this has been | |
| 295 // called, the Initialize() and Terminate() methods should be used as normal. | |
| 296 static void InitializeContextFactoryForTests(bool allow_test_contexts); | |
| 297 | |
| 298 static void Initialize(); | 227 static void Initialize(); |
| 299 static bool WasInitializedWithThread(); | 228 static bool WasInitializedWithThread(); |
| 300 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); | 229 static scoped_refptr<base::MessageLoopProxy> GetCompositorMessageLoop(); |
| 301 static void Terminate(); | 230 static void Terminate(); |
| 302 | 231 |
| 303 // Schedules a redraw of the layer tree associated with this compositor. | 232 // Schedules a redraw of the layer tree associated with this compositor. |
| 304 void ScheduleDraw(); | 233 void ScheduleDraw(); |
| 305 | 234 |
| 306 // Sets the root of the layer tree drawn by this Compositor. The root layer | 235 // Sets the root of the layer tree drawn by this Compositor. The root layer |
| 307 // must have no parent. The compositor's root layer is reset if the root layer | 236 // must have no parent. The compositor's root layer is reset if the root layer |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 bool draw_on_compositing_end_; | 381 bool draw_on_compositing_end_; |
| 453 | 382 |
| 454 base::WeakPtrFactory<Compositor> schedule_draw_factory_; | 383 base::WeakPtrFactory<Compositor> schedule_draw_factory_; |
| 455 | 384 |
| 456 DISALLOW_COPY_AND_ASSIGN(Compositor); | 385 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 457 }; | 386 }; |
| 458 | 387 |
| 459 } // namespace ui | 388 } // namespace ui |
| 460 | 389 |
| 461 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 390 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |