7143617: Improve fontmanager layout lookup operations
authorbae
Tue, 28 Feb 2012 10:44:56 +0400
changeset 13036 0fd2665c9314
parent 13035 27b066eebe1f
child 13037 99200b262b30
7143617: Improve fontmanager layout lookup operations Reviewed-by: igor, prr, mschoene
jdk/src/share/native/sun/font/layout/LookupProcessor.cpp
jdk/src/share/native/sun/font/layout/LookupProcessor.h
--- a/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp	Wed Feb 22 15:38:24 2012 -0500
+++ b/jdk/src/share/native/sun/font/layout/LookupProcessor.cpp	Tue Feb 28 10:44:56 2012 +0400
@@ -95,6 +95,10 @@
 
         if (selectMask != 0) {
             const LookupTable *lookupTable = lookupListTable->getLookupTable(lookup);
+
+            if (!lookupTable)
+                continue;
+
             le_uint16 lookupFlags = SWAPW(lookupTable->lookupFlags);
 
             glyphIterator.reset(lookupFlags, selectMask);
@@ -136,6 +140,9 @@
     for (le_uint16 lookup = 0; lookup < lookupCount; lookup += 1) {
         le_uint16 lookupListIndex = SWAPW(featureTable->lookupListIndexArray[lookup]);
 
+        if (lookupListIndex >= lookupSelectCount)
+            continue;
+
         lookupSelectArray[lookupListIndex] |= featureMask;
         lookupOrderArray[store++] = lookupListIndex;
     }
@@ -147,7 +154,7 @@
         Offset scriptListOffset, Offset featureListOffset, Offset lookupListOffset,
         LETag scriptTag, LETag languageTag, const FeatureMap *featureMap, le_int32 featureMapCount, le_bool orderFeatures,
         LEErrorCode& success)
-    : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL),
+    : lookupListTable(NULL), featureListTable(NULL), lookupSelectArray(NULL), lookupSelectCount(0),
       lookupOrderArray(NULL), lookupOrderCount(0)
 {
     const ScriptListTable *scriptListTable = NULL;
@@ -195,6 +202,8 @@
         lookupSelectArray[i] = 0;
     }
 
+    lookupSelectCount = lookupListCount;
+
     le_int32 count, order = 0;
     le_int32 featureReferences = 0;
     const FeatureTable *featureTable = NULL;
@@ -211,6 +220,10 @@
         le_uint16 featureIndex = SWAPW(langSysTable->featureIndexArray[feature]);
 
         featureTable = featureListTable->getFeatureTable(featureIndex, &featureTag);
+
+        if (!featureTable)
+            continue;
+
         featureReferences += SWAPW(featureTable->lookupCount);
     }
 
--- a/jdk/src/share/native/sun/font/layout/LookupProcessor.h	Wed Feb 22 15:38:24 2012 -0500
+++ b/jdk/src/share/native/sun/font/layout/LookupProcessor.h	Tue Feb 28 10:44:56 2012 +0400
@@ -90,6 +90,7 @@
     const FeatureListTable  *featureListTable;
 
     FeatureMask            *lookupSelectArray;
+    le_uint32              lookupSelectCount;
 
     le_uint16               *lookupOrderArray;
     le_uint32               lookupOrderCount;