2018-11-30 22:52:05 +03:00
|
|
|
/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 4; -*- */
|
2015-11-06 03:19:24 +03:00
|
|
|
/* 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_D3D11_INTEROP_H_
|
|
|
|
#define SHARED_SURFACE_D3D11_INTEROP_H_
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
#include "SharedSurface.h"
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace gl {
|
|
|
|
|
2016-07-18 00:32:34 +03:00
|
|
|
class DXInterop2Device;
|
2015-11-06 03:19:24 +03:00
|
|
|
class GLContext;
|
|
|
|
class WGLLibrary;
|
|
|
|
|
|
|
|
class SharedSurface_D3D11Interop : public SharedSurface {
|
2016-03-11 00:17:46 +03:00
|
|
|
public:
|
2016-12-30 02:17:23 +03:00
|
|
|
const GLuint mProdTex;
|
|
|
|
const GLuint mInteropFB;
|
|
|
|
const GLuint mInteropRB;
|
2016-07-18 00:32:34 +03:00
|
|
|
const RefPtr<DXInterop2Device> mInterop;
|
|
|
|
const HANDLE mLockHandle;
|
|
|
|
const RefPtr<ID3D11Texture2D> mTexD3D;
|
|
|
|
const HANDLE mDXGIHandle;
|
2016-03-11 00:17:46 +03:00
|
|
|
const bool mNeedsFinish;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2016-07-18 00:32:34 +03:00
|
|
|
protected:
|
|
|
|
bool mLockedForGL;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
public:
|
2016-07-18 00:32:34 +03:00
|
|
|
static UniquePtr<SharedSurface_D3D11Interop> Create(DXInterop2Device* interop,
|
2015-11-06 03:19:24 +03:00
|
|
|
GLContext* gl,
|
|
|
|
const gfx::IntSize& size,
|
|
|
|
bool hasAlpha);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
static SharedSurface_D3D11Interop* Cast(SharedSurface* surf) {
|
|
|
|
MOZ_ASSERT(surf->mType == SharedSurfaceType::DXGLInterop2);
|
|
|
|
return (SharedSurface_D3D11Interop*)surf;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
protected:
|
|
|
|
SharedSurface_D3D11Interop(GLContext* gl, const gfx::IntSize& size,
|
2016-12-30 02:17:23 +03:00
|
|
|
bool hasAlpha, GLuint prodTex, GLuint interopFB,
|
2016-07-18 00:32:34 +03:00
|
|
|
GLuint interopRB, DXInterop2Device* interop,
|
|
|
|
HANDLE lockHandle, ID3D11Texture2D* texD3D,
|
|
|
|
HANDLE dxgiHandle);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
public:
|
2019-04-11 15:36:51 +03:00
|
|
|
virtual ~SharedSurface_D3D11Interop();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void LockProdImpl() override {}
|
|
|
|
void UnlockProdImpl() override {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
void ProducerAcquireImpl() override;
|
|
|
|
void ProducerReleaseImpl() override;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
GLuint ProdRenderbuffer() override {
|
2016-12-30 02:17:23 +03:00
|
|
|
MOZ_ASSERT(!mProdTex);
|
|
|
|
return mInteropRB;
|
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
GLuint ProdTexture() override {
|
2016-12-30 02:17:23 +03:00
|
|
|
MOZ_ASSERT(mProdTex);
|
|
|
|
return mProdTex;
|
2015-11-06 03:19:24 +03:00
|
|
|
}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2019-04-11 15:36:51 +03:00
|
|
|
bool ToSurfaceDescriptor(
|
2015-11-06 03:19:24 +03:00
|
|
|
layers::SurfaceDescriptor* const out_descriptor) override;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SurfaceFactory_D3D11Interop : public SurfaceFactory {
|
|
|
|
public:
|
2016-07-18 00:32:34 +03:00
|
|
|
const RefPtr<DXInterop2Device> mInterop;
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
static UniquePtr<SurfaceFactory_D3D11Interop> Create(
|
|
|
|
GLContext* gl, const SurfaceCaps& caps,
|
2016-09-27 06:22:20 +03:00
|
|
|
layers::LayersIPCChannel* allocator, const layers::TextureFlags& flags);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
protected:
|
|
|
|
SurfaceFactory_D3D11Interop(GLContext* gl, const SurfaceCaps& caps,
|
2016-09-27 06:22:20 +03:00
|
|
|
layers::LayersIPCChannel* allocator,
|
2015-11-06 03:19:24 +03:00
|
|
|
const layers::TextureFlags& flags,
|
2016-07-18 00:32:34 +03:00
|
|
|
DXInterop2Device* interop);
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
public:
|
2019-04-11 15:36:51 +03:00
|
|
|
virtual ~SurfaceFactory_D3D11Interop();
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2015-11-06 03:19:24 +03:00
|
|
|
protected:
|
2019-04-11 15:36:51 +03:00
|
|
|
UniquePtr<SharedSurface> CreateShared(const gfx::IntSize& size) override {
|
2015-11-06 03:19:24 +03:00
|
|
|
bool hasAlpha = mReadCaps.alpha;
|
2016-07-18 00:32:34 +03:00
|
|
|
return SharedSurface_D3D11Interop::Create(mInterop, mGL, size, hasAlpha);
|
2015-11-06 03:19:24 +03:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} /* namespace gl */
|
|
|
|
} /* namespace mozilla */
|
|
|
|
|
|
|
|
#endif /* SHARED_SURFACE_D3D11_INTEROP_H_ */
|