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

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: 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"
11 #include "base/observer_list.h" 11 #include "base/observer_list.h"
12 #include "cc/layer_tree_host_client.h" 12 #include "cc/layer_tree_host_client.h"
13 #include "skia/ext/refptr.h"
13 #include "ui/compositor/compositor_export.h" 14 #include "ui/compositor/compositor_export.h"
14 #include "ui/gfx/native_widget_types.h" 15 #include "ui/gfx/native_widget_types.h"
15 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
16 #include "ui/gfx/transform.h" 17 #include "ui/gfx/transform.h"
17 #include "ui/gl/gl_share_group.h" 18 #include "ui/gl/gl_share_group.h"
18 19
19 class SkBitmap; 20 class SkBitmap;
20 21
21 namespace cc { 22 namespace cc {
22 class FontAtlas; 23 class FontAtlas;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 WebKit::WebGraphicsContext3D*
72 CreateOrGetOffscreenSkiaContextForMainThread() = 0;
73 virtual WebKit::WebGraphicsContext3D*
74 CreateOrGetOffscreenSkiaContextForCompositorThread() = 0;
75 virtual GrContext*
76 CreateOrGetOffscreenSkiaGrContextForMainThread() = 0;
77 virtual GrContext*
78 CreateOrGetOffscreenSkiaGrContextForCompositorThread() = 0;
79
70 // Destroys per-compositor data. 80 // Destroys per-compositor data.
71 virtual void RemoveCompositor(Compositor* compositor) = 0; 81 virtual void RemoveCompositor(Compositor* compositor) = 0;
72 }; 82 };
73 83
74 // The default factory that creates in-process contexts. 84 // The default factory that creates in-process contexts.
75 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory { 85 class COMPOSITOR_EXPORT DefaultContextFactory : public ContextFactory {
76 public: 86 public:
77 DefaultContextFactory(); 87 DefaultContextFactory();
78 virtual ~DefaultContextFactory(); 88 virtual ~DefaultContextFactory();
79 89
80 // ContextFactory implementation 90 // ContextFactory implementation
81 virtual cc::OutputSurface* CreateOutputSurface( 91 virtual cc::OutputSurface* CreateOutputSurface(
82 Compositor* compositor) OVERRIDE; 92 Compositor* compositor) OVERRIDE;
83 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE; 93 virtual WebKit::WebGraphicsContext3D* CreateOffscreenContext() OVERRIDE;
94 virtual WebKit::WebGraphicsContext3D*
95 CreateOrGetOffscreenSkiaContextForMainThread() OVERRIDE;
96 virtual WebKit::WebGraphicsContext3D*
97 CreateOrGetOffscreenSkiaContextForCompositorThread() OVERRIDE;
98 virtual GrContext*
99 CreateOrGetOffscreenSkiaGrContextForMainThread() OVERRIDE;
100 virtual GrContext*
101 CreateOrGetOffscreenSkiaGrContextForCompositorThread() OVERRIDE;
84 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE; 102 virtual void RemoveCompositor(Compositor* compositor) OVERRIDE;
85 103
86 bool Initialize(); 104 bool Initialize();
87 105
88 void set_share_group(gfx::GLShareGroup* share_group) { 106 void set_share_group(gfx::GLShareGroup* share_group) {
89 share_group_ = share_group; 107 share_group_ = share_group;
90 } 108 }
91 109
92 private: 110 private:
93 WebKit::WebGraphicsContext3D* CreateContextCommon( 111 WebKit::WebGraphicsContext3D* CreateContextCommon(
94 Compositor* compositor, 112 Compositor* compositor,
95 bool offscreen); 113 bool offscreen);
96 114
115 void CreateOrGetOffscreenContextCommon(
116 scoped_ptr<WebKit::WebGraphicsContext3D>* context3d,
117 skia::RefPtr<GrContext>* gr_context);
118
97 scoped_refptr<gfx::GLShareGroup> share_group_; 119 scoped_refptr<gfx::GLShareGroup> share_group_;
120 scoped_ptr<WebKit::WebGraphicsContext3D> offscreen_skia_context_main_thread_;
121 scoped_ptr<WebKit::WebGraphicsContext3D>
122 offscreen_skia_context_compositor_thread_;
123 skia::RefPtr<GrContext> offscreen_skia_gr_context_main_thread_;
124 skia::RefPtr<GrContext> offscreen_skia_gr_context_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
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*
292 createOrGetOffscreenContext3dForMainThread() OVERRIDE;
293 virtual WebKit::WebGraphicsContext3D*
294 createOrGetOffscreenContext3dForCompositorThread() OVERRIDE;
295 virtual GrContext* createOrGetOffscreenGrContextForMainThread() OVERRIDE;
296 virtual GrContext* createOrGetOffscreenGrContextForCompositorThread()
297 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
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698