Commit 23b3299c authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

usp10: Make the script cache accessible from a string analysis.

parent 140a610e
...@@ -159,7 +159,7 @@ typedef struct { ...@@ -159,7 +159,7 @@ typedef struct {
typedef struct { typedef struct {
BOOL invalid; BOOL invalid;
HDC hdc; ScriptCache *sc;
int cItems; int cItems;
int cMaxGlyphs; int cMaxGlyphs;
SCRIPT_ITEM* pItem; SCRIPT_ITEM* pItem;
...@@ -517,9 +517,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, ...@@ -517,9 +517,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
{ {
HRESULT hr; HRESULT hr;
StringAnalysis* analysis; StringAnalysis* analysis;
int numItemizedItems; int i, numItemizedItems = 255;
int i;
SCRIPT_CACHE* sc = 0;
TRACE("(%p,%p,%d,%d,%d,0x%x,%d,%p,%p,%p,%p,%p,%p)\n", TRACE("(%p,%p,%d,%d,%d,0x%x,%d,%p,%p,%p,%p,%p,%p)\n",
hdc, pString, cString, cGlyphs, iCharset, dwFlags, hdc, pString, cString, cGlyphs, iCharset, dwFlags,
...@@ -534,8 +532,6 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, ...@@ -534,8 +532,6 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
analysis = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, analysis = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(StringAnalysis)); sizeof(StringAnalysis));
analysis->hdc = hdc;
numItemizedItems = 255;
analysis->pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, analysis->pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
numItemizedItems*sizeof(SCRIPT_ITEM)+1); numItemizedItems*sizeof(SCRIPT_ITEM)+1);
...@@ -556,10 +552,10 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, ...@@ -556,10 +552,10 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
analysis->glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, analysis->glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof(StringGlyphs)*analysis->numItems); sizeof(StringGlyphs)*analysis->numItems);
sc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCRIPT_CACHE));
for(i=0; i<analysis->numItems; i++) for(i=0; i<analysis->numItems; i++)
{ {
SCRIPT_CACHE *sc = (SCRIPT_CACHE *)&analysis->sc;
int cChar = analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos; int cChar = analysis->pItem[i+1].iCharPos - analysis->pItem[i].iCharPos;
int numGlyphs = 1.5 * cChar + 16; int numGlyphs = 1.5 * cChar + 16;
WORD* glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WORD)*numGlyphs); WORD* glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WORD)*numGlyphs);
...@@ -587,10 +583,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc, ...@@ -587,10 +583,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC hdc,
analysis->glyphs[i].abc = abc; analysis->glyphs[i].abc = abc;
} }
HeapFree(GetProcessHeap(), 0, sc);
*pssa = analysis; *pssa = analysis;
return S_OK; return S_OK;
} }
...@@ -628,7 +621,6 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, ...@@ -628,7 +621,6 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
WORD *glyphs; WORD *glyphs;
int item, cnt, x; int item, cnt, x;
HRESULT hr; HRESULT hr;
SCRIPT_CACHE sc = 0;
TRACE("(%p,%d,%d,0x%1x,%p,%d,%d,%d)\n", TRACE("(%p,%d,%d,0x%1x,%p,%d,%d,%d)\n",
ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled); ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled);
...@@ -671,17 +663,15 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa, ...@@ -671,17 +663,15 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_STRING_ANALYSIS ssa,
cnt += analysis->glyphs[item].numGlyphs; /* point to the end of the copied text */ cnt += analysis->glyphs[item].numGlyphs; /* point to the end of the copied text */
} }
hr = ScriptTextOut(analysis->hdc, &sc, iX, iY, uOptions, prc, &analysis->pItem->a, hr = ScriptTextOut(analysis->sc->hdc, (SCRIPT_CACHE *)&analysis->sc, iX, iY,
NULL, 0, glyphs, cnt, analysis->glyphs->piAdvance, NULL, uOptions, prc, &analysis->pItem->a, NULL, 0, glyphs, cnt,
analysis->glyphs->pGoffset); analysis->glyphs->piAdvance, NULL, analysis->glyphs->pGoffset);
TRACE("ScriptTextOut hr=%08x\n", hr); TRACE("ScriptTextOut hr=%08x\n", hr);
/* /*
* Free the output buffer and script cache * Free the output buffer and script cache
*/ */
HeapFree(GetProcessHeap(), 0, glyphs); HeapFree(GetProcessHeap(), 0, glyphs);
ScriptFreeCache(&sc);
return hr; return hr;
} }
...@@ -1524,7 +1514,7 @@ const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa) ...@@ -1524,7 +1514,7 @@ const SIZE * WINAPI ScriptString_pSize(SCRIPT_STRING_ANALYSIS ssa)
* appropriate place so that we can just pass cached * appropriate place so that we can just pass cached
* values here. * values here.
*/ */
if (!GetTextMetricsW(analysis->hdc, &metric)) if (!GetTextMetricsW(analysis->sc->hdc, &metric))
{ {
HeapFree(GetProcessHeap(), 0, analysis->sz); HeapFree(GetProcessHeap(), 0, analysis->sz);
analysis->sz = NULL; analysis->sz = NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment