Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: ui/compositor/compositor.h

Issue 12212007: cc: Route offscreen context creation for compositor to the browser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android build Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 22 matching lines...) Expand all
33 } 33 }
34 34
35 namespace WebKit { 35 namespace WebKit {
36 class WebGraphicsContext3D; 36 class WebGraphicsContext3D;
37 } 37 }
38 38
39 namespace ui { 39 namespace ui {
40 40
41 class Compositor; 41 class Compositor;
42 class CompositorObserver; 42 class CompositorObserver;
43 class ContextProvider;
43 class Layer; 44 class Layer;
44 class PostedSwapQueue; 45 class PostedSwapQueue;
45 46
46 // This class abstracts the creation of the 3D context for the compositor. It is 47 // This class abstracts the creation of the 3D context for the compositor. It is
47 // a global object. 48 // a global object.
48 class COMPOSITOR_EXPORT ContextFactory { 49 class COMPOSITOR_EXPORT ContextFactory {
49 public: 50 public:
50 virtual ~ContextFactory() {} 51 virtual ~ContextFactory() {}
51 52
52 // Gets the global instance. 53 // Gets the global instance.
53 static ContextFactory* GetInstance(); 54 static ContextFactory* GetInstance();
54 55
55 // Sets the global instance. Caller keeps ownership. 56 // Sets the global instance. Caller keeps ownership.
56 // If this function isn't called (for tests), a "default" factory will be 57 // If this function isn't called (for tests), a "default" factory will be
57 // created on the first call of GetInstance. 58 // created on the first call of GetInstance.
58 static void SetInstance(ContextFactory* instance); 59 static void SetInstance(ContextFactory* instance);
59 60
60 // Creates an output surface for the given compositor. The factory may keep 61 // 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 62 // per-compositor data (e.g. a shared context), that needs to be cleaned up
62 // by calling RemoveCompositor when the compositor gets destroyed. 63 // by calling RemoveCompositor when the compositor gets destroyed.
63 virtual cc::OutputSurface* CreateOutputSurface( 64 virtual cc::OutputSurface* CreateOutputSurface(
64 Compositor* compositor) = 0; 65 Compositor* compositor) = 0;
65 66
66 // Creates a context used for offscreen rendering. This context can be shared 67 // Creates a context used for offscreen rendering. This context can be shared
67 // with all compositors. 68 // with all compositors.
68 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0; 69 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() = 0;
69 70
71 virtual scoped_refptr<ui::ContextProvider>
72 OffscreenContextProviderForMainThread() = 0;
73 virtual scoped_refptr<ui::ContextProvider>
74 OffscreenContextProviderForCompositorThread() = 0;
75
70 // Destroys per-compositor data. 76 // Destroys per-compositor data.
71 virtual void RemoveCompositor(Compositor* compositor) = 0; 77 virtual void RemoveCompositor(Compositor* compositor) = 0;
72 }; 78 };
73 79
74 // The default factory that creates in-process contexts. 80 // The default factory that creates in-process contexts.
75 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { 81 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
76 public: 82 public:
77 DefaultContextFactory(); 83 DefaultContextFactory();
78 virtual ~DefaultContextFactory(); 84 virtual ~DefaultContextFactory();
79 85
80 // ContextFactory implementation 86 // ContextFactory implementation
81 virtual cc::OutputSurface* CreateOutputSurface( 87 virtual cc::OutputSurface* CreateOutputSurface(
82 Compositor* compositor) OVERRIDE; 88 Compositor* compositor) OVERRIDE;
83 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; 89 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE;
90 virtual scoped_refptr<ui::ContextProvider>
91 OffscreenContextProviderForMainThread() OVERRIDE;
92 virtual scoped_refptr<ui::ContextProvider>
93 OffscreenContextProviderForCompositorThread() OVERRIDE;
84 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; 94 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
85 95
86 bool Initialize(); 96 bool Initialize();
87 97
88 void set_share_group(gfx::GLShareGroup* share_group) { 98 void set_share_group(gfx::GLShareGroup* share_group) {
89 share_group_ = share_group; 99 share_group_ = share_group;
90 } 100 }
91 101
92 private: 102 private:
93 WebKit::WebGraphicsContext3D* CreateContextCommon( 103 WebKit::WebGraphicsContext3D* CreateContextCommon(
94 Compositor* compositor, 104 Compositor* compositor,
95 bool offscreen); 105 bool offscreen);
96 106
97 scoped_refptr<gfx::GLShareGroup> share_group_; 107 scoped_refptr<gfx::GLShareGroup> share_group_;
108 class DefaultContextProvider;
109 scoped_refptr<DefaultContextProvider> offscreen_contexts_main_thread_;
110 scoped_refptr<DefaultContextProvider> offscreen_contexts_compositor_thread_;
98 111
99 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory); 112 DISALLOW_COPY_AND_ASSIGN(DefaultContextFactory);
100 }; 113 };
101 114
102 // Texture provide an abstraction over the external texture that can be passed 115 // Texture provide an abstraction over the external texture that can be passed
103 // to a layer. 116 // to a layer.
104 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> { 117 class COMPOSITOR_EXPORT Texture : public base::RefCounted<Texture> {
105 public: 118 public:
106 Texture(bool flipped, const gfx::Size& size, float device_scale_factor); 119 Texture(bool flipped, const gfx::Size& size, float device_scale_factor);
107 120
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 float pageScale) OVERRIDE; 277 float pageScale) OVERRIDE;
265 virtual scoped_ptr<cc::OutputSurface> 278 virtual scoped_ptr<cc::OutputSurface>
266 createOutputSurface() OVERRIDE; 279 createOutputSurface() OVERRIDE;
267 virtual void didRecreateOutputSurface(bool success) OVERRIDE; 280 virtual void didRecreateOutputSurface(bool success) OVERRIDE;
268 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE; 281 virtual scoped_ptr<cc::InputHandler> createInputHandler() OVERRIDE;
269 virtual void willCommit() OVERRIDE; 282 virtual void willCommit() OVERRIDE;
270 virtual void didCommit() OVERRIDE; 283 virtual void didCommit() OVERRIDE;
271 virtual void didCommitAndDrawFrame() OVERRIDE; 284 virtual void didCommitAndDrawFrame() OVERRIDE;
272 virtual void didCompleteSwapBuffers() OVERRIDE; 285 virtual void didCompleteSwapBuffers() OVERRIDE;
273 virtual void scheduleComposite() OVERRIDE; 286 virtual void scheduleComposite() OVERRIDE;
274 287 virtual scoped_refptr<ui::ContextProvider>
288 OffscreenContextProviderForMainThread() OVERRIDE;
289 virtual scoped_refptr<ui::ContextProvider>
290 OffscreenContextProviderForCompositorThread() OVERRIDE;
275 291
276 int last_started_frame() { return last_started_frame_; } 292 int last_started_frame() { return last_started_frame_; }
277 int last_ended_frame() { return last_ended_frame_; } 293 int last_ended_frame() { return last_ended_frame_; }
278 294
279 bool IsLocked() { return compositor_lock_ != NULL; } 295 bool IsLocked() { return compositor_lock_ != NULL; }
280 296
281 private: 297 private:
282 friend class base::RefCounted<Compositor>; 298 friend class base::RefCounted<Compositor>;
283 friend class CompositorLock; 299 friend class CompositorLock;
284 300
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 bool disable_schedule_composite_; 332 bool disable_schedule_composite_;
317 333
318 CompositorLock* compositor_lock_; 334 CompositorLock* compositor_lock_;
319 335
320 DISALLOW_COPY_AND_ASSIGN(Compositor); 336 DISALLOW_COPY_AND_ASSIGN(Compositor);
321 }; 337 };
322 338
323 } // namespace ui 339 } // namespace ui
324 340
325 #endif // UI_COMPOSITOR_COMPOSITOR_H_ 341 #endif // UI_COMPOSITOR_COMPOSITOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698