2013-05-27 18:12:13 +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_GRALLOC_H_
|
|
|
|
#define SHARED_SURFACE_GRALLOC_H_
|
|
|
|
|
2014-10-08 08:11:54 +04:00
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
2014-01-10 17:06:06 +04:00
|
|
|
#include "mozilla/layers/LayersSurfaces.h"
|
2014-07-12 02:10:49 +04:00
|
|
|
#include "SharedSurface.h"
|
2013-05-27 18:12:13 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
class ISurfaceAllocator;
|
2014-06-19 04:04:05 +04:00
|
|
|
class GrallocTextureClientOGL;
|
2013-05-27 18:12:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace gl {
|
|
|
|
class GLContext;
|
|
|
|
class GLLibraryEGL;
|
|
|
|
|
|
|
|
class SharedSurface_Gralloc
|
2014-07-12 02:10:49 +04:00
|
|
|
: public SharedSurface
|
2013-05-27 18:12:13 +04:00
|
|
|
{
|
|
|
|
public:
|
2014-08-16 04:38:08 +04:00
|
|
|
static UniquePtr<SharedSurface_Gralloc> Create(GLContext* prodGL,
|
|
|
|
const GLFormats& formats,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha,
|
2014-10-08 08:11:54 +04:00
|
|
|
layers::TextureFlags flags,
|
2014-08-16 04:38:08 +04:00
|
|
|
layers::ISurfaceAllocator* allocator);
|
2013-05-27 18:12:13 +04:00
|
|
|
|
|
|
|
static SharedSurface_Gralloc* Cast(SharedSurface* surf) {
|
2014-07-12 02:10:49 +04:00
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::Gralloc);
|
2013-05-27 18:12:13 +04:00
|
|
|
|
|
|
|
return (SharedSurface_Gralloc*)surf;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLLibraryEGL* const mEGL;
|
2014-04-22 03:59:30 +04:00
|
|
|
EGLSync mSync;
|
2013-11-27 19:19:34 +04:00
|
|
|
RefPtr<layers::ISurfaceAllocator> mAllocator;
|
2014-06-19 04:04:05 +04:00
|
|
|
RefPtr<layers::GrallocTextureClientOGL> mTextureClient;
|
2013-05-27 18:12:13 +04:00
|
|
|
const GLuint mProdTex;
|
|
|
|
|
|
|
|
SharedSurface_Gralloc(GLContext* prodGL,
|
2013-12-10 20:11:58 +04:00
|
|
|
const gfx::IntSize& size,
|
2013-05-27 18:12:13 +04:00
|
|
|
bool hasAlpha,
|
|
|
|
GLLibraryEGL* egl,
|
|
|
|
layers::ISurfaceAllocator* allocator,
|
2014-06-19 04:04:05 +04:00
|
|
|
layers::GrallocTextureClientOGL* textureClient,
|
|
|
|
GLuint prodTex);
|
2013-05-27 18:12:13 +04:00
|
|
|
|
|
|
|
static bool HasExtensions(GLLibraryEGL* egl, GLContext* gl);
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_Gralloc();
|
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void Fence() override;
|
|
|
|
virtual bool WaitSync() override;
|
|
|
|
virtual bool PollSync() override;
|
2013-05-27 18:12:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void WaitForBufferOwnership() override;
|
2014-05-15 02:40:15 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual void LockProdImpl() override {}
|
|
|
|
virtual void UnlockProdImpl() override {}
|
2013-05-27 18:12:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual GLuint ProdTexture() override {
|
2013-05-27 18:12:13 +04:00
|
|
|
return mProdTex;
|
|
|
|
}
|
|
|
|
|
2014-06-19 04:04:05 +04:00
|
|
|
layers::GrallocTextureClientOGL* GetTextureClient() {
|
2014-01-10 17:06:06 +04:00
|
|
|
return mTextureClient;
|
2013-05-27 18:12:13 +04:00
|
|
|
}
|
2015-06-05 03:15:38 +03:00
|
|
|
|
|
|
|
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
|
2013-05-27 18:12:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceFactory_Gralloc
|
2014-07-12 02:10:49 +04:00
|
|
|
: public SurfaceFactory
|
2013-05-27 18:12:13 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-06-05 03:15:38 +03:00
|
|
|
SurfaceFactory_Gralloc(GLContext* prodGL, const SurfaceCaps& caps,
|
|
|
|
const RefPtr<layers::ISurfaceAllocator>& allocator,
|
|
|
|
const layers::TextureFlags& flags);
|
2013-05-27 18:12:13 +04:00
|
|
|
|
2015-03-21 19:28:04 +03:00
|
|
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
|
2013-05-27 18:12:13 +04:00
|
|
|
bool hasAlpha = mReadCaps.alpha;
|
2014-08-16 04:38:08 +04:00
|
|
|
|
|
|
|
UniquePtr<SharedSurface> ret;
|
|
|
|
if (mAllocator) {
|
2014-10-08 08:11:54 +04:00
|
|
|
ret = SharedSurface_Gralloc::Create(mGL, mFormats, size, hasAlpha,
|
|
|
|
mFlags, mAllocator);
|
2013-10-09 16:47:32 +04:00
|
|
|
}
|
2014-08-16 04:38:08 +04:00
|
|
|
return Move(ret);
|
2013-05-27 18:12:13 +04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_GRALLOC_H_ */
|