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