static ULONG STDMETHODCALLTYPE d3d10_blend_state_Release(ID3D10BlendState *iface) { struct d3d10_blend_state *state = impl_from_ID3D10BlendState(iface); ULONG refcount = InterlockedDecrement(&state->refcount); TRACE("%p decreasing refcount to %u.\n", state, refcount); if (!refcount) { struct d3d10_device *device = impl_from_ID3D10Device(state->device); wine_rb_remove(&device->blend_states, &state->desc); ID3D10Device1_Release(state->device); HeapFree(GetProcessHeap(), 0, state); } return refcount; }
static ULONG STDMETHODCALLTYPE d2d_dc_render_target_Release(ID2D1DCRenderTarget *iface) { struct d2d_dc_render_target *render_target = impl_from_ID2D1DCRenderTarget(iface); ULONG refcount = InterlockedDecrement(&render_target->refcount); TRACE("%p decreasing refcount to %u.\n", iface, refcount); if (!refcount) { IUnknown_Release(render_target->dxgi_inner); if (render_target->dxgi_surface) IDXGISurface1_Release(render_target->dxgi_surface); ID3D10Device1_Release(render_target->d3d_device); heap_free(render_target); } return refcount; }
static ULONG STDMETHODCALLTYPE d3d10_pixel_shader_Release(ID3D10PixelShader *iface) { struct d3d10_pixel_shader *This = impl_from_ID3D10PixelShader(iface); ULONG refcount = InterlockedDecrement(&This->refcount); TRACE("%p decreasing refcount to %u\n", This, refcount); if (!refcount) { ID3D10Device1 *device = This->device; wined3d_shader_decref(This->wined3d_shader); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D10Device1_Release(device); } return refcount; }
static ULONG STDMETHODCALLTYPE d3d10_query_Release(ID3D10Query *iface) { struct d3d10_query *query = impl_from_ID3D10Query(iface); ULONG refcount = InterlockedDecrement(&query->refcount); TRACE("%p decreasing refcount to %u.\n", query, refcount); if (!refcount) { ID3D10Device1_Release(query->device); wined3d_mutex_lock(); wined3d_query_decref(query->wined3d_query); wined3d_private_store_cleanup(&query->private_store); wined3d_mutex_unlock(); HeapFree(GetProcessHeap(), 0, query); } return refcount; }
static ULONG STDMETHODCALLTYPE d3d10_texture3d_Release(ID3D10Texture3D *iface) { struct d3d10_texture3d *texture = impl_from_ID3D10Texture3D(iface); ULONG refcount = InterlockedDecrement(&texture->refcount); TRACE("%p decreasing refcount to %u.\n", texture, refcount); if (!refcount) { ID3D10Device1 *device = texture->device; wined3d_texture_decref(texture->wined3d_texture); /* Release the device last, it may cause the wined3d device to be * destroyed. */ ID3D10Device1_Release(device); } return refcount; }
static void test_create_device(void) { D3D10_FEATURE_LEVEL1 feature_level, supported_feature_level; DXGI_SWAP_CHAIN_DESC swapchain_desc, obtained_desc; IDXGISwapChain *swapchain; ID3D10Device1 *device; unsigned int i; ULONG refcount; HWND window; HRESULT hr; for (i = 0; i < sizeof(d3d10_feature_levels) / sizeof(*d3d10_feature_levels); ++i) { if (SUCCEEDED(hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, d3d10_feature_levels[i], D3D10_1_SDK_VERSION, &device))) { supported_feature_level = d3d10_feature_levels[i]; break; } } if (FAILED(hr)) { skip("Failed to create HAL device.\n"); return; } feature_level = ID3D10Device1_GetFeatureLevel(device); ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n", feature_level, supported_feature_level); ID3D10Device1_Release(device); hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); device = (ID3D10Device1 *)0xdeadbeef; hr = D3D10CreateDevice1(NULL, 0xffffffff, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &device); todo_wine ok(hr == E_INVALIDARG, "D3D10CreateDevice1 returned %#x.\n", hr); ok(!device, "Got unexpected device pointer %p.\n", device); device = (ID3D10Device1 *)0xdeadbeef; hr = D3D10CreateDevice1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, 0, D3D10_1_SDK_VERSION, &device); ok(hr == E_INVALIDARG, "D3D10CreateDevice1 returned %#x.\n", hr); ok(!device, "Got unexpected device pointer %p.\n", device); window = CreateWindowA("static", "d3d10_1_test", 0, 0, 0, 0, 0, 0, 0, 0, 0); swapchain_desc.BufferDesc.Width = 800; swapchain_desc.BufferDesc.Height = 600; swapchain_desc.BufferDesc.RefreshRate.Numerator = 60; swapchain_desc.BufferDesc.RefreshRate.Denominator = 60; swapchain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; swapchain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; swapchain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; swapchain_desc.SampleDesc.Count = 1; swapchain_desc.SampleDesc.Quality = 0; swapchain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swapchain_desc.BufferCount = 1; swapchain_desc.OutputWindow = window; swapchain_desc.Windowed = TRUE; swapchain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swapchain_desc.Flags = 0; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, &device); ok(SUCCEEDED(hr), "D3D10CreateDeviceAndSwapChain1 failed %#x.\n", hr); memset(&obtained_desc, 0, sizeof(obtained_desc)); hr = IDXGISwapChain_GetDesc(swapchain, &obtained_desc); ok(SUCCEEDED(hr), "GetDesc failed %#x.\n", hr); ok(obtained_desc.BufferDesc.Width == swapchain_desc.BufferDesc.Width, "Got unexpected BufferDesc.Width %u.\n", obtained_desc.BufferDesc.Width); ok(obtained_desc.BufferDesc.Height == swapchain_desc.BufferDesc.Height, "Got unexpected BufferDesc.Height %u.\n", obtained_desc.BufferDesc.Height); todo_wine ok(obtained_desc.BufferDesc.RefreshRate.Numerator == swapchain_desc.BufferDesc.RefreshRate.Numerator, "Got unexpected BufferDesc.RefreshRate.Numerator %u.\n", obtained_desc.BufferDesc.RefreshRate.Numerator); todo_wine ok(obtained_desc.BufferDesc.RefreshRate.Denominator == swapchain_desc.BufferDesc.RefreshRate.Denominator, "Got unexpected BufferDesc.RefreshRate.Denominator %u.\n", obtained_desc.BufferDesc.RefreshRate.Denominator); ok(obtained_desc.BufferDesc.Format == swapchain_desc.BufferDesc.Format, "Got unexpected BufferDesc.Format %#x.\n", obtained_desc.BufferDesc.Format); ok(obtained_desc.BufferDesc.ScanlineOrdering == swapchain_desc.BufferDesc.ScanlineOrdering, "Got unexpected BufferDesc.ScanlineOrdering %#x.\n", obtained_desc.BufferDesc.ScanlineOrdering); ok(obtained_desc.BufferDesc.Scaling == swapchain_desc.BufferDesc.Scaling, "Got unexpected BufferDesc.Scaling %#x.\n", obtained_desc.BufferDesc.Scaling); ok(obtained_desc.SampleDesc.Count == swapchain_desc.SampleDesc.Count, "Got unexpected SampleDesc.Count %u.\n", obtained_desc.SampleDesc.Count); ok(obtained_desc.SampleDesc.Quality == swapchain_desc.SampleDesc.Quality, "Got unexpected SampleDesc.Quality %u.\n", obtained_desc.SampleDesc.Quality); todo_wine ok(obtained_desc.BufferUsage == swapchain_desc.BufferUsage, "Got unexpected BufferUsage %#x.\n", obtained_desc.BufferUsage); ok(obtained_desc.BufferCount == swapchain_desc.BufferCount, "Got unexpected BufferCount %u.\n", obtained_desc.BufferCount); ok(obtained_desc.OutputWindow == swapchain_desc.OutputWindow, "Got unexpected OutputWindow %p.\n", obtained_desc.OutputWindow); ok(obtained_desc.Windowed == swapchain_desc.Windowed, "Got unexpected Windowed %#x.\n", obtained_desc.Windowed); ok(obtained_desc.SwapEffect == swapchain_desc.SwapEffect, "Got unexpected SwapEffect %#x.\n", obtained_desc.SwapEffect); ok(obtained_desc.Flags == swapchain_desc.Flags, "Got unexpected Flags %#x.\n", obtained_desc.Flags); refcount = IDXGISwapChain_Release(swapchain); ok(!refcount, "Swapchain has %u references left.\n", refcount); feature_level = ID3D10Device1_GetFeatureLevel(device); ok(feature_level == supported_feature_level, "Got feature level %#x, expected %#x.\n", feature_level, supported_feature_level); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, NULL, NULL, &device); ok(SUCCEEDED(hr), "D3D10CreateDeviceAndSwapChain1 failed %#x.\n", hr); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, NULL, NULL, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, NULL, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); swapchain = (IDXGISwapChain *)0xdeadbeef; device = (ID3D10Device1 *)0xdeadbeef; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, 0, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, &device); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain); ok(!device, "Got unexpected device pointer %p.\n", device); swapchain = (IDXGISwapChain *)0xdeadbeef; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, NULL); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain); swapchain_desc.OutputWindow = NULL; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, NULL, &device); ok(SUCCEEDED(hr), "D3D10CreateDeviceAndSwapChain1 failed %#x.\n", hr); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); swapchain = (IDXGISwapChain *)0xdeadbeef; device = (ID3D10Device1 *)0xdeadbeef; swapchain_desc.OutputWindow = NULL; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, &device); todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "D3D10CreateDeviceAndSwapChain1 returned %#x.\n", hr); if (SUCCEEDED(hr)) { refcount = IDXGISwapChain_Release(swapchain); ok(!refcount, "Swapchain has %u references left.\n", refcount); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); } else { ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain); ok(!device, "Got unexpected device pointer %p.\n", device); } swapchain = (IDXGISwapChain *)0xdeadbeef; device = (ID3D10Device1 *)0xdeadbeef; swapchain_desc.OutputWindow = window; swapchain_desc.BufferDesc.Format = DXGI_FORMAT_BC5_UNORM; hr = D3D10CreateDeviceAndSwapChain1(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, supported_feature_level, D3D10_1_SDK_VERSION, &swapchain_desc, &swapchain, &device); ok(hr == E_INVALIDARG, "D3D10CreateDeviceAndSwapChain1 returned %#x.\n", hr); ok(!swapchain, "Got unexpected swapchain pointer %p.\n", swapchain); ok(!device, "Got unexpected device pointer %p.\n", device); DestroyWindow(window); }
static void test_getdc(void) { struct device_desc device_desc; D3D10_TEXTURE2D_DESC desc; ID3D10Texture2D *texture; IDXGISurface1 *surface1; ID3D10Device1 *device; ULONG refcount; HRESULT hr; HDC dc; device_desc.feature_level = D3D10_FEATURE_LEVEL_10_1; device_desc.flags = D3D10_CREATE_DEVICE_BGRA_SUPPORT; if (!(device = create_device(&device_desc))) { skip("Failed to create device.\n"); return; } /* Without D3D10_RESOURCE_MISC_GDI_COMPATIBLE. */ desc.Width = 512; desc.Height = 512; desc.MipLevels = 1; desc.ArraySize = 1; desc.Format = DXGI_FORMAT_B8G8R8A8_UNORM; desc.SampleDesc.Count = 1; desc.SampleDesc.Quality = 0; desc.Usage = D3D10_USAGE_DEFAULT; desc.BindFlags = D3D10_BIND_RENDER_TARGET; desc.CPUAccessFlags = 0; desc.MiscFlags = 0; hr = ID3D10Device1_CreateTexture2D(device, &desc, NULL, &texture); ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface1, (void**)&surface1); ok(SUCCEEDED(hr), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr); hr = IDXGISurface1_GetDC(surface1, FALSE, &dc); todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); IDXGISurface1_Release(surface1); ID3D10Texture2D_Release(texture); desc.MiscFlags = D3D10_RESOURCE_MISC_GDI_COMPATIBLE; hr = ID3D10Device1_CreateTexture2D(device, &desc, NULL, &texture); ok(SUCCEEDED(hr), "Failed to create texture, hr %#x.\n", hr); hr = ID3D10Texture2D_QueryInterface(texture, &IID_IDXGISurface1, (void**)&surface1); ok(SUCCEEDED(hr), "Failed to get IDXGISurface1 interface, hr %#x.\n", hr); hr = IDXGISurface1_ReleaseDC(surface1, NULL); todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); hr = IDXGISurface1_GetDC(surface1, FALSE, &dc); todo_wine ok(SUCCEEDED(hr), "Failed to get DC, hr %#x.\n", hr); /* One more time. */ dc = (HDC)0xdeadbeef; hr = IDXGISurface1_GetDC(surface1, FALSE, &dc); todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); ok(dc == (HDC)0xdeadbeef, "Got unexpected dc %p.\n", dc); hr = IDXGISurface1_ReleaseDC(surface1, NULL); todo_wine ok(SUCCEEDED(hr), "Failed to release DC, hr %#x.\n", hr); hr = IDXGISurface1_ReleaseDC(surface1, NULL); todo_wine ok(hr == DXGI_ERROR_INVALID_CALL, "Got unexpected hr %#x.\n", hr); IDXGISurface1_Release(surface1); ID3D10Texture2D_Release(texture); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); }
static void test_create_blend_state(void) { static const D3D10_BLEND_DESC1 desc_conversion_tests[] = { { FALSE, FALSE, { { FALSE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD }, }, }, { FALSE, TRUE, { { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { FALSE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_RED }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { FALSE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_GREEN }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, }, }, { FALSE, TRUE, { { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_SUBTRACT, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ZERO, D3D10_BLEND_ONE, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ZERO, D3D10_BLEND_ONE, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ONE, D3D10_BLEND_OP_MAX, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { TRUE, D3D10_BLEND_ONE, D3D10_BLEND_ONE, D3D10_BLEND_OP_MIN, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { FALSE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, { FALSE, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_BLEND_ONE, D3D10_BLEND_ZERO, D3D10_BLEND_OP_ADD, D3D10_COLOR_WRITE_ENABLE_ALL }, }, }, }; ID3D10BlendState1 *blend_state1, *blend_state2; D3D10_BLEND_DESC1 desc, obtained_desc; ID3D10BlendState *d3d10_blend_state; D3D10_BLEND_DESC d3d10_blend_desc; ULONG refcount, expected_refcount; ID3D10Device1 *device; ID3D10Device *tmp; unsigned int i, j; IUnknown *iface; HRESULT hr; if (!(device = create_device(NULL))) { skip("Failed to create device.\n"); return; } hr = ID3D10Device1_CreateBlendState1(device, NULL, &blend_state1); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); memset(&desc, 0, sizeof(desc)); desc.AlphaToCoverageEnable = FALSE; desc.IndependentBlendEnable = FALSE; desc.RenderTarget[0].BlendEnable = FALSE; desc.RenderTarget[0].SrcBlend = D3D10_BLEND_ONE; desc.RenderTarget[0].DestBlend = D3D10_BLEND_ZERO; desc.RenderTarget[0].BlendOp = D3D10_BLEND_OP_ADD; desc.RenderTarget[0].SrcBlendAlpha = D3D10_BLEND_ONE; desc.RenderTarget[0].DestBlendAlpha = D3D10_BLEND_ZERO; desc.RenderTarget[0].BlendOpAlpha = D3D10_BLEND_OP_ADD; desc.RenderTarget[0].RenderTargetWriteMask = D3D10_COLOR_WRITE_ENABLE_ALL; expected_refcount = get_refcount((IUnknown *)device) + 1; hr = ID3D10Device1_CreateBlendState1(device, &desc, &blend_state1); ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr); hr = ID3D10Device1_CreateBlendState1(device, &desc, &blend_state2); ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr); ok(blend_state1 == blend_state2, "Got different blend state objects.\n"); refcount = get_refcount((IUnknown *)device); ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount); tmp = NULL; expected_refcount = refcount + 1; ID3D10BlendState1_GetDevice(blend_state1, &tmp); ok(tmp == (ID3D10Device *)device, "Got unexpected device %p, expected %p.\n", tmp, device); refcount = get_refcount((IUnknown *)device); ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); ID3D10Device_Release(tmp); ID3D10BlendState1_GetDesc1(blend_state1, &obtained_desc); ok(obtained_desc.AlphaToCoverageEnable == FALSE, "Got unexpected alpha to coverage enable %#x.\n", obtained_desc.AlphaToCoverageEnable); ok(obtained_desc.IndependentBlendEnable == FALSE, "Got unexpected independent blend enable %#x.\n", obtained_desc.IndependentBlendEnable); for (i = 0; i < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i) { ok(obtained_desc.RenderTarget[i].BlendEnable == FALSE, "Got unexpected blend enable %#x for render target %u.\n", obtained_desc.RenderTarget[i].BlendEnable, i); ok(obtained_desc.RenderTarget[i].SrcBlend == D3D10_BLEND_ONE, "Got unexpected src blend %u for render target %u.\n", obtained_desc.RenderTarget[i].SrcBlend, i); ok(obtained_desc.RenderTarget[i].DestBlend == D3D10_BLEND_ZERO, "Got unexpected dest blend %u for render target %u.\n", obtained_desc.RenderTarget[i].DestBlend, i); ok(obtained_desc.RenderTarget[i].BlendOp == D3D10_BLEND_OP_ADD, "Got unexpected blend op %u for render target %u.\n", obtained_desc.RenderTarget[i].BlendOp, i); ok(obtained_desc.RenderTarget[i].SrcBlendAlpha == D3D10_BLEND_ONE, "Got unexpected src blend alpha %u for render target %u.\n", obtained_desc.RenderTarget[i].SrcBlendAlpha, i); ok(obtained_desc.RenderTarget[i].DestBlendAlpha == D3D10_BLEND_ZERO, "Got unexpected dest blend alpha %u for render target %u.\n", obtained_desc.RenderTarget[i].DestBlendAlpha, i); ok(obtained_desc.RenderTarget[i].BlendOpAlpha == D3D10_BLEND_OP_ADD, "Got unexpected blend op alpha %u for render target %u.\n", obtained_desc.RenderTarget[i].BlendOpAlpha, i); ok(obtained_desc.RenderTarget[i].RenderTargetWriteMask == D3D10_COLOR_WRITE_ENABLE_ALL, "Got unexpected render target write mask %#x for render target %u.\n", obtained_desc.RenderTarget[0].RenderTargetWriteMask, i); } hr = ID3D10BlendState1_QueryInterface(blend_state1, &IID_ID3D10BlendState, (void **)&iface); ok(SUCCEEDED(hr), "Blend state should implement ID3D10BlendState.\n"); IUnknown_Release(iface); hr = ID3D10BlendState1_QueryInterface(blend_state1, &IID_ID3D11BlendState, (void **)&iface); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Blend state should implement ID3D11BlendState.\n"); if (SUCCEEDED(hr)) IUnknown_Release(iface); refcount = ID3D10BlendState1_Release(blend_state1); ok(refcount == 1, "Got unexpected refcount %u.\n", refcount); refcount = ID3D10BlendState1_Release(blend_state2); ok(!refcount, "Blend state has %u references left.\n", refcount); for (i = 0; i < sizeof(desc_conversion_tests) / sizeof(*desc_conversion_tests); ++i) { const D3D10_BLEND_DESC1 *current_desc = &desc_conversion_tests[i]; hr = ID3D10Device1_CreateBlendState1(device, current_desc, &blend_state1); ok(SUCCEEDED(hr), "Failed to create blend state, hr %#x.\n", hr); hr = ID3D10BlendState1_QueryInterface(blend_state1, &IID_ID3D10BlendState, (void **)&d3d10_blend_state); ok(SUCCEEDED(hr), "Blend state should implement ID3D10BlendState.\n"); ID3D10BlendState_GetDesc(d3d10_blend_state, &d3d10_blend_desc); ok(d3d10_blend_desc.AlphaToCoverageEnable == current_desc->AlphaToCoverageEnable, "Got unexpected alpha to coverage enable %#x for test %u.\n", d3d10_blend_desc.AlphaToCoverageEnable, i); ok(d3d10_blend_desc.SrcBlend == current_desc->RenderTarget[0].SrcBlend, "Got unexpected src blend %u for test %u.\n", d3d10_blend_desc.SrcBlend, i); ok(d3d10_blend_desc.DestBlend == current_desc->RenderTarget[0].DestBlend, "Got unexpected dest blend %u for test %u.\n", d3d10_blend_desc.DestBlend, i); ok(d3d10_blend_desc.BlendOp == current_desc->RenderTarget[0].BlendOp, "Got unexpected blend op %u for test %u.\n", d3d10_blend_desc.BlendOp, i); ok(d3d10_blend_desc.SrcBlendAlpha == current_desc->RenderTarget[0].SrcBlendAlpha, "Got unexpected src blend alpha %u for test %u.\n", d3d10_blend_desc.SrcBlendAlpha, i); ok(d3d10_blend_desc.DestBlendAlpha == current_desc->RenderTarget[0].DestBlendAlpha, "Got unexpected dest blend alpha %u for test %u.\n", d3d10_blend_desc.DestBlendAlpha, i); ok(d3d10_blend_desc.BlendOpAlpha == current_desc->RenderTarget[0].BlendOpAlpha, "Got unexpected blend op alpha %u for test %u.\n", d3d10_blend_desc.BlendOpAlpha, i); for (j = 0; j < D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT; j++) { unsigned int k = current_desc->IndependentBlendEnable ? j : 0; ok(d3d10_blend_desc.BlendEnable[j] == current_desc->RenderTarget[k].BlendEnable, "Got unexpected blend enable %#x for test %u, render target %u.\n", d3d10_blend_desc.BlendEnable[j], i, j); ok(d3d10_blend_desc.RenderTargetWriteMask[j] == current_desc->RenderTarget[k].RenderTargetWriteMask, "Got unexpected render target write mask %#x for test %u, render target %u.\n", d3d10_blend_desc.RenderTargetWriteMask[j], i, j); } ID3D10BlendState_Release(d3d10_blend_state); refcount = ID3D10BlendState1_Release(blend_state1); ok(!refcount, "Got unexpected refcount %u.\n", refcount); } refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); }
static void test_create_shader_resource_view(void) { D3D10_SHADER_RESOURCE_VIEW_DESC1 srv_desc; D3D10_TEXTURE2D_DESC texture_desc; ULONG refcount, expected_refcount; ID3D10ShaderResourceView1 *srview; D3D10_BUFFER_DESC buffer_desc; ID3D10Texture2D *texture; ID3D10Device *tmp_device; ID3D10Device1 *device; ID3D10Buffer *buffer; IUnknown *iface; HRESULT hr; if (!(device = create_device(NULL))) { skip("Failed to create device.\n"); return; } buffer_desc.ByteWidth = 1024; buffer_desc.Usage = D3D10_USAGE_DEFAULT; buffer_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; buffer_desc.CPUAccessFlags = 0; buffer_desc.MiscFlags = 0; hr = ID3D10Device1_CreateBuffer(device, &buffer_desc, NULL, &buffer); ok(SUCCEEDED(hr), "Failed to create a buffer, hr %#x\n", hr); hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)buffer, NULL, &srview); ok(hr == E_INVALIDARG, "Got unexpected hr %#x.\n", hr); srv_desc.Format = DXGI_FORMAT_R32G32B32A32_FLOAT; srv_desc.ViewDimension = D3D10_1_SRV_DIMENSION_BUFFER; U(srv_desc).Buffer.ElementOffset = 0; U(srv_desc).Buffer.ElementWidth = 64; expected_refcount = get_refcount((IUnknown *)device) + 1; hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)buffer, &srv_desc, &srview); ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr); refcount = get_refcount((IUnknown *)device); ok(refcount >= expected_refcount, "Got unexpected refcount %u, expected >= %u.\n", refcount, expected_refcount); tmp_device = NULL; expected_refcount = refcount + 1; ID3D10ShaderResourceView1_GetDevice(srview, &tmp_device); ok(tmp_device == (ID3D10Device *)device, "Got unexpected device %p, expected %p.\n", tmp_device, device); refcount = get_refcount((IUnknown *)device); ok(refcount == expected_refcount, "Got unexpected refcount %u, expected %u.\n", refcount, expected_refcount); ID3D10Device_Release(tmp_device); hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface); ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n"); IUnknown_Release(iface); hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Shader resource view should implement ID3D11ShaderResourceView.\n"); if (SUCCEEDED(hr)) IUnknown_Release(iface); ID3D10ShaderResourceView1_Release(srview); ID3D10Buffer_Release(buffer); texture_desc.Width = 512; texture_desc.Height = 512; texture_desc.MipLevels = 0; texture_desc.ArraySize = 1; texture_desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; texture_desc.SampleDesc.Count = 1; texture_desc.SampleDesc.Quality = 0; texture_desc.Usage = D3D10_USAGE_DEFAULT; texture_desc.BindFlags = D3D10_BIND_SHADER_RESOURCE; texture_desc.CPUAccessFlags = 0; texture_desc.MiscFlags = 0; hr = ID3D10Device1_CreateTexture2D(device, &texture_desc, NULL, &texture); ok(SUCCEEDED(hr), "Failed to create a 2d texture, hr %#x\n", hr); hr = ID3D10Device1_CreateShaderResourceView1(device, (ID3D10Resource *)texture, NULL, &srview); ok(SUCCEEDED(hr), "Failed to create a shader resource view, hr %#x\n", hr); ID3D10ShaderResourceView1_GetDesc1(srview, &srv_desc); ok(srv_desc.Format == texture_desc.Format, "Got unexpected format %#x.\n", srv_desc.Format); ok(srv_desc.ViewDimension == D3D10_1_SRV_DIMENSION_TEXTURE2D, "Got unexpected view dimension %#x.\n", srv_desc.ViewDimension); ok(U(srv_desc).Texture2D.MostDetailedMip == 0, "Got unexpected MostDetailedMip %u.\n", U(srv_desc).Texture2D.MostDetailedMip); ok(U(srv_desc).Texture2D.MipLevels == 10, "Got unexpected MipLevels %u.\n", U(srv_desc).Texture2D.MipLevels); hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D10ShaderResourceView, (void **)&iface); ok(SUCCEEDED(hr), "Shader resource view should implement ID3D10ShaderResourceView.\n"); IUnknown_Release(iface); hr = ID3D10ShaderResourceView1_QueryInterface(srview, &IID_ID3D11ShaderResourceView, (void **)&iface); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Shader resource view should implement ID3D11ShaderResourceView.\n"); if (SUCCEEDED(hr)) IUnknown_Release(iface); ID3D10ShaderResourceView1_Release(srview); ID3D10Texture2D_Release(texture); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); }
static void test_device_interfaces(void) { IDXGIAdapter *dxgi_adapter; IDXGIDevice *dxgi_device; ID3D10Device1 *device; IUnknown *iface; ULONG refcount; unsigned int i; HRESULT hr; for (i = 0; i < sizeof(d3d10_feature_levels) / sizeof(*d3d10_feature_levels); ++i) { struct device_desc device_desc; device_desc.feature_level = d3d10_feature_levels[i]; device_desc.flags = 0; if (!(device = create_device(&device_desc))) { skip("Failed to create device for feature level %#x.\n", d3d10_feature_levels[i]); continue; } hr = ID3D10Device1_QueryInterface(device, &IID_IUnknown, (void **)&iface); ok(SUCCEEDED(hr), "Device should implement IUnknown interface, hr %#x.\n", hr); IUnknown_Release(iface); hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIObject, (void **)&iface); ok(SUCCEEDED(hr), "Device should implement IDXGIObject interface, hr %#x.\n", hr); IUnknown_Release(iface); hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); ok(SUCCEEDED(hr), "Device should implement IDXGIDevice.\n"); hr = IDXGIDevice_GetParent(dxgi_device, &IID_IDXGIAdapter, (void **)&dxgi_adapter); ok(SUCCEEDED(hr), "Device parent should implement IDXGIAdapter.\n"); hr = IDXGIAdapter_GetParent(dxgi_adapter, &IID_IDXGIFactory, (void **)&iface); ok(SUCCEEDED(hr), "Adapter parent should implement IDXGIFactory.\n"); IUnknown_Release(iface); IDXGIAdapter_Release(dxgi_adapter); hr = IDXGIDevice_GetParent(dxgi_device, &IID_IDXGIAdapter1, (void **)&dxgi_adapter); ok(SUCCEEDED(hr), "Device parent should implement IDXGIAdapter1.\n"); hr = IDXGIAdapter_GetParent(dxgi_adapter, &IID_IDXGIFactory1, (void **)&iface); ok(hr == E_NOINTERFACE, "Adapter parent should not implement IDXGIFactory1.\n"); IDXGIAdapter_Release(dxgi_adapter); IDXGIDevice_Release(dxgi_device); hr = ID3D10Device1_QueryInterface(device, &IID_IDXGIDevice1, (void **)&iface); ok(SUCCEEDED(hr), "Device should implement IDXGIDevice1.\n"); IUnknown_Release(iface); hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10Multithread, (void **)&iface); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Device should implement ID3D10Multithread interface, hr %#x.\n", hr); if (SUCCEEDED(hr)) IUnknown_Release(iface); hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10InfoQueue, (void **)&iface); ok(hr == E_NOINTERFACE, "Found ID3D10InfoQueue interface in non-debug mode, hr %#x.\n", hr); hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10Device, (void **)&iface); ok(SUCCEEDED(hr), "Device should implement ID3D10Device interface, hr %#x.\n", hr); IUnknown_Release(iface); hr = ID3D10Device1_QueryInterface(device, &IID_ID3D11Device, (void **)&iface); ok(SUCCEEDED(hr) || broken(hr == E_NOINTERFACE) /* Not available on all Windows versions. */, "Device should implement ID3D11Device interface, hr %#x.\n", hr); if (SUCCEEDED(hr)) IUnknown_Release(iface); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); } for (i = 0; i < sizeof(d3d10_feature_levels) / sizeof(*d3d10_feature_levels); ++i) { struct device_desc device_desc; device_desc.feature_level = d3d10_feature_levels[i]; device_desc.flags = D3D10_CREATE_DEVICE_DEBUG; if (!(device = create_device(&device_desc))) { skip("Failed to create device for feature level %#x.\n", d3d10_feature_levels[i]); continue; } hr = ID3D10Device1_QueryInterface(device, &IID_ID3D10InfoQueue, (void **)&iface); todo_wine ok(hr == S_OK, "Device should implement ID3D10InfoQueue interface, hr %#x.\n", hr); if (SUCCEEDED(hr)) IUnknown_Release(iface); refcount = ID3D10Device1_Release(device); ok(!refcount, "Device has %u references left.\n", refcount); } }
HRESULT WINAPI D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, D3D10_FEATURE_LEVEL1 feature_level, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc, IDXGISwapChain **swapchain, ID3D10Device1 **device) { IDXGIDevice *dxgi_device; IDXGIFactory *factory; HRESULT hr; TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, " "feature_level %s, sdk_version %d, swapchain_desc %p, swapchain %p, device %p.\n", adapter, debug_d3d10_driver_type(driver_type), swrast, flags, debug_d3d10_feature_level(feature_level), sdk_version, swapchain_desc, swapchain, device); if (swapchain) *swapchain = NULL; if (!device) return E_INVALIDARG; if (FAILED(hr = D3D10CreateDevice1(adapter, driver_type, swrast, flags, feature_level, sdk_version, device))) { WARN("Failed to create a device, returning %#x.\n", hr); *device = NULL; return hr; } if (swapchain) { if (FAILED(hr = ID3D10Device1_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device))) { ERR("Failed to get a dxgi device from the d3d10 device, returning %#x.\n", hr); goto cleanup; } hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { ERR("Failed to get the device adapter, returning %#x.\n", hr); goto cleanup; } hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); IDXGIAdapter_Release(adapter); if (FAILED(hr)) { ERR("Failed to get the adapter factory, returning %#x.\n", hr); goto cleanup; } hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain); IDXGIFactory_Release(factory); if (FAILED(hr)) { WARN("Failed to create a swapchain, returning %#x.\n", hr); goto cleanup; } TRACE("Created IDXGISwapChain %p.\n", *swapchain); } return S_OK; cleanup: ID3D10Device1_Release(*device); *device = NULL; return hr; }
static void test_color_brush(void) { D2D1_MATRIX_3X2_F matrix, tmp_matrix; D2D1_BRUSH_PROPERTIES brush_desc; D2D1_COLOR_F color, tmp_color; ID2D1SolidColorBrush *brush; IDXGISwapChain *swapchain; ID2D1RenderTarget *rt; ID3D10Device1 *device; IDXGISurface *surface; D2D1_RECT_F rect; float opacity; HWND window; HRESULT hr; if (!(device = create_device())) { skip("Failed to create device, skipping tests.\n"); return; } window = CreateWindowA("static", "d2d1_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, NULL, NULL, NULL); swapchain = create_swapchain(device, window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); ok(!!rt, "Failed to create render target.\n"); ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); set_color(&color, 0.0f, 0.0f, 0.0f, 0.0f); hr = ID2D1RenderTarget_CreateSolidColorBrush(rt, &color, NULL, &brush); ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr); opacity = ID2D1SolidColorBrush_GetOpacity(brush); ok(opacity == 1.0f, "Got unexpected opacity %.8e.\n", opacity); set_matrix_identity(&matrix); ID2D1SolidColorBrush_GetTransform(brush, &tmp_matrix); ok(!memcmp(&tmp_matrix, &matrix, sizeof(matrix)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", tmp_matrix._11, tmp_matrix._12, tmp_matrix._21, tmp_matrix._22, tmp_matrix._31, tmp_matrix._32); tmp_color = ID2D1SolidColorBrush_GetColor(brush); ok(!memcmp(&tmp_color, &color, sizeof(color)), "Got unexpected color {%.8e, %.8e, %.8e, %.8e}.\n", tmp_color.r, tmp_color.g, tmp_color.b, tmp_color.a); ID2D1SolidColorBrush_Release(brush); set_color(&color, 0.0f, 1.0f, 0.0f, 0.8f); brush_desc.opacity = 0.3f; set_matrix_identity(&matrix); scale_matrix(&matrix, 2.0f, 2.0f); brush_desc.transform = matrix; hr = ID2D1RenderTarget_CreateSolidColorBrush(rt, &color, &brush_desc, &brush); ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr); opacity = ID2D1SolidColorBrush_GetOpacity(brush); ok(opacity == 0.3f, "Got unexpected opacity %.8e.\n", opacity); ID2D1SolidColorBrush_GetTransform(brush, &tmp_matrix); ok(!memcmp(&tmp_matrix, &matrix, sizeof(matrix)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", tmp_matrix._11, tmp_matrix._12, tmp_matrix._21, tmp_matrix._22, tmp_matrix._31, tmp_matrix._32); tmp_color = ID2D1SolidColorBrush_GetColor(brush); ok(!memcmp(&tmp_color, &color, sizeof(color)), "Got unexpected color {%.8e, %.8e, %.8e, %.8e}.\n", tmp_color.r, tmp_color.g, tmp_color.b, tmp_color.a); ID2D1RenderTarget_BeginDraw(rt); set_color(&color, 0.0f, 0.0f, 1.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); ID2D1SolidColorBrush_SetOpacity(brush, 1.0f); set_rect(&rect, 40.0f, 120.0f, 120.0f, 360.0f); ID2D1RenderTarget_FillRectangle(rt, &rect, (ID2D1Brush *)brush); set_matrix_identity(&matrix); scale_matrix(&matrix, 0.5f, 2.0f); translate_matrix(&matrix, 320.0f, 240.0f); rotate_matrix(&matrix, M_PI / 4.0f); ID2D1RenderTarget_SetTransform(rt, &matrix); set_color(&color, 1.0f, 0.0f, 0.0f, 0.625f); ID2D1SolidColorBrush_SetColor(brush, &color); ID2D1SolidColorBrush_SetOpacity(brush, 0.75f); set_rect(&rect, -80.0f, -60.0f, 80.0f, 60.0f); ID2D1RenderTarget_FillRectangle(rt, &rect, (ID2D1Brush *)brush); hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); ok(compare_surface(surface, "6d1218fca5e21fb7e287b3a439d60dbc251f5ceb"), "Surface does not match.\n"); ID2D1SolidColorBrush_Release(brush); ID2D1RenderTarget_Release(rt); IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); ID3D10Device1_Release(device); DestroyWindow(window); }
static void test_state_block(void) { IDWriteRenderingParams *text_rendering_params1, *text_rendering_params2; D2D1_DRAWING_STATE_DESCRIPTION drawing_state; ID2D1DrawingStateBlock *state_block; IDWriteFactory *dwrite_factory; IDXGISwapChain *swapchain; ID2D1RenderTarget *rt; ID3D10Device1 *device; IDXGISurface *surface; ID2D1Factory *factory; ULONG refcount; HWND window; HRESULT hr; static const D2D1_MATRIX_3X2_F identity = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, }; static const D2D1_MATRIX_3X2_F transform1 = { 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, }; static const D2D1_MATRIX_3X2_F transform2 = { 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, }; if (!(device = create_device())) { skip("Failed to create device, skipping tests.\n"); return; } window = CreateWindowA("static", "d2d1_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, NULL, NULL, NULL); swapchain = create_swapchain(device, window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); ok(!!rt, "Failed to create render target.\n"); ID2D1RenderTarget_GetFactory(rt, &factory); hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, &IID_IDWriteFactory, (IUnknown **)&dwrite_factory); ok(SUCCEEDED(hr), "Failed to create dwrite factory, hr %#x.\n", hr); hr = IDWriteFactory_CreateRenderingParams(dwrite_factory, &text_rendering_params1); ok(SUCCEEDED(hr), "Failed to create dwrite rendering params, hr %#x.\n", hr); IDWriteFactory_Release(dwrite_factory); drawing_state.antialiasMode = ID2D1RenderTarget_GetAntialiasMode(rt); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); drawing_state.textAntialiasMode = ID2D1RenderTarget_GetTextAntialiasMode(rt); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_DEFAULT, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ID2D1RenderTarget_GetTags(rt, &drawing_state.tag1, &drawing_state.tag2); ok(!drawing_state.tag1 && !drawing_state.tag2, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ID2D1RenderTarget_GetTransform(rt, &drawing_state.transform); ok(!memcmp(&drawing_state.transform, &identity, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1RenderTarget_GetTextRenderingParams(rt, &text_rendering_params2); ok(!text_rendering_params2, "Got unexpected text rendering params %p.\n", text_rendering_params2); hr = ID2D1Factory_CreateDrawingStateBlock(factory, NULL, NULL, &state_block); ok(SUCCEEDED(hr), "Failed to create drawing state block, hr %#x\n", hr); ID2D1DrawingStateBlock_GetDescription(state_block, &drawing_state); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_DEFAULT, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ok(!drawing_state.tag1 && !drawing_state.tag2, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ok(!memcmp(&drawing_state.transform, &identity, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1DrawingStateBlock_GetTextRenderingParams(state_block, &text_rendering_params2); ok(!text_rendering_params2, "Got unexpected text rendering params %p.\n", text_rendering_params2); ID2D1DrawingStateBlock_Release(state_block); drawing_state.antialiasMode = D2D1_ANTIALIAS_MODE_ALIASED; drawing_state.textAntialiasMode = D2D1_TEXT_ANTIALIAS_MODE_ALIASED; drawing_state.tag1 = 0xdead; drawing_state.tag2 = 0xbeef; drawing_state.transform = transform1; hr = ID2D1Factory_CreateDrawingStateBlock(factory, &drawing_state, text_rendering_params1, &state_block); ok(SUCCEEDED(hr), "Failed to create drawing state block, hr %#x\n", hr); ID2D1DrawingStateBlock_GetDescription(state_block, &drawing_state); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_ALIASED, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_ALIASED, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ok(drawing_state.tag1 == 0xdead && drawing_state.tag2 == 0xbeef, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ok(!memcmp(&drawing_state.transform, &transform1, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1DrawingStateBlock_GetTextRenderingParams(state_block, &text_rendering_params2); ok(text_rendering_params2 == text_rendering_params1, "Got unexpected text rendering params %p, expected %p.\n", text_rendering_params2, text_rendering_params1); IDWriteRenderingParams_Release(text_rendering_params2); ID2D1RenderTarget_RestoreDrawingState(rt, state_block); drawing_state.antialiasMode = ID2D1RenderTarget_GetAntialiasMode(rt); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_ALIASED, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); drawing_state.textAntialiasMode = ID2D1RenderTarget_GetTextAntialiasMode(rt); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_ALIASED, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ID2D1RenderTarget_GetTags(rt, &drawing_state.tag1, &drawing_state.tag2); ok(drawing_state.tag1 == 0xdead && drawing_state.tag2 == 0xbeef, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ID2D1RenderTarget_GetTransform(rt, &drawing_state.transform); ok(!memcmp(&drawing_state.transform, &transform1, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1RenderTarget_GetTextRenderingParams(rt, &text_rendering_params2); ok(text_rendering_params2 == text_rendering_params1, "Got unexpected text rendering params %p, expected %p.\n", text_rendering_params2, text_rendering_params1); IDWriteRenderingParams_Release(text_rendering_params2); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_PER_PRIMITIVE); ID2D1RenderTarget_SetTextAntialiasMode(rt, D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE); ID2D1RenderTarget_SetTags(rt, 1, 2); ID2D1RenderTarget_SetTransform(rt, &transform2); ID2D1RenderTarget_SetTextRenderingParams(rt, NULL); drawing_state.antialiasMode = ID2D1RenderTarget_GetAntialiasMode(rt); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); drawing_state.textAntialiasMode = ID2D1RenderTarget_GetTextAntialiasMode(rt); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ID2D1RenderTarget_GetTags(rt, &drawing_state.tag1, &drawing_state.tag2); ok(drawing_state.tag1 == 1 && drawing_state.tag2 == 2, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ID2D1RenderTarget_GetTransform(rt, &drawing_state.transform); ok(!memcmp(&drawing_state.transform, &transform2, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1RenderTarget_GetTextRenderingParams(rt, &text_rendering_params2); ok(!text_rendering_params2, "Got unexpected text rendering params %p.\n", text_rendering_params2); ID2D1RenderTarget_SaveDrawingState(rt, state_block); ID2D1DrawingStateBlock_GetDescription(state_block, &drawing_state); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_PER_PRIMITIVE, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_GRAYSCALE, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ok(drawing_state.tag1 == 1 && drawing_state.tag2 == 2, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ok(!memcmp(&drawing_state.transform, &transform2, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1DrawingStateBlock_GetTextRenderingParams(state_block, &text_rendering_params2); ok(!text_rendering_params2, "Got unexpected text rendering params %p.\n", text_rendering_params2); drawing_state.antialiasMode = D2D1_ANTIALIAS_MODE_ALIASED; drawing_state.textAntialiasMode = D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE; drawing_state.tag1 = 3; drawing_state.tag2 = 4; drawing_state.transform = transform1; ID2D1DrawingStateBlock_SetDescription(state_block, &drawing_state); ID2D1DrawingStateBlock_SetTextRenderingParams(state_block, text_rendering_params1); ID2D1DrawingStateBlock_GetDescription(state_block, &drawing_state); ok(drawing_state.antialiasMode == D2D1_ANTIALIAS_MODE_ALIASED, "Got unexpected antialias mode %#x.\n", drawing_state.antialiasMode); ok(drawing_state.textAntialiasMode == D2D1_TEXT_ANTIALIAS_MODE_CLEARTYPE, "Got unexpected text antialias mode %#x.\n", drawing_state.textAntialiasMode); ok(drawing_state.tag1 == 3 && drawing_state.tag2 == 4, "Got unexpected tags %08x%08x:%08x%08x.\n", (unsigned int)(drawing_state.tag1 >> 32), (unsigned int)(drawing_state.tag1), (unsigned int)(drawing_state.tag2 >> 32), (unsigned int)(drawing_state.tag2)); ok(!memcmp(&drawing_state.transform, &transform1, sizeof(drawing_state.transform)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", drawing_state.transform._11, drawing_state.transform._12, drawing_state.transform._21, drawing_state.transform._22, drawing_state.transform._31, drawing_state.transform._32); ID2D1DrawingStateBlock_GetTextRenderingParams(state_block, &text_rendering_params2); ok(text_rendering_params2 == text_rendering_params1, "Got unexpected text rendering params %p, expected %p.\n", text_rendering_params2, text_rendering_params1); IDWriteRenderingParams_Release(text_rendering_params2); ID2D1DrawingStateBlock_Release(state_block); refcount = IDWriteRenderingParams_Release(text_rendering_params1); ok(!refcount, "Rendering params %u references left.\n", refcount); ID2D1Factory_Release(factory); ID2D1RenderTarget_Release(rt); IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); ID3D10Device1_Release(device); DestroyWindow(window); }
static void test_clip(void) { IDXGISwapChain *swapchain; D2D1_MATRIX_3X2_F matrix; D2D1_SIZE_U pixel_size; ID2D1RenderTarget *rt; ID3D10Device1 *device; IDXGISurface *surface; D2D1_POINT_2F point; D2D1_COLOR_F color; float dpi_x, dpi_y; D2D1_RECT_F rect; D2D1_SIZE_F size; HWND window; HRESULT hr; static const D2D1_MATRIX_3X2_F identity = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, }; if (!(device = create_device())) { skip("Failed to create device, skipping tests.\n"); return; } window = CreateWindowA("static", "d2d1_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, NULL, NULL, NULL); swapchain = create_swapchain(device, window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); ok(!!rt, "Failed to create render target.\n"); ID2D1RenderTarget_GetDpi(rt, &dpi_x, &dpi_y); ok(dpi_x == 96.0f, "Got unexpected dpi_x %.8e.\n", dpi_x); ok(dpi_y == 96.0f, "Got unexpected dpi_x %.8e.\n", dpi_y); size = ID2D1RenderTarget_GetSize(rt); ok(size.width == 640.0f, "Got unexpected width %.8e.\n", size.width); ok(size.height == 480.0f, "Got unexpected height %.8e.\n", size.height); pixel_size = ID2D1RenderTarget_GetPixelSize(rt); ok(pixel_size.width == 640, "Got unexpected width %u.\n", pixel_size.width); ok(pixel_size.height == 480, "Got unexpected height %u.\n", pixel_size.height); ID2D1RenderTarget_GetTransform(rt, &matrix); ok(!memcmp(&matrix, &identity, sizeof(matrix)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", matrix._11, matrix._12, matrix._21, matrix._22, matrix._31, matrix._32); ID2D1RenderTarget_BeginDraw(rt); set_color(&color, 1.0f, 1.0f, 0.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); ID2D1RenderTarget_SetDpi(rt, 48.0f, 192.0f); ID2D1RenderTarget_GetDpi(rt, &dpi_x, &dpi_y); ok(dpi_x == 48.0f, "Got unexpected dpi_x %.8e.\n", dpi_x); ok(dpi_y == 192.0f, "Got unexpected dpi_x %.8e.\n", dpi_y); size = ID2D1RenderTarget_GetSize(rt); ok(size.width == 1280.0f, "Got unexpected width %.8e.\n", size.width); ok(size.height == 240.0f, "Got unexpected height %.8e.\n", size.height); pixel_size = ID2D1RenderTarget_GetPixelSize(rt); ok(pixel_size.width == 640, "Got unexpected width %u.\n", pixel_size.width); ok(pixel_size.height == 480, "Got unexpected height %u.\n", pixel_size.height); /* The effective clip rect is the intersection of all currently pushed * clip rects. Clip rects are in DIPs. */ set_rect(&rect, 0.0f, 0.0f, 1280.0f, 80.0f); ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED); set_rect(&rect, 0.0f, 0.0f, 426.0f, 240.0f); ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED); set_color(&color, 0.0f, 1.0f, 0.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); ID2D1RenderTarget_PopAxisAlignedClip(rt); ID2D1RenderTarget_PopAxisAlignedClip(rt); ID2D1RenderTarget_SetDpi(rt, 0.0f, 0.0f); ID2D1RenderTarget_GetDpi(rt, &dpi_x, &dpi_y); ok(dpi_x == 96.0f, "Got unexpected dpi_x %.8e.\n", dpi_x); ok(dpi_y == 96.0f, "Got unexpected dpi_y %.8e.\n", dpi_y); /* Transformations apply to clip rects, the effective clip rect is the * (axis-aligned) bounding box of the transformed clip rect. */ set_point(&point, 320.0f, 240.0f); D2D1MakeRotateMatrix(30.0f, point, &matrix); ID2D1RenderTarget_SetTransform(rt, &matrix); set_rect(&rect, 215.0f, 208.0f, 425.0f, 272.0f); ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED); set_color(&color, 1.0f, 1.0f, 1.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); ID2D1RenderTarget_PopAxisAlignedClip(rt); /* Transformations are applied when pushing the clip rect, transformations * set afterwards have no effect on the current clip rect. This includes * SetDpi(). */ ID2D1RenderTarget_SetTransform(rt, &identity); set_rect(&rect, 427.0f, 320.0f, 640.0f, 480.0f); ID2D1RenderTarget_PushAxisAlignedClip(rt, &rect, D2D1_ANTIALIAS_MODE_ALIASED); ID2D1RenderTarget_SetTransform(rt, &matrix); ID2D1RenderTarget_SetDpi(rt, 48.0f, 192.0f); set_color(&color, 1.0f, 0.0f, 0.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); ID2D1RenderTarget_PopAxisAlignedClip(rt); hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); ok(compare_surface(surface, "035a44d4198d6e422e9de6185b5b2c2bac5e33c9"), "Surface does not match.\n"); ID2D1RenderTarget_Release(rt); IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); ID3D10Device1_Release(device); DestroyWindow(window); }
static void test_bitmap_brush(void) { D2D1_BITMAP_INTERPOLATION_MODE interpolation_mode; D2D1_MATRIX_3X2_F matrix, tmp_matrix; D2D1_BITMAP_PROPERTIES bitmap_desc; ID2D1Bitmap *bitmap, *tmp_bitmap; D2D1_RECT_F src_rect, dst_rect; D2D1_EXTEND_MODE extend_mode; IDXGISwapChain *swapchain; ID2D1BitmapBrush *brush; ID2D1RenderTarget *rt; ID3D10Device1 *device; IDXGISurface *surface; D2D1_COLOR_F color; D2D1_SIZE_U size; ULONG refcount; float opacity; HWND window; HRESULT hr; static const DWORD bitmap_data[] = { 0xffff0000, 0xffffff00, 0xff00ff00, 0xff00ffff, 0xff0000ff, 0xffff00ff, 0xff000000, 0xff7f7f7f, 0xffffffff, 0xffffffff, 0xffffffff, 0xff000000, 0xffffffff, 0xff000000, 0xff000000, 0xff000000, }; if (!(device = create_device())) { skip("Failed to create device, skipping tests.\n"); return; } window = CreateWindowA("static", "d2d1_test", WS_OVERLAPPEDWINDOW | WS_VISIBLE, 0, 0, 640, 480, NULL, NULL, NULL, NULL); swapchain = create_swapchain(device, window, TRUE); hr = IDXGISwapChain_GetBuffer(swapchain, 0, &IID_IDXGISurface, (void **)&surface); ok(SUCCEEDED(hr), "Failed to get buffer, hr %#x.\n", hr); rt = create_render_target(surface); ok(!!rt, "Failed to create render target.\n"); ID2D1RenderTarget_SetDpi(rt, 192.0f, 48.0f); ID2D1RenderTarget_SetAntialiasMode(rt, D2D1_ANTIALIAS_MODE_ALIASED); set_size_u(&size, 4, 4); bitmap_desc.pixelFormat.format = DXGI_FORMAT_B8G8R8A8_UNORM; bitmap_desc.pixelFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; bitmap_desc.dpiX = 96.0f; bitmap_desc.dpiY = 96.0f; hr = ID2D1RenderTarget_CreateBitmap(rt, size, bitmap_data, 4 * sizeof(*bitmap_data), &bitmap_desc, &bitmap); ok(SUCCEEDED(hr), "Failed to create bitmap, hr %#x.\n", hr); /* Creating a brush with a NULL bitmap crashes on Vista, but works fine on * Windows 7+. */ hr = ID2D1RenderTarget_CreateBitmapBrush(rt, bitmap, NULL, NULL, &brush); ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr); ID2D1BitmapBrush_GetBitmap(brush, &tmp_bitmap); ok(tmp_bitmap == bitmap, "Got unexpected bitmap %p, expected %p.\n", tmp_bitmap, bitmap); ID2D1Bitmap_Release(tmp_bitmap); opacity = ID2D1BitmapBrush_GetOpacity(brush); ok(opacity == 1.0f, "Got unexpected opacity %.8e.\n", opacity); set_matrix_identity(&matrix); ID2D1BitmapBrush_GetTransform(brush, &tmp_matrix); ok(!memcmp(&tmp_matrix, &matrix, sizeof(matrix)), "Got unexpected matrix {%.8e, %.8e, %.8e, %.8e, %.8e, %.8e}.\n", tmp_matrix._11, tmp_matrix._12, tmp_matrix._21, tmp_matrix._22, tmp_matrix._31, tmp_matrix._32); extend_mode = ID2D1BitmapBrush_GetExtendModeX(brush); ok(extend_mode == D2D1_EXTEND_MODE_CLAMP, "Got unexpected extend mode %#x.\n", extend_mode); extend_mode = ID2D1BitmapBrush_GetExtendModeY(brush); ok(extend_mode == D2D1_EXTEND_MODE_CLAMP, "Got unexpected extend mode %#x.\n", extend_mode); interpolation_mode = ID2D1BitmapBrush_GetInterpolationMode(brush); ok(interpolation_mode == D2D1_BITMAP_INTERPOLATION_MODE_LINEAR, "Got unexpected interpolation mode %#x.\n", interpolation_mode); ID2D1BitmapBrush_Release(brush); hr = ID2D1RenderTarget_CreateBitmapBrush(rt, bitmap, NULL, NULL, &brush); ok(SUCCEEDED(hr), "Failed to create brush, hr %#x.\n", hr); set_matrix_identity(&matrix); translate_matrix(&matrix, 40.0f, 120.0f); scale_matrix(&matrix, 20.0f, 60.0f); ID2D1BitmapBrush_SetTransform(brush, &matrix); ID2D1BitmapBrush_SetInterpolationMode(brush, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR); ID2D1RenderTarget_BeginDraw(rt); set_color(&color, 0.0f, 0.0f, 1.0f, 1.0f); ID2D1RenderTarget_Clear(rt, &color); set_rect(&dst_rect, 40.0f, 120.0f, 120.0f, 360.0f); ID2D1RenderTarget_FillRectangle(rt, &dst_rect, (ID2D1Brush *)brush); set_matrix_identity(&matrix); scale_matrix(&matrix, 0.5f, 2.0f); translate_matrix(&matrix, 320.0f, 240.0f); rotate_matrix(&matrix, M_PI / 4.0f); ID2D1RenderTarget_SetTransform(rt, &matrix); set_matrix_identity(&matrix); translate_matrix(&matrix, -80.0f, -60.0f); scale_matrix(&matrix, 40.0f, 30.0f); ID2D1BitmapBrush_SetTransform(brush, &matrix); ID2D1BitmapBrush_SetOpacity(brush, 0.75f); set_rect(&dst_rect, -80.0f, -60.0f, 80.0f, 60.0f); ID2D1RenderTarget_FillRectangle(rt, &dst_rect, (ID2D1Brush *)brush); set_matrix_identity(&matrix); translate_matrix(&matrix, 200.0f, 120.0f); scale_matrix(&matrix, 20.0f, 60.0f); ID2D1RenderTarget_SetTransform(rt, &matrix); ID2D1RenderTarget_DrawBitmap(rt, bitmap, NULL, 0.25f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL); set_rect(&dst_rect, -4.0f, 12.0f, -8.0f, 8.0f); ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 0.75f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, NULL); set_rect(&dst_rect, 0.0f, 8.0f, 4.0f, 12.0f); set_rect(&src_rect, 2.0f, 1.0f, 4.0f, 3.0f); ID2D1RenderTarget_DrawBitmap(rt, bitmap, &dst_rect, 1.0f, D2D1_BITMAP_INTERPOLATION_MODE_NEAREST_NEIGHBOR, &src_rect); hr = ID2D1RenderTarget_EndDraw(rt, NULL, NULL); ok(SUCCEEDED(hr), "Failed to end draw, hr %#x.\n", hr); ok(compare_surface(surface, "393636185359a550d459e1e5f0e25411814f724c"), "Surface does not match.\n"); ID2D1BitmapBrush_Release(brush); refcount = ID2D1Bitmap_Release(bitmap); ok(!refcount, "Bitmap has %u references left.\n", refcount); ID2D1RenderTarget_Release(rt); IDXGISurface_Release(surface); IDXGISwapChain_Release(swapchain); ID3D10Device1_Release(device); DestroyWindow(window); }