| 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 "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class GLSurface; | 29 class GLSurface; |
| 30 class GLShareGroup; | 30 class GLShareGroup; |
| 31 class Point; | 31 class Point; |
| 32 class Rect; | 32 class Rect; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace WebKit { | 35 namespace WebKit { |
| 36 class WebGraphicsContext3D; | 36 class WebGraphicsContext3D; |
| 37 } | 37 } |
| 38 | 38 |
| 39 namespace webkit { |
| 40 namespace gpu { |
| 41 class GrContextForWebGraphicsContext3D; |
| 42 } |
| 43 } |
| 44 |
| 39 namespace ui { | 45 namespace ui { |
| 40 | 46 |
| 41 class Compositor; | 47 class Compositor; |
| 42 class CompositorObserver; | 48 class CompositorObserver; |
| 43 class Layer; | 49 class Layer; |
| 44 class PostedSwapQueue; | 50 class PostedSwapQueue; |
| 45 | 51 |
| 46 // This class abstracts the creation of the 3D context for the compositor. It is | 52 // This class abstracts the creation of the 3D context for the compositor. It is |
| 47 // a global object. | 53 // a global object. |
| 48 class COMPOSITOR_EXPORT ContextFactory { | 54 class COMPOSITOR_EXPORT ContextFactory { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 60 // Creates an output surface for the given compositor. The factory may keep | 66 // Creates an output surface for the given compositor. The factory may keep |
| 61 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 67 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
| 62 // by calling RemoveCompositor when the compositor gets destroyed. | 68 // by calling RemoveCompositor when the compositor gets destroyed. |
| 63 virtual cc::OutputSurface* CreateOutputSurface( | 69 virtual cc::OutputSurface* CreateOutputSurface( |
| 64 Compositor* compositor) = 0; | 70 Compositor* compositor) = 0; |
| 65 | 71 |
| 66 // Creates a context used for offscreen rendering. This context can be shared | 72 // Creates a context used for offscreen rendering. This context can be shared |
| 67 // with all compositors. | 73 // with all compositors. |
| 68 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; | 74 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; |
| 69 | 75 |
| 76 virtual WebKit::WebGraphicsContext3D* OffscreenContextForMainThread() = 0; |
| 77 virtual WebKit::WebGraphicsContext3D* OffscreenContextForCompositorThread() = |
| 78 0; |
| 79 virtual GrContext* OffscreenGrContextForMainThread() = 0; |
| 80 virtual GrContext* OffscreenGrContextForCompositorThread() = 0; |
| 81 virtual void DestroyOffscreenContext3dForCompositorThread() = 0; |
| 82 |
| 70 // Destroys per-compositor data. | 83 // Destroys per-compositor data. |
| 71 virtual void RemoveCompositor(Compositor* compositor) = 0; | 84 virtual void RemoveCompositor(Compositor* compositor) = 0; |
| 72 }; | 85 }; |
| 73 | 86 |
| 74 // The default factory that creates in-process contexts. | 87 // The default factory that creates in-process contexts. |
| 75 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 88 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
| 76 public: | 89 public: |
| 77 DefaultContextFactory(); | 90 DefaultContextFactory(); |
| 78 virtual ~DefaultContextFactory(); | 91 virtual ~DefaultContextFactory(); |
| 79 | 92 |
| 80 // ContextFactory implementation | 93 // ContextFactory implementation |
| 81 virtual cc::OutputSurface* CreateOutputSurface( | 94 virtual cc::OutputSurface* CreateOutputSurface( |
| 82 Compositor* compositor) OVERRIDE; | 95 Compositor* compositor) OVERRIDE; |
| 83 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; | 96 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; |
| 97 virtual WebKit::WebGraphicsContext3D* OffscreenContextForMainThread() |
| 98 OVERRIDE; |
| 99 virtual WebKit::WebGraphicsContext3D* OffscreenContextForCompositorThread() |
| 100 OVERRIDE; |
| 101 virtual GrContext* OffscreenGrContextForMainThread() OVERRIDE; |
| 102 virtual GrContext* OffscreenGrContextForCompositorThread() OVERRIDE; |
| 103 virtual void DestroyOffscreenContext3dForCompositorThread() OVERRIDE; |
| 84 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 104 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
| 85 | 105 |
| 86 bool Initialize(); | 106 bool Initialize(); |
| 87 | 107 |
| 88 void set_share_group(gfx::GLShareGroup* share_group) { | 108 void set_share_group(gfx::GLShareGroup* share_group) { |
| 89 share_group_ = share_group; | 109 share_group_ = share_group; |
| 90 } | 110 } |
| 91 | 111 |
| 92 private: | 112 private: |
| 93 WebKit::WebGraphicsContext3D* CreateContextCommon( | 113 WebKit::WebGraphicsContext3D* CreateContextCommon( |
| 94 Compositor* compositor, | 114 Compositor* compositor, |
| 95 bool offscreen); | 115 bool offscreen); |
| 96 | 116 |
| 97 scoped_refptr<gfx::GLShareGroup> share_group_; | 117 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 118 scoped_ptr<WebKit::WebGraphicsContext3D> test_offscreen_context_main_thread_; |
| 119 scoped_ptr<WebKit::WebGraphicsContext3D> |
| 120 test_offscreen_context_compositor_thread_; |
| 121 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> |
| 122 grcontext_main_thread_; |
| 123 scoped_ptr<webkit::gpu::GrContextForWebGraphicsContext3D> |
| 124 grcontext_compositor_thread_; |
| 98 | 125 |
| 99 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); | 126 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); |
| 100 }; | 127 }; |
| 101 | 128 |
| 102 // Texture provide an abstraction over the external texture that can be passed | 129 // Texture provide an abstraction over the external texture that can be passed |
| 103 // to a layer. | 130 // to a layer. |
| 104 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 131 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
| 105 public: | 132 public: |
| 106 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | 133 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); |
| 107 | 134 |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 // LayerTreeHostClient implementation. | 281 // LayerTreeHostClient implementation. |
| 255 virtual void willBeginFrame() OVERRIDE; | 282 virtual void willBeginFrame() OVERRIDE; |
| 256 virtual void didBeginFrame() OVERRIDE; | 283 virtual void didBeginFrame() OVERRIDE; |
| 257 virtual void animate(double frameBeginTime) OVERRIDE; | 284 virtual void animate(double frameBeginTime) OVERRIDE; |
| 258 virtual void layout() OVERRIDE; | 285 virtual void layout() OVERRIDE; |
| 259 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, | 286 virtual void applyScrollAndScale(gfx::Vector2d scrollDelta, |
| 260 float pageScale) OVERRIDE; | 287 float pageScale) OVERRIDE; |
| 261 virtual scoped_ptr<cc::OutputSurface> | 288 virtual scoped_ptr<cc::OutputSurface> |
| 262 createOutputSurface() OVERRIDE; | 289 createOutputSurface() OVERRIDE; |
| 263 virtual void didRecreateOutputSurface(bool success) OVERRIDE; | 290 virtual void didRecreateOutputSurface(bool success) OVERRIDE; |
| 291 virtual WebKit::WebGraphicsContext3D* OffscreenContext3dForMainThread() |
| 292 OVERRIDE; |
| 293 virtual WebKit::WebGraphicsContext3D* OffscreenContext3dForCompositorThread() |
| 294 OVERRIDE; |
| 295 virtual GrContext* OffscreenGrContextForMainThread() OVERRIDE; |
| 296 virtual GrContext* OffscreenGrContextForCompositorThread() OVERRIDE; |
| 297 virtual void DestroyOffscreenContext3dForCompositorThread() OVERRIDE; |
| 264 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; | 298 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; |
| 265 virtual void willCommit() OVERRIDE; | 299 virtual void willCommit() OVERRIDE; |
| 266 virtual void didCommit() OVERRIDE; | 300 virtual void didCommit() OVERRIDE; |
| 267 virtual void didCommitAndDrawFrame() OVERRIDE; | 301 virtual void didCommitAndDrawFrame() OVERRIDE; |
| 268 virtual void didCompleteSwapBuffers() OVERRIDE; | 302 virtual void didCompleteSwapBuffers() OVERRIDE; |
| 269 virtual void scheduleComposite() OVERRIDE; | 303 virtual void scheduleComposite() OVERRIDE; |
| 270 virtual scoped_ptr<cc::FontAtlas> createFontAtlas() OVERRIDE; | 304 virtual scoped_ptr<cc::FontAtlas> createFontAtlas() OVERRIDE; |
| 271 | 305 |
| 272 | 306 |
| 273 int last_started_frame() { return last_started_frame_; } | 307 int last_started_frame() { return last_started_frame_; } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 bool disable_schedule_composite_; | 347 bool disable_schedule_composite_; |
| 314 | 348 |
| 315 CompositorLock* compositor_lock_; | 349 CompositorLock* compositor_lock_; |
| 316 | 350 |
| 317 DISALLOW_COPY_AND_ASSIGN(Compositor); | 351 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 318 }; | 352 }; |
| 319 | 353 |
| 320 } // namespace ui | 354 } // namespace ui |
| 321 | 355 |
| 322 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 356 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |