JRE-722 LCD text rendering performance on OSX 25X slower than grayscale
Handled overlapped interleaved glyphs
diff --git a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
index 8459016..75681fe 100644
--- a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
+++ b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
@@ -808,9 +808,8 @@
J2dTracePrimitive("OGLMTVertexCache_enable_failed");
return JNI_FALSE;
}
- OGLMTVertexCache_addGlyphQuad(oglc, dx1, dy1, dx2, dy2,
- cell->tx1, cell->ty1, cell->tx2, cell->ty2,
- dtx1, dty1, dtx2, dty2);
+ OGLMTVertexCache_addGlyphQuad(dx1, dy1, dx2, dy2, cell->tx1, cell->ty1,
+ cell->tx2, cell->ty2, dtx1, dty1, dtx2, dty2);
return JNI_TRUE;
}
diff --git a/src/share/native/sun/java2d/opengl/OGLVertexCache.c b/src/share/native/sun/java2d/opengl/OGLVertexCache.c
index 265a7ee..53c9a8a 100644
--- a/src/share/native/sun/java2d/opengl/OGLVertexCache.c
+++ b/src/share/native/sun/java2d/opengl/OGLVertexCache.c
@@ -27,6 +27,7 @@
#include <stdlib.h>
#include <string.h>
+#include <float.h>
#include "sun_java2d_SunGraphics2D.h"
@@ -56,6 +57,8 @@
static jint evenLCDGlyphInd = 0;
static jint oddLCDGlyphInd = ODD_LCD_GLYPHS_OFFSET;
static jint lcdGlyphInd = 0;
+static jfloat evenOx2 = FLT_MIN;
+static jfloat oddOx2 = FLT_MIN;
static GLuint maskCacheTexID = 0;
static jint maskCacheIndex = 0;
@@ -365,6 +368,7 @@
// and caches have been invalidated before subsequent Draws are
// executed
j2d_glTextureBarrierNV();
+ evenOx2 = FLT_MIN;
}
j2d_glDrawArrays(GL_QUADS, 0, evenLCDGlyphInd);
evenLCDGlyphInd = 0;
@@ -374,6 +378,7 @@
if (mtUseTxtBarrier) {
// See the comment above
j2d_glTextureBarrierNV();
+ oddOx2 = FLT_MIN;
}
j2d_glDrawArrays(GL_QUADS, ODD_LCD_GLYPHS_OFFSET,
oddLCDGlyphInd - ODD_LCD_GLYPHS_OFFSET);
@@ -382,8 +387,7 @@
}
}
-void OGLMTVertexCache_addGlyphQuad(OGLContext *oglc,
- jfloat dx1, jfloat dy1,
+void OGLMTVertexCache_addGlyphQuad(jfloat dx1, jfloat dy1,
jfloat dx2, jfloat dy2,
jfloat tx1, jfloat ty1,
jfloat tx2, jfloat ty2,
@@ -392,13 +396,21 @@
{
jint* ind;
if (lcdGlyphInd & 0x1) {
- if (oddLCDGlyphInd >= OGLMTVC_MAX_INDEX) {
+ if (oddLCDGlyphInd >= OGLMTVC_MAX_INDEX ||
+ (mtUseTxtBarrier && oddOx2 >= dx1))
+ {
OGLMTVertexCache_flush(OGLMTVC_FLUSH_ODD);
+ } else if (mtUseTxtBarrier) {
+ oddOx2 = dx2;
}
ind = &oddLCDGlyphInd;
} else {
- if (evenLCDGlyphInd >= ODD_LCD_GLYPHS_OFFSET) {
+ if (evenLCDGlyphInd >= ODD_LCD_GLYPHS_OFFSET ||
+ (mtUseTxtBarrier && evenOx2 >= dx1))
+ {
OGLMTVertexCache_flush(OGLMTVC_FLUSH_EVEN);
+ } else if (mtUseTxtBarrier) {
+ evenOx2 = dx2;
}
ind = &evenLCDGlyphInd;
}
diff --git a/src/share/native/sun/java2d/opengl/OGLVertexCache.h b/src/share/native/sun/java2d/opengl/OGLVertexCache.h
index d610275..5572daa 100644
--- a/src/share/native/sun/java2d/opengl/OGLVertexCache.h
+++ b/src/share/native/sun/java2d/opengl/OGLVertexCache.h
@@ -89,8 +89,7 @@
jfloat dx2, jfloat dy2);
jboolean OGLMTVertexCache_enable(OGLContext *oglc, jboolean useTxtBarrier);
-void OGLMTVertexCache_addGlyphQuad(OGLContext *oglc,
- jfloat dx1, jfloat dy1,
+void OGLMTVertexCache_addGlyphQuad(jfloat dx1, jfloat dy1,
jfloat dx2, jfloat dy2,
jfloat tx1, jfloat ty1,
jfloat tx2, jfloat ty2,