2013-02-13 15:26:24 -08: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_ANGLE_H_
|
|
|
|
#define SHARED_SURFACE_ANGLE_H_
|
|
|
|
|
|
|
|
#include <windows.h>
|
2014-07-11 15:10:49 -07:00
|
|
|
#include "SharedSurface.h"
|
|
|
|
|
2014-10-31 07:57:32 -07:00
|
|
|
struct IDXGIKeyedMutex;
|
|
|
|
struct ID3D11Texture2D;
|
|
|
|
|
2013-02-13 15:26:24 -08:00
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
|
|
|
class GLContext;
|
2014-07-11 15:10:49 -07:00
|
|
|
class GLLibraryEGL;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
class SharedSurface_ANGLEShareHandle
|
2014-07-11 15:10:49 -07:00
|
|
|
: public SharedSurface
|
2013-02-13 15:26:24 -08:00
|
|
|
{
|
|
|
|
public:
|
2014-08-15 17:38:08 -07:00
|
|
|
static UniquePtr<SharedSurface_ANGLEShareHandle> Create(GLContext* gl,
|
|
|
|
EGLContext context,
|
|
|
|
EGLConfig config,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
static SharedSurface_ANGLEShareHandle* Cast(SharedSurface* surf) {
|
2014-07-11 15:10:49 -07:00
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::EGLSurfaceANGLE);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
return (SharedSurface_ANGLEShareHandle*)surf;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GLLibraryEGL* const mEGL;
|
|
|
|
const EGLContext mContext;
|
|
|
|
const EGLSurface mPBuffer;
|
2015-06-04 17:15:38 -07:00
|
|
|
public:
|
2014-06-18 17:04:05 -07:00
|
|
|
const HANDLE mShareHandle;
|
2015-06-04 17:15:38 -07:00
|
|
|
protected:
|
2014-10-31 07:57:32 -07:00
|
|
|
RefPtr<IDXGIKeyedMutex> mKeyedMutex;
|
|
|
|
RefPtr<IDXGIKeyedMutex> mConsumerKeyedMutex;
|
|
|
|
RefPtr<ID3D11Texture2D> mConsumerTexture;
|
|
|
|
|
2014-09-02 15:15:41 -07:00
|
|
|
const GLuint mFence;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
SharedSurface_ANGLEShareHandle(GLContext* gl,
|
|
|
|
GLLibraryEGL* egl,
|
2013-12-10 08:11:58 -08:00
|
|
|
const gfx::IntSize& size,
|
2013-02-13 15:26:24 -08:00
|
|
|
bool hasAlpha,
|
|
|
|
EGLContext context,
|
|
|
|
EGLSurface pbuffer,
|
2014-09-02 15:15:41 -07:00
|
|
|
HANDLE shareHandle,
|
2014-10-31 07:57:32 -07:00
|
|
|
const RefPtr<IDXGIKeyedMutex>& keyedMutex,
|
2014-09-02 15:15:41 -07:00
|
|
|
GLuint fence);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
EGLDisplay Display();
|
|
|
|
|
|
|
|
public:
|
|
|
|
virtual ~SharedSurface_ANGLEShareHandle();
|
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void LockProdImpl() override;
|
|
|
|
virtual void UnlockProdImpl() override;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void Fence() override;
|
|
|
|
virtual void ProducerAcquireImpl() override;
|
|
|
|
virtual void ProducerReleaseImpl() override;
|
2015-06-04 17:15:38 -07:00
|
|
|
virtual void ProducerReadAcquireImpl() override;
|
|
|
|
virtual void ProducerReadReleaseImpl() override;
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void ConsumerAcquireImpl() override;
|
|
|
|
virtual void ConsumerReleaseImpl() override;
|
|
|
|
virtual bool WaitSync() override;
|
|
|
|
virtual bool PollSync() override;
|
2014-09-02 15:15:41 -07:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual void Fence_ContentThread_Impl() override;
|
|
|
|
virtual bool WaitSync_ContentThread_Impl() override;
|
|
|
|
virtual bool PollSync_ContentThread_Impl() override;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2014-10-31 07:57:32 -07:00
|
|
|
const RefPtr<ID3D11Texture2D>& GetConsumerTexture() const {
|
|
|
|
return mConsumerTexture;
|
|
|
|
}
|
2015-06-04 17:15:38 -07:00
|
|
|
|
|
|
|
virtual bool ToSurfaceDescriptor(layers::SurfaceDescriptor* const out_descriptor) override;
|
2013-02-13 15:26:24 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SurfaceFactory_ANGLEShareHandle
|
2014-07-11 15:10:49 -07:00
|
|
|
: public SurfaceFactory
|
2013-02-13 15:26:24 -08:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
GLContext* const mProdGL;
|
|
|
|
GLLibraryEGL* const mEGL;
|
|
|
|
EGLContext mContext;
|
|
|
|
EGLConfig mConfig;
|
|
|
|
|
|
|
|
public:
|
2014-08-15 17:38:08 -07:00
|
|
|
static UniquePtr<SurfaceFactory_ANGLEShareHandle> Create(GLContext* gl,
|
2015-06-04 17:15:38 -07:00
|
|
|
const SurfaceCaps& caps,
|
|
|
|
const RefPtr<layers::ISurfaceAllocator>& allocator,
|
|
|
|
const layers::TextureFlags& flags);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
protected:
|
2015-06-04 17:15:38 -07:00
|
|
|
SurfaceFactory_ANGLEShareHandle(GLContext* gl, const SurfaceCaps& caps,
|
|
|
|
const RefPtr<layers::ISurfaceAllocator>& allocator,
|
|
|
|
const layers::TextureFlags& flags, GLLibraryEGL* egl,
|
2014-09-24 16:42:27 -07:00
|
|
|
bool* const out_success);
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2015-03-21 09:28:04 -07:00
|
|
|
virtual UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
|
2013-02-13 15:26:24 -08:00
|
|
|
bool hasAlpha = mReadCaps.alpha;
|
2014-06-18 17:04:05 -07:00
|
|
|
return SharedSurface_ANGLEShareHandle::Create(mProdGL,
|
2013-02-13 15:26:24 -08:00
|
|
|
mContext, mConfig,
|
|
|
|
size, hasAlpha);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace gfx */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_ANGLE_H_ */
|