JRE-457 OGLTR_DisableGlyphModeState is slow
Skipped number of OGLTR_DisableGlyphModeState calls in sequence of draw text operations
(cherry picked from commit d52fc84)
diff --git a/src/share/native/sun/java2d/opengl/OGLRenderQueue.c b/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
index 3724c13..9d941e8 100644
--- a/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
+++ b/src/share/native/sun/java2d/opengl/OGLRenderQueue.c
@@ -93,6 +93,10 @@
"OGLRenderQueue_flushBuffer: opcode=%d, rem=%d",
opcode, (end-b));
+ if (opcode != sun_java2d_pipe_BufferedOpCodes_DRAW_GLYPH_LIST) {
+ OGLTR_DisableGlyphModeState(JNI_FALSE);
+ }
+
switch (opcode) {
// draw ops
@@ -701,6 +705,8 @@
}
}
+ OGLTR_DisableGlyphModeState(JNI_FALSE);
+
if (oglc != NULL) {
RESET_PREVIOUS_OP();
if (sync) {
diff --git a/src/share/native/sun/java2d/opengl/OGLRenderQueue.h b/src/share/native/sun/java2d/opengl/OGLRenderQueue.h
index 88bd4e5..9137db0 100644
--- a/src/share/native/sun/java2d/opengl/OGLRenderQueue.h
+++ b/src/share/native/sun/java2d/opengl/OGLRenderQueue.h
@@ -129,5 +129,6 @@
OGLContext *OGLRenderQueue_GetCurrentContext();
OGLSDOps *OGLRenderQueue_GetCurrentDestination();
void OGLRenderQueue_CheckPreviousOp(jint op);
+void OGLTR_DisableGlyphModeState(jboolean force);
#endif /* OGLRenderQueue_h_Included */
diff --git a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
index 1352621..745339b 100644
--- a/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
+++ b/src/share/native/sun/java2d/opengl/OGLTextRenderer.c
@@ -164,6 +164,7 @@
*/
static SurfaceDataBounds previousGlyphBounds;
+static jboolean performDisableGlyphModeState = JNI_FALSE;
/**
* Initializes the one glyph cache (texture and data structure).
* If lcdCache is JNI_TRUE, the texture will contain RGB data,
@@ -507,9 +508,10 @@
/**
* Disables any pending state associated with the current "glyph mode".
*/
-static void
-OGLTR_DisableGlyphModeState()
+void
+OGLTR_DisableGlyphModeState(jboolean force)
{
+ if (!performDisableGlyphModeState && !force) return;
switch (glyphMode) {
case MODE_NO_CACHE_LCD:
j2d_glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
@@ -532,6 +534,7 @@
default:
break;
}
+ performDisableGlyphModeState = JNI_FALSE;
}
static jboolean
@@ -542,7 +545,7 @@
jfloat x1, y1, x2, y2;
if (glyphMode != MODE_USE_CACHE_GRAY) {
- OGLTR_DisableGlyphModeState();
+ OGLTR_DisableGlyphModeState(JNI_TRUE);
CHECK_PREVIOUS_OP(OGL_STATE_GLYPH_OP);
glyphMode = MODE_USE_CACHE_GRAY;
}
@@ -721,7 +724,7 @@
*opened = JNI_FALSE;
j2d_glEnd();
}
- OGLTR_DisableGlyphModeState();
+ OGLTR_DisableGlyphModeState(JNI_TRUE);
CHECK_PREVIOUS_OP(GL_TEXTURE_2D);
j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -844,7 +847,7 @@
jint h = ginfo->height;
if (glyphMode != MODE_NO_CACHE_GRAY) {
- OGLTR_DisableGlyphModeState();
+ OGLTR_DisableGlyphModeState(JNI_TRUE);
CHECK_PREVIOUS_OP(OGL_STATE_MASK_OP);
glyphMode = MODE_NO_CACHE_GRAY;
}
@@ -885,7 +888,7 @@
GLenum pixelFormat = rgbOrder ? GL_RGB : GL_BGR;
if (glyphMode != MODE_NO_CACHE_LCD) {
- OGLTR_DisableGlyphModeState();
+ OGLTR_DisableGlyphModeState(JNI_TRUE);
CHECK_PREVIOUS_OP(GL_TEXTURE_2D);
j2d_glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
@@ -1030,7 +1033,7 @@
OGLTR_DrawColorGlyphNoCache(OGLContext *oglc, GlyphInfo *ginfo, jint x, jint y)
{
if (glyphMode != MODE_NO_CACHE_COLOR) {
- OGLTR_DisableGlyphModeState();
+ OGLTR_DisableGlyphModeState(JNI_TRUE);
CHECK_PREVIOUS_OP(OGL_STATE_RESET);
glyphMode = MODE_NO_CACHE_COLOR;
}
@@ -1210,7 +1213,7 @@
if (lcdOpened) {
j2d_glEnd();
}
- OGLTR_DisableGlyphModeState();
+ performDisableGlyphModeState = JNI_TRUE;
}
JNIEXPORT void JNICALL