7188942: Remove support of pbuffers in OGL Java2d pipeline
Reviewed-by: prr, flar
This commit is contained in:
parent
a26c73956c
commit
ffbfb8f10b
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -379,23 +379,11 @@ public final class CGLGraphicsConfig extends CGraphicsConfig
|
|||||||
public VolatileImage createCompatibleVolatileImage(int width, int height,
|
public VolatileImage createCompatibleVolatileImage(int width, int height,
|
||||||
int transparency,
|
int transparency,
|
||||||
int type) {
|
int type) {
|
||||||
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
|
if ((type != FBOBJECT && type != TEXTURE)
|
||||||
transparency == Transparency.BITMASK)
|
|| transparency == Transparency.BITMASK
|
||||||
{
|
|| type == FBOBJECT && !isCapPresent(CAPS_EXT_FBOBJECT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == FBOBJECT) {
|
|
||||||
if (!isCapPresent(CAPS_EXT_FBOBJECT)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else if (type == PBUFFER) {
|
|
||||||
boolean isOpaque = transparency == Transparency.OPAQUE;
|
|
||||||
if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
||||||
transparency, type);
|
transparency, type);
|
||||||
Surface sd = vi.getDestSurface();
|
Surface sd = vi.getDestSurface();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,9 +51,6 @@ public abstract class CGLSurfaceData extends OGLSurfaceData {
|
|||||||
private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
|
private native void initOps(long pConfigInfo, long pPeerData, long layerPtr,
|
||||||
int xoff, int yoff, boolean isOpaque);
|
int xoff, int yoff, boolean isOpaque);
|
||||||
|
|
||||||
protected native boolean initPbuffer(long pData, long pConfigInfo,
|
|
||||||
boolean isOpaque, int width, int height);
|
|
||||||
|
|
||||||
protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
|
protected CGLSurfaceData(CGLGraphicsConfig gc, ColorModel cm, int type,
|
||||||
int width, int height) {
|
int width, int height) {
|
||||||
super(gc, cm, type);
|
super(gc, cm, type);
|
||||||
@ -139,7 +136,7 @@ public abstract class CGLSurfaceData extends OGLSurfaceData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a SurfaceData object representing an off-screen buffer (either a
|
* Creates a SurfaceData object representing an off-screen buffer (either a
|
||||||
* Pbuffer or Texture).
|
* FBO or Texture).
|
||||||
*/
|
*/
|
||||||
public static CGLOffScreenSurfaceData createData(CGLGraphicsConfig gc,
|
public static CGLOffScreenSurfaceData createData(CGLGraphicsConfig gc,
|
||||||
int width, int height, ColorModel cm, Image image, int type) {
|
int width, int height, ColorModel cm, Image image, int type) {
|
||||||
|
@ -45,7 +45,7 @@ import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
|||||||
|
|
||||||
public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||||
|
|
||||||
private boolean accelerationEnabled;
|
private final boolean accelerationEnabled;
|
||||||
|
|
||||||
public CGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
public CGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
||||||
super(vImg, context);
|
super(vImg, context);
|
||||||
@ -53,18 +53,13 @@ public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
/*
|
/*
|
||||||
* We will attempt to accelerate this image only under the
|
* We will attempt to accelerate this image only under the
|
||||||
* following conditions:
|
* following conditions:
|
||||||
* - the image is opaque OR
|
* - the image is not bitmask AND the GraphicsConfig supports the FBO
|
||||||
* - the image is translucent AND
|
* extension
|
||||||
* - the GraphicsConfig supports the FBO extension OR
|
|
||||||
* - the GraphicsConfig has a stored alpha channel
|
|
||||||
*/
|
*/
|
||||||
int transparency = vImg.getTransparency();
|
int transparency = vImg.getTransparency();
|
||||||
CGLGraphicsConfig gc = (CGLGraphicsConfig)vImg.getGraphicsConfig();
|
CGLGraphicsConfig gc = (CGLGraphicsConfig) vImg.getGraphicsConfig();
|
||||||
accelerationEnabled =
|
accelerationEnabled = gc.isCapPresent(CAPS_EXT_FBOBJECT)
|
||||||
(transparency == Transparency.OPAQUE) ||
|
&& transparency != Transparency.BITMASK;
|
||||||
((transparency == Transparency.TRANSLUCENT) &&
|
|
||||||
(gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
|
|
||||||
gc.isCapPresent(CAPS_STORED_ALPHA)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAccelerationEnabled() {
|
protected boolean isAccelerationEnabled() {
|
||||||
@ -72,7 +67,7 @@ public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a pbuffer-based SurfaceData object (or init the backbuffer
|
* Create a FBO-based SurfaceData object (or init the backbuffer
|
||||||
* of an existing window if this is a double buffered GraphicsConfig)
|
* of an existing window if this is a double buffered GraphicsConfig)
|
||||||
*/
|
*/
|
||||||
protected SurfaceData initAcceleratedSurface() {
|
protected SurfaceData initAcceleratedSurface() {
|
||||||
@ -113,10 +108,9 @@ public class CGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
||||||
int type = vImg.getForcedAccelSurfaceType();
|
int type = vImg.getForcedAccelSurfaceType();
|
||||||
// if acceleration type is forced (type != UNDEFINED) then
|
// if acceleration type is forced (type != UNDEFINED) then
|
||||||
// use the forced type, otherwise choose one based on caps
|
// use the forced type, otherwise choose FBOBJECT
|
||||||
if (type == OGLSurfaceData.UNDEFINED) {
|
if (type == OGLSurfaceData.UNDEFINED) {
|
||||||
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ?
|
type = OGLSurfaceData.FBOBJECT;
|
||||||
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
|
|
||||||
}
|
}
|
||||||
if (createVSynced) {
|
if (createVSynced) {
|
||||||
// TODO: modify parameter to delegate
|
// TODO: modify parameter to delegate
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -342,18 +342,10 @@ Java_sun_java2d_opengl_CGLGraphicsConfig_getCGLConfigInfo
|
|||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
caps |= CAPS_DOUBLEBUFFERED;
|
caps |= CAPS_DOUBLEBUFFERED;
|
||||||
}
|
}
|
||||||
[sharedPixelFormat
|
|
||||||
getValues: &value
|
|
||||||
forAttribute: NSOpenGLPFAAlphaSize
|
|
||||||
forVirtualScreen: contextVirtualScreen];
|
|
||||||
if (value != 0) {
|
|
||||||
caps |= CAPS_STORED_ALPHA;
|
|
||||||
}
|
|
||||||
|
|
||||||
J2dRlsTraceLn2(J2D_TRACE_INFO,
|
J2dRlsTraceLn1(J2D_TRACE_INFO,
|
||||||
"CGLGraphicsConfig_getCGLConfigInfo: db=%d alpha=%d",
|
"CGLGraphicsConfig_getCGLConfigInfo: db=%d",
|
||||||
(caps & CAPS_DOUBLEBUFFERED) != 0,
|
(caps & CAPS_DOUBLEBUFFERED) != 0);
|
||||||
(caps & CAPS_STORED_ALPHA) != 0);
|
|
||||||
|
|
||||||
// remove before shipping (?)
|
// remove before shipping (?)
|
||||||
#if 1
|
#if 1
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -39,7 +39,6 @@ typedef struct _CGLSDOps {
|
|||||||
AWTView *peerData;
|
AWTView *peerData;
|
||||||
CGLLayer *layer;
|
CGLLayer *layer;
|
||||||
GLclampf argb[4]; // background clear color
|
GLclampf argb[4]; // background clear color
|
||||||
NSOpenGLPixelBuffer *pbuffer;
|
|
||||||
CGLGraphicsConfigInfo *configInfo;
|
CGLGraphicsConfigInfo *configInfo;
|
||||||
} CGLSDOps;
|
} CGLSDOps;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -110,9 +110,7 @@ JNF_COCOA_EXIT(env);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function disposes of any native windowing system resources associated
|
* This function disposes of any native windowing system resources associated
|
||||||
* with this surface. For instance, if the given OGLSDOps is of type
|
* with this surface.
|
||||||
* OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
|
|
||||||
* surface.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
||||||
@ -122,16 +120,7 @@ OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
|||||||
JNF_COCOA_ENTER(env);
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
|
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
|
||||||
if (oglsdo->drawableType == OGLSD_PBUFFER) {
|
if (oglsdo->drawableType == OGLSD_WINDOW) {
|
||||||
if (oglsdo->textureID != 0) {
|
|
||||||
j2d_glDeleteTextures(1, &oglsdo->textureID);
|
|
||||||
oglsdo->textureID = 0;
|
|
||||||
}
|
|
||||||
if (cglsdo->pbuffer != NULL) {
|
|
||||||
[cglsdo->pbuffer release];
|
|
||||||
cglsdo->pbuffer = NULL;
|
|
||||||
}
|
|
||||||
} else if (oglsdo->drawableType == OGLSD_WINDOW) {
|
|
||||||
// detach the NSView from the NSOpenGLContext
|
// detach the NSView from the NSOpenGLContext
|
||||||
CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
|
CGLGraphicsConfigInfo *cglInfo = cglsdo->configInfo;
|
||||||
OGLContext *oglc = cglInfo->context;
|
OGLContext *oglc = cglInfo->context;
|
||||||
@ -277,23 +266,12 @@ OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
|
|||||||
|
|
||||||
JNF_COCOA_ENTER(env);
|
JNF_COCOA_ENTER(env);
|
||||||
|
|
||||||
// set the current surface
|
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
|
||||||
if (dstOps->drawableType == OGLSD_PBUFFER) {
|
NSView *nsView = (NSView *)cglsdo->peerData;
|
||||||
// REMIND: pbuffers are not fully tested yet...
|
|
||||||
[ctxinfo->context clearDrawable];
|
|
||||||
[ctxinfo->context makeCurrentContext];
|
|
||||||
[ctxinfo->context setPixelBuffer: dstCGLOps->pbuffer
|
|
||||||
cubeMapFace: 0
|
|
||||||
mipMapLevel: 0
|
|
||||||
currentVirtualScreen: [ctxinfo->context currentVirtualScreen]];
|
|
||||||
} else {
|
|
||||||
CGLSDOps *cglsdo = (CGLSDOps *)dstOps->privOps;
|
|
||||||
NSView *nsView = (NSView *)cglsdo->peerData;
|
|
||||||
|
|
||||||
if ([ctxinfo->context view] != nsView) {
|
if ([ctxinfo->context view] != nsView) {
|
||||||
[ctxinfo->context makeCurrentContext];
|
[ctxinfo->context makeCurrentContext];
|
||||||
[ctxinfo->context setView: nsView];
|
[ctxinfo->context setView: nsView];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
|
if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) {
|
||||||
@ -303,16 +281,6 @@ JNF_COCOA_ENTER(env);
|
|||||||
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((srcOps != dstOps) && (srcOps->drawableType == OGLSD_PBUFFER)) {
|
|
||||||
// bind pbuffer to the render texture object (since we are preparing
|
|
||||||
// to copy from the pbuffer)
|
|
||||||
CGLSDOps *srcCGLOps = (CGLSDOps *)srcOps->privOps;
|
|
||||||
j2d_glBindTexture(GL_TEXTURE_2D, srcOps->textureID);
|
|
||||||
[ctxinfo->context
|
|
||||||
setTextureImageToPixelBuffer: srcCGLOps->pbuffer
|
|
||||||
colorBuffer: GL_FRONT];
|
|
||||||
}
|
|
||||||
|
|
||||||
JNF_COCOA_EXIT(env);
|
JNF_COCOA_EXIT(env);
|
||||||
|
|
||||||
return oglc;
|
return oglc;
|
||||||
@ -464,105 +432,6 @@ Java_sun_java2d_opengl_CGLSurfaceData_clearWindow
|
|||||||
cglsdo->layer = NULL;
|
cglsdo->layer = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_sun_java2d_opengl_CGLSurfaceData_initPbuffer
|
|
||||||
(JNIEnv *env, jobject cglsd,
|
|
||||||
jlong pData, jlong pConfigInfo, jboolean isOpaque,
|
|
||||||
jint width, jint height)
|
|
||||||
{
|
|
||||||
J2dTraceLn3(J2D_TRACE_INFO, "CGLSurfaceData_initPbuffer: w=%d h=%d opq=%d", width, height, isOpaque);
|
|
||||||
|
|
||||||
OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
|
|
||||||
if (oglsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGLSDOps *cglsdo = (CGLSDOps *)oglsdo->privOps;
|
|
||||||
if (cglsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: cgl ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
CGLGraphicsConfigInfo *cglInfo = (CGLGraphicsConfigInfo *)
|
|
||||||
jlong_to_ptr(pConfigInfo);
|
|
||||||
if (cglInfo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: cgl config info is null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// find the maximum allowable texture dimensions (this value ultimately
|
|
||||||
// determines our maximum pbuffer size)
|
|
||||||
int pbMax = 0;
|
|
||||||
j2d_glGetIntegerv(GL_MAX_TEXTURE_SIZE, &pbMax);
|
|
||||||
|
|
||||||
int pbWidth = 0;
|
|
||||||
int pbHeight = 0;
|
|
||||||
if (OGLC_IS_CAP_PRESENT(cglInfo->context, CAPS_TEXNONPOW2)) {
|
|
||||||
// use non-power-of-two dimensions directly
|
|
||||||
pbWidth = (width <= pbMax) ? width : 0;
|
|
||||||
pbHeight = (height <= pbMax) ? height : 0;
|
|
||||||
} else {
|
|
||||||
// find the appropriate power-of-two dimensions
|
|
||||||
pbWidth = OGLSD_NextPowerOfTwo(width, pbMax);
|
|
||||||
pbHeight = OGLSD_NextPowerOfTwo(height, pbMax);
|
|
||||||
}
|
|
||||||
|
|
||||||
J2dTraceLn3(J2D_TRACE_VERBOSE, " desired pbuffer dimensions: w=%d h=%d max=%d", pbWidth, pbHeight, pbMax);
|
|
||||||
|
|
||||||
// if either dimension is 0, we cannot allocate a pbuffer/texture with the
|
|
||||||
// requested dimensions
|
|
||||||
if (pbWidth == 0 || pbHeight == 0) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: dimensions too large");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
int format = isOpaque ? GL_RGB : GL_RGBA;
|
|
||||||
|
|
||||||
JNF_COCOA_ENTER(env);
|
|
||||||
|
|
||||||
cglsdo->pbuffer =
|
|
||||||
[[NSOpenGLPixelBuffer alloc]
|
|
||||||
initWithTextureTarget: GL_TEXTURE_2D
|
|
||||||
textureInternalFormat: format
|
|
||||||
textureMaxMipMapLevel: 0
|
|
||||||
pixelsWide: pbWidth
|
|
||||||
pixelsHigh: pbHeight];
|
|
||||||
if (cglsdo->pbuffer == nil) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: could not create pbuffer");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure the actual dimensions match those that we requested
|
|
||||||
GLsizei actualWidth = [cglsdo->pbuffer pixelsWide];
|
|
||||||
GLsizei actualHeight = [cglsdo->pbuffer pixelsHigh];
|
|
||||||
if (actualWidth != pbWidth || actualHeight != pbHeight) {
|
|
||||||
J2dRlsTraceLn2(J2D_TRACE_ERROR, "CGLSurfaceData_initPbuffer: actual (w=%d h=%d) != requested", actualWidth, actualHeight);
|
|
||||||
[cglsdo->pbuffer release];
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
GLuint texID = 0;
|
|
||||||
j2d_glGenTextures(1, &texID);
|
|
||||||
j2d_glBindTexture(GL_TEXTURE_2D, texID);
|
|
||||||
|
|
||||||
oglsdo->drawableType = OGLSD_PBUFFER;
|
|
||||||
oglsdo->isOpaque = isOpaque;
|
|
||||||
oglsdo->width = width;
|
|
||||||
oglsdo->height = height;
|
|
||||||
oglsdo->textureID = texID;
|
|
||||||
oglsdo->textureWidth = pbWidth;
|
|
||||||
oglsdo->textureHeight = pbHeight;
|
|
||||||
oglsdo->activeBuffer = GL_FRONT;
|
|
||||||
oglsdo->needsInit = JNI_TRUE;
|
|
||||||
|
|
||||||
OGLSD_INIT_TEXTURE_FILTER(oglsdo, GL_NEAREST);
|
|
||||||
|
|
||||||
JNF_COCOA_EXIT(env);
|
|
||||||
|
|
||||||
return JNI_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
#pragma mark "--- CGLSurfaceData methods - Mac OS X specific ---"
|
#pragma mark "--- CGLSurfaceData methods - Mac OS X specific ---"
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -246,7 +246,7 @@ public abstract class VolatileSurfaceManager
|
|||||||
* SurfaceData object, or null if the surface creation was not successful.
|
* SurfaceData object, or null if the surface creation was not successful.
|
||||||
*
|
*
|
||||||
* Platform-specific subclasses should initialize an accelerated
|
* Platform-specific subclasses should initialize an accelerated
|
||||||
* surface (e.g. a DirectDraw surface on Windows, an OpenGL pbuffer,
|
* surface (e.g. a DirectDraw surface on Windows, an OpenGL FBO,
|
||||||
* or an X11 pixmap).
|
* or an X11 pixmap).
|
||||||
*/
|
*/
|
||||||
protected abstract SurfaceData initAcceleratedSurface();
|
protected abstract SurfaceData initAcceleratedSurface();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -164,9 +164,6 @@ public class OGLContext extends BufferedContext {
|
|||||||
@Native
|
@Native
|
||||||
static final int CAPS_EXT_FBOBJECT =
|
static final int CAPS_EXT_FBOBJECT =
|
||||||
(CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE);
|
(CAPS_RT_TEXTURE_ALPHA | CAPS_RT_TEXTURE_OPAQUE);
|
||||||
/** Indicates that the context supports a stored alpha channel. */
|
|
||||||
@Native
|
|
||||||
static final int CAPS_STORED_ALPHA = CAPS_RT_PLAIN_ALPHA;
|
|
||||||
/** Indicates that the context is doublebuffered. */
|
/** Indicates that the context is doublebuffered. */
|
||||||
@Native
|
@Native
|
||||||
static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0);
|
static final int CAPS_DOUBLEBUFFERED = (FIRST_PRIVATE_CAP << 0);
|
||||||
@ -205,9 +202,6 @@ public class OGLContext extends BufferedContext {
|
|||||||
if ((caps & CAPS_EXT_FBOBJECT) != 0) {
|
if ((caps & CAPS_EXT_FBOBJECT) != 0) {
|
||||||
sb.append("CAPS_EXT_FBOBJECT|");
|
sb.append("CAPS_EXT_FBOBJECT|");
|
||||||
}
|
}
|
||||||
if ((caps & CAPS_STORED_ALPHA) != 0) {
|
|
||||||
sb.append("CAPS_STORED_ALPHA|");
|
|
||||||
}
|
|
||||||
if ((caps & CAPS_DOUBLEBUFFERED) != 0) {
|
if ((caps & CAPS_DOUBLEBUFFERED) != 0) {
|
||||||
sb.append("CAPS_DOUBLEBUFFERED|");
|
sb.append("CAPS_DOUBLEBUFFERED|");
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -91,7 +91,6 @@ import static sun.java2d.opengl.OGLContext.OGLContextCaps.*;
|
|||||||
* OGL Type Corresponding SurfaceType
|
* OGL Type Corresponding SurfaceType
|
||||||
* -------- -------------------------
|
* -------- -------------------------
|
||||||
* WINDOW OpenGLSurface
|
* WINDOW OpenGLSurface
|
||||||
* PBUFFER OpenGLSurface
|
|
||||||
* TEXTURE OpenGLTexture
|
* TEXTURE OpenGLTexture
|
||||||
* FLIP_BACKBUFFER OpenGLSurface
|
* FLIP_BACKBUFFER OpenGLSurface
|
||||||
* FBOBJECT OpenGLSurfaceRTT
|
* FBOBJECT OpenGLSurfaceRTT
|
||||||
@ -104,7 +103,6 @@ public abstract class OGLSurfaceData extends SurfaceData
|
|||||||
*
|
*
|
||||||
* @see sun.java2d.pipe.hw.AccelSurface
|
* @see sun.java2d.pipe.hw.AccelSurface
|
||||||
*/
|
*/
|
||||||
public static final int PBUFFER = RT_PLAIN;
|
|
||||||
public static final int FBOBJECT = RT_TEXTURE;
|
public static final int FBOBJECT = RT_TEXTURE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,9 +170,6 @@ public abstract class OGLSurfaceData extends SurfaceData
|
|||||||
boolean texRect,
|
boolean texRect,
|
||||||
int width, int height);
|
int width, int height);
|
||||||
protected native boolean initFlipBackbuffer(long pData);
|
protected native boolean initFlipBackbuffer(long pData);
|
||||||
protected abstract boolean initPbuffer(long pData, long pConfigInfo,
|
|
||||||
boolean isOpaque,
|
|
||||||
int width, int height);
|
|
||||||
|
|
||||||
private native int getTextureTarget(long pData);
|
private native int getTextureTarget(long pData);
|
||||||
private native int getTextureID(long pData);
|
private native int getTextureID(long pData);
|
||||||
@ -250,7 +245,6 @@ public abstract class OGLSurfaceData extends SurfaceData
|
|||||||
return OpenGLTexture;
|
return OpenGLTexture;
|
||||||
case FBOBJECT:
|
case FBOBJECT:
|
||||||
return OpenGLSurfaceRTT;
|
return OpenGLSurfaceRTT;
|
||||||
case PBUFFER:
|
|
||||||
default:
|
default:
|
||||||
return OpenGLSurface;
|
return OpenGLSurface;
|
||||||
}
|
}
|
||||||
@ -266,13 +260,6 @@ public abstract class OGLSurfaceData extends SurfaceData
|
|||||||
boolean success = false;
|
boolean success = false;
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PBUFFER:
|
|
||||||
success = initPbuffer(getNativeOps(),
|
|
||||||
graphicsConfig.getNativeConfigInfo(),
|
|
||||||
isOpaque,
|
|
||||||
width, height);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TEXTURE:
|
case TEXTURE:
|
||||||
success = initTexture(getNativeOps(),
|
success = initTexture(getNativeOps(),
|
||||||
isOpaque, isTexNonPow2Available(),
|
isOpaque, isTexNonPow2Available(),
|
||||||
@ -311,10 +298,9 @@ public abstract class OGLSurfaceData extends SurfaceData
|
|||||||
try {
|
try {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case TEXTURE:
|
case TEXTURE:
|
||||||
case PBUFFER:
|
|
||||||
case FBOBJECT:
|
case FBOBJECT:
|
||||||
// need to make sure the context is current before
|
// need to make sure the context is current before
|
||||||
// creating the texture (or pbuffer, or fbobject)
|
// creating the texture or fbobject
|
||||||
OGLContext.setScratchSurface(graphicsConfig);
|
OGLContext.setScratchSurface(graphicsConfig);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -51,7 +51,6 @@ class OGLUtilities {
|
|||||||
*/
|
*/
|
||||||
public static final int UNDEFINED = OGLSurfaceData.UNDEFINED;
|
public static final int UNDEFINED = OGLSurfaceData.UNDEFINED;
|
||||||
public static final int WINDOW = OGLSurfaceData.WINDOW;
|
public static final int WINDOW = OGLSurfaceData.WINDOW;
|
||||||
public static final int PBUFFER = OGLSurfaceData.PBUFFER;
|
|
||||||
public static final int TEXTURE = OGLSurfaceData.TEXTURE;
|
public static final int TEXTURE = OGLSurfaceData.TEXTURE;
|
||||||
public static final int FLIP_BACKBUFFER = OGLSurfaceData.FLIP_BACKBUFFER;
|
public static final int FLIP_BACKBUFFER = OGLSurfaceData.FLIP_BACKBUFFER;
|
||||||
public static final int FBOBJECT = OGLSurfaceData.FBOBJECT;
|
public static final int FBOBJECT = OGLSurfaceData.FBOBJECT;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,8 +43,7 @@ public interface AccelSurface extends BufferedContextProvider, Surface {
|
|||||||
*/
|
*/
|
||||||
@Native public static final int WINDOW = 1;
|
@Native public static final int WINDOW = 1;
|
||||||
/**
|
/**
|
||||||
* Render-To Plain surface (pbuffer for OpenGL, Render Target surface
|
* Render-To Plain surface (Render Target surface for Direct3D)
|
||||||
* for Direct3D)
|
|
||||||
*/
|
*/
|
||||||
@Native public static final int RT_PLAIN = 2;
|
@Native public static final int RT_PLAIN = 2;
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -122,8 +122,6 @@ typedef struct {
|
|||||||
sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP
|
sun_java2d_opengl_OGLContext_OGLContextCaps_LAST_SHARED_CAP
|
||||||
#define CAPS_EXT_FBOBJECT \
|
#define CAPS_EXT_FBOBJECT \
|
||||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT
|
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_EXT_FBOBJECT
|
||||||
#define CAPS_STORED_ALPHA \
|
|
||||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_STORED_ALPHA
|
|
||||||
#define CAPS_DOUBLEBUFFERED \
|
#define CAPS_DOUBLEBUFFERED \
|
||||||
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED
|
sun_java2d_opengl_OGLContext_OGLContextCaps_CAPS_DOUBLEBUFFERED
|
||||||
#define CAPS_EXT_LCD_SHADER \
|
#define CAPS_EXT_LCD_SHADER \
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -118,7 +118,7 @@ typedef struct {
|
|||||||
* x/yOffset would be (0,0) (the same applies to pbuffers).
|
* x/yOffset would be (0,0) (the same applies to pbuffers).
|
||||||
*
|
*
|
||||||
* jint width/height;
|
* jint width/height;
|
||||||
* The cached surface bounds. For offscreen surface types (OGLSD_PBUFFER,
|
* The cached surface bounds. For offscreen surface types (OGLSD_FBOBJECT,
|
||||||
* OGLSD_TEXTURE, etc.) these values must remain constant. Onscreen window
|
* OGLSD_TEXTURE, etc.) these values must remain constant. Onscreen window
|
||||||
* surfaces (OGLSD_WINDOW, OGLSD_FLIP_BACKBUFFER, etc.) may have their
|
* surfaces (OGLSD_WINDOW, OGLSD_FLIP_BACKBUFFER, etc.) may have their
|
||||||
* bounds changed in response to a programmatic or user-initiated event, so
|
* bounds changed in response to a programmatic or user-initiated event, so
|
||||||
@ -218,7 +218,6 @@ struct _OGLSDOps {
|
|||||||
*/
|
*/
|
||||||
#define OGLSD_UNDEFINED sun_java2d_pipe_hw_AccelSurface_UNDEFINED
|
#define OGLSD_UNDEFINED sun_java2d_pipe_hw_AccelSurface_UNDEFINED
|
||||||
#define OGLSD_WINDOW sun_java2d_pipe_hw_AccelSurface_WINDOW
|
#define OGLSD_WINDOW sun_java2d_pipe_hw_AccelSurface_WINDOW
|
||||||
#define OGLSD_PBUFFER sun_java2d_pipe_hw_AccelSurface_RT_PLAIN
|
|
||||||
#define OGLSD_TEXTURE sun_java2d_pipe_hw_AccelSurface_TEXTURE
|
#define OGLSD_TEXTURE sun_java2d_pipe_hw_AccelSurface_TEXTURE
|
||||||
#define OGLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER
|
#define OGLSD_FLIP_BACKBUFFER sun_java2d_pipe_hw_AccelSurface_FLIP_BACKBUFFER
|
||||||
#define OGLSD_FBOBJECT sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
|
#define OGLSD_FBOBJECT sun_java2d_pipe_hw_AccelSurface_RT_TEXTURE
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -399,23 +399,11 @@ public class GLXGraphicsConfig
|
|||||||
createCompatibleVolatileImage(int width, int height,
|
createCompatibleVolatileImage(int width, int height,
|
||||||
int transparency, int type)
|
int transparency, int type)
|
||||||
{
|
{
|
||||||
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
|
if ((type != FBOBJECT && type != TEXTURE)
|
||||||
transparency == Transparency.BITMASK)
|
|| transparency == Transparency.BITMASK
|
||||||
{
|
|| type == FBOBJECT && !isCapPresent(CAPS_EXT_FBOBJECT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == FBOBJECT) {
|
|
||||||
if (!isCapPresent(CAPS_EXT_FBOBJECT)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else if (type == PBUFFER) {
|
|
||||||
boolean isOpaque = transparency == Transparency.OPAQUE;
|
|
||||||
if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
||||||
transparency, type);
|
transparency, type);
|
||||||
Surface sd = vi.getDestSurface();
|
Surface sd = vi.getDestSurface();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -30,11 +30,10 @@ import java.awt.GraphicsDevice;
|
|||||||
import java.awt.GraphicsEnvironment;
|
import java.awt.GraphicsEnvironment;
|
||||||
import java.awt.Image;
|
import java.awt.Image;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.Transparency;
|
|
||||||
import java.awt.image.ColorModel;
|
import java.awt.image.ColorModel;
|
||||||
|
|
||||||
import sun.awt.X11ComponentPeer;
|
import sun.awt.X11ComponentPeer;
|
||||||
import sun.java2d.SurfaceData;
|
import sun.java2d.SurfaceData;
|
||||||
import sun.java2d.loops.SurfaceType;
|
|
||||||
|
|
||||||
public abstract class GLXSurfaceData extends OGLSurfaceData {
|
public abstract class GLXSurfaceData extends OGLSurfaceData {
|
||||||
|
|
||||||
@ -42,9 +41,6 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
|
|||||||
private GLXGraphicsConfig graphicsConfig;
|
private GLXGraphicsConfig graphicsConfig;
|
||||||
|
|
||||||
private native void initOps(X11ComponentPeer peer, long aData);
|
private native void initOps(X11ComponentPeer peer, long aData);
|
||||||
protected native boolean initPbuffer(long pData, long pConfigInfo,
|
|
||||||
boolean isOpaque,
|
|
||||||
int width, int height);
|
|
||||||
|
|
||||||
protected GLXSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc,
|
protected GLXSurfaceData(X11ComponentPeer peer, GLXGraphicsConfig gc,
|
||||||
ColorModel cm, int type)
|
ColorModel cm, int type)
|
||||||
@ -91,7 +87,7 @@ public abstract class GLXSurfaceData extends OGLSurfaceData {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a SurfaceData object representing an off-screen buffer (either
|
* Creates a SurfaceData object representing an off-screen buffer (either
|
||||||
* a Pbuffer or Texture).
|
* a FBO or Texture).
|
||||||
*/
|
*/
|
||||||
public static GLXOffScreenSurfaceData createData(GLXGraphicsConfig gc,
|
public static GLXOffScreenSurfaceData createData(GLXGraphicsConfig gc,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
|
@ -46,7 +46,7 @@ import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
|||||||
|
|
||||||
public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||||
|
|
||||||
private boolean accelerationEnabled;
|
private final boolean accelerationEnabled;
|
||||||
|
|
||||||
public GLXVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
public GLXVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
||||||
super(vImg, context);
|
super(vImg, context);
|
||||||
@ -54,18 +54,13 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
/*
|
/*
|
||||||
* We will attempt to accelerate this image only under the
|
* We will attempt to accelerate this image only under the
|
||||||
* following conditions:
|
* following conditions:
|
||||||
* - the image is opaque OR
|
* - the image is not bitmask AND the GraphicsConfig supports the FBO
|
||||||
* - the image is translucent AND
|
* extension
|
||||||
* - the GraphicsConfig supports the FBO extension OR
|
|
||||||
* - the GraphicsConfig has a stored alpha channel
|
|
||||||
*/
|
*/
|
||||||
int transparency = vImg.getTransparency();
|
int transparency = vImg.getTransparency();
|
||||||
GLXGraphicsConfig gc = (GLXGraphicsConfig)vImg.getGraphicsConfig();
|
GLXGraphicsConfig gc = (GLXGraphicsConfig) vImg.getGraphicsConfig();
|
||||||
accelerationEnabled =
|
accelerationEnabled = gc.isCapPresent(CAPS_EXT_FBOBJECT)
|
||||||
(transparency == Transparency.OPAQUE) ||
|
&& transparency != Transparency.BITMASK;
|
||||||
((transparency == Transparency.TRANSLUCENT) &&
|
|
||||||
(gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
|
|
||||||
gc.isCapPresent(CAPS_STORED_ALPHA)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAccelerationEnabled() {
|
protected boolean isAccelerationEnabled() {
|
||||||
@ -73,7 +68,7 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a pbuffer-based SurfaceData object (or init the backbuffer
|
* Create a FBO-based SurfaceData object (or init the backbuffer
|
||||||
* of an existing window if this is a double buffered GraphicsConfig)
|
* of an existing window if this is a double buffered GraphicsConfig)
|
||||||
*/
|
*/
|
||||||
protected SurfaceData initAcceleratedSurface() {
|
protected SurfaceData initAcceleratedSurface() {
|
||||||
@ -113,10 +108,9 @@ public class GLXVolatileSurfaceManager extends VolatileSurfaceManager {
|
|||||||
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
||||||
int type = vImg.getForcedAccelSurfaceType();
|
int type = vImg.getForcedAccelSurfaceType();
|
||||||
// if acceleration type is forced (type != UNDEFINED) then
|
// if acceleration type is forced (type != UNDEFINED) then
|
||||||
// use the forced type, otherwise choose one based on caps
|
// use the forced type, otherwise choose FBOBJECT
|
||||||
if (type == OGLSurfaceData.UNDEFINED) {
|
if (type == OGLSurfaceData.UNDEFINED) {
|
||||||
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ?
|
type = OGLSurfaceData.FBOBJECT;
|
||||||
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
|
|
||||||
}
|
}
|
||||||
if (createVSynced) {
|
if (createVSynced) {
|
||||||
sData = GLXSurfaceData.createData(peer, vImg, type);
|
sData = GLXSurfaceData.createData(peer, vImg, type);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -472,7 +472,7 @@ Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
|
|||||||
GLXPbuffer scratch;
|
GLXPbuffer scratch;
|
||||||
GLXGraphicsConfigInfo *glxinfo;
|
GLXGraphicsConfigInfo *glxinfo;
|
||||||
jint caps = CAPS_EMPTY;
|
jint caps = CAPS_EMPTY;
|
||||||
int db, alpha;
|
int db;
|
||||||
const unsigned char *versionstr;
|
const unsigned char *versionstr;
|
||||||
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getGLXConfigInfo");
|
J2dRlsTraceLn(J2D_TRACE_INFO, "GLXGraphicsConfig_getGLXConfigInfo");
|
||||||
@ -583,10 +583,6 @@ Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo(JNIEnv *env,
|
|||||||
if (db) {
|
if (db) {
|
||||||
caps |= CAPS_DOUBLEBUFFERED;
|
caps |= CAPS_DOUBLEBUFFERED;
|
||||||
}
|
}
|
||||||
j2d_glXGetFBConfigAttrib(awt_display, fbconfig, GLX_ALPHA_SIZE, &alpha);
|
|
||||||
if (alpha > 0) {
|
|
||||||
caps |= CAPS_STORED_ALPHA;
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
|
// initialize the OGLContext, which wraps the GLXFBConfig and GLXContext
|
||||||
oglc = GLXGC_InitOGLContext(fbconfig, context, scratch, caps);
|
oglc = GLXGC_InitOGLContext(fbconfig, context, scratch, caps);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -111,25 +111,13 @@ Java_sun_java2d_opengl_GLXSurfaceData_initOps(JNIEnv *env, jobject glxsd,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function disposes of any native windowing system resources associated
|
* This function disposes of any native windowing system resources associated
|
||||||
* with this surface. For instance, if the given OGLSDOps is of type
|
* with this surface.
|
||||||
* OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
|
|
||||||
* surface.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
||||||
{
|
{
|
||||||
GLXSDOps *glxsdo = (GLXSDOps *)oglsdo->privOps;
|
|
||||||
|
|
||||||
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
|
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
|
||||||
|
// X Window is free'd later by AWT code...
|
||||||
if (oglsdo->drawableType == OGLSD_PBUFFER) {
|
|
||||||
if (glxsdo->drawable != 0) {
|
|
||||||
j2d_glXDestroyPbuffer(awt_display, glxsdo->drawable);
|
|
||||||
glxsdo->drawable = 0;
|
|
||||||
}
|
|
||||||
} else if (oglsdo->drawableType == OGLSD_WINDOW) {
|
|
||||||
// X Window is free'd later by AWT code...
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,74 +346,6 @@ GLXSD_BadAllocXErrHandler(Display *display, XErrorEvent *xerr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_sun_java2d_opengl_GLXSurfaceData_initPbuffer
|
|
||||||
(JNIEnv *env, jobject glxsd,
|
|
||||||
jlong pData, jlong pConfigInfo,
|
|
||||||
jboolean isOpaque,
|
|
||||||
jint width, jint height)
|
|
||||||
{
|
|
||||||
OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
|
|
||||||
GLXGraphicsConfigInfo *glxinfo =
|
|
||||||
(GLXGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
|
|
||||||
GLXSDOps *glxsdo;
|
|
||||||
GLXPbuffer pbuffer;
|
|
||||||
int attrlist[] = {GLX_PBUFFER_WIDTH, 0,
|
|
||||||
GLX_PBUFFER_HEIGHT, 0,
|
|
||||||
GLX_PRESERVED_CONTENTS, GL_FALSE, 0};
|
|
||||||
|
|
||||||
J2dTraceLn3(J2D_TRACE_INFO,
|
|
||||||
"GLXSurfaceData_initPbuffer: w=%d h=%d opq=%d",
|
|
||||||
width, height, isOpaque);
|
|
||||||
|
|
||||||
if (oglsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"GLXSurfaceData_initPbuffer: ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
glxsdo = (GLXSDOps *)oglsdo->privOps;
|
|
||||||
if (glxsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"GLXSurfaceData_initPbuffer: glx ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (glxinfo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"GLXSurfaceData_initPbuffer: glx config info is null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
attrlist[1] = width;
|
|
||||||
attrlist[3] = height;
|
|
||||||
|
|
||||||
surfaceCreationFailed = JNI_FALSE;
|
|
||||||
EXEC_WITH_XERROR_HANDLER(
|
|
||||||
GLXSD_BadAllocXErrHandler,
|
|
||||||
pbuffer = j2d_glXCreatePbuffer(awt_display,
|
|
||||||
glxinfo->fbconfig, attrlist));
|
|
||||||
if ((pbuffer == 0) || surfaceCreationFailed) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"GLXSurfaceData_initPbuffer: could not create glx pbuffer");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
oglsdo->drawableType = OGLSD_PBUFFER;
|
|
||||||
oglsdo->isOpaque = isOpaque;
|
|
||||||
oglsdo->width = width;
|
|
||||||
oglsdo->height = height;
|
|
||||||
oglsdo->xOffset = 0;
|
|
||||||
oglsdo->yOffset = 0;
|
|
||||||
|
|
||||||
glxsdo->drawable = pbuffer;
|
|
||||||
glxsdo->xdrawable = 0;
|
|
||||||
|
|
||||||
OGLSD_SetNativeDimensions(env, oglsdo, width, height);
|
|
||||||
|
|
||||||
return JNI_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OGLSD_SwapBuffers(JNIEnv *env, jlong window)
|
OGLSD_SwapBuffers(JNIEnv *env, jlong window)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -27,7 +27,6 @@ package sun.java2d.opengl;
|
|||||||
|
|
||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
import java.awt.BufferCapabilities;
|
import java.awt.BufferCapabilities;
|
||||||
import java.awt.BufferCapabilities.FlipContents;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@ -425,23 +424,11 @@ public class WGLGraphicsConfig
|
|||||||
createCompatibleVolatileImage(int width, int height,
|
createCompatibleVolatileImage(int width, int height,
|
||||||
int transparency, int type)
|
int transparency, int type)
|
||||||
{
|
{
|
||||||
if (type == FLIP_BACKBUFFER || type == WINDOW || type == UNDEFINED ||
|
if ((type != FBOBJECT && type != TEXTURE)
|
||||||
transparency == Transparency.BITMASK)
|
|| transparency == Transparency.BITMASK
|
||||||
{
|
|| type == FBOBJECT && !isCapPresent(CAPS_EXT_FBOBJECT)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == FBOBJECT) {
|
|
||||||
if (!isCapPresent(CAPS_EXT_FBOBJECT)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
} else if (type == PBUFFER) {
|
|
||||||
boolean isOpaque = transparency == Transparency.OPAQUE;
|
|
||||||
if (!isOpaque && !isCapPresent(CAPS_STORED_ALPHA)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
SunVolatileImage vi = new AccelTypedVolatileImage(this, width, height,
|
||||||
transparency, type);
|
transparency, type);
|
||||||
Surface sd = vi.getDestSurface();
|
Surface sd = vi.getDestSurface();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2009, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -43,9 +43,6 @@ public abstract class WGLSurfaceData extends OGLSurfaceData {
|
|||||||
|
|
||||||
private native void initOps(long pConfigInfo, WComponentPeer peer,
|
private native void initOps(long pConfigInfo, WComponentPeer peer,
|
||||||
long hwnd);
|
long hwnd);
|
||||||
protected native boolean initPbuffer(long pData, long pConfigInfo,
|
|
||||||
boolean isOpaque,
|
|
||||||
int width, int height);
|
|
||||||
|
|
||||||
protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
|
protected WGLSurfaceData(WComponentPeer peer, WGLGraphicsConfig gc,
|
||||||
ColorModel cm, int type)
|
ColorModel cm, int type)
|
||||||
|
@ -43,10 +43,9 @@ import static sun.java2d.pipe.hw.AccelSurface.*;
|
|||||||
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
|
import sun.java2d.pipe.hw.ExtendedBufferCapabilities;
|
||||||
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*;
|
||||||
|
|
||||||
public class WGLVolatileSurfaceManager
|
public class WGLVolatileSurfaceManager extends VolatileSurfaceManager {
|
||||||
extends VolatileSurfaceManager
|
|
||||||
{
|
private final boolean accelerationEnabled;
|
||||||
private boolean accelerationEnabled;
|
|
||||||
|
|
||||||
public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
public WGLVolatileSurfaceManager(SunVolatileImage vImg, Object context) {
|
||||||
super(vImg, context);
|
super(vImg, context);
|
||||||
@ -54,18 +53,13 @@ public class WGLVolatileSurfaceManager
|
|||||||
/*
|
/*
|
||||||
* We will attempt to accelerate this image only under the
|
* We will attempt to accelerate this image only under the
|
||||||
* following conditions:
|
* following conditions:
|
||||||
* - the image is opaque OR
|
* - the image is not bitmask AND the GraphicsConfig supports the FBO
|
||||||
* - the image is translucent AND
|
* extension
|
||||||
* - the GraphicsConfig supports the FBO extension OR
|
|
||||||
* - the GraphicsConfig has a stored alpha channel
|
|
||||||
*/
|
*/
|
||||||
int transparency = vImg.getTransparency();
|
int transparency = vImg.getTransparency();
|
||||||
WGLGraphicsConfig gc = (WGLGraphicsConfig)vImg.getGraphicsConfig();
|
WGLGraphicsConfig gc = (WGLGraphicsConfig) vImg.getGraphicsConfig();
|
||||||
accelerationEnabled =
|
accelerationEnabled = gc.isCapPresent(CAPS_EXT_FBOBJECT)
|
||||||
(transparency == Transparency.OPAQUE) ||
|
&& transparency != Transparency.BITMASK;
|
||||||
((transparency == Transparency.TRANSLUCENT) &&
|
|
||||||
(gc.isCapPresent(CAPS_EXT_FBOBJECT) ||
|
|
||||||
gc.isCapPresent(CAPS_STORED_ALPHA)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isAccelerationEnabled() {
|
protected boolean isAccelerationEnabled() {
|
||||||
@ -73,7 +67,7 @@ public class WGLVolatileSurfaceManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a pbuffer-based SurfaceData object (or init the backbuffer
|
* Create a FBO-based SurfaceData object (or init the backbuffer
|
||||||
* of an existing window if this is a double buffered GraphicsConfig).
|
* of an existing window if this is a double buffered GraphicsConfig).
|
||||||
*/
|
*/
|
||||||
protected SurfaceData initAcceleratedSurface() {
|
protected SurfaceData initAcceleratedSurface() {
|
||||||
@ -111,10 +105,9 @@ public class WGLVolatileSurfaceManager
|
|||||||
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
ColorModel cm = gc.getColorModel(vImg.getTransparency());
|
||||||
int type = vImg.getForcedAccelSurfaceType();
|
int type = vImg.getForcedAccelSurfaceType();
|
||||||
// if acceleration type is forced (type != UNDEFINED) then
|
// if acceleration type is forced (type != UNDEFINED) then
|
||||||
// use the forced type, otherwise choose one based on caps
|
// use the forced type, otherwise choose FBOBJECT
|
||||||
if (type == OGLSurfaceData.UNDEFINED) {
|
if (type == OGLSurfaceData.UNDEFINED) {
|
||||||
type = gc.isCapPresent(CAPS_EXT_FBOBJECT) ?
|
type = OGLSurfaceData.FBOBJECT;
|
||||||
OGLSurfaceData.FBOBJECT : OGLSurfaceData.PBUFFER;
|
|
||||||
}
|
}
|
||||||
if (createVSynced) {
|
if (createVSynced) {
|
||||||
sData = WGLSurfaceData.createData(peer, vImg, type);
|
sData = WGLSurfaceData.createData(peer, vImg, type);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2008, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -502,8 +502,8 @@ Java_sun_java2d_opengl_WGLGraphicsConfig_getWGLConfigInfo(JNIEnv *env,
|
|||||||
const unsigned char *versionstr;
|
const unsigned char *versionstr;
|
||||||
const char *extstr;
|
const char *extstr;
|
||||||
jint caps = CAPS_EMPTY;
|
jint caps = CAPS_EMPTY;
|
||||||
int attrKeys[] = { WGL_DOUBLE_BUFFER_ARB, WGL_ALPHA_BITS_ARB };
|
int attrKeys[] = { WGL_DOUBLE_BUFFER_ARB};
|
||||||
int attrVals[2];
|
int attrVals[1];
|
||||||
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getWGLConfigInfo");
|
J2dRlsTraceLn(J2D_TRACE_INFO, "WGLGraphicsConfig_getWGLConfigInfo");
|
||||||
|
|
||||||
@ -624,13 +624,10 @@ Java_sun_java2d_opengl_WGLGraphicsConfig_getWGLConfigInfo(JNIEnv *env,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get config-specific capabilities
|
// get config-specific capabilities
|
||||||
j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 2, attrKeys, attrVals);
|
j2d_wglGetPixelFormatAttribivARB(hdc, pixfmt, 0, 1, attrKeys, attrVals);
|
||||||
if (attrVals[0]) {
|
if (attrVals[0]) {
|
||||||
caps |= CAPS_DOUBLEBUFFERED;
|
caps |= CAPS_DOUBLEBUFFERED;
|
||||||
}
|
}
|
||||||
if (attrVals[1] > 0) {
|
|
||||||
caps |= CAPS_STORED_ALPHA;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create the scratch pbuffer
|
// create the scratch pbuffer
|
||||||
scratch = j2d_wglCreatePbufferARB(hdc, pixfmt, 1, 1, NULL);
|
scratch = j2d_wglCreatePbufferARB(hdc, pixfmt, 1, 1, NULL);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -107,28 +107,13 @@ Java_sun_java2d_opengl_WGLSurfaceData_initOps(JNIEnv *env, jobject wglsd,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This function disposes of any native windowing system resources associated
|
* This function disposes of any native windowing system resources associated
|
||||||
* with this surface. For instance, if the given OGLSDOps is of type
|
* with this surface.
|
||||||
* OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
|
|
||||||
* surface.
|
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo)
|
||||||
{
|
{
|
||||||
WGLSDOps *wglsdo = (WGLSDOps *)oglsdo->privOps;
|
|
||||||
|
|
||||||
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
|
J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface");
|
||||||
|
// Window is free'd later by AWT code...
|
||||||
if (oglsdo->drawableType == OGLSD_PBUFFER) {
|
|
||||||
if (wglsdo->pbuffer != 0) {
|
|
||||||
if (wglsdo->pbufferDC != 0) {
|
|
||||||
j2d_wglReleasePbufferDCARB(wglsdo->pbuffer,
|
|
||||||
wglsdo->pbufferDC);
|
|
||||||
wglsdo->pbufferDC = 0;
|
|
||||||
}
|
|
||||||
j2d_wglDestroyPbufferARB(wglsdo->pbuffer);
|
|
||||||
wglsdo->pbuffer = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -276,19 +261,11 @@ OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
|
|||||||
ctxinfo = (WGLCtxInfo *)oglc->ctxInfo;
|
ctxinfo = (WGLCtxInfo *)oglc->ctxInfo;
|
||||||
|
|
||||||
// get the hdc for the destination surface
|
// get the hdc for the destination surface
|
||||||
if (dstOps->drawableType == OGLSD_PBUFFER) {
|
dstHDC = GetDC(dstWGLOps->window);
|
||||||
dstHDC = dstWGLOps->pbufferDC;
|
|
||||||
} else {
|
|
||||||
dstHDC = GetDC(dstWGLOps->window);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the hdc for the source surface
|
// get the hdc for the source surface
|
||||||
if (srcOps->drawableType == OGLSD_PBUFFER) {
|
// the source will always be equal to the destination in this case
|
||||||
srcHDC = srcWGLOps->pbufferDC;
|
srcHDC = dstHDC;
|
||||||
} else {
|
|
||||||
// the source will always be equal to the destination in this case
|
|
||||||
srcHDC = dstHDC;
|
|
||||||
}
|
|
||||||
|
|
||||||
// REMIND: in theory we should be able to use wglMakeContextCurrentARB()
|
// REMIND: in theory we should be able to use wglMakeContextCurrentARB()
|
||||||
// even when the src/dst surfaces are the same, but this causes problems
|
// even when the src/dst surfaces are the same, but this causes problems
|
||||||
@ -306,9 +283,7 @@ OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
||||||
"OGLSD_MakeOGLContextCurrent: could not make current");
|
"OGLSD_MakeOGLContextCurrent: could not make current");
|
||||||
if (dstOps->drawableType != OGLSD_PBUFFER) {
|
ReleaseDC(dstWGLOps->window, dstHDC);
|
||||||
ReleaseDC(dstWGLOps->window, dstHDC);
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,9 +294,7 @@ OGLSD_MakeOGLContextCurrent(JNIEnv *env, OGLSDOps *srcOps, OGLSDOps *dstOps)
|
|||||||
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dstOps->drawableType != OGLSD_PBUFFER) {
|
ReleaseDC(dstWGLOps->window, dstHDC);
|
||||||
ReleaseDC(dstWGLOps->window, dstHDC);
|
|
||||||
}
|
|
||||||
|
|
||||||
return oglc;
|
return oglc;
|
||||||
}
|
}
|
||||||
@ -400,141 +373,6 @@ OGLSD_InitOGLWindow(JNIEnv *env, OGLSDOps *oglsdo)
|
|||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
|
||||||
Java_sun_java2d_opengl_WGLSurfaceData_initPbuffer
|
|
||||||
(JNIEnv *env, jobject wglsd,
|
|
||||||
jlong pData, jlong pConfigInfo,
|
|
||||||
jboolean isOpaque,
|
|
||||||
jint width, jint height)
|
|
||||||
{
|
|
||||||
int attrKeys[] = {
|
|
||||||
WGL_MAX_PBUFFER_WIDTH_ARB,
|
|
||||||
WGL_MAX_PBUFFER_HEIGHT_ARB,
|
|
||||||
};
|
|
||||||
int attrVals[2];
|
|
||||||
int pbAttrList[] = { 0 };
|
|
||||||
OGLSDOps *oglsdo = (OGLSDOps *)jlong_to_ptr(pData);
|
|
||||||
WGLGraphicsConfigInfo *wglInfo =
|
|
||||||
(WGLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo);
|
|
||||||
WGLSDOps *wglsdo;
|
|
||||||
HWND hwnd;
|
|
||||||
HDC hdc, pbufferDC;
|
|
||||||
HPBUFFERARB pbuffer;
|
|
||||||
int maxWidth, maxHeight;
|
|
||||||
int actualWidth, actualHeight;
|
|
||||||
|
|
||||||
J2dTraceLn3(J2D_TRACE_INFO,
|
|
||||||
"WGLSurfaceData_initPbuffer: w=%d h=%d opq=%d",
|
|
||||||
width, height, isOpaque);
|
|
||||||
|
|
||||||
if (oglsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
wglsdo = (WGLSDOps *)oglsdo->privOps;
|
|
||||||
if (wglsdo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: wgl ops are null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wglInfo == NULL) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: wgl config info is null");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// create a scratch window
|
|
||||||
hwnd = WGLGC_CreateScratchWindow(wglInfo->screen);
|
|
||||||
if (hwnd == 0) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: could not create scratch window");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the HDC for the scratch window
|
|
||||||
hdc = GetDC(hwnd);
|
|
||||||
if (hdc == 0) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: could not get dc for scratch window");
|
|
||||||
DestroyWindow(hwnd);
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get the maximum allowable pbuffer dimensions
|
|
||||||
j2d_wglGetPixelFormatAttribivARB(hdc, wglInfo->pixfmt, 0, 2,
|
|
||||||
attrKeys, attrVals);
|
|
||||||
maxWidth = attrVals[0];
|
|
||||||
maxHeight = attrVals[1];
|
|
||||||
|
|
||||||
J2dTraceLn4(J2D_TRACE_VERBOSE,
|
|
||||||
" desired pbuffer dimensions: w=%d h=%d maxw=%d maxh=%d",
|
|
||||||
width, height, maxWidth, maxHeight);
|
|
||||||
|
|
||||||
// if either dimension is 0 or larger than the maximum, we cannot
|
|
||||||
// allocate a pbuffer with the requested dimensions
|
|
||||||
if (width == 0 || width > maxWidth ||
|
|
||||||
height == 0 || height > maxHeight)
|
|
||||||
{
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: invalid dimensions");
|
|
||||||
ReleaseDC(hwnd, hdc);
|
|
||||||
DestroyWindow(hwnd);
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
pbuffer = j2d_wglCreatePbufferARB(hdc, wglInfo->pixfmt,
|
|
||||||
width, height, pbAttrList);
|
|
||||||
|
|
||||||
ReleaseDC(hwnd, hdc);
|
|
||||||
DestroyWindow(hwnd);
|
|
||||||
|
|
||||||
if (pbuffer == 0) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: could not create wgl pbuffer");
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// note that we get the DC for the pbuffer at creation time, and then
|
|
||||||
// release the DC when the pbuffer is disposed; the WGL_ARB_pbuffer
|
|
||||||
// spec is vague about such things, but from past experience we know
|
|
||||||
// this approach to be more robust than, for example, doing a
|
|
||||||
// Get/ReleasePbufferDC() everytime we make a context current
|
|
||||||
pbufferDC = j2d_wglGetPbufferDCARB(pbuffer);
|
|
||||||
if (pbufferDC == 0) {
|
|
||||||
J2dRlsTraceLn(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: could not get dc for pbuffer");
|
|
||||||
j2d_wglDestroyPbufferARB(pbuffer);
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// make sure the actual dimensions match those that we requested
|
|
||||||
j2d_wglQueryPbufferARB(pbuffer, WGL_PBUFFER_WIDTH_ARB, &actualWidth);
|
|
||||||
j2d_wglQueryPbufferARB(pbuffer, WGL_PBUFFER_HEIGHT_ARB, &actualHeight);
|
|
||||||
|
|
||||||
if (width != actualWidth || height != actualHeight) {
|
|
||||||
J2dRlsTraceLn2(J2D_TRACE_ERROR,
|
|
||||||
"WGLSurfaceData_initPbuffer: actual (w=%d h=%d) != requested",
|
|
||||||
actualWidth, actualHeight);
|
|
||||||
j2d_wglReleasePbufferDCARB(pbuffer, pbufferDC);
|
|
||||||
j2d_wglDestroyPbufferARB(pbuffer);
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
oglsdo->drawableType = OGLSD_PBUFFER;
|
|
||||||
oglsdo->isOpaque = isOpaque;
|
|
||||||
oglsdo->width = width;
|
|
||||||
oglsdo->height = height;
|
|
||||||
wglsdo->pbuffer = pbuffer;
|
|
||||||
wglsdo->pbufferDC = pbufferDC;
|
|
||||||
|
|
||||||
OGLSD_SetNativeDimensions(env, oglsdo, width, height);
|
|
||||||
|
|
||||||
return JNI_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
|
OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
* version 2 for more details (a copy is included in the LICENSE file that
|
||||||
|
* accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License version
|
||||||
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.awt.AlphaComposite;
|
||||||
|
import java.awt.Color;
|
||||||
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Image;
|
||||||
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.awt.image.VolatileImage;
|
||||||
|
|
||||||
|
import static java.awt.Transparency.BITMASK;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @test
|
||||||
|
* @bug 7188942
|
||||||
|
* @summary We should get correct volatile image, when we use BITMASK
|
||||||
|
* transparency
|
||||||
|
*/
|
||||||
|
public final class BitmaskVolatileImage {
|
||||||
|
|
||||||
|
public static final int S = 8;
|
||||||
|
|
||||||
|
public static void main(final String[] args) {
|
||||||
|
GraphicsConfiguration gc =
|
||||||
|
GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
|
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||||
|
VolatileImage vi = gc.createCompatibleVolatileImage(S, S, BITMASK);
|
||||||
|
BufferedImage ci = gc.createCompatibleImage(S, S, BITMASK);
|
||||||
|
|
||||||
|
int attempt = 0;
|
||||||
|
do {
|
||||||
|
if (++attempt > 10) {
|
||||||
|
throw new RuntimeException("Too many attempts: " + attempt);
|
||||||
|
}
|
||||||
|
vi.validate(gc);
|
||||||
|
test(vi, ci, gc);
|
||||||
|
} while (vi.contentsLost());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void test(VolatileImage vi, BufferedImage ci, GraphicsConfiguration gc) {
|
||||||
|
for (int r = 0; r <= 255; ++r) {
|
||||||
|
for (int a = 0; a <= 255; ++a) {
|
||||||
|
fill(vi, new Color(r, 0, 0, a));
|
||||||
|
fill(ci, new Color(r, 0, 0, a));
|
||||||
|
validate(ci, vi.getSnapshot());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void fill(Image image, Color color) {
|
||||||
|
Graphics2D g2d = (Graphics2D) image.getGraphics();
|
||||||
|
g2d.setColor(color);
|
||||||
|
g2d.setComposite(AlphaComposite.Src);
|
||||||
|
g2d.fillRect(0, 0, S, S);
|
||||||
|
g2d.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void validate(BufferedImage ci, BufferedImage snapshot) {
|
||||||
|
for (int y = 0; y < ci.getHeight(); y++) {
|
||||||
|
for (int x = 0; x < ci.getWidth(); x++) {
|
||||||
|
int ci_rgb = ci.getRGB(x, y);
|
||||||
|
int vi_rgb = snapshot.getRGB(x, y);
|
||||||
|
if (ci_rgb != vi_rgb) {
|
||||||
|
System.err.println("Exp:" + Integer.toHexString(ci_rgb));
|
||||||
|
System.err.println("Actual:" + Integer.toHexString(vi_rgb));
|
||||||
|
throw new RuntimeException("Colors mismatch!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user