diff options
Diffstat (limited to 'ui/gfx/compositor/compositor_gl.cc')
-rw-r--r-- | ui/gfx/compositor/compositor_gl.cc | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/ui/gfx/compositor/compositor_gl.cc b/ui/gfx/compositor/compositor_gl.cc index f152ffc..4beb65c 100644 --- a/ui/gfx/compositor/compositor_gl.cc +++ b/ui/gfx/compositor/compositor_gl.cc @@ -15,6 +15,57 @@ namespace ui { +#if defined COMPOSITOR_2 +namespace { + +class CompositorGL : public Compositor { + public: + explicit CompositorGL(gfx::AcceleratedWidget widget); + + private: + // Overridden from Compositor. + virtual Texture* CreateTexture() OVERRIDE; + virtual void NotifyStart() OVERRIDE; + virtual void NotifyEnd() OVERRIDE; + + // The GL context used for compositing. + scoped_ptr<gfx::GLContext> gl_context_; + + // Keep track of whether compositing has started or not. + bool started_; + + DISALLOW_COPY_AND_ASSIGN(CompositorGL); +}; + +CompositorGL::CompositorGL(gfx::AcceleratedWidget widget) + : gl_context_(gfx::GLContext::CreateViewGLContext(widget, false)), + started_(false) { +} + +Texture* CompositorGL::CreateTexture() { + return NULL; +} + +void CompositorGL::NotifyStart() { + started_ = true; + gl_context_->MakeCurrent(); +} + +void CompositorGL::NotifyEnd() { + DCHECK(started_); + gl_context_->SwapBuffers(); + started_ = false; +} + +} // namespace + +// static +Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { + if (gfx::GetGLImplementation() != gfx::kGLImplementationNone) + return new CompositorGL(widget); + return NULL; +} +#else class CompositorGL : public Compositor { public: explicit CompositorGL(gfx::AcceleratedWidget widget); @@ -77,5 +128,5 @@ Compositor* Compositor::Create(gfx::AcceleratedWidget widget) { return new CompositorGL(widget); return NULL; } - +#endif } // namespace ui |