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