From 7b02acd91e64159e836953d252af4c2427196e11 Mon Sep 17 00:00:00 2001 From: softworkz Date: Thu, 11 Jan 2024 02:36:23 +0100 Subject: [PATCH] CueStyler: Fix outline rendering of TimedTextCue elements --- dxaml/xcp/dxaml/lib/CueStyler.cpp | 37 +++++++++---------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/dxaml/xcp/dxaml/lib/CueStyler.cpp b/dxaml/xcp/dxaml/lib/CueStyler.cpp index 044096252f..8afb48ea5f 100644 --- a/dxaml/xcp/dxaml/lib/CueStyler.cpp +++ b/dxaml/xcp/dxaml/lib/CueStyler.cpp @@ -1436,44 +1436,29 @@ CCueStyler::CreateOutline(_In_ wmc::ITimedTextLine* pLine, wmc::TimedTextDouble thickness = {}; double fontSize = {}; - double offset = {}; + double outlineWidth = {}; IFC(CalculateFontSize(pStyle, &fontSize)); - IFC(pStyle->get_OutlineThickness(&thickness)); if (thickness.Unit == wmc::TimedTextUnit_Percentage) { - offset = (thickness.Value / 100) * fontSize; + outlineWidth = (thickness.Value / 100) * fontSize; } else { - offset = thickness.Value; + outlineWidth = thickness.Value; } - // Upper left - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, -offset)); - - // Upper center - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, -offset)); - - // Upper right - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, -offset)); - - // Left - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, 0)); - - // Right - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, 0)); - - // Lower left - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, -offset, offset)); - - // Lower center - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, 0, offset)); + const int iterations = 32; + for (int i = 0; i < iterations; ++i) + { + double fraction = static_cast(i) / iterations; + double offsetX = std::sin(fraction * 2 * M_PI) * outlineWidth; + double offsetY = std::cos(fraction * 2 * M_PI) * outlineWidth; - // Lower right - IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offset, offset)); + IFC(CreateOutlineHelper(pLine, pStyle, pRegion, pCueElement, offsetX, offsetY)); + } Cleanup: return hr;