src/share/native/sun/java2d/opengl/OGLBlitLoops.c
Print this page
@@ -387,15 +387,28 @@
* This restriction should not be an issue as this method is only used
* currently to cache a static system memory image into an OpenGL texture in
* a hidden-acceleration situation.
*/
static void
-OGLBlitSwToTexture(SurfaceDataRasInfo *srcInfo, OGLPixelFormat *pf,
- OGLSDOps *dstOps,
+OGLBlitSwToTexture(OGLContext *oglc, SurfaceDataRasInfo *srcInfo,
+ OGLPixelFormat *pf, OGLSDOps *dstOps,
jint dx1, jint dy1, jint dx2, jint dy2)
{
j2d_glBindTexture(dstOps->textureTarget, dstOps->textureID);
+
+ if (oglc->extraAlpha != 1.0f) {
+ OGLContext_SetExtraAlpha(oglc->extraAlpha);
+ }
+ if (!pf->hasAlpha) {
+ // if the source surface does not have an alpha channel,
+ // we need to ensure that the alpha values are forced to
+ // the current extra alpha value (see OGLContext_SetExtraAlpha()
+ // for more information)
+ j2d_glPixelTransferf(GL_ALPHA_SCALE, 0.0f);
+ j2d_glPixelTransferf(GL_ALPHA_BIAS, oglc->extraAlpha);
+ }
+
// in case pixel stride is not a multiple of scanline stride the copy
// has to be done line by line (see 6207877)
if (srcInfo->scanStride % srcInfo->pixelStride != 0) {
jint width = dx2 - dx1;
jint height = dy2 - dy1;
@@ -411,10 +424,18 @@
} else {
j2d_glTexSubImage2D(dstOps->textureTarget, 0,
dx1, dy1, dx2-dx1, dy2-dy1,
pf->format, pf->type, srcInfo->rasBase);
}
+ if (oglc->extraAlpha != 1.0f) {
+ OGLContext_SetExtraAlpha(1.0f);
+ }
+ if (!pf->hasAlpha) {
+ // restore scale/bias to their original values
+ j2d_glPixelTransferf(GL_ALPHA_SCALE, 1.0f);
+ j2d_glPixelTransferf(GL_ALPHA_BIAS, 0.0f);
+ }
}
/**
* General blit method for copying a native OpenGL surface (of type "Surface"
* or "Texture") to another OpenGL "Surface". If texture is JNI_TRUE, this
@@ -625,11 +646,11 @@
if (texture) {
// These coordinates will always be integers since we
// only ever do a straight copy from sw to texture.
// Thus these casts are "safe" - no loss of precision.
- OGLBlitSwToTexture(&srcInfo, &pf, dstOps,
+ OGLBlitSwToTexture(oglc, &srcInfo, &pf, dstOps,
(jint)dx1, (jint)dy1, (jint)dx2, (jint)dy2);
} else {
jboolean viaTexture;
if (xform) {
// we must use the via-texture codepath when there