2013-08-12 03:17:23 +04:00
|
|
|
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-04-17 01:35:57 +04:00
|
|
|
#include "GLManager.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "CompositorOGL.h" // for CompositorOGL
|
|
|
|
#include "GLContext.h" // for GLContext
|
2015-03-21 19:28:04 +03:00
|
|
|
#include "mozilla/Attributes.h" // for override
|
2015-10-18 08:24:48 +03:00
|
|
|
#include "mozilla/RefPtr.h" // for RefPtr
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
2013-04-26 02:25:33 +04:00
|
|
|
#include "mozilla/layers/LayerManagerComposite.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
|
|
|
#include "mozilla/mozalloc.h" // for operator new, etc
|
2013-04-17 01:35:57 +04:00
|
|
|
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
class GLManagerCompositor : public GLManager
|
|
|
|
{
|
|
|
|
public:
|
2014-08-20 08:55:14 +04:00
|
|
|
explicit GLManagerCompositor(CompositorOGL* aCompositor)
|
2013-04-17 01:35:57 +04:00
|
|
|
: mImpl(aCompositor)
|
|
|
|
{}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GLContext* gl() const override
|
2013-04-17 01:35:57 +04:00
|
|
|
{
|
|
|
|
return mImpl->gl();
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void ActivateProgram(ShaderProgramOGL *aProg) override
|
2014-11-10 22:34:06 +03:00
|
|
|
{
|
|
|
|
mImpl->ActivateProgram(aProg);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual ShaderProgramOGL* GetProgram(GLenum aTarget, gfx::SurfaceFormat aFormat) override
|
2013-04-17 01:35:57 +04:00
|
|
|
{
|
2013-11-08 10:22:05 +04:00
|
|
|
ShaderConfigOGL config = ShaderConfigFromTargetAndFormat(aTarget, aFormat);
|
|
|
|
return mImpl->GetShaderProgramFor(config);
|
|
|
|
}
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual const gfx::Matrix4x4& GetProjMatrix() const override
|
2013-11-08 10:22:05 +04:00
|
|
|
{
|
|
|
|
return mImpl->GetProjMatrix();
|
2013-04-17 01:35:57 +04:00
|
|
|
}
|
|
|
|
|
2014-05-22 14:29:54 +04:00
|
|
|
virtual void BindAndDrawQuad(ShaderProgramOGL *aProg,
|
|
|
|
const gfx::Rect& aLayerRect,
|
2015-03-21 19:28:04 +03:00
|
|
|
const gfx::Rect& aTextureRect) override
|
2013-04-17 01:35:57 +04:00
|
|
|
{
|
2014-05-22 14:29:54 +04:00
|
|
|
mImpl->BindAndDrawQuad(aProg, aLayerRect, aTextureRect);
|
2013-04-17 01:35:57 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<CompositorOGL> mImpl;
|
2013-04-17 01:35:57 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
/* static */ GLManager*
|
2013-12-09 05:40:59 +04:00
|
|
|
GLManager::CreateGLManager(LayerManagerComposite* aManager)
|
2013-04-17 01:35:57 +04:00
|
|
|
{
|
2015-10-06 09:39:00 +03:00
|
|
|
if (aManager && aManager->GetCompositor()->GetBackendType() == LayersBackend::LAYERS_OPENGL) {
|
2016-04-14 13:38:42 +03:00
|
|
|
return new GLManagerCompositor(aManager->GetCompositor()->AsCompositorOGL());
|
2013-04-17 01:35:57 +04:00
|
|
|
}
|
2013-12-09 05:40:59 +04:00
|
|
|
return nullptr;
|
2013-04-17 01:35:57 +04:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|