1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/layers/opengl/GLManager.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- 1.5 + * This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +#include "GLManager.h" 1.10 +#include "CompositorOGL.h" // for CompositorOGL 1.11 +#include "GLContext.h" // for GLContext 1.12 +#include "mozilla/Assertions.h" // for MOZ_CRASH 1.13 +#include "mozilla/Attributes.h" // for MOZ_OVERRIDE 1.14 +#include "mozilla/RefPtr.h" // for RefPtr 1.15 +#include "mozilla/layers/Compositor.h" // for Compositor 1.16 +#include "mozilla/layers/LayerManagerComposite.h" 1.17 +#include "mozilla/layers/LayersTypes.h" 1.18 +#include "mozilla/mozalloc.h" // for operator new, etc 1.19 +#include "nsAutoPtr.h" // for nsRefPtr 1.20 + 1.21 +using namespace mozilla::gl; 1.22 + 1.23 +namespace mozilla { 1.24 +namespace layers { 1.25 + 1.26 +class GLManagerCompositor : public GLManager 1.27 +{ 1.28 +public: 1.29 + GLManagerCompositor(CompositorOGL* aCompositor) 1.30 + : mImpl(aCompositor) 1.31 + {} 1.32 + 1.33 + virtual GLContext* gl() const MOZ_OVERRIDE 1.34 + { 1.35 + return mImpl->gl(); 1.36 + } 1.37 + 1.38 + virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE 1.39 + { 1.40 + ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(aTarget, aFormat); 1.41 + return mImpl->GetShaderProgramFor(config); 1.42 + } 1.43 + 1.44 + virtual const gfx::Matrix4x4& GetProjMatrix() const MOZ_OVERRIDE 1.45 + { 1.46 + return mImpl->GetProjMatrix(); 1.47 + } 1.48 + 1.49 + virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE 1.50 + { 1.51 + mImpl->BindAndDrawQuad(aProg); 1.52 + } 1.53 + 1.54 +private: 1.55 + RefPtr<CompositorOGL> mImpl; 1.56 +}; 1.57 + 1.58 +/* static */ GLManager* 1.59 +GLManager::CreateGLManager(LayerManagerComposite* aManager) 1.60 +{ 1.61 + if (aManager && 1.62 + Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) { 1.63 + return new GLManagerCompositor(static_cast<CompositorOGL*>( 1.64 + aManager->GetCompositor())); 1.65 + } 1.66 + return nullptr; 1.67 +} 1.68 + 1.69 +} 1.70 +}