| 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/hash_tables.h" | 10 #include "base/hash_tables.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/observer_list.h" | 13 #include "base/observer_list.h" |
| 14 #include "base/time.h" | 14 #include "base/time.h" |
| 15 #include "cc/layer_tree_host_client.h" | 15 #include "cc/layer_tree_host_client.h" |
| 16 #include "ui/compositor/compositor_export.h" | 16 #include "ui/compositor/compositor_export.h" |
| 17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
| 18 #include "ui/gfx/size.h" | 18 #include "ui/gfx/size.h" |
| 19 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 20 #include "ui/gl/gl_share_group.h" | 20 #include "ui/gl/gl_share_group.h" |
| 21 | 21 |
| 22 class SkBitmap; | 22 class SkBitmap; |
| 23 | 23 |
| 24 namespace cc { | 24 namespace cc { |
| 25 class ContextProvider; |
| 25 class Layer; | 26 class Layer; |
| 26 class LayerTreeHost; | 27 class LayerTreeHost; |
| 27 } | 28 } |
| 28 | 29 |
| 29 namespace gfx { | 30 namespace gfx { |
| 30 class GLContext; | 31 class GLContext; |
| 31 class GLSurface; | 32 class GLSurface; |
| 32 class GLShareGroup; | 33 class GLShareGroup; |
| 33 class Point; | 34 class Point; |
| 34 class Rect; | 35 class Rect; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 62 // Creates an output surface for the given compositor. The factory may keep | 63 // Creates an output surface for the given compositor. The factory may keep |
| 63 // per-compositor data (e.g. a shared context), that needs to be cleaned up | 64 // per-compositor data (e.g. a shared context), that needs to be cleaned up |
| 64 // by calling RemoveCompositor when the compositor gets destroyed. | 65 // by calling RemoveCompositor when the compositor gets destroyed. |
| 65 virtual cc::OutputSurface* CreateOutputSurface( | 66 virtual cc::OutputSurface* CreateOutputSurface( |
| 66 Compositor* compositor) = 0; | 67 Compositor* compositor) = 0; |
| 67 | 68 |
| 68 // Creates a context used for offscreen rendering. This context can be shared | 69 // Creates a context used for offscreen rendering. This context can be shared |
| 69 // with all compositors. | 70 // with all compositors. |
| 70 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; | 71 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; |
| 71 | 72 |
| 73 virtual scoped_refptr<cc::ContextProvider> |
| 74 OffscreenContextProviderForMainThread() = 0; |
| 75 virtual scoped_refptr<cc::ContextProvider> |
| 76 OffscreenContextProviderForCompositorThread() = 0; |
| 77 |
| 72 // Destroys per-compositor data. | 78 // Destroys per-compositor data. |
| 73 virtual void RemoveCompositor(Compositor* compositor) = 0; | 79 virtual void RemoveCompositor(Compositor* compositor) = 0; |
| 74 }; | 80 }; |
| 75 | 81 |
| 76 // The default factory that creates in-process contexts. | 82 // The default factory that creates in-process contexts. |
| 77 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { | 83 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { |
| 78 public: | 84 public: |
| 79 DefaultContextFactory(); | 85 DefaultContextFactory(); |
| 80 virtual ~DefaultContextFactory(); | 86 virtual ~DefaultContextFactory(); |
| 81 | 87 |
| 82 // ContextFactory implementation | 88 // ContextFactory implementation |
| 83 virtual cc::OutputSurface* CreateOutputSurface( | 89 virtual cc::OutputSurface* CreateOutputSurface( |
| 84 Compositor* compositor) OVERRIDE; | 90 Compositor* compositor) OVERRIDE; |
| 85 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; | 91 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; |
| 92 virtual scoped_refptr<cc::ContextProvider> |
| 93 OffscreenContextProviderForMainThread() OVERRIDE; |
| 94 virtual scoped_refptr<cc::ContextProvider> |
| 95 OffscreenContextProviderForCompositorThread() OVERRIDE; |
| 86 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; | 96 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; |
| 87 | 97 |
| 88 bool Initialize(); | 98 bool Initialize(); |
| 89 | 99 |
| 90 void set_share_group(gfx::GLShareGroup* share_group) { | 100 void set_share_group(gfx::GLShareGroup* share_group) { |
| 91 share_group_ = share_group; | 101 share_group_ = share_group; |
| 92 } | 102 } |
| 93 | 103 |
| 94 private: | 104 private: |
| 95 WebKit::WebGraphicsContext3D* CreateContextCommon( | 105 WebKit::WebGraphicsContext3D* CreateContextCommon( |
| 96 Compositor* compositor, | 106 Compositor* compositor, |
| 97 bool offscreen); | 107 bool offscreen); |
| 98 | 108 |
| 99 scoped_refptr<gfx::GLShareGroup> share_group_; | 109 scoped_refptr<gfx::GLShareGroup> share_group_; |
| 110 class DefaultContextProvider; |
| 111 scoped_refptr<DefaultContextProvider> offscreen_contexts_main_thread_; |
| 112 scoped_refptr<DefaultContextProvider> offscreen_contexts_compositor_thread_; |
| 100 | 113 |
| 101 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); | 114 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); |
| 102 }; | 115 }; |
| 103 | 116 |
| 104 // Texture provide an abstraction over the external texture that can be passed | 117 // Texture provide an abstraction over the external texture that can be passed |
| 105 // to a layer. | 118 // to a layer. |
| 106 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { | 119 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { |
| 107 public: | 120 public: |
| 108 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); | 121 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); |
| 109 | 122 |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 float pageScale) OVERRIDE; | 279 float pageScale) OVERRIDE; |
| 267 virtual scoped_ptr<cc::OutputSurface> | 280 virtual scoped_ptr<cc::OutputSurface> |
| 268 createOutputSurface() OVERRIDE; | 281 createOutputSurface() OVERRIDE; |
| 269 virtual void didRecreateOutputSurface(bool success) OVERRIDE; | 282 virtual void didRecreateOutputSurface(bool success) OVERRIDE; |
| 270 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; | 283 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; |
| 271 virtual void willCommit() OVERRIDE; | 284 virtual void willCommit() OVERRIDE; |
| 272 virtual void didCommit() OVERRIDE; | 285 virtual void didCommit() OVERRIDE; |
| 273 virtual void didCommitAndDrawFrame() OVERRIDE; | 286 virtual void didCommitAndDrawFrame() OVERRIDE; |
| 274 virtual void didCompleteSwapBuffers() OVERRIDE; | 287 virtual void didCompleteSwapBuffers() OVERRIDE; |
| 275 virtual void scheduleComposite() OVERRIDE; | 288 virtual void scheduleComposite() OVERRIDE; |
| 276 | 289 virtual scoped_refptr<cc::ContextProvider> |
| 290 OffscreenContextProviderForMainThread() OVERRIDE; |
| 291 virtual scoped_refptr<cc::ContextProvider> |
| 292 OffscreenContextProviderForCompositorThread() OVERRIDE; |
| 277 | 293 |
| 278 int last_started_frame() { return last_started_frame_; } | 294 int last_started_frame() { return last_started_frame_; } |
| 279 int last_ended_frame() { return last_ended_frame_; } | 295 int last_ended_frame() { return last_ended_frame_; } |
| 280 | 296 |
| 281 bool IsLocked() { return compositor_lock_ != NULL; } | 297 bool IsLocked() { return compositor_lock_ != NULL; } |
| 282 | 298 |
| 283 private: | 299 private: |
| 284 friend class base::RefCounted<Compositor>; | 300 friend class base::RefCounted<Compositor>; |
| 285 friend class CompositorLock; | 301 friend class CompositorLock; |
| 286 | 302 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 bool disable_schedule_composite_; | 334 bool disable_schedule_composite_; |
| 319 | 335 |
| 320 CompositorLock* compositor_lock_; | 336 CompositorLock* compositor_lock_; |
| 321 | 337 |
| 322 DISALLOW_COPY_AND_ASSIGN(Compositor); | 338 DISALLOW_COPY_AND_ASSIGN(Compositor); |
| 323 }; | 339 }; |
| 324 | 340 |
| 325 } // namespace ui | 341 } // namespace ui |
| 326 | 342 |
| 327 #endif // UI_COMPOSITOR_COMPOSITOR_H_ | 343 #endif // UI_COMPOSITOR_COMPOSITOR_H_ |
| OLD | NEW |