From: Giovanni Mascellani giovanni@mascellani.eu
--- dlls/d2d1/Makefile.in | 2 +- dlls/d2d1/device.c | 733 +++++++++++++----------------------------- 2 files changed, 232 insertions(+), 503 deletions(-)
diff --git a/dlls/d2d1/Makefile.in b/dlls/d2d1/Makefile.in index 4378350c129..c8adeaf6fec 100644 --- a/dlls/d2d1/Makefile.in +++ b/dlls/d2d1/Makefile.in @@ -1,6 +1,6 @@ MODULE = d2d1.dll IMPORTLIB = d2d1 -IMPORTS = d3d10_1 dxguid uuid gdi32 user32 advapi32 +IMPORTS = d3d10_1 dxguid uuid gdi32 user32 advapi32 d3dcompiler DELAYIMPORTS = dwrite xmllite ole32
SOURCES = \ diff --git a/dlls/d2d1/device.c b/dlls/d2d1/device.c index 505bdc8c00e..87ad77cf025 100644 --- a/dlls/d2d1/device.c +++ b/dlls/d2d1/device.c @@ -17,6 +17,7 @@ */
#include "d2d1_private.h" +#include <d3dcompiler.h>
WINE_DEFAULT_DEBUG_CHANNEL(d2d);
@@ -3230,107 +3231,54 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, {"POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 8, D3D11_INPUT_PER_VERTEX_DATA, 0}, }; - static const DWORD vs_code_outline[] = - { -#if 0 - float3x2 transform_geometry; - float stroke_width; - float4 transform_rtx; - float4 transform_rty; - - struct output - { - float2 p : WORLD_POSITION; - float4 b : BEZIER; - nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; - float4 position : SV_POSITION; - }; - - /* The lines PₚᵣₑᵥP₀ and P₀Pₙₑₓₜ, both offset by ±½w, intersect each other at: - * - * Pᵢ = P₀ ± w · ½q⃑ᵢ. - * - * Where: - * - * q⃑ᵢ = q̂ₚᵣₑᵥ⊥ + tan(½θ) · -q̂ₚᵣₑᵥ - * θ = ∠PₚᵣₑᵥP₀Pₙₑₓₜ - * q⃑ₚᵣₑᵥ = P₀ - Pₚᵣₑᵥ */ - void main(float2 position : POSITION, float2 prev : PREV, float2 next : NEXT, out struct output o) - { - float2 q_prev, q_next, v_p, q_i; - float2x2 geom; - float l; - - o.stroke_transform = float2x2(transform_rtx.xy, transform_rty.xy) * stroke_width * 0.5f; - - geom = float2x2(transform_geometry._11_21, transform_geometry._12_22); - q_prev = normalize(mul(geom, prev)); - q_next = normalize(mul(geom, next)); - - /* tan(½θ) = sin(θ) / (1 + cos(θ)) - * = (q̂ₚᵣₑᵥ⊥ · q̂ₙₑₓₜ) / (1 + (q̂ₚᵣₑᵥ · q̂ₙₑₓₜ)) */ - v_p = float2(-q_prev.y, q_prev.x); - l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next)); - q_i = l * q_prev + v_p; - - o.b = float4(0.0, 0.0, 0.0, 0.0); - - o.p = mul(float3(position, 1.0f), transform_geometry) + stroke_width * 0.5f * q_i; - position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f)) - * float2(transform_rtx.w, transform_rty.w); - o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f); - } -#endif - 0x43425844, 0xfb16cd75, 0xf5ec3e80, 0xceacf250, 0x91d29d18, 0x00000001, 0x00000608, 0x00000003, - 0x0000002c, 0x00000098, 0x00000154, 0x4e475349, 0x00000064, 0x00000003, 0x00000008, 0x00000050, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000059, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x0000005e, 0x00000000, 0x00000000, 0x00000003, 0x00000002, - 0x00000303, 0x49534f50, 0x4e4f4954, 0x45525000, 0x454e0056, 0xab005458, 0x4e47534f, 0x000000b4, - 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000c03, - 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, 0x00000096, 0x00000000, - 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001, 0x00000000, 0x00000003, - 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003, 0x00000004, 0x0000000f, - 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, 0x454b4f52, 0x4152545f, - 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853, 0x000004ac, 0x00010040, - 0x0000012b, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f, 0x00101032, 0x00000000, - 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, 0x00000002, 0x03000065, 0x00102032, - 0x00000000, 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102032, 0x00000002, 0x03000065, - 0x00102032, 0x00000003, 0x04000067, 0x001020f2, 0x00000004, 0x00000001, 0x02000068, 0x00000003, - 0x0800000f, 0x00100012, 0x00000000, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002, - 0x0800000f, 0x00100022, 0x00000000, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002, - 0x0700000f, 0x00100042, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000000, 0x05000044, - 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000000, 0x00100aa6, - 0x00000000, 0x00100046, 0x00000000, 0x0800000f, 0x00100012, 0x00000001, 0x00208046, 0x00000000, - 0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100022, 0x00000001, 0x00208046, 0x00000000, - 0x00000001, 0x00101046, 0x00000001, 0x0700000f, 0x00100042, 0x00000000, 0x00100046, 0x00000001, - 0x00100046, 0x00000001, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, 0x07000038, - 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000001, 0x06000036, 0x001000c2, - 0x00000001, 0x80100556, 0x00000041, 0x00000001, 0x0700000f, 0x00100042, 0x00000000, 0x00100a26, - 0x00000001, 0x00100046, 0x00000000, 0x0700000f, 0x00100012, 0x00000000, 0x00100046, 0x00000001, - 0x00100046, 0x00000000, 0x07000000, 0x00100012, 0x00000000, 0x0010000a, 0x00000000, 0x00004001, - 0x3f800000, 0x0800000e, 0x00100012, 0x00000000, 0x8010002a, 0x00000041, 0x00000000, 0x0010000a, - 0x00000000, 0x09000032, 0x00100032, 0x00000000, 0x00100006, 0x00000000, 0x00100046, 0x00000001, - 0x00100f36, 0x00000001, 0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001, - 0x00004001, 0x3f000000, 0x05000036, 0x00100032, 0x00000001, 0x00101046, 0x00000000, 0x05000036, - 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000002, 0x00100246, - 0x00000001, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00100022, 0x00000002, 0x00100246, - 0x00000001, 0x00208246, 0x00000000, 0x00000001, 0x09000032, 0x00100032, 0x00000000, 0x00100aa6, - 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x05000036, 0x00102032, 0x00000000, - 0x00100046, 0x00000000, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, - 0x00000000, 0x00000000, 0x06000036, 0x00100032, 0x00000001, 0x00208046, 0x00000000, 0x00000002, - 0x06000036, 0x001000c2, 0x00000001, 0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2, - 0x00000001, 0x00100e46, 0x00000001, 0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2, - 0x00000001, 0x00100e46, 0x00000001, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, - 0x05000036, 0x00102032, 0x00000002, 0x00100086, 0x00000001, 0x05000036, 0x00102032, 0x00000003, - 0x001005d6, 0x00000001, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x08000010, - 0x00100082, 0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000000, 0x08000010, - 0x00100012, 0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000000, 0x08000038, - 0x00100022, 0x00000000, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, - 0x00100012, 0x00000000, 0x0010003a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, - 0x00102032, 0x00000004, 0x00100046, 0x00000000, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, - 0x00000000, 0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, - 0x3f800000, 0x0100003e, - }; + static const char vs_code_outline[] = + "float3x2 transform_geometry;\n" + "float stroke_width;\n" + "float4 transform_rtx;\n" + "float4 transform_rty;\n" + "\n" + "struct output\n" + "{\n" + " float2 p : WORLD_POSITION;\n" + " float4 b : BEZIER;\n" + " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n" + " float4 position : SV_POSITION;\n" + "};\n" + "\n" + "/* The lines PₚᵣₑᵥP₀ and P₀Pₙₑₓₜ, both offset by ±½w, intersect each other at:\n" + " *\n" + " * Pᵢ = P₀ ± w · ½q⃑ᵢ.\n" + " *\n" + " * Where:\n" + " *\n" + " * q⃑ᵢ = q̂ₚᵣₑᵥ⊥ + tan(½θ) · -q̂ₚᵣₑᵥ\n" + " * θ = ∠PₚᵣₑᵥP₀Pₙₑₓₜ\n" + " * q⃑ₚᵣₑᵥ = P₀ - Pₚᵣₑᵥ */\n" + "void main(float2 position : POSITION, float2 prev : PREV, float2 next : NEXT, out struct output o)\n" + "{\n" + " float2 q_prev, q_next, v_p, q_i;\n" + " float2x2 geom;\n" + " float l;\n" + "\n" + " o.stroke_transform = float2x2(transform_rtx.xy, transform_rty.xy) * stroke_width * 0.5f;\n" + "\n" + " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n" + " q_prev = normalize(mul(geom, prev));\n" + " q_next = normalize(mul(geom, next));\n" + "\n" + " /* tan(½θ) = sin(θ) / (1 + cos(θ))\n" + " * = (q̂ₚᵣₑᵥ⊥ · q̂ₙₑₓₜ) / (1 + (q̂ₚᵣₑᵥ · q̂ₙₑₓₜ)) */\n" + " v_p = float2(-q_prev.y, q_prev.x);\n" + " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n" + " q_i = l * q_prev + v_p;\n" + "\n" + " o.b = float4(0.0, 0.0, 0.0, 0.0);\n" + "\n" + " o.p = mul(float3(position, 1.0f), transform_geometry) + stroke_width * 0.5f * q_i;\n" + " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n" + " * float2(transform_rtx.w, transform_rty.w);\n" + " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n" + "}\n"; /* ⎡p0.x p0.y 1⎤ * A = ⎢p1.x p1.y 1⎥ * ⎣p2.x p2.y 1⎦ @@ -3348,160 +3296,68 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, * A'T = B' * T = A'⁻¹B' */ - static const DWORD vs_code_bezier_outline[] = - { -#if 0 - float3x2 transform_geometry; - float stroke_width; - float4 transform_rtx; - float4 transform_rty; - - struct output - { - float2 p : WORLD_POSITION; - float4 b : BEZIER; - nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; - float4 position : SV_POSITION; - }; - - void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2, - float2 prev : PREV, float2 next : NEXT, out struct output o) - { - float2 q_prev, q_next, v_p, q_i, p; - float2x2 geom, rt; - float l; - - geom = float2x2(transform_geometry._11_21, transform_geometry._12_22); - rt = float2x2(transform_rtx.xy, transform_rty.xy); - o.stroke_transform = rt * stroke_width * 0.5f; - - p = mul(geom, position); - p0 = mul(geom, p0); - p1 = mul(geom, p1); - p2 = mul(geom, p2); - - p -= p0; - p1 -= p0; - p2 -= p0; - - q_prev = normalize(mul(geom, prev)); - q_next = normalize(mul(geom, next)); - - v_p = float2(-q_prev.y, q_prev.x); - l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next)); - q_i = l * q_prev + v_p; - p += 0.5f * stroke_width * q_i; - - v_p = mul(rt, p2); - v_p = normalize(float2(-v_p.y, v_p.x)); - if (abs(dot(mul(rt, p1), v_p)) < 1.0f) - { - o.b.xzw = float3(0.0f, 0.0f, 0.0f); - o.b.y = dot(mul(rt, p), v_p); - } - else - { - o.b.zw = sign(dot(mul(rt, p1), v_p)) * v_p; - v_p = -float2(-p.y, p.x) / dot(float2(-p1.y, p1.x), p2); - o.b.x = dot(v_p, p1 - 0.5f * p2); - o.b.y = dot(v_p, p1); - } - - o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i; - position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f)) - * float2(transform_rtx.w, transform_rty.w); - o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f); - } -#endif - 0x43425844, 0x356a0c5f, 0x8e4ba153, 0xe52cf793, 0xa6b774ea, 0x00000001, 0x00000afc, 0x00000003, - 0x0000002c, 0x000000e4, 0x000001a0, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x000000a1, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a1, 0x00000001, 0x00000000, 0x00000003, 0x00000002, - 0x00000303, 0x000000a1, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x000000a3, - 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000303, 0x000000a8, 0x00000000, 0x00000000, - 0x00000003, 0x00000005, 0x00000303, 0x49534f50, 0x4e4f4954, 0x50005000, 0x00564552, 0x5458454e, - 0xababab00, 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, - 0x00000003, 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, - 0x0000000f, 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, - 0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, - 0x00000003, 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, - 0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, - 0x52444853, 0x00000954, 0x00010040, 0x00000255, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, - 0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, - 0x00000002, 0x0300005f, 0x00101032, 0x00000003, 0x0300005f, 0x00101032, 0x00000004, 0x0300005f, - 0x00101032, 0x00000005, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, - 0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2, - 0x00000004, 0x00000001, 0x02000068, 0x00000006, 0x0800000f, 0x00100012, 0x00000000, 0x00208046, - 0x00000000, 0x00000000, 0x00101046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000, 0x00208046, - 0x00000000, 0x00000001, 0x00101046, 0x00000005, 0x0700000f, 0x00100042, 0x00000000, 0x00100046, - 0x00000000, 0x00100046, 0x00000000, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, - 0x07000038, 0x00100032, 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x0800000f, - 0x00100012, 0x00000001, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000004, 0x0800000f, - 0x00100022, 0x00000001, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000004, 0x0700000f, - 0x00100042, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000001, 0x05000044, 0x00100042, - 0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, - 0x00100046, 0x00000001, 0x06000036, 0x001000c2, 0x00000001, 0x80100556, 0x00000041, 0x00000001, - 0x0700000f, 0x00100042, 0x00000000, 0x00100a26, 0x00000001, 0x00100046, 0x00000000, 0x0700000f, - 0x00100012, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000000, 0x07000000, 0x00100012, - 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0800000e, 0x00100012, 0x00000000, - 0x8010002a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100032, 0x00000000, - 0x00100006, 0x00000000, 0x00100046, 0x00000001, 0x00100f36, 0x00000001, 0x05000036, 0x00100032, - 0x00000001, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, - 0x08000010, 0x00100012, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000, - 0x08000010, 0x00100022, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001, - 0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001, 0x00004001, 0x3f000000, - 0x09000032, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, - 0x00000002, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x0800000f, 0x00100012, - 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0800000f, 0x00100022, - 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000000, 0x0800000f, 0x00100012, - 0x00000003, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100022, - 0x00000003, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000001, 0x08000000, 0x00100032, - 0x00000002, 0x00100046, 0x00000002, 0x80100046, 0x00000041, 0x00000003, 0x09000032, 0x00100032, - 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0800000f, - 0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000002, 0x00100046, 0x00000000, 0x0800000f, - 0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000003, 0x00100046, 0x00000000, 0x0800000f, - 0x00100012, 0x00000004, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000003, 0x0800000f, - 0x00100022, 0x00000004, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000003, 0x08000000, - 0x001000c2, 0x00000002, 0x80100406, 0x00000041, 0x00000003, 0x00100406, 0x00000004, 0x0800000f, - 0x00100082, 0x00000000, 0x00208046, 0x00000000, 0x00000003, 0x00100ae6, 0x00000002, 0x06000036, - 0x00100042, 0x00000003, 0x8010003a, 0x00000041, 0x00000000, 0x0800000f, 0x00100082, 0x00000003, - 0x00208046, 0x00000000, 0x00000002, 0x00100ae6, 0x00000002, 0x0700000f, 0x00100082, 0x00000000, - 0x00100ae6, 0x00000003, 0x00100ae6, 0x00000003, 0x05000044, 0x00100082, 0x00000000, 0x0010003a, - 0x00000000, 0x07000038, 0x001000c2, 0x00000003, 0x00100ff6, 0x00000000, 0x00100ea6, 0x00000003, - 0x0700000f, 0x00100022, 0x00000004, 0x00100046, 0x00000002, 0x00100ae6, 0x00000003, 0x06000036, - 0x00100042, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, 0x0800000f, 0x00100012, 0x00000002, - 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002, 0x0800000f, 0x00100022, 0x00000002, - 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002, 0x08000000, 0x00100032, 0x00000005, - 0x80100046, 0x00000041, 0x00000003, 0x00100046, 0x00000002, 0x06000036, 0x00100042, 0x00000005, - 0x8010001a, 0x00000041, 0x00000005, 0x0700000f, 0x00100022, 0x00000000, 0x00100a26, 0x00000005, - 0x00100ae6, 0x00000002, 0x0d000032, 0x00100032, 0x00000002, 0x80100ae6, 0x00000041, 0x00000002, - 0x00004002, 0x3f000000, 0x3f000000, 0x00000000, 0x00000000, 0x00100046, 0x00000005, 0x0800000e, - 0x00100032, 0x00000000, 0x80100a26, 0x00000041, 0x00000000, 0x00100556, 0x00000000, 0x0700000f, - 0x00100012, 0x00000002, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0700000f, 0x00100022, - 0x00000002, 0x00100046, 0x00000000, 0x00100046, 0x00000005, 0x0800000f, 0x00100012, 0x00000000, - 0x00208046, 0x00000000, 0x00000002, 0x00100046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000, - 0x00208046, 0x00000000, 0x00000003, 0x00100046, 0x00000005, 0x0700000f, 0x00100012, 0x00000000, - 0x00100046, 0x00000000, 0x00100ae6, 0x00000003, 0x07000031, 0x00100022, 0x00000000, 0x00004001, - 0x00000000, 0x0010000a, 0x00000000, 0x07000031, 0x00100042, 0x00000000, 0x0010000a, 0x00000000, - 0x00004001, 0x00000000, 0x08000031, 0x00100012, 0x00000000, 0x8010000a, 0x00000081, 0x00000000, - 0x00004001, 0x3f800000, 0x0800001e, 0x00100022, 0x00000000, 0x8010001a, 0x00000041, 0x00000000, - 0x0010002a, 0x00000000, 0x0500002b, 0x00100022, 0x00000000, 0x0010001a, 0x00000000, 0x07000038, - 0x001000c2, 0x00000002, 0x00100ea6, 0x00000003, 0x00100556, 0x00000000, 0x08000036, 0x001000d2, - 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x09000037, 0x001020f2, - 0x00000001, 0x00100006, 0x00000000, 0x00100e46, 0x00000004, 0x00100e46, 0x00000002, 0x06000036, - 0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x06000036, 0x001000c2, 0x00000000, - 0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, - 0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2, 0x00000000, 0x00100e46, 0x00000000, - 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x05000036, 0x00102032, 0x00000002, - 0x00100086, 0x00000000, 0x05000036, 0x00102032, 0x00000003, 0x001005d6, 0x00000000, 0x05000036, - 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000000, 0x00208246, - 0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022, 0x00000000, 0x00208246, - 0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022, 0x00000001, 0x0010001a, - 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012, 0x00000001, 0x0010000a, - 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032, 0x00000004, 0x00100046, - 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, 0x001020c2, - 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, - }; + static const char vs_code_bezier_outline[] = + "float3x2 transform_geometry;\n" + "float stroke_width;\n" + "float4 transform_rtx;\n" + "float4 transform_rty;\n" + "\n" + "struct output\n" + "{\n" + " float2 p : WORLD_POSITION;\n" + " float4 b : BEZIER;\n" + " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n" + " float4 position : SV_POSITION;\n" + "};\n" + "\n" + "void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,\n" + " float2 prev : PREV, float2 next : NEXT, out struct output o)\n" + "{\n" + " float2 q_prev, q_next, v_p, q_i, p;\n" + " float2x2 geom, rt;\n" + " float l;\n" + "\n" + " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n" + " rt = float2x2(transform_rtx.xy, transform_rty.xy);\n" + " o.stroke_transform = rt * stroke_width * 0.5f;\n" + "\n" + " p = mul(geom, position);\n" + " p0 = mul(geom, p0);\n" + " p1 = mul(geom, p1);\n" + " p2 = mul(geom, p2);\n" + "\n" + " p -= p0;\n" + " p1 -= p0;\n" + " p2 -= p0;\n" + "\n" + " q_prev = normalize(mul(geom, prev));\n" + " q_next = normalize(mul(geom, next));\n" + "\n" + " v_p = float2(-q_prev.y, q_prev.x);\n" + " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n" + " q_i = l * q_prev + v_p;\n" + " p += 0.5f * stroke_width * q_i;\n" + "\n" + " v_p = mul(rt, p2);\n" + " v_p = normalize(float2(-v_p.y, v_p.x));\n" + " if (abs(dot(mul(rt, p1), v_p)) < 1.0f)\n" + " {\n" + " o.b.xzw = float3(0.0f, 0.0f, 0.0f);\n" + " o.b.y = dot(mul(rt, p), v_p);\n" + " }\n" + " else\n" + " {\n" + " o.b.zw = sign(dot(mul(rt, p1), v_p)) * v_p;\n" + " v_p = -float2(-p.y, p.x) / dot(float2(-p1.y, p1.x), p2);\n" + " o.b.x = dot(v_p, p1 - 0.5f * p2);\n" + " o.b.y = dot(v_p, p1);\n" + " }\n" + "\n" + " o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;\n" + " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n" + " * float2(transform_rtx.w, transform_rty.w);\n" + " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n" + "}\n"; /* ⎡p0.x p0.y 1⎤ * A = ⎢p1.x p1.y 1⎥ * ⎣p2.x p2.y 1⎦ @@ -3519,244 +3375,103 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, * A'T = B' * T = A'⁻¹B' = (B'⁻¹A')⁻¹ */ - static const DWORD vs_code_arc_outline[] = - { -#if 0 - float3x2 transform_geometry; - float stroke_width; - float4 transform_rtx; - float4 transform_rty; - - struct output - { - float2 p : WORLD_POSITION; - float4 b : BEZIER; - nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; - float4 position : SV_POSITION; - }; - - void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2, - float2 prev : PREV, float2 next : NEXT, out struct output o) - { - float2 q_prev, q_next, v_p, q_i, p; - float2x2 geom, rt, p_inv; - float l; - float a; - float2 bc; - - geom = float2x2(transform_geometry._11_21, transform_geometry._12_22); - rt = float2x2(transform_rtx.xy, transform_rty.xy); - o.stroke_transform = rt * stroke_width * 0.5f; - - p = mul(geom, position); - p0 = mul(geom, p0); - p1 = mul(geom, p1); - p2 = mul(geom, p2); - - p -= p0; - p1 -= p0; - p2 -= p0; - - q_prev = normalize(mul(geom, prev)); - q_next = normalize(mul(geom, next)); - - v_p = float2(-q_prev.y, q_prev.x); - l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next)); - q_i = l * q_prev + v_p; - p += 0.5f * stroke_width * q_i; - - p_inv = float2x2(p1.y, -p1.x, p2.y - p1.y, p1.x - p2.x) / (p1.x * p2.y - p2.x * p1.y); - o.b.xy = mul(p_inv, p) + float2(1.0f, 0.0f); - o.b.zw = 0.0f; - - o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i; - position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f)) - * float2(transform_rtx.w, transform_rty.w); - o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f); - } -#endif - 0x43425844, 0xde1911bf, 0xfff8c893, 0xb0bfc24d, 0x78c9bbc4, 0x00000001, 0x00000924, 0x00000003, - 0x0000002c, 0x000000e4, 0x000001a0, 0x4e475349, 0x000000b0, 0x00000006, 0x00000008, 0x00000098, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x000000a1, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000303, 0x000000a1, 0x00000001, 0x00000000, 0x00000003, 0x00000002, - 0x00000303, 0x000000a1, 0x00000002, 0x00000000, 0x00000003, 0x00000003, 0x00000303, 0x000000a3, - 0x00000000, 0x00000000, 0x00000003, 0x00000004, 0x00000303, 0x000000a8, 0x00000000, 0x00000000, - 0x00000003, 0x00000005, 0x00000303, 0x49534f50, 0x4e4f4954, 0x50005000, 0x00564552, 0x5458454e, - 0xababab00, 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, - 0x00000003, 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, - 0x0000000f, 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, - 0x00000001, 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, - 0x00000003, 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, - 0x54530052, 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, - 0x52444853, 0x0000077c, 0x00010040, 0x000001df, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, - 0x0300005f, 0x00101032, 0x00000000, 0x0300005f, 0x00101032, 0x00000001, 0x0300005f, 0x00101032, - 0x00000002, 0x0300005f, 0x00101032, 0x00000003, 0x0300005f, 0x00101032, 0x00000004, 0x0300005f, - 0x00101032, 0x00000005, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, - 0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2, - 0x00000004, 0x00000001, 0x02000068, 0x00000004, 0x0800000f, 0x00100012, 0x00000000, 0x00208046, - 0x00000000, 0x00000000, 0x00101046, 0x00000005, 0x0800000f, 0x00100022, 0x00000000, 0x00208046, - 0x00000000, 0x00000001, 0x00101046, 0x00000005, 0x0700000f, 0x00100042, 0x00000000, 0x00100046, - 0x00000000, 0x00100046, 0x00000000, 0x05000044, 0x00100042, 0x00000000, 0x0010002a, 0x00000000, - 0x07000038, 0x00100032, 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x0800000f, - 0x00100012, 0x00000001, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000004, 0x0800000f, - 0x00100022, 0x00000001, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000004, 0x0700000f, - 0x00100042, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000001, 0x05000044, 0x00100042, - 0x00000000, 0x0010002a, 0x00000000, 0x07000038, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, - 0x00100046, 0x00000001, 0x06000036, 0x001000c2, 0x00000001, 0x80100556, 0x00000041, 0x00000001, - 0x0700000f, 0x00100042, 0x00000000, 0x00100a26, 0x00000001, 0x00100046, 0x00000000, 0x0700000f, - 0x00100012, 0x00000000, 0x00100046, 0x00000001, 0x00100046, 0x00000000, 0x07000000, 0x00100012, - 0x00000000, 0x0010000a, 0x00000000, 0x00004001, 0x3f800000, 0x0800000e, 0x00100012, 0x00000000, - 0x8010002a, 0x00000041, 0x00000000, 0x0010000a, 0x00000000, 0x09000032, 0x00100032, 0x00000000, - 0x00100006, 0x00000000, 0x00100046, 0x00000001, 0x00100f36, 0x00000001, 0x05000036, 0x00100032, - 0x00000001, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, - 0x08000010, 0x00100012, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000000, - 0x08000010, 0x00100022, 0x00000002, 0x00100246, 0x00000001, 0x00208246, 0x00000000, 0x00000001, - 0x08000038, 0x00100042, 0x00000000, 0x0020803a, 0x00000000, 0x00000001, 0x00004001, 0x3f000000, - 0x09000032, 0x00100032, 0x00000001, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, - 0x00000002, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x0800000f, 0x00100012, - 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000000, 0x0800000f, 0x00100022, - 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000000, 0x0800000f, 0x00100022, - 0x00000003, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000001, 0x0800000f, 0x00100012, - 0x00000003, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000001, 0x08000000, 0x00100032, - 0x00000002, 0x00100046, 0x00000002, 0x80100516, 0x00000041, 0x00000003, 0x09000032, 0x00100032, - 0x00000000, 0x00100aa6, 0x00000000, 0x00100046, 0x00000000, 0x00100046, 0x00000002, 0x0800000f, - 0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000003, 0x0800000f, - 0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000003, 0x08000000, - 0x001000c2, 0x00000000, 0x80100406, 0x00000041, 0x00000003, 0x00100406, 0x00000002, 0x0800000f, - 0x00100022, 0x00000002, 0x00208046, 0x00000000, 0x00000000, 0x00101046, 0x00000002, 0x0800000f, - 0x00100012, 0x00000002, 0x00208046, 0x00000000, 0x00000001, 0x00101046, 0x00000002, 0x08000000, - 0x00100032, 0x00000002, 0x80100046, 0x00000041, 0x00000003, 0x00100046, 0x00000002, 0x07000038, - 0x00100082, 0x00000001, 0x0010003a, 0x00000000, 0x0010000a, 0x00000002, 0x0a000032, 0x00100082, - 0x00000001, 0x0010001a, 0x00000002, 0x0010002a, 0x00000000, 0x8010003a, 0x00000041, 0x00000001, - 0x08000000, 0x00100042, 0x00000003, 0x0010002a, 0x00000000, 0x8010000a, 0x00000041, 0x00000002, - 0x08000000, 0x00100082, 0x00000003, 0x8010003a, 0x00000041, 0x00000000, 0x0010001a, 0x00000002, - 0x0a000038, 0x00100032, 0x00000003, 0x00100046, 0x00000002, 0x00004002, 0x3f800000, 0xbf800000, - 0x00000000, 0x00000000, 0x0700000e, 0x001000f2, 0x00000002, 0x00100e46, 0x00000003, 0x00100ff6, - 0x00000001, 0x0700000f, 0x00100012, 0x00000002, 0x00100046, 0x00000002, 0x00100046, 0x00000000, - 0x0700000f, 0x00100022, 0x00000002, 0x00100ae6, 0x00000002, 0x00100046, 0x00000000, 0x0a000000, - 0x00102032, 0x00000001, 0x00100046, 0x00000002, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, - 0x00000000, 0x08000036, 0x001020c2, 0x00000001, 0x00004002, 0x00000000, 0x00000000, 0x00000000, - 0x00000000, 0x06000036, 0x00100032, 0x00000000, 0x00208046, 0x00000000, 0x00000002, 0x06000036, - 0x001000c2, 0x00000000, 0x00208406, 0x00000000, 0x00000003, 0x08000038, 0x001000f2, 0x00000000, - 0x00100e46, 0x00000000, 0x00208ff6, 0x00000000, 0x00000001, 0x0a000038, 0x001000f2, 0x00000000, - 0x00100e46, 0x00000000, 0x00004002, 0x3f000000, 0x3f000000, 0x3f000000, 0x3f000000, 0x05000036, - 0x00102032, 0x00000002, 0x00100086, 0x00000000, 0x05000036, 0x00102032, 0x00000003, 0x001005d6, - 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, - 0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022, - 0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022, - 0x00000001, 0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012, - 0x00000001, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032, - 0x00000004, 0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, - 0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, - 0x0100003e, - }; - static const DWORD vs_code_triangle[] = - { -#if 0 - float3x2 transform_geometry; - float4 transform_rtx; - float4 transform_rty; - - struct output - { - float2 p : WORLD_POSITION; - float4 b : BEZIER; - nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; - float4 position : SV_POSITION; - }; - - void main(float2 position : POSITION, out struct output o) - { - o.p = mul(float3(position, 1.0f), transform_geometry); - o.b = float4(1.0, 0.0, 1.0, 1.0); - o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0); - position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f)) - * float2(transform_rtx.w, transform_rty.w); - o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f); - } -#endif - 0x43425844, 0xda43bf17, 0x06e6d155, 0xdbce2ae5, 0x8aed6fd8, 0x00000001, 0x0000034c, 0x00000003, - 0x0000002c, 0x00000060, 0x0000011c, 0x4e475349, 0x0000002c, 0x00000001, 0x00000008, 0x00000020, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x49534f50, 0x4e4f4954, 0xababab00, - 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003, - 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, - 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001, - 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003, - 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, - 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853, - 0x00000228, 0x00010040, 0x0000008a, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f, - 0x00101032, 0x00000000, 0x03000065, 0x00102032, 0x00000000, 0x03000065, 0x001020f2, 0x00000001, - 0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, 0x00000003, 0x04000067, 0x001020f2, - 0x00000004, 0x00000001, 0x02000068, 0x00000002, 0x05000036, 0x00100032, 0x00000000, 0x00101046, - 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, - 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, 0x00000000, 0x08000010, 0x00100022, - 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, 0x00000001, 0x05000036, 0x00102032, - 0x00000000, 0x00100046, 0x00000001, 0x08000036, 0x001020f2, 0x00000001, 0x00004002, 0x3f800000, - 0x00000000, 0x3f800000, 0x3f800000, 0x08000036, 0x00102032, 0x00000002, 0x00004002, 0x3f800000, - 0x00000000, 0x00000000, 0x00000000, 0x08000036, 0x00102032, 0x00000003, 0x00004002, 0x00000000, - 0x3f800000, 0x00000000, 0x00000000, 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, - 0x08000010, 0x00100012, 0x00000000, 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001, - 0x08000010, 0x00100022, 0x00000000, 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001, - 0x08000038, 0x00100022, 0x00000001, 0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, - 0x08000038, 0x00100012, 0x00000001, 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, - 0x0a000000, 0x00102032, 0x00000004, 0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, - 0x00000000, 0x00000000, 0x08000036, 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, - 0x00000000, 0x3f800000, 0x0100003e, - }; - static const DWORD vs_code_curve[] = - { -#if 0 - float3x2 transform_geometry; - float4 transform_rtx; - float4 transform_rty; - - struct output - { - float2 p : WORLD_POSITION; - float4 b : BEZIER; - nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM; - float4 position : SV_POSITION; - }; - - void main(float2 position : POSITION, float3 texcoord : TEXCOORD0, out struct output o) - { - o.p = mul(float3(position, 1.0f), transform_geometry); - o.b = float4(texcoord, 1.0); - o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0); - position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f)) - * float2(transform_rtx.w, transform_rty.w); - o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f); - } -#endif - 0x43425844, 0xedb7472a, 0x2c2ea147, 0x36710079, 0xffc2e907, 0x00000001, 0x00000380, 0x00000003, - 0x0000002c, 0x00000080, 0x0000013c, 0x4e475349, 0x0000004c, 0x00000002, 0x00000008, 0x00000038, - 0x00000000, 0x00000000, 0x00000003, 0x00000000, 0x00000303, 0x00000041, 0x00000000, 0x00000000, - 0x00000003, 0x00000001, 0x00000707, 0x49534f50, 0x4e4f4954, 0x58455400, 0x524f4f43, 0xabab0044, - 0x4e47534f, 0x000000b4, 0x00000005, 0x00000008, 0x00000080, 0x00000000, 0x00000000, 0x00000003, - 0x00000000, 0x00000c03, 0x0000008f, 0x00000000, 0x00000000, 0x00000003, 0x00000001, 0x0000000f, - 0x00000096, 0x00000000, 0x00000000, 0x00000003, 0x00000002, 0x00000c03, 0x00000096, 0x00000001, - 0x00000000, 0x00000003, 0x00000003, 0x00000c03, 0x000000a7, 0x00000000, 0x00000001, 0x00000003, - 0x00000004, 0x0000000f, 0x4c524f57, 0x4f505f44, 0x49544953, 0x42004e4f, 0x45495a45, 0x54530052, - 0x454b4f52, 0x4152545f, 0x4f46534e, 0x53004d52, 0x4f505f56, 0x49544953, 0xab004e4f, 0x52444853, - 0x0000023c, 0x00010040, 0x0000008f, 0x04000059, 0x00208e46, 0x00000000, 0x00000004, 0x0300005f, - 0x00101032, 0x00000000, 0x0300005f, 0x00101072, 0x00000001, 0x03000065, 0x00102032, 0x00000000, - 0x03000065, 0x001020f2, 0x00000001, 0x03000065, 0x00102032, 0x00000002, 0x03000065, 0x00102032, - 0x00000003, 0x04000067, 0x001020f2, 0x00000004, 0x00000001, 0x02000068, 0x00000002, 0x05000036, - 0x00100032, 0x00000000, 0x00101046, 0x00000000, 0x05000036, 0x00100042, 0x00000000, 0x00004001, - 0x3f800000, 0x08000010, 0x00100012, 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, - 0x00000000, 0x08000010, 0x00100022, 0x00000001, 0x00100246, 0x00000000, 0x00208246, 0x00000000, - 0x00000001, 0x05000036, 0x00102032, 0x00000000, 0x00100046, 0x00000001, 0x05000036, 0x00102072, - 0x00000001, 0x00101246, 0x00000001, 0x05000036, 0x00102082, 0x00000001, 0x00004001, 0x3f800000, - 0x08000036, 0x00102032, 0x00000002, 0x00004002, 0x3f800000, 0x00000000, 0x00000000, 0x00000000, - 0x08000036, 0x00102032, 0x00000003, 0x00004002, 0x00000000, 0x3f800000, 0x00000000, 0x00000000, - 0x05000036, 0x00100042, 0x00000001, 0x00004001, 0x3f800000, 0x08000010, 0x00100012, 0x00000000, - 0x00208246, 0x00000000, 0x00000002, 0x00100246, 0x00000001, 0x08000010, 0x00100022, 0x00000000, - 0x00208246, 0x00000000, 0x00000003, 0x00100246, 0x00000001, 0x08000038, 0x00100022, 0x00000001, - 0x0010001a, 0x00000000, 0x0020803a, 0x00000000, 0x00000003, 0x08000038, 0x00100012, 0x00000001, - 0x0010000a, 0x00000000, 0x0020803a, 0x00000000, 0x00000002, 0x0a000000, 0x00102032, 0x00000004, - 0x00100046, 0x00000001, 0x00004002, 0xbf800000, 0x3f800000, 0x00000000, 0x00000000, 0x08000036, - 0x001020c2, 0x00000004, 0x00004002, 0x00000000, 0x00000000, 0x00000000, 0x3f800000, 0x0100003e, - }; + static const char vs_code_arc_outline[] = + "float3x2 transform_geometry;\n" + "float stroke_width;\n" + "float4 transform_rtx;\n" + "float4 transform_rty;\n" + "\n" + "struct output\n" + "{\n" + " float2 p : WORLD_POSITION;\n" + " float4 b : BEZIER;\n" + " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n" + " float4 position : SV_POSITION;\n" + "};\n" + "\n" + "void main(float2 position : POSITION, float2 p0 : P0, float2 p1 : P1, float2 p2 : P2,\n" + " float2 prev : PREV, float2 next : NEXT, out struct output o)\n" + "{\n" + " float2 q_prev, q_next, v_p, q_i, p;\n" + " float2x2 geom, rt, p_inv;\n" + " float l;\n" + " float a;\n" + " float2 bc;\n" + "\n" + " geom = float2x2(transform_geometry._11_21, transform_geometry._12_22);\n" + " rt = float2x2(transform_rtx.xy, transform_rty.xy);\n" + " o.stroke_transform = rt * stroke_width * 0.5f;\n" + "\n" + " p = mul(geom, position);\n" + " p0 = mul(geom, p0);\n" + " p1 = mul(geom, p1);\n" + " p2 = mul(geom, p2);\n" + "\n" + " p -= p0;\n" + " p1 -= p0;\n" + " p2 -= p0;\n" + "\n" + " q_prev = normalize(mul(geom, prev));\n" + " q_next = normalize(mul(geom, next));\n" + "\n" + " v_p = float2(-q_prev.y, q_prev.x);\n" + " l = -dot(v_p, q_next) / (1.0f + dot(q_prev, q_next));\n" + " q_i = l * q_prev + v_p;\n" + " p += 0.5f * stroke_width * q_i;\n" + "\n" + " p_inv = float2x2(p1.y, -p1.x, p2.y - p1.y, p1.x - p2.x) / (p1.x * p2.y - p2.x * p1.y);\n" + " o.b.xy = mul(p_inv, p) + float2(1.0f, 0.0f);\n" + " o.b.zw = 0.0f;\n" + "\n" + " o.p = mul(float3(position, 1.0f), transform_geometry) + 0.5f * stroke_width * q_i;\n" + " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n" + " * float2(transform_rtx.w, transform_rty.w);\n" + " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n" + "}\n"; + static const char vs_code_triangle[] = + "float3x2 transform_geometry;\n" + "float4 transform_rtx;\n" + "float4 transform_rty;\n" + "\n" + "struct output\n" + "{\n" + " float2 p : WORLD_POSITION;\n" + " float4 b : BEZIER;\n" + " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n" + " float4 position : SV_POSITION;\n" + "};\n" + "\n" + "void main(float2 position : POSITION, out struct output o)\n" + "{\n" + " o.p = mul(float3(position, 1.0f), transform_geometry);\n" + " o.b = float4(1.0, 0.0, 1.0, 1.0);\n" + " o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);\n" + " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n" + " * float2(transform_rtx.w, transform_rty.w);\n" + " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n" + "}\n"; + static const char vs_code_curve[] = + "float3x2 transform_geometry;\n" + "float4 transform_rtx;\n" + "float4 transform_rty;\n" + "\n" + "struct output\n" + "{\n" + " float2 p : WORLD_POSITION;\n" + " float4 b : BEZIER;\n" + " nointerpolation float2x2 stroke_transform : STROKE_TRANSFORM;\n" + " float4 position : SV_POSITION;\n" + "};\n" + "\n" + "void main(float2 position : POSITION, float3 texcoord : TEXCOORD0, out struct output o)\n" + "{\n" + " o.p = mul(float3(position, 1.0f), transform_geometry);\n" + " o.b = float4(texcoord, 1.0);\n" + " o.stroke_transform = float2x2(1.0, 0.0, 0.0, 1.0);\n" + " position = mul(float2x3(transform_rtx.xyz, transform_rty.xyz), float3(o.p, 1.0f))\n" + " * float2(transform_rtx.w, transform_rty.w);\n" + " o.position = float4(position + float2(-1.0f, 1.0f), 0.0f, 1.0f);\n" + "}\n"; static const DWORD ps_code[] = { #if 0 @@ -4224,21 +3939,22 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, enum d2d_shape_type shape_type; const D3D11_INPUT_ELEMENT_DESC *il_desc; unsigned int il_element_count; - const void *vs_code; + const char *name; + const char *vs_code; size_t vs_code_size; } shape_info[] = { {D2D_SHAPE_TYPE_OUTLINE, il_desc_outline, ARRAY_SIZE(il_desc_outline), - vs_code_outline, sizeof(vs_code_outline)}, + "outline", vs_code_outline, sizeof(vs_code_outline) - 1}, {D2D_SHAPE_TYPE_BEZIER_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline), - vs_code_bezier_outline, sizeof(vs_code_bezier_outline)}, + "bezier_outline", vs_code_bezier_outline, sizeof(vs_code_bezier_outline) - 1}, {D2D_SHAPE_TYPE_ARC_OUTLINE, il_desc_curve_outline, ARRAY_SIZE(il_desc_curve_outline), - vs_code_arc_outline, sizeof(vs_code_arc_outline)}, + "arc_outline", vs_code_arc_outline, sizeof(vs_code_arc_outline) - 1}, {D2D_SHAPE_TYPE_TRIANGLE, il_desc_triangle, ARRAY_SIZE(il_desc_triangle), - vs_code_triangle, sizeof(vs_code_triangle)}, + "triangle", vs_code_triangle, sizeof(vs_code_triangle) - 1}, {D2D_SHAPE_TYPE_CURVE, il_desc_curve, ARRAY_SIZE(il_desc_curve), - vs_code_curve, sizeof(vs_code_curve)}, + "curve", vs_code_curve, sizeof(vs_code_curve) - 1}, }; static const struct { @@ -4289,21 +4005,34 @@ static HRESULT d2d_device_context_init(struct d2d_device_context *render_target, for (i = 0; i < ARRAY_SIZE(shape_info); ++i) { const struct shape_info *si = &shape_info[i]; + ID3D10Blob *compiled; + + if (FAILED(hr = D3DCompile(si->vs_code, si->vs_code_size, si->name, NULL, NULL, + "main", "vs_4_0", 0, 0, &compiled, NULL))) + { + WARN("Failed to compile shader for shape type %#x, hr %#lx.\n", si->shape_type, hr); + goto err; + }
if (FAILED(hr = ID3D11Device1_CreateInputLayout(render_target->d3d_device, si->il_desc, si->il_element_count, - si->vs_code, si->vs_code_size, &render_target->shape_resources[si->shape_type].il))) + ID3D10Blob_GetBufferPointer(compiled), ID3D10Blob_GetBufferSize(compiled), + &render_target->shape_resources[si->shape_type].il))) { WARN("Failed to create input layout for shape type %#x, hr %#lx.\n", si->shape_type, hr); + ID3D10Blob_Release(compiled); goto err; }
- if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d_device, si->vs_code, - si->vs_code_size, NULL, &render_target->shape_resources[si->shape_type].vs))) + if (FAILED(hr = ID3D11Device1_CreateVertexShader(render_target->d3d_device, + ID3D10Blob_GetBufferPointer(compiled), ID3D10Blob_GetBufferSize(compiled), + NULL, &render_target->shape_resources[si->shape_type].vs))) { WARN("Failed to create vertex shader for shape type %#x, hr %#lx.\n", si->shape_type, hr); + ID3D10Blob_Release(compiled); goto err; }
+ ID3D10Blob_Release(compiled); }
buffer_desc.ByteWidth = sizeof(struct d2d_vs_cb);