< prev index next >

src/java.desktop/windows/native/libawt/java2d/opengl/WGLSurfaceData.c

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 2004, 2013, 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. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2004, 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. Oracle designates this
*** 105,136 **** } } /** * 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 OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo) { - WGLSDOps *wglsdo = (WGLSDOps *)oglsdo->privOps; - J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface"); ! ! 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; ! } ! } } /** * Makes the given context current to its associated "scratch" surface. If * the operation is successful, this method will return JNI_TRUE; otherwise, --- 105,121 ---- } } /** * This function disposes of any native windowing system resources associated ! * with this surface. */ void OGLSD_DestroyOGLSurface(JNIEnv *env, OGLSDOps *oglsdo) { J2dTraceLn(J2D_TRACE_INFO, "OGLSD_DestroyOGLSurface"); ! // Window is free'd later by AWT code... } /** * Makes the given context current to its associated "scratch" surface. If * the operation is successful, this method will return JNI_TRUE; otherwise,
*** 274,296 **** } ctxinfo = (WGLCtxInfo *)oglc->ctxInfo; // get the hdc for the destination surface - if (dstOps->drawableType == OGLSD_PBUFFER) { - dstHDC = dstWGLOps->pbufferDC; - } else { dstHDC = GetDC(dstWGLOps->window); - } // get the hdc for the source surface - if (srcOps->drawableType == OGLSD_PBUFFER) { - srcHDC = srcWGLOps->pbufferDC; - } 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() // even when the src/dst surfaces are the same, but this causes problems // on ATI's drivers (see 6525997); for now we will only use it when the // surfaces are different, otherwise we will use the old --- 259,273 ----
*** 304,329 **** success = j2d_wglMakeCurrent(dstHDC, ctxinfo->context); } if (!success) { J2dRlsTraceLn(J2D_TRACE_ERROR, "OGLSD_MakeOGLContextCurrent: could not make current"); - if (dstOps->drawableType != OGLSD_PBUFFER) { ReleaseDC(dstWGLOps->window, dstHDC); - } return NULL; } if (OGLC_IS_CAP_PRESENT(oglc, CAPS_EXT_FBOBJECT)) { // the GL_EXT_framebuffer_object extension is present, so we // must bind to the default (windowing system provided) // framebuffer j2d_glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); } - if (dstOps->drawableType != OGLSD_PBUFFER) { ReleaseDC(dstWGLOps->window, dstHDC); - } return oglc; } /** --- 281,302 ----
*** 398,542 **** oglsdo->width, oglsdo->height); 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 OGLSD_SwapBuffers(JNIEnv *env, jlong pPeerData) { HWND window; HDC hdc; --- 371,380 ----
< prev index next >