Commit a60e45b6 authored by Ziqing Hui's avatar Ziqing Hui Committed by Alexandre Julliard

d2d1: Implement d2d_effect_SetInputCount().

parent 1ab13117
...@@ -565,12 +565,22 @@ struct d2d_device ...@@ -565,12 +565,22 @@ struct d2d_device
void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) DECLSPEC_HIDDEN; void d2d_device_init(struct d2d_device *device, ID2D1Factory1 *factory, IDXGIDevice *dxgi_device) DECLSPEC_HIDDEN;
struct d2d_effect_info
{
const CLSID *clsid;
UINT32 default_input_count;
UINT32 min_inputs;
UINT32 max_inputs;
};
struct d2d_effect struct d2d_effect
{ {
ID2D1Effect ID2D1Effect_iface; ID2D1Effect ID2D1Effect_iface;
ID2D1Image ID2D1Image_iface; ID2D1Image ID2D1Image_iface;
LONG refcount; LONG refcount;
const struct d2d_effect_info *info;
ID2D1Factory *factory; ID2D1Factory *factory;
ID2D1Image **inputs; ID2D1Image **inputs;
size_t inputs_size; size_t inputs_size;
......
...@@ -20,17 +20,11 @@ ...@@ -20,17 +20,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(d2d); WINE_DEFAULT_DEBUG_CHANNEL(d2d);
struct d2d_effect_info
{
const CLSID *clsid;
UINT32 default_input_count;
};
static const struct d2d_effect_info builtin_effects[] = static const struct d2d_effect_info builtin_effects[] =
{ {
{&CLSID_D2D12DAffineTransform, 1}, {&CLSID_D2D12DAffineTransform, 1, 1, 1},
{&CLSID_D2D13DPerspectiveTransform, 1}, {&CLSID_D2D13DPerspectiveTransform, 1, 1, 1},
{&CLSID_D2D1Composite, 2} {&CLSID_D2D1Composite, 2, 1, 0xffffffff}
}; };
static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface) static inline struct d2d_effect *impl_from_ID2D1Effect(ID2D1Effect *iface)
...@@ -207,9 +201,38 @@ static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 ind ...@@ -207,9 +201,38 @@ static void STDMETHODCALLTYPE d2d_effect_SetInput(ID2D1Effect *iface, UINT32 ind
static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count) static HRESULT STDMETHODCALLTYPE d2d_effect_SetInputCount(ID2D1Effect *iface, UINT32 count)
{ {
FIXME("iface %p, count %u stub!\n", iface, count); struct d2d_effect *effect = impl_from_ID2D1Effect(iface);
unsigned int i;
return E_NOTIMPL; TRACE("iface %p, count %u.\n", iface, count);
if (count < effect->info->min_inputs || count > effect->info->max_inputs)
return E_INVALIDARG;
if (count == effect->input_count)
return S_OK;
if (count < effect->input_count)
{
for (i = count; i < effect->input_count; ++i)
{
if (effect->inputs[i])
ID2D1Image_Release(effect->inputs[i]);
}
effect->input_count = count;
return S_OK;
}
if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
count, sizeof(*effect->inputs)))
{
ERR("Failed to resize inputs array.\n");
return E_OUTOFMEMORY;
}
memset(&effect->inputs[effect->input_count], 0, sizeof(*effect->inputs) * (count - effect->input_count));
effect->input_count = count;
return S_OK;
} }
static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input) static void STDMETHODCALLTYPE d2d_effect_GetInput(ID2D1Effect *iface, UINT32 index, ID2D1Image **input)
...@@ -326,15 +349,9 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const ...@@ -326,15 +349,9 @@ HRESULT d2d_effect_init(struct d2d_effect *effect, ID2D1Factory *factory, const
{ {
if (IsEqualGUID(effect_id, builtin_effects[i].clsid)) if (IsEqualGUID(effect_id, builtin_effects[i].clsid))
{ {
effect->input_count = builtin_effects[i].default_input_count; effect->info = &builtin_effects[i];
d2d_effect_SetInputCount(&effect->ID2D1Effect_iface, effect->info->default_input_count);
if (!d2d_array_reserve((void **)&effect->inputs, &effect->inputs_size,
effect->input_count, sizeof(*effect->inputs)))
return E_OUTOFMEMORY;
memset(effect->inputs, 0, sizeof(*effect->inputs) * effect->input_count);
ID2D1Factory_AddRef(effect->factory = factory); ID2D1Factory_AddRef(effect->factory = factory);
return S_OK; return S_OK;
} }
} }
......
...@@ -9811,10 +9811,8 @@ static void test_effect(BOOL d3d11) ...@@ -9811,10 +9811,8 @@ static void test_effect(BOOL d3d11)
winetest_push_context("Input %u", j); winetest_push_context("Input %u", j);
hr = ID2D1Effect_SetInputCount(effect, j); hr = ID2D1Effect_SetInputCount(effect, j);
if (j < test->min_inputs || j > test->max_inputs) if (j < test->min_inputs || j > test->max_inputs)
todo_wine
ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr);
else else
todo_wine
ok(hr == S_OK, "Got unexpected hr %#x.\n", hr); ok(hr == S_OK, "Got unexpected hr %#x.\n", hr);
winetest_pop_context(); winetest_pop_context();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment