Commit 1014d9a1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d2d1: Implement d2d_bitmap_brush_SetInterpolationMode().

parent 247275ae
......@@ -499,7 +499,8 @@ static ULONG STDMETHODCALLTYPE d2d_bitmap_brush_Release(ID2D1BitmapBrush *iface)
if (!refcount)
{
ID3D10SamplerState_Release(brush->u.bitmap.sampler_state);
if (brush->u.bitmap.sampler_state)
ID3D10SamplerState_Release(brush->u.bitmap.sampler_state);
HeapFree(GetProcessHeap(), 0, brush);
}
......@@ -565,7 +566,16 @@ static void STDMETHODCALLTYPE d2d_bitmap_brush_SetExtendModeY(ID2D1BitmapBrush *
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetInterpolationMode(ID2D1BitmapBrush *iface,
D2D1_BITMAP_INTERPOLATION_MODE mode)
{
FIXME("iface %p, mode %#x stub!\n", iface, mode);
struct d2d_brush *brush = impl_from_ID2D1BitmapBrush(iface);
TRACE("iface %p, mode %#x.\n", iface, mode);
brush->u.bitmap.interpolation_mode = mode;
if (brush->u.bitmap.sampler_state)
{
ID3D10SamplerState_Release(brush->u.bitmap.sampler_state);
brush->u.bitmap.sampler_state = NULL;
}
}
static void STDMETHODCALLTYPE d2d_bitmap_brush_SetBitmap(ID2D1BitmapBrush *iface, ID2D1Bitmap *bitmap)
......@@ -627,35 +637,16 @@ static const struct ID2D1BitmapBrushVtbl d2d_bitmap_brush_vtbl =
HRESULT d2d_bitmap_brush_init(struct d2d_brush *brush, struct d2d_d3d_render_target *render_target, ID2D1Bitmap *bitmap,
const D2D1_BITMAP_BRUSH_PROPERTIES *bitmap_brush_desc, const D2D1_BRUSH_PROPERTIES *brush_desc)
{
D3D10_SAMPLER_DESC sampler_desc;
HRESULT hr;
FIXME("Ignoring brush properties.\n");
d2d_brush_init(brush, &render_target->ID2D1RenderTarget_iface, D2D_BRUSH_TYPE_BITMAP,
brush_desc, (ID2D1BrushVtbl *)&d2d_bitmap_brush_vtbl);
brush->u.bitmap.bitmap = unsafe_impl_from_ID2D1Bitmap(bitmap);
sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
sampler_desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.MipLODBias = 0.0f;
sampler_desc.MaxAnisotropy = 0;
sampler_desc.ComparisonFunc = D3D10_COMPARISON_NEVER;
sampler_desc.BorderColor[0] = 0.0f;
sampler_desc.BorderColor[1] = 0.0f;
sampler_desc.BorderColor[2] = 0.0f;
sampler_desc.BorderColor[3] = 0.0f;
sampler_desc.MinLOD = 0.0f;
sampler_desc.MaxLOD = 0.0f;
if (FAILED(hr = ID3D10Device_CreateSamplerState(render_target->device,
&sampler_desc, &brush->u.bitmap.sampler_state)))
{
ERR("Failed to create sampler state, hr %#x.\n", hr);
return hr;
}
if (bitmap_brush_desc)
brush->u.bitmap.interpolation_mode = bitmap_brush_desc->interpolationMode;
else
brush->u.bitmap.interpolation_mode = D2D1_BITMAP_INTERPOLATION_MODE_LINEAR;
return S_OK;
}
......@@ -672,9 +663,36 @@ struct d2d_brush *unsafe_impl_from_ID2D1Brush(ID2D1Brush *iface)
void d2d_brush_bind_resources(struct d2d_brush *brush, ID3D10Device *device)
{
HRESULT hr;
if (brush->type == D2D_BRUSH_TYPE_BITMAP)
{
ID3D10Device_PSSetShaderResources(device, 0, 1, &brush->u.bitmap.bitmap->view);
if (!brush->u.bitmap.sampler_state)
{
D3D10_SAMPLER_DESC sampler_desc;
if (brush->u.bitmap.interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR)
sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_POINT;
else
sampler_desc.Filter = D3D10_FILTER_MIN_MAG_MIP_LINEAR;
sampler_desc.AddressU = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.AddressV = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.AddressW = D3D10_TEXTURE_ADDRESS_CLAMP;
sampler_desc.MipLODBias = 0.0f;
sampler_desc.MaxAnisotropy = 0;
sampler_desc.ComparisonFunc = D3D10_COMPARISON_NEVER;
sampler_desc.BorderColor[0] = 0.0f;
sampler_desc.BorderColor[1] = 0.0f;
sampler_desc.BorderColor[2] = 0.0f;
sampler_desc.BorderColor[3] = 0.0f;
sampler_desc.MinLOD = 0.0f;
sampler_desc.MaxLOD = 0.0f;
if (FAILED(hr = ID3D10Device_CreateSamplerState(device,
&sampler_desc, &brush->u.bitmap.sampler_state)))
ERR("Failed to create sampler state, hr %#x.\n", hr);
}
ID3D10Device_PSSetSamplers(device, 0, 1, &brush->u.bitmap.sampler_state);
}
}
......@@ -125,6 +125,7 @@ struct d2d_brush
struct
{
struct d2d_bitmap *bitmap;
D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode;
ID3D10SamplerState *sampler_state;
} bitmap;
} u;
......
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