JRE-457 OGLTR_DisableGlyphModeState is slow
Improved fix by skipping NOOP operation. Added one more test on glyph mode state changing.
diff --git a/src/share/native/sun/java2d/opengl/OGLRenderQueue.c b/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
index 9d941e8..672294e 100644
--- a/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
+++ b/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
@@ -93,7 +93,9 @@
"OGLRenderQueue_flushBuffer: opcode=%d, rem=%d",
opcode, (end-b));
- if (opcode != sun_java2d_pipe_BufferedOpCodes_DRAW_GLYPH_LIST) {
+ if (opcode != sun_java2d_pipe_BufferedOpCodes_DRAW_GLYPH_LIST &&
+ opcode != sun_java2d_pipe_BufferedOpCodes_NOOP)
+ {
OGLTR_DisableGlyphModeState(JNI_FALSE);
}
diff --git a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
index 745339b..a134f9c 100644
--- a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
+++ b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
@@ -511,7 +511,12 @@
void
OGLTR_DisableGlyphModeState(jboolean force)
{
- if (!performDisableGlyphModeState && !force) return;
+ int skip = !performDisableGlyphModeState && !force;
+ J2dTraceLn2(J2D_TRACE_VERBOSE,
+ "OGLTR_DisableGlyphModeState: mode=%d skip=%d",
+ glyphMode, skip);
+
+ if (skip) return;
switch (glyphMode) {
case MODE_NO_CACHE_LCD:
j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
@@ -535,6 +540,7 @@
break;
}
performDisableGlyphModeState = JNI_FALSE;
+ glyphMode = MODE_NOT_INITED;
}
static jboolean
@@ -1076,7 +1082,6 @@
RETURN_IF_NULL(positions);
}
- glyphMode = MODE_NOT_INITED;
isCachedDestValid = JNI_FALSE;
// We have to obtain an information about destination content
diff --git a/test/jbu/quality/text/MixedTextTest.java b/test/jbu/quality/text/MixedTextTest.java
index 4a81b44..216bcb5 100644
--- a/test/jbu/quality/text/MixedTextTest.java
+++ b/test/jbu/quality/text/MixedTextTest.java
@@ -19,10 +19,8 @@
import org.junit.Test;
import quality.util.RenderUtil;
-import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
-import java.io.File;
public class MixedTextTest {
@@ -76,4 +74,50 @@
RenderUtil.checkImage(bi, "text", "lcdgray.png");
}
+
+ @Test
+ public void testCacheNoCacheLCD() throws Exception {
+ final Font smallFont = new Font("Menlo", Font.PLAIN, 20);
+ final Font bigFont = new Font("Menlo", Font.PLAIN, 50);
+ BufferedImage bi = RenderUtil.capture(120, 120,
+ graphics2D -> {
+ graphics2D.setFont(smallFont);
+
+ graphics2D.setRenderingHint(
+ RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+
+
+ graphics2D.drawString("A", 0, 50);
+
+ graphics2D.setFont(bigFont);
+
+ graphics2D.setRenderingHint(
+ RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+
+ graphics2D.drawString("A", 10, 50);
+
+ graphics2D.setFont(smallFont);
+
+ graphics2D.setRenderingHint(
+ RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+
+
+ graphics2D.drawString("A", 38, 50);
+
+ graphics2D.setFont(bigFont);
+
+ graphics2D.setRenderingHint(
+ RenderingHints.KEY_TEXT_ANTIALIASING,
+ RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);
+
+
+ graphics2D.drawString("A", 48, 50);
+ });
+
+ RenderUtil.checkImage(bi, "text", "cnclcd.png");
+ }
+
}
diff --git a/test/jbu/testdata/quality/text/osx_lowres_rendering/cnclcd.png b/test/jbu/testdata/quality/text/osx_lowres_rendering/cnclcd.png
new file mode 100644
index 0000000..07340f5
--- /dev/null
+++ b/test/jbu/testdata/quality/text/osx_lowres_rendering/cnclcd.png
Binary files differ
diff --git a/test/jbu/testdata/quality/text/osx_sierra_rendering/cnclcd.png b/test/jbu/testdata/quality/text/osx_sierra_rendering/cnclcd.png
new file mode 100644
index 0000000..47e0dda
--- /dev/null
+++ b/test/jbu/testdata/quality/text/osx_sierra_rendering/cnclcd.png
Binary files differ