Huw Davies : usp10: Simplify the reordering of glyphs.

Alexandre Julliard julliard at winehq.org
Fri Jan 11 13:46:58 CST 2013


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

Author: Huw Davies <huw at codeweavers.com>
Date:   Fri Jan 11 11:09:19 2013 +0000

usp10: Simplify the reordering of glyphs.

---

 dlls/usp10/usp10.c |   40 ++++++++++++++++++----------------------
 1 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/dlls/usp10/usp10.c b/dlls/usp10/usp10.c
index 75fe597..b77c251 100644
--- a/dlls/usp10/usp10.c
+++ b/dlls/usp10/usp10.c
@@ -3239,6 +3239,7 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
     HRESULT hr = S_OK;
     INT i;
     INT *lpDx;
+    WORD *reordered_glyphs = (WORD *)pwGlyphs;
 
     TRACE("(%p, %p, %d, %d, %04x, %p, %p, %p, %d, %p, %d, %p, %p, %p)\n",
          hdc, psc, x, y, fuOptions, lprc, psa, pwcReserved, iReserved, pwGlyphs, cGlyphs,
@@ -3253,8 +3254,22 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
         fuOptions |= ETO_GLYPH_INDEX;                             /* Say don't do translation to glyph */
 
     lpDx = heap_alloc(cGlyphs * sizeof(INT) * 2);
+    if (!lpDx) return E_OUTOFMEMORY;
     fuOptions |= ETO_PDY;
 
+    if (psa->fRTL && psa->fLogicalOrder)
+    {
+        reordered_glyphs = heap_alloc( cGlyphs * sizeof(WORD) );
+        if (!reordered_glyphs)
+        {
+            heap_free( lpDx );
+            return E_OUTOFMEMORY;
+        }
+
+        for (i = 0; i < cGlyphs; i++)
+            reordered_glyphs[i] = pwGlyphs[cGlyphs - 1 - i];
+    }
+
     for (i = 0; i < cGlyphs; i++)
     {
         lpDx[i * 2] = piAdvance[i];
@@ -3269,29 +3284,10 @@ HRESULT WINAPI ScriptTextOut(const HDC hdc, SCRIPT_CACHE *psc, int x, int y, UIN
         }
     }
 
-    if (psa->fRTL && psa->fLogicalOrder)
-    {
-        int i;
-        WORD *rtlGlyphs;
-
-        rtlGlyphs = heap_alloc(cGlyphs * sizeof(WORD));
-        if (!rtlGlyphs)
-        {
-            heap_free(lpDx);
-            return E_OUTOFMEMORY;
-        }
-
-        for (i = 0; i < cGlyphs; i++)
-            rtlGlyphs[i] = pwGlyphs[cGlyphs-1-i];
-
-        if (!ExtTextOutW(hdc, x, y, fuOptions, lprc, rtlGlyphs, cGlyphs, lpDx))
-            hr = S_FALSE;
-        heap_free(rtlGlyphs);
-    }
-    else
-        if (!ExtTextOutW(hdc, x, y, fuOptions, lprc, pwGlyphs, cGlyphs, lpDx))
-            hr = S_FALSE;
+    if (!ExtTextOutW(hdc, x, y, fuOptions, lprc, reordered_glyphs, cGlyphs, lpDx))
+        hr = S_FALSE;
 
+    if (reordered_glyphs != pwGlyphs) heap_free( reordered_glyphs );
     heap_free(lpDx);
 
     return hr;




More information about the wine-cvs mailing list