Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #include "GLManager.h" |
michael@0 | 7 | #include "CompositorOGL.h" // for CompositorOGL |
michael@0 | 8 | #include "GLContext.h" // for GLContext |
michael@0 | 9 | #include "mozilla/Assertions.h" // for MOZ_CRASH |
michael@0 | 10 | #include "mozilla/Attributes.h" // for MOZ_OVERRIDE |
michael@0 | 11 | #include "mozilla/RefPtr.h" // for RefPtr |
michael@0 | 12 | #include "mozilla/layers/Compositor.h" // for Compositor |
michael@0 | 13 | #include "mozilla/layers/LayerManagerComposite.h" |
michael@0 | 14 | #include "mozilla/layers/LayersTypes.h" |
michael@0 | 15 | #include "mozilla/mozalloc.h" // for operator new, etc |
michael@0 | 16 | #include "nsAutoPtr.h" // for nsRefPtr |
michael@0 | 17 | |
michael@0 | 18 | using namespace mozilla::gl; |
michael@0 | 19 | |
michael@0 | 20 | namespace mozilla { |
michael@0 | 21 | namespace layers { |
michael@0 | 22 | |
michael@0 | 23 | class GLManagerCompositor : public GLManager |
michael@0 | 24 | { |
michael@0 | 25 | public: |
michael@0 | 26 | GLManagerCompositor(CompositorOGL* aCompositor) |
michael@0 | 27 | : mImpl(aCompositor) |
michael@0 | 28 | {} |
michael@0 | 29 | |
michael@0 | 30 | virtual GLContext* gl() const MOZ_OVERRIDE |
michael@0 | 31 | { |
michael@0 | 32 | return mImpl->gl(); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) MOZ_OVERRIDE |
michael@0 | 36 | { |
michael@0 | 37 | ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(aTarget, aFormat); |
michael@0 | 38 | return mImpl->GetShaderProgramFor(config); |
michael@0 | 39 | } |
michael@0 | 40 | |
michael@0 | 41 | virtual const gfx::Matrix4x4& GetProjMatrix() const MOZ_OVERRIDE |
michael@0 | 42 | { |
michael@0 | 43 | return mImpl->GetProjMatrix(); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | virtual void BindAndDrawQuad(ShaderProgramOGL *aProg) MOZ_OVERRIDE |
michael@0 | 47 | { |
michael@0 | 48 | mImpl->BindAndDrawQuad(aProg); |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | private: |
michael@0 | 52 | RefPtr<CompositorOGL> mImpl; |
michael@0 | 53 | }; |
michael@0 | 54 | |
michael@0 | 55 | /* static */ GLManager* |
michael@0 | 56 | GLManager::CreateGLManager(LayerManagerComposite* aManager) |
michael@0 | 57 | { |
michael@0 | 58 | if (aManager && |
michael@0 | 59 | Compositor::GetBackend() == LayersBackend::LAYERS_OPENGL) { |
michael@0 | 60 | return new GLManagerCompositor(static_cast<CompositorOGL*>( |
michael@0 | 61 | aManager->GetCompositor())); |
michael@0 | 62 | } |
michael@0 | 63 | return nullptr; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | } |
michael@0 | 67 | } |