michael@0: /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "GLManager.h" michael@0: #include "CompositorOGL.h" // for CompositorOGL michael@0: #include "GLContext.h" // for GLContext michael@0: #include "mozilla/Assertions.h" // for MOZ_CRASH michael@0: #include "mozilla/Attributes.h" // for MOZ_OVERRIDE michael@0: #include "mozilla/RefPtr.h" // for RefPtr michael@0: #include "mozilla/layers/Compositor.h" // for Compositor michael@0: #include "mozilla/layers/LayerManagerComposite.h" michael@0: #include "mozilla/layers/LayersTypes.h" michael@0: #include "mozilla/mozalloc.h" // for operator new, etc michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: michael@0: using namespace mozilla::gl; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: class GLManagerCompositor : public GLManager michael@0: { michael@0: public: michael@0: GLManagerCompositor(CompositorOGL* aCompositor) michael@0: : mImpl(aCompositor) michael@0: {} michael@0: michael@0: virtual GLContext* gl() const MOZ_OVERRIDE michael@0: { michael@0: return mImpl->gl(); michael@0: } michael@0: michael@0: virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE michael@0: { michael@0: ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(aTarget, aFormat); michael@0: return mImpl->GetShaderProgramFor(config); michael@0: } michael@0: michael@0: virtual const gfx::Matrix4x4& GetProjMatrix() const MOZ_OVERRIDE michael@0: { michael@0: return mImpl->GetProjMatrix(); michael@0: } michael@0: michael@0: virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE michael@0: { michael@0: mImpl->BindAndDrawQuad(aProg); michael@0: } michael@0: michael@0: private: michael@0: RefPtr mImpl; michael@0: }; michael@0: michael@0: /* static */ GLManager* michael@0: GLManager::CreateGLManager(LayerManagerComposite* aManager) michael@0: { michael@0: if (aManager && michael@0: Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) { michael@0: return new GLManagerCompositor(static_cast( michael@0: aManager->GetCompositor())); michael@0: } michael@0: return nullptr; michael@0: } michael@0: michael@0: } michael@0: }