< prev index next >
src/java.desktop/share/native/common/java2d/opengl/OGLTextRenderer.c
Print this page
*** 299,308 ****
--- 299,310 ----
"uniform vec3 src_adj;"
"uniform sampler2D glyph_tex;"
"uniform sampler2D dst_tex;"
"uniform sampler3D invgamma_tex;"
"uniform sampler3D gamma_tex;"
+ "uniform vec3 gamma;"
+ "uniform vec3 invgamma;"
""
"void main(void)"
"{"
// load the RGB value from the glyph image at the current texcoord
" vec3 glyph_clr = vec3(texture2D(glyph_tex, gl_TexCoord[0].st));"
*** 311,325 ****
" discard;"
" }"
// load the RGB value from the corresponding destination pixel
" vec3 dst_clr = vec3(texture2D(dst_tex, gl_TexCoord[1].st));"
// gamma adjust the dest color using the invgamma LUT
! " vec3 dst_adj = vec3(texture3D(invgamma_tex, dst_clr.stp));"
// linearly interpolate the three color values
" vec3 result = mix(dst_adj, src_adj, glyph_clr);"
// gamma re-adjust the resulting color (alpha is always set to 1.0)
! " gl_FragColor = vec4(vec3(texture3D(gamma_tex, result.stp)), 1.0);"
"}";
/**
* Compiles and links the LCD text shader program. If successful, this
* function returns a handle to the newly created shader program; otherwise
--- 313,327 ----
" discard;"
" }"
// load the RGB value from the corresponding destination pixel
" vec3 dst_clr = vec3(texture2D(dst_tex, gl_TexCoord[1].st));"
// gamma adjust the dest color using the invgamma LUT
! " vec3 dst_adj = pow(dst_clr.rgb, invgamma);"
// linearly interpolate the three color values
" vec3 result = mix(dst_adj, src_adj, glyph_clr);"
// gamma re-adjust the resulting color (alpha is always set to 1.0)
! " gl_FragColor = vec4(pow(result.rgb, gamma), 1.0);"
"}";
/**
* Compiles and links the LCD text shader program. If successful, this
* function returns a handle to the newly created shader program; otherwise
*** 420,433 ****
--- 422,442 ----
GLfloat lut[LUT_EDGE][LUT_EDGE][LUT_EDGE][3];
GLfloat invlut[LUT_EDGE][LUT_EDGE][LUT_EDGE][3];
int min = 0;
int max = LUT_EDGE - 1;
int x, y, z;
+ GLint loc;
J2dTraceLn1(J2D_TRACE_INFO,
"OGLTR_UpdateLCDTextContrast: contrast=%d", contrast);
+ loc = j2d_glGetUniformLocationARB(lcdTextProgram, "gamma");
+ j2d_glUniform3fARB(loc, g, g, g);
+
+ loc = j2d_glGetUniformLocationARB(lcdTextProgram, "invgamma");
+ j2d_glUniform3fARB(loc, ig, ig, ig);
+
for (z = min; z <= max; z++) {
double zval = ((double)z) / max;
GLfloat gz = (GLfloat)pow(zval, g);
GLfloat igz = (GLfloat)pow(zval, ig);
*** 476,486 ****
* shader as needed.
*/
static jboolean
OGLTR_UpdateLCDTextColor(jint contrast)
{
! double gamma = ((double)contrast) / 100.0;
GLfloat radj, gadj, badj;
GLfloat clr[4];
GLint loc;
J2dTraceLn1(J2D_TRACE_INFO,
--- 485,495 ----
* shader as needed.
*/
static jboolean
OGLTR_UpdateLCDTextColor(jint contrast)
{
! double invgamma = ((double)contrast) / 100;
GLfloat radj, gadj, badj;
GLfloat clr[4];
GLint loc;
J2dTraceLn1(J2D_TRACE_INFO,
*** 497,509 ****
// get the current OpenGL primary color state
j2d_glGetFloatv(GL_CURRENT_COLOR, clr);
// gamma adjust the primary color
! radj = (GLfloat)pow(clr[0], gamma);
! gadj = (GLfloat)pow(clr[1], gamma);
! badj = (GLfloat)pow(clr[2], gamma);
// update the "src_adj" parameter of the shader program with this value
loc = j2d_glGetUniformLocationARB(lcdTextProgram, "src_adj");
j2d_glUniform3fARB(loc, radj, gadj, badj);
--- 506,518 ----
// get the current OpenGL primary color state
j2d_glGetFloatv(GL_CURRENT_COLOR, clr);
// gamma adjust the primary color
! radj = (GLfloat)pow(clr[0], invgamma);
! gadj = (GLfloat)pow(clr[1], invgamma);
! badj = (GLfloat)pow(clr[2], invgamma);
// update the "src_adj" parameter of the shader program with this value
loc = j2d_glGetUniformLocationARB(lcdTextProgram, "src_adj");
j2d_glUniform3fARB(loc, radj, gadj, badj);
< prev index next >