/** * Output test raster (produced in D3DTest function). Utility * used in debugging only. Enable by setting J2D_TRACE_LEVEL=J2D_VERBOSE * prior to running application with debug java. The output from this will * be seen only if D3DTest fails. */ void TestRasterOutput(byte *rasPtr, int x, int y, int w, int h, int scanStride, int pixelStride, TIntTestRaster goldenArray) { int goldenValue; for (int traceRow = y; traceRow < h; ++traceRow) { byte *tmpRasPtr = rasPtr + traceRow * scanStride; for (int traceCol = x; traceCol < w; ++traceCol) { DWORD pixelVal; switch (pixelStride) { case 1: pixelVal = *tmpRasPtr; break; case 2: pixelVal = *((unsigned short*)tmpRasPtr); break; default: pixelVal = *((unsigned int*)tmpRasPtr) & 0x00ffffff; break; } tmpRasPtr += pixelStride; if (goldenArray == NULL) { if (pixelVal) { J2dTrace(J2D_TRACE_VERBOSE, "1"); } else { J2dTrace(J2D_TRACE_VERBOSE, "0"); } } else { goldenValue = (goldenArray[traceRow][traceCol] & 0x00ffffff); if ((goldenValue == 0 && pixelVal != 0) || (goldenValue != 0 && pixelVal == 0)) { J2dTrace(J2D_TRACE_VERBOSE, "x"); } else { J2dTrace(J2D_TRACE_VERBOSE, "-"); } } } J2dTrace(J2D_TRACE_VERBOSE, "\n"); } }
/** * Attempts to create a new GLXFBConfig for the requested screen and visual. * If there are no valid GLXFBConfigs available, 0 is returned. */ static GLXFBConfig GLXGC_InitFBConfig(JNIEnv *env, jint screennum, jint visnum) { jboolean foundconfig = JNI_FALSE; GLXFBConfig *fbconfigs; GLXFBConfig fbc; int nconfs, i; int attrlist[] = {GLX_VISUAL_ID, 0, GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT | GLX_PIXMAP_BIT | GLX_PBUFFER_BIT, GLX_RENDER_TYPE, GLX_RGBA_BIT, GLX_STENCIL_SIZE, 1, 0}; J2dTraceLn2(J2D_TRACE_INFO, "in GLXGC_InitFBConfig (scn=%d vis=0x%x)", screennum, visnum); attrlist[1] = visnum; // find all fbconfigs for this screen with the provided attributes fbconfigs = j2d_glXChooseFBConfig(awt_display, screennum, attrlist, &nconfs); if ((fbconfigs == NULL) || (nconfs <= 0)) { J2dTraceLn(J2D_TRACE_ERROR, "could not find any valid fbconfigs"); return 0; } J2dTraceLn(J2D_TRACE_VERBOSE, "candidate fbconfigs:"); // iterate through the list of fbconfigs, looking for the one that matches // the requested visual ID and supports RGBA rendering as well as the // creation of windows, pbuffers, and pixmaps for (i = 0; i < nconfs; i++) { XVisualInfo *xvi; int dtype, rtype, ssize, caveat; fbc = fbconfigs[i]; xvi = j2d_glXGetVisualFromFBConfig(awt_display, fbc); j2d_glXGetFBConfigAttrib(awt_display, fbc, GLX_DRAWABLE_TYPE, &dtype); j2d_glXGetFBConfigAttrib(awt_display, fbc, GLX_RENDER_TYPE, &rtype); j2d_glXGetFBConfigAttrib(awt_display, fbc, GLX_STENCIL_SIZE, &ssize); j2d_glXGetFBConfigAttrib(awt_display, fbc, GLX_CONFIG_CAVEAT, &caveat); J2dTrace5(J2D_TRACE_VERBOSE, " id=0x%x dtype=0x%x rtype=0x%x ssize=%d caveat=%d valid=", xvi->visualid, dtype, rtype, ssize, caveat); // REMIND: we may want to check caveat to avoid "GLX_SLOW" configs... if ((xvi->visualid == visnum) && (dtype == attrlist[3]) && (rtype & GLX_RGBA_BIT) && (ssize > 0)) { J2dTrace(J2D_TRACE_VERBOSE, "true\n"); foundconfig = JNI_TRUE; break; } J2dTrace(J2D_TRACE_VERBOSE, "false\n"); } // free the list of fbconfigs XFree(fbconfigs); if (!foundconfig) { J2dTraceLn(J2D_TRACE_ERROR, "could not find an appropriate fbconfig"); return 0; } return fbc; }