[PATCH 2/5] d2d1: Use the same device for all WIC render targets from the same factory.
Henri Verbeet
hverbeet at codeweavers.com
Tue Aug 4 01:53:26 CDT 2015
---
dlls/d2d1/d2d1_private.h | 2 +-
dlls/d2d1/factory.c | 16 +++++++++++++++-
dlls/d2d1/wic_render_target.c | 16 ++--------------
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/dlls/d2d1/d2d1_private.h b/dlls/d2d1/d2d1_private.h
index d3c0117..08e0b3f 100644
--- a/dlls/d2d1/d2d1_private.h
+++ b/dlls/d2d1/d2d1_private.h
@@ -105,7 +105,7 @@ struct d2d_wic_render_target
};
HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory *factory,
- IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
+ ID3D10Device1 *device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc) DECLSPEC_HIDDEN;
struct d2d_gradient
{
diff --git a/dlls/d2d1/factory.c b/dlls/d2d1/factory.c
index 91534ce..0d15548 100644
--- a/dlls/d2d1/factory.c
+++ b/dlls/d2d1/factory.c
@@ -28,6 +28,8 @@ struct d2d_factory
{
ID2D1Factory ID2D1Factory_iface;
LONG refcount;
+
+ ID3D10Device1 *wic_device;
};
static inline struct d2d_factory *impl_from_ID2D1Factory(ID2D1Factory *iface)
@@ -71,7 +73,11 @@ static ULONG STDMETHODCALLTYPE d2d_factory_Release(ID2D1Factory *iface)
TRACE("%p decreasing refcount to %u.\n", iface, refcount);
if (!refcount)
+ {
+ if (factory->wic_device)
+ ID3D10Device1_Release(factory->wic_device);
HeapFree(GetProcessHeap(), 0, factory);
+ }
return refcount;
}
@@ -210,6 +216,7 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateDrawingStateBlock(ID2D1Factor
static HRESULT STDMETHODCALLTYPE d2d_factory_CreateWicBitmapRenderTarget(ID2D1Factory *iface,
IWICBitmap *target, const D2D1_RENDER_TARGET_PROPERTIES *desc, ID2D1RenderTarget **render_target)
{
+ struct d2d_factory *factory = impl_from_ID2D1Factory(iface);
struct d2d_wic_render_target *object;
HRESULT hr;
@@ -218,7 +225,14 @@ static HRESULT STDMETHODCALLTYPE d2d_factory_CreateWicBitmapRenderTarget(ID2D1Fa
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
return E_OUTOFMEMORY;
- if (FAILED(hr = d2d_wic_render_target_init(object, iface, target, desc)))
+ if (!factory->wic_device && FAILED(hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL,
+ D3D10_CREATE_DEVICE_BGRA_SUPPORT, D3D10_FEATURE_LEVEL_10_0, D3D10_1_SDK_VERSION, &factory->wic_device)))
+ {
+ WARN("Failed to create device, hr %#x.\n", hr);
+ return hr;
+ }
+
+ if (FAILED(hr = d2d_wic_render_target_init(object, iface, factory->wic_device, target, desc)))
{
WARN("Failed to initialize render target, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
diff --git a/dlls/d2d1/wic_render_target.c b/dlls/d2d1/wic_render_target.c
index a2ad73a..973303c 100644
--- a/dlls/d2d1/wic_render_target.c
+++ b/dlls/d2d1/wic_render_target.c
@@ -782,11 +782,10 @@ static const struct ID2D1RenderTargetVtbl d2d_wic_render_target_vtbl =
};
HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target, ID2D1Factory *factory,
- IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc)
+ ID3D10Device1 *device, IWICBitmap *bitmap, const D2D1_RENDER_TARGET_PROPERTIES *desc)
{
D3D10_TEXTURE2D_DESC texture_desc;
ID3D10Texture2D *texture;
- ID3D10Device1 *device;
HRESULT hr;
FIXME("Ignoring render target properties.\n");
@@ -846,17 +845,9 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target,
texture_desc.CPUAccessFlags = 0;
texture_desc.MiscFlags = 0;
- if (FAILED(hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL,
- D3D10_CREATE_DEVICE_BGRA_SUPPORT, D3D10_FEATURE_LEVEL_10_0, D3D10_1_SDK_VERSION, &device)))
- {
- WARN("Failed to create device, hr %#x.\n", hr);
- return hr;
- }
-
if (FAILED(hr = ID3D10Device1_CreateTexture2D(device, &texture_desc, NULL, &texture)))
{
WARN("Failed to create texture, hr %#x.\n", hr);
- ID3D10Device1_Release(device);
return hr;
}
@@ -865,7 +856,6 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target,
if (FAILED(hr))
{
WARN("Failed to get DXGI surface interface, hr %#x.\n", hr);
- ID3D10Device1_Release(device);
return hr;
}
@@ -873,9 +863,7 @@ HRESULT d2d_wic_render_target_init(struct d2d_wic_render_target *render_target,
texture_desc.BindFlags = 0;
texture_desc.CPUAccessFlags = D3D10_CPU_ACCESS_READ;
- hr = ID3D10Device1_CreateTexture2D(device, &texture_desc, NULL, &render_target->readback_texture);
- ID3D10Device1_Release(device);
- if (FAILED(hr))
+ if (FAILED(hr = ID3D10Device1_CreateTexture2D(device, &texture_desc, NULL, &render_target->readback_texture)))
{
WARN("Failed to create readback texture, hr %#x.\n", hr);
IDXGISurface_Release(render_target->dxgi_surface);
--
2.1.4
More information about the wine-patches
mailing list