mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1046550 - Part 2: Allow creating D2D 1.1 DrawTargets for D3D11 textures. r=bas
This commit is contained in:
parent
019c0468a9
commit
8c5c06f212
@ -37,6 +37,7 @@ typedef _cairo_scaled_font cairo_scaled_font_t;
|
|||||||
|
|
||||||
struct ID3D10Device1;
|
struct ID3D10Device1;
|
||||||
struct ID3D10Texture2D;
|
struct ID3D10Texture2D;
|
||||||
|
struct ID3D11Texture2D;
|
||||||
struct ID3D11Device;
|
struct ID3D11Device;
|
||||||
struct ID2D1Device;
|
struct ID2D1Device;
|
||||||
struct IDWriteRenderingParams;
|
struct IDWriteRenderingParams;
|
||||||
@ -1190,6 +1191,8 @@ public:
|
|||||||
static void SetDirect3D10Device(ID3D10Device1 *aDevice);
|
static void SetDirect3D10Device(ID3D10Device1 *aDevice);
|
||||||
static ID3D10Device1 *GetDirect3D10Device();
|
static ID3D10Device1 *GetDirect3D10Device();
|
||||||
#ifdef USE_D2D1_1
|
#ifdef USE_D2D1_1
|
||||||
|
static TemporaryRef<DrawTarget> CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat);
|
||||||
|
|
||||||
static void SetDirect3D11Device(ID3D11Device *aDevice);
|
static void SetDirect3D11Device(ID3D11Device *aDevice);
|
||||||
static ID3D11Device *GetDirect3D11Device();
|
static ID3D11Device *GetDirect3D11Device();
|
||||||
static ID2D1Device *GetD2D1Device();
|
static ID2D1Device *GetD2D1Device();
|
||||||
|
@ -593,6 +593,52 @@ DrawTargetD2D1::CreateFilter(FilterType aType)
|
|||||||
return FilterNodeD2D1::Create(this, mDC, aType);
|
return FilterNodeD2D1::Create(this, mDC, aType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DrawTargetD2D1::Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat)
|
||||||
|
{
|
||||||
|
HRESULT hr;
|
||||||
|
|
||||||
|
hr = Factory::GetD2D1Device()->CreateDeviceContext(D2D1_DEVICE_CONTEXT_OPTIONS_ENABLE_MULTITHREADED_OPTIMIZATIONS, byRef(mDC));
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
gfxWarning() << *this << ": Error " << hr << " failed to initialize new DeviceContext.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
RefPtr<IDXGISurface> dxgiSurface;
|
||||||
|
aTexture->QueryInterface(__uuidof(IDXGISurface),
|
||||||
|
(void**)((IDXGISurface**)byRef(dxgiSurface)));
|
||||||
|
if (!dxgiSurface) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
D2D1_BITMAP_PROPERTIES1 props;
|
||||||
|
props.dpiX = 96;
|
||||||
|
props.dpiY = 96;
|
||||||
|
props.pixelFormat = D2DPixelFormat(aFormat);
|
||||||
|
props.colorContext = nullptr;
|
||||||
|
props.bitmapOptions = D2D1_BITMAP_OPTIONS_TARGET;
|
||||||
|
mDC->CreateBitmapFromDxgiSurface(dxgiSurface, props, (ID2D1Bitmap1**)byRef(mBitmap));
|
||||||
|
|
||||||
|
if (FAILED(hr)) {
|
||||||
|
gfxWarning() << *this << ": Error " << hr << " failed to create new CommandList.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
mFormat = aFormat;
|
||||||
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
|
aTexture->GetDesc(&desc);
|
||||||
|
mSize.width = desc.Width;
|
||||||
|
mSize.height = desc.Height;
|
||||||
|
|
||||||
|
mDC->CreateBitmap(D2DIntSize(mSize), nullptr, 0, props, (ID2D1Bitmap1**)byRef(mTempBitmap));
|
||||||
|
|
||||||
|
mDC->SetTarget(mBitmap);
|
||||||
|
|
||||||
|
mDC->BeginDraw();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat)
|
DrawTargetD2D1::Init(const IntSize &aSize, SurfaceFormat aFormat)
|
||||||
{
|
{
|
||||||
|
@ -125,6 +125,7 @@ public:
|
|||||||
virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; }
|
virtual void *GetNativeSurface(NativeSurfaceType aType) { return nullptr; }
|
||||||
|
|
||||||
bool Init(const IntSize &aSize, SurfaceFormat aFormat);
|
bool Init(const IntSize &aSize, SurfaceFormat aFormat);
|
||||||
|
bool Init(ID3D11Texture2D* aTexture, SurfaceFormat aFormat);
|
||||||
uint32_t GetByteSize() const;
|
uint32_t GetByteSize() const;
|
||||||
|
|
||||||
TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
|
TemporaryRef<ID2D1Image> GetImageForSurface(SourceSurface *aSurface, Matrix &aSourceTransform,
|
||||||
|
@ -548,6 +548,7 @@ Factory::SetDirect3D10Device(ID3D10Device1 *aDevice)
|
|||||||
|
|
||||||
ID3D10Device1*
|
ID3D10Device1*
|
||||||
Factory::GetDirect3D10Device()
|
Factory::GetDirect3D10Device()
|
||||||
|
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
UINT mode = mD3D10Device->GetExceptionMode();
|
UINT mode = mD3D10Device->GetExceptionMode();
|
||||||
@ -557,6 +558,28 @@ Factory::GetDirect3D10Device()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_D2D1_1
|
#ifdef USE_D2D1_1
|
||||||
|
TemporaryRef<DrawTarget>
|
||||||
|
Factory::CreateDrawTargetForD3D11Texture(ID3D11Texture2D *aTexture, SurfaceFormat aFormat)
|
||||||
|
{
|
||||||
|
RefPtr<DrawTargetD2D1> newTarget;
|
||||||
|
|
||||||
|
newTarget = new DrawTargetD2D1();
|
||||||
|
if (newTarget->Init(aTexture, aFormat)) {
|
||||||
|
RefPtr<DrawTarget> retVal = newTarget;
|
||||||
|
|
||||||
|
if (mRecorder) {
|
||||||
|
retVal = new DrawTargetRecording(mRecorder, retVal, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfxWarning() << "Failed to create draw target for D3D10 texture.";
|
||||||
|
|
||||||
|
// Failed
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Factory::SetDirect3D11Device(ID3D11Device *aDevice)
|
Factory::SetDirect3D11Device(ID3D11Device *aDevice)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user