gfx/layers/opengl/GLManager.cpp

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial