/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*/
#include <stdlib.h>
#include "sun_java2d_opengl_WGLSurfaceData.h"
#include "jni.h"
#include "jlong.h"
#include "jni_util.h"
#include "sizecalc.h"
#include "OGLRenderQueue.h"
#include "WGLGraphicsConfig.h"
#include "WGLSurfaceData.h"
/**
* The methods in this file implement the native windowing system specific
* layer (WGL) for the OpenGL-based Java 2D pipeline.
*/
extern LockFunc OGLSD_Lock;
extern GetRasInfoFunc OGLSD_GetRasInfo;
extern UnlockFunc OGLSD_Unlock;
extern DisposeFunc OGLSD_Dispose;
extern OGLPixelFormat PixelFormats[];
int srcStride,
int* imageData);
extern void
{
sizeof(OGLSDOps));
return;
}
return;
}
} else {
}
}
}
/**
* This function disposes of any native windowing system resources associated
* with this surface. For instance, if the given OGLSDOps is of type
* OGLSD_PBUFFER, this method implementation will destroy the actual pbuffer
* surface.
*/
void
{
}
}
}
}
/**
* Makes the given context current to its associated "scratch" surface. If
* the operation is successful, this method will return JNI_TRUE; otherwise,
* returns JNI_FALSE.
*/
static jboolean
{
"WGLSD_MakeCurrentToScratch: context is null");
return JNI_FALSE;
}
"WGLSD_MakeCurrentToScratch: could not make current");
return JNI_FALSE;
}
return JNI_TRUE;
}
/**
* Returns a pointer (as a jlong) to the native WGLGraphicsConfigInfo
* associated with the given OGLSDOps. This method can be called from
* shared code to retrieve the native GraphicsConfig data in a platform-
* independent manner.
*/
{
"OGLSD_GetNativeConfigInfo: ops are null");
return 0L;
}
"OGLSD_GetNativeConfigInfo: wgl ops are null");
return 0L;
}
}
/**
* Makes the given GraphicsConfig's context current to its associated
* "scratch" surface. If there is a problem making the context current,
* this method will return NULL; otherwise, returns a pointer to the
* OGLContext that is associated with the given GraphicsConfig.
*/
{
"OGLSD_SetScratchContext: wgl config info is null");
return NULL;
}
return NULL;
}
// the GL_EXT_framebuffer_object extension is present, so this call
// will ensure that we are bound to the scratch pbuffer (and not
// some other framebuffer object)
}
return oglc;
}
/**
* Makes a context current to the given source and destination
* surfaces. If there is a problem making the context current, this method
* will return NULL; otherwise, returns a pointer to the OGLContext that is
* associated with the destination surface.
*/
{
"OGLSD_MakeOGLContextCurrent: context is null");
return NULL;
}
// first make sure we have a current context (if the context isn't
// already current to some drawable, we will make it current to
// its scratch surface)
if (oglc != currentContext) {
return NULL;
}
}
// now bind to the fbobject associated with the destination surface;
// this means that all rendering will go into the fbobject destination
// (note that we unbind the currently bound texture first; this is
// recommended procedure when binding an fbobject)
return oglc;
}
// get the hdc for the destination surface
} else {
}
// get the hdc for the source surface
} else {
// the source will always be equal to the destination in this case
}
// REMIND: in theory we should be able to use wglMakeContextCurrentARB()
// on ATI's drivers (see 6525997); for now we will only use it when the
// surfaces are different, otherwise we will use the old
// wglMakeCurrent() approach...
// use WGL_ARB_make_current_read extension to make context current
success =
} else {
// use the old approach for making current to the destination
}
if (!success) {
"OGLSD_MakeOGLContextCurrent: could not make current");
}
return NULL;
}
// the GL_EXT_framebuffer_object extension is present, so we
// must bind to the default (windowing system provided)
// framebuffer
}
}
return oglc;
}
/**
* This function initializes a native window surface and caches the window
* bounds in the given OGLSDOps. Returns JNI_TRUE if the operation was
* successful; JNI_FALSE otherwise.
*/
{
"OGLSD_InitOGLWindow: ops are null");
return JNI_FALSE;
}
"OGLSD_InitOGLWindow: wgl ops are null");
return JNI_FALSE;
}
"OGLSD_InitOGLWindow: graphics config info is null");
return JNI_FALSE;
}
"OGLSD_InitOGLWindow: disposed component");
return JNI_FALSE;
}
if (hdc == 0) {
"OGLSD_InitOGLWindow: invalid hdc");
return JNI_FALSE;
}
"OGLSD_InitOGLWindow: error setting pixel format");
return JNI_FALSE;
}
return JNI_TRUE;
}
{
int attrKeys[] = {
};
int pbAttrList[] = { 0 };
"WGLSurfaceData_initPbuffer: w=%d h=%d opq=%d",
"WGLSurfaceData_initPbuffer: ops are null");
return JNI_FALSE;
}
"WGLSurfaceData_initPbuffer: wgl ops are null");
return JNI_FALSE;
}
"WGLSurfaceData_initPbuffer: wgl config info is null");
return JNI_FALSE;
}
// create a scratch window
if (hwnd == 0) {
"WGLSurfaceData_initPbuffer: could not create scratch window");
return JNI_FALSE;
}
// get the HDC for the scratch window
if (hdc == 0) {
"WGLSurfaceData_initPbuffer: could not get dc for scratch window");
return JNI_FALSE;
}
// get the maximum allowable pbuffer dimensions
" desired pbuffer dimensions: w=%d h=%d maxw=%d maxh=%d",
// if either dimension is 0 or larger than the maximum, we cannot
// allocate a pbuffer with the requested dimensions
{
"WGLSurfaceData_initPbuffer: invalid dimensions");
return JNI_FALSE;
}
if (pbuffer == 0) {
"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
if (pbufferDC == 0) {
"WGLSurfaceData_initPbuffer: could not get dc for pbuffer");
return JNI_FALSE;
}
// make sure the actual dimensions match those that we requested
"WGLSurfaceData_initPbuffer: actual (w=%d h=%d) != requested",
return JNI_FALSE;
}
return JNI_TRUE;
}
void
{
"OGLSD_SwapBuffers: disposed component");
return;
}
if (hdc == 0) {
"OGLSD_SwapBuffers: invalid hdc");
return;
}
if (!SwapBuffers(hdc)) {
"OGLSD_SwapBuffers: error in SwapBuffers");
}
"OGLSD_SwapBuffers: error while releasing dc");
}
}
// needed by Mac OS X port, no-op on other platforms
void
{
}
/*
* Class: sun_java2d_opengl_WGLSurfaceData
* Method: updateWindowAccelImpl
* Signature: (JJII)Z
*/
{
void *pDst;
if (w <= 0 || h <= 0) {
return JNI_TRUE;
}
return JNI_FALSE;
}
width = w;
height = h;
return JNI_FALSE;
}
// the code below is mostly copied from OGLBlitLoops_SurfaceToSwBlit
// this accounts for lower-left origin of the source region
// we must read one scanline at a time because there is no way
// to read starting at the top-left corner of the source region
while (height > 0) {
srcy--;
dsty++;
height--;
}
// the pixels read from the surface are already premultiplied
(int*)pDst);
return JNI_FALSE;
}
// hBitmap is released in UpdateWindow
return JNI_TRUE;
}