changeset 10938:46bd0ff75f66

8129582: Controls slow considerably when displaying RTL-languages text on Linux Reviewed-by: kcr
author prr
date Fri, 01 Jun 2018 11:01:13 -0700
parents 77a9be043f2c
children 7c3e0fda26c2
files modules/javafx.graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/modules/javafx.graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java	Fri Jun 01 11:38:40 2018 +0530
+++ b/modules/javafx.graphics/src/main/java/com/sun/javafx/font/freetype/PangoGlyphLayout.java	Fri Jun 01 11:01:13 2018 -0700
@@ -35,6 +35,11 @@
 import com.sun.javafx.text.TextRun;
 
 class PangoGlyphLayout extends GlyphLayout {
+    private static final long fontmap;
+
+    static {
+        fontmap = OSPango.pango_ft2_font_map_new();
+    }
 
     private int getSlot(PGFont font, PangoGlyphString glyphString) {
         CompositeFontResource fr = (CompositeFontResource)font.getFontResource();
@@ -63,7 +68,7 @@
         return slot;
     }
 
-    private boolean check(long checkValue, String message, long fontmap, long context, long desc, long attrList) {
+    private boolean check(long checkValue, String message, long context, long desc, long attrList) {
         if (checkValue != 0) return false;
         if (message != null && PrismFontFactory.debugFonts) {
             System.err.println(message);
@@ -72,7 +77,6 @@
         if (attrList != 0) OSPango.pango_attr_list_unref(attrList);
         if (desc != 0) OSPango.pango_font_description_free(desc);
         if (context != 0) OSPango.g_object_unref(context);
-        if (fontmap != 0) OSPango.g_object_unref(fontmap);
         return true;
     }
 
@@ -85,12 +89,11 @@
         if (composite) {
             fr = ((CompositeFontResource)fr).getSlotResource(0);
         }
-        long fontmap = OSPango.pango_ft2_font_map_new();
-        if (check(fontmap, "Failed allocating PangoFontMap.", 0, 0, 0, 0)) {
+        if (check(fontmap, "Failed allocating PangoFontMap.", 0, 0, 0)) {
             return;
         }
         long context = OSPango.pango_font_map_create_context(fontmap);
-        if (check(context, "Failed allocating PangoContext.", fontmap, 0, 0, 0)) {
+        if (check(context, "Failed allocating PangoContext.", 0, 0, 0)) {
             return;
         }
         boolean rtl = (run.getLevel() & 1) != 0;
@@ -101,7 +104,7 @@
         int style = fr.isItalic() ? OSPango.PANGO_STYLE_ITALIC : OSPango.PANGO_STYLE_NORMAL;
         int weight = fr.isBold() ? OSPango.PANGO_WEIGHT_BOLD : OSPango.PANGO_WEIGHT_NORMAL;
         long desc = OSPango.pango_font_description_new();
-        if (check(desc, "Failed allocating FontDescription.", fontmap, context, 0, 0)) {
+        if (check(desc, "Failed allocating FontDescription.", context, 0, 0)) {
             return;
         }
         OSPango.pango_font_description_set_family(desc, fr.getFamilyName());
@@ -110,11 +113,11 @@
         OSPango.pango_font_description_set_style(desc, style);
         OSPango.pango_font_description_set_weight(desc, weight);
         long attrList = OSPango.pango_attr_list_new();
-        if (check(attrList, "Failed allocating PangoAttributeList.", fontmap, context, desc, 0)) {
+        if (check(attrList, "Failed allocating PangoAttributeList.", context, desc, 0)) {
             return;
         }
         long attr = OSPango.pango_attr_font_desc_new(desc);
-        if (check(attr, "Failed allocating PangoAttribute.", fontmap, context, desc, attrList)) {
+        if (check(attr, "Failed allocating PangoAttribute.", context, desc, attrList)) {
             return;
         }
         OSPango.pango_attr_list_insert(attrList, attr);
@@ -125,7 +128,7 @@
 
         if (str == 0L) {
             str = OSPango.g_utf16_to_utf8(text);
-            if (check(str, "Failed allocating UTF-8 buffer.", fontmap, context, desc, attrList)) {
+            if (check(str, "Failed allocating UTF-8 buffer.", context, desc, attrList)) {
                 return;
             }
         }
@@ -190,7 +193,7 @@
             run.shape(glyphCount, glyphs, pos, indices);
         }
 
-        check(0, null, fontmap, context, desc, attrList);
+        check(0, null, context, desc, attrList);
     }
 
     @Override