changeset 5198:c368675b0728

RT-31536: Some websites are rendered poorly
author Felipe Heidrich <felipe.heidrich@oracle.com>
date Fri, 27 Sep 2013 09:29:32 -0700
parents 0f199384c1d6
children 4f279342c9b3
files modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyph.java
diffstat 1 files changed, 27 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyph.java	Fri Sep 27 09:12:33 2013 -0700
+++ b/modules/graphics/src/main/java/com/sun/javafx/font/directwrite/DWGlyph.java	Fri Sep 27 09:29:32 2013 -0700
@@ -96,36 +96,44 @@
          */
         int textureType = OS.DWRITE_TEXTURE_CLEARTYPE_3x1;
         IDWriteGlyphRunAnalysis runAnalysis = createAnalysis(0, 0);
-        rect = runAnalysis.GetAlphaTextureBounds(textureType);
-        if ((rect.right - rect.left == 0) ||
-             (rect.bottom - rect.top == 0)) {
-            /* Check for both texture types due to some limitations with
-             * IDWriteGlyphRunAnalysis. See RT-31587.
-             */
-            rect = runAnalysis.GetAlphaTextureBounds(OS.DWRITE_TEXTURE_ALIASED_1x1);
+        if (runAnalysis != null) {
+            rect = runAnalysis.GetAlphaTextureBounds(textureType);
+            if (rect == null || rect.right - rect.left == 0 || rect.bottom - rect.top == 0) {
+                /* Check for both texture types due to some limitations with
+                 * IDWriteGlyphRunAnalysis. See RT-31587.
+                 */
+                rect = runAnalysis.GetAlphaTextureBounds(OS.DWRITE_TEXTURE_ALIASED_1x1);
+            }
+            runAnalysis.Release();
         }
-        runAnalysis.Release();
+        if (rect == null) {
+            rect = new RECT();
+        }
     }
 
     byte[] getLCDMask(float subPixelX, float subPixelY) {
-        int textureType = OS.DWRITE_TEXTURE_CLEARTYPE_3x1;
         IDWriteGlyphRunAnalysis runAnalysis = createAnalysis(subPixelX, subPixelY);
-        rect = runAnalysis.GetAlphaTextureBounds(textureType);
-        if ((rect.right - rect.left == 0) ||
-            (rect.bottom - rect.top == 0)) {
-            rect = runAnalysis.GetAlphaTextureBounds(OS.DWRITE_TEXTURE_ALIASED_1x1);
-            if ((rect.right - rect.left == 0) ||
-                (rect.bottom - rect.top == 0)) {
-                return new byte[0];
+        byte[] buffer = null;
+        if (runAnalysis != null) {
+            int textureType = OS.DWRITE_TEXTURE_CLEARTYPE_3x1;
+            rect = runAnalysis.GetAlphaTextureBounds(textureType);
+            if (rect != null && rect.right - rect.left != 0 && rect.bottom - rect.top != 0) {
+                buffer = runAnalysis.CreateAlphaTexture(textureType, rect);
             } else {
                 /* In some cases IDWriteGlyphRunAnalysis is unable to produce
                  * LCD masks. But as long as the size can determined D2D can be
                  * used to do the rendering. */
-                return getD2DMask(subPixelX, subPixelY, true);
+                rect = runAnalysis.GetAlphaTextureBounds(OS.DWRITE_TEXTURE_ALIASED_1x1);
+                if (rect != null && rect.right - rect.left != 0 && rect.bottom - rect.top != 0) {
+                    buffer = getD2DMask(subPixelX, subPixelY, true);
+                }
             }
+            runAnalysis.Release();
         }
-        byte[] buffer = runAnalysis.CreateAlphaTexture(textureType, rect);
-        runAnalysis.Release();
+        if (buffer == null) {
+            buffer = new byte[0];
+            rect = new RECT();
+        }
         return buffer;
     }