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

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jan 4 04:45:00 CST 2007


Module: wine
Branch: master
Commit: 23b3299cdb9b6e5c25bb19c0b3ecb51c5e76ac7a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=23b3299cdb9b6e5c25bb19c0b3ecb51c5e76ac7a

Author: Hans Leidekker <hans at it.vu.nl>
Date:   Wed Jan  3 12:12:03 2007 +0100

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

---

 dlls/usp10/usp10.c |   24 +++++++-----------------
 1 files changed, 7 insertions(+), 17 deletions(-)

diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 68110e5..f315f5a 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -159,7 +159,7 @@ typedef struct {
 
 typedef struct {
     BOOL invalid;
-    HDC hdc;
+    ScriptCache *sc;
     int cItems;
     int cMaxGlyphs;
     SCRIPT_ITEM* pItem;
@@ -517,9 +517,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
 {
     HRESULT hr;
     StringAnalysis* analysis;
-    int numItemizedItems;
-    int i;
-    SCRIPT_CACHE* sc = 0;
+    int i, numItemizedItems = 255;
 
     TRACE("(%p,%p,%d,%d,%d,0x%x,%d,%p,%p,%p,%p,%p,%p)\n",
       hdc, pString, cString, cGlyphs, iCharset, dwFlags,
@@ -534,8 +532,6 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
     analysis = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                        sizeof(StringAnalysis));
 
-    analysis->hdc = hdc;
-    numItemizedItems = 255;
     analysis->pItem = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                               numItemizedItems*sizeof(SCRIPT_ITEM)+1);
 
@@ -556,10 +552,10 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
 
     analysis->glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
                                  sizeof(StringGlyphs)*analysis->numItems);
-    sc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SCRIPT_CACHE));
 
     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 numGlyphs = 1.5 * cChar + 16;
         WORD* glyphs = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WORD)*numGlyphs);
@@ -587,10 +583,7 @@ HRESULT WINAPI ScriptStringAnalyse(HDC h
         analysis->glyphs[i].abc = abc;
     }
 
-    HeapFree(GetProcessHeap(), 0, sc);
-
     *pssa = analysis;
-
     return S_OK;
 }
 
@@ -628,7 +621,6 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_ST
     WORD *glyphs;
     int   item, cnt, x;
     HRESULT hr;
-    SCRIPT_CACHE sc = 0;
 
     TRACE("(%p,%d,%d,0x%1x,%p,%d,%d,%d)\n",
          ssa, iX, iY, uOptions, prc, iMinSel, iMaxSel, fDisabled);
@@ -671,17 +663,15 @@ HRESULT WINAPI ScriptStringOut(SCRIPT_ST
         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,
-                       NULL, 0, glyphs, cnt, analysis->glyphs->piAdvance, NULL,
-                       analysis->glyphs->pGoffset);
+    hr = ScriptTextOut(analysis->sc->hdc, (SCRIPT_CACHE *)&analysis->sc, iX, iY,
+                       uOptions, prc, &analysis->pItem->a, NULL, 0, glyphs, cnt,
+                       analysis->glyphs->piAdvance, NULL, analysis->glyphs->pGoffset);
     TRACE("ScriptTextOut hr=%08x\n", hr);
 
     /*
      * Free the output buffer and script cache
      */
     HeapFree(GetProcessHeap(), 0, glyphs);
-    ScriptFreeCache(&sc);
-
     return hr;
 }
 
@@ -1524,7 +1514,7 @@ const SIZE * WINAPI ScriptString_pSize(S
          * appropriate place so that we can just pass cached
          * values here.
          */
-        if (!GetTextMetricsW(analysis->hdc, &metric))
+        if (!GetTextMetricsW(analysis->sc->hdc, &metric))
         {
             HeapFree(GetProcessHeap(), 0, analysis->sz);
             analysis->sz = NULL;




More information about the wine-cvs mailing list