2013-02-14 03:26:24 +04:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40; -*- */
|
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
#ifndef SHARED_SURFACE_GL_H_
|
|
|
|
#define SHARED_SURFACE_GL_H_
|
|
|
|
|
2014-03-06 01:49:37 +04:00
|
|
|
#include "ScopedGLHelpers.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
#include "SharedSurface.h"
|
|
|
|
#include "SurfaceTypes.h"
|
|
|
|
#include "GLContextTypes.h"
|
|
|
|
#include "nsAutoPtr.h"
|
2013-09-25 00:45:14 +04:00
|
|
|
#include "gfxTypes.h"
|
2013-06-05 04:05:28 +04:00
|
|
|
#include "mozilla/Mutex.h"
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
#include <queue>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
}
|
2013-12-10 20:11:58 +04:00
|
|
|
namespace gfx {
|
|
|
|
class DataSourceSurface;
|
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
// For readback and bootstrapping:
|
|
|
|
class SharedSurface_Basic
|
2014-07-12 02:10:49 +04:00
|
|
|
: public SharedSurface
|
2013-02-14 03:26:24 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-08-16 04:38:08 +04:00
|
|
|
static UniquePtr<SharedSurface_Basic> Create(GLContext* gl,
|
|
|
|
const GLFormats& formats,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2015-06-05 00:21:32 +03:00
|
|
|
static UniquePtr<SharedSurface_Basic> Wrap(GLContext* gl,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha,
|
|
|
|
GLuint tex);
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
static SharedSurface_Basic* Cast(SharedSurface* surf) {
|
2014-07-12 02:10:49 +04:00
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::Basic);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
return (SharedSurface_Basic*)surf;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
const GLuint mTex;
|
2015-06-05 00:21:32 +03:00
|
|
|
const bool mOwnsTex;
|
2014-03-06 01:49:37 +04:00
|
|
|
GLuint mFB;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
SharedSurface_Basic(GLContext* gl,
|
2013-12-10 20:11:58 +04:00
|
|
|
const gfx::IntSize& size,
|
2013-02-14 03:26:24 +04:00
|
|
|
bool hasAlpha,
|
2015-06-05 00:21:32 +03:00
|
|
|
GLuint tex,
|
|
|
|
bool ownsTex);
|
2013-02-14 03:26:24 +04:00
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_Basic();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void LockProdImpl() override {}
|
|
|
|
virtual void UnlockProdImpl() override {}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Fence() override {}
|
|
|
|
virtual bool WaitSync() override { return true; }
|
|
|
|
virtual bool PollSync() override { return true; }
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GLuint ProdTexture() override {
|
2013-02-14 03:26:24 +04:00
|
|
|
return mTex;
|
|
|
|
}
|
2015-05-29 03:08:53 +03:00
|
|
|
|
2015-06-05 00:21:32 +03:00
|
|
|
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override {
|
|
|
|
MOZ_CRASH("don't do this");
|
|
|
|
return false;
|
2015-05-29 03:08:53 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-06-05 00:21:32 +03:00
|
|
|
class SurfaceFactory_Basic
|
2015-05-29 03:08:53 +03:00
|
|
|
: public SurfaceFactory
|
|
|
|
{
|
|
|
|
public:
|
2015-06-05 00:21:32 +03:00
|
|
|
SurfaceFactory_Basic(GLContext* gl, const SurfaceCaps& caps,
|
|
|
|
const layers::TextureFlags& flags);
|
2015-05-29 03:08:53 +03:00
|
|
|
|
|
|
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
|
|
|
|
bool hasAlpha = mReadCaps.alpha;
|
2015-06-05 00:21:32 +03:00
|
|
|
return SharedSurface_Basic::Create(mGL, mFormats, size, hasAlpha);
|
2015-05-29 03:08:53 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-02-14 03:26:24 +04:00
|
|
|
} /* namespace gfx */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_GL_H_ */
|