< prev index next >

src/java.desktop/unix/native/common/java2d/opengl/GLXGraphicsConfig.c

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 262             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 263                                      GLX_DRAWABLE_TYPE, &dtype);
 264             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 265                                      GLX_RENDER_TYPE, &rtype);
 266             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 267                                      GLX_DEPTH_SIZE, &depth);
 268             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 269                                      GLX_STENCIL_SIZE, &stencil);
 270 
 271             // these attributes don't affect our decision, but they are
 272             // interesting for trace logs, so we will query them anyway
 273             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 274                                      GLX_DOUBLEBUFFER, &db);
 275             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 276                                      GLX_ALPHA_SIZE, &alpha);
 277 
 278             J2dRlsTrace5(J2D_TRACE_VERBOSE,
 279                 "[V]     id=0x%x db=%d alpha=%d depth=%d stencil=%d valid=",
 280                          fbvisualid, db, alpha, depth, stencil);
 281 
 282 #ifdef __sparc
 283             /*
 284              * Sun's OpenGL implementation will always
 285              * return at least two GLXFBConfigs (visuals) from
 286              * glXChooseFBConfig().  The first will be a linear (gamma
 287              * corrected) visual; the second will have the same capabilities
 288              * as the first, except it will be a non-linear (non-gamma
 289              * corrected) visual, which is the one we want, otherwise
 290              * everything will look "washed out".  So we will reject any
 291              * visuals that have gamma values other than 1.0 (the value
 292              * returned by glXGetFBConfigAttrib() will be scaled
 293              * by 100, so 100 corresponds to a gamma value of 1.0, 220
 294              * corresponds to 2.2, and so on).
 295              */
 296             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 297                                      GLX_GAMMA_VALUE_SUN, &gamma);
 298             if (gamma != 100) {
 299                 J2dRlsTrace(J2D_TRACE_VERBOSE, "false (linear visual)\n");
 300                 continue;
 301             }
 302 #endif /* __sparc */
 303 
 304             if ((dtype & GLX_WINDOW_BIT) &&
 305                 (dtype & GLX_PBUFFER_BIT) &&
 306                 (rtype & GLX_RGBA_BIT) &&
 307                 (depth >= 16))
 308             {
 309                 if (visualid == 0) {
 310                     // when visualid == 0, we loop through all configs
 311                     // looking for an fbconfig that has the smallest combined
 312                     // depth+stencil size (this keeps VRAM usage to a minimum)
 313                     if ((depth + stencil) < minDepthPlusStencil) {
 314                         J2dRlsTrace(J2D_TRACE_VERBOSE, "true\n");
 315                         minDepthPlusStencil = depth + stencil;
 316                         chosenConfig = fbc;
 317                     } else {
 318                         J2dRlsTrace(J2D_TRACE_VERBOSE,
 319                                     "false (large depth)\n");
 320                     }
 321                     continue;
 322                 } else {
 323                     // in this case, visualid == fbvisualid, which means


 508         J2dRlsTraceLn(J2D_TRACE_ERROR,
 509             "GLXGraphicsConfig_getGLXConfigInfo: could not create GLX context");
 510         return 0L;
 511     }
 512 
 513     // this is pretty sketchy, but it seems to be the easiest way to create
 514     // some form of GLXDrawable using only the display and a GLXFBConfig
 515     // (in order to make the context current for checking the version,
 516     // extensions, etc)...
 517     scratch = GLXGC_InitScratchPbuffer(fbconfig);
 518     if (scratch == 0) {
 519         J2dRlsTraceLn(J2D_TRACE_ERROR,
 520             "GLXGraphicsConfig_getGLXConfigInfo: could not create scratch pbuffer");
 521         j2d_glXDestroyContext(awt_display, context);
 522         return 0L;
 523     }
 524 
 525     // the context must be made current before we can query the
 526     // version and extension strings
 527     j2d_glXMakeContextCurrent(awt_display, scratch, scratch, context);
 528 
 529 #ifdef __sparc
 530     /*
 531      * 6438225: The software rasterizer used by Sun's OpenGL libraries
 532      * for certain boards has quality issues, and besides, performance
 533      * of these boards is not high enough to justify the use of the
 534      * OpenGL-based Java 2D pipeline.  If we detect one of the following
 535      * boards via the GL_RENDERER string, just give up:
 536      *   - FFB[2[+]] ("Creator[3D]")
 537      *   - PGX-series ("m64")
 538      *   - AFB ("Elite3D")
 539      */
 540     {
 541         const char *renderer = (const char *)j2d_glGetString(GL_RENDERER);
 542 
 543         J2dRlsTraceLn1(J2D_TRACE_VERBOSE,
 544             "GLXGraphicsConfig_getGLXConfigInfo: detected renderer (%s)",
 545             (renderer == NULL) ? "null" : renderer);
 546 
 547         if (renderer == NULL ||
 548             strncmp(renderer, "Creator", 7) == 0 ||
 549             strncmp(renderer, "SUNWm64", 7) == 0 ||
 550             strncmp(renderer, "Elite", 5) == 0)
 551         {
 552             J2dRlsTraceLn1(J2D_TRACE_ERROR,
 553                 "GLXGraphicsConfig_getGLXConfigInfo: unsupported board (%s)",
 554                 (renderer == NULL) ? "null" : renderer);
 555             j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
 556             j2d_glXDestroyPbuffer(awt_display, scratch);
 557             j2d_glXDestroyContext(awt_display, context);
 558             return 0L;
 559         }
 560     }
 561 #endif /* __sparc */
 562 
 563     versionstr = j2d_glGetString(GL_VERSION);
 564     OGLContext_GetExtensionInfo(env, &caps);
 565 
 566     // destroy the temporary resources
 567     j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
 568 
 569     J2dRlsTraceLn1(J2D_TRACE_INFO,
 570         "GLXGraphicsConfig_getGLXConfigInfo: OpenGL version=%s",
 571                    (versionstr == NULL) ? "null" : (char *)versionstr);
 572 
 573     if (!OGLContext_IsVersionSupported(versionstr)) {
 574         J2dRlsTraceLn(J2D_TRACE_ERROR,
 575             "GLXGraphicsConfig_getGLXConfigInfo: OpenGL 1.2 is required");
 576         j2d_glXDestroyPbuffer(awt_display, scratch);
 577         j2d_glXDestroyContext(awt_display, context);
 578         return 0L;
 579     }
 580 
 581     // get config-specific capabilities


   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 262             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 263                                      GLX_DRAWABLE_TYPE, &dtype);
 264             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 265                                      GLX_RENDER_TYPE, &rtype);
 266             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 267                                      GLX_DEPTH_SIZE, &depth);
 268             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 269                                      GLX_STENCIL_SIZE, &stencil);
 270 
 271             // these attributes don't affect our decision, but they are
 272             // interesting for trace logs, so we will query them anyway
 273             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 274                                      GLX_DOUBLEBUFFER, &db);
 275             j2d_glXGetFBConfigAttrib(awt_display, fbc,
 276                                      GLX_ALPHA_SIZE, &alpha);
 277 
 278             J2dRlsTrace5(J2D_TRACE_VERBOSE,
 279                 "[V]     id=0x%x db=%d alpha=%d depth=%d stencil=%d valid=",
 280                          fbvisualid, db, alpha, depth, stencil);
 281 






















 282             if ((dtype & GLX_WINDOW_BIT) &&
 283                 (dtype & GLX_PBUFFER_BIT) &&
 284                 (rtype & GLX_RGBA_BIT) &&
 285                 (depth >= 16))
 286             {
 287                 if (visualid == 0) {
 288                     // when visualid == 0, we loop through all configs
 289                     // looking for an fbconfig that has the smallest combined
 290                     // depth+stencil size (this keeps VRAM usage to a minimum)
 291                     if ((depth + stencil) < minDepthPlusStencil) {
 292                         J2dRlsTrace(J2D_TRACE_VERBOSE, "true\n");
 293                         minDepthPlusStencil = depth + stencil;
 294                         chosenConfig = fbc;
 295                     } else {
 296                         J2dRlsTrace(J2D_TRACE_VERBOSE,
 297                                     "false (large depth)\n");
 298                     }
 299                     continue;
 300                 } else {
 301                     // in this case, visualid == fbvisualid, which means


 486         J2dRlsTraceLn(J2D_TRACE_ERROR,
 487             "GLXGraphicsConfig_getGLXConfigInfo: could not create GLX context");
 488         return 0L;
 489     }
 490 
 491     // this is pretty sketchy, but it seems to be the easiest way to create
 492     // some form of GLXDrawable using only the display and a GLXFBConfig
 493     // (in order to make the context current for checking the version,
 494     // extensions, etc)...
 495     scratch = GLXGC_InitScratchPbuffer(fbconfig);
 496     if (scratch == 0) {
 497         J2dRlsTraceLn(J2D_TRACE_ERROR,
 498             "GLXGraphicsConfig_getGLXConfigInfo: could not create scratch pbuffer");
 499         j2d_glXDestroyContext(awt_display, context);
 500         return 0L;
 501     }
 502 
 503     // the context must be made current before we can query the
 504     // version and extension strings
 505     j2d_glXMakeContextCurrent(awt_display, scratch, scratch, context);


































 506 
 507     versionstr = j2d_glGetString(GL_VERSION);
 508     OGLContext_GetExtensionInfo(env, &caps);
 509 
 510     // destroy the temporary resources
 511     j2d_glXMakeContextCurrent(awt_display, None, None, NULL);
 512 
 513     J2dRlsTraceLn1(J2D_TRACE_INFO,
 514         "GLXGraphicsConfig_getGLXConfigInfo: OpenGL version=%s",
 515                    (versionstr == NULL) ? "null" : (char *)versionstr);
 516 
 517     if (!OGLContext_IsVersionSupported(versionstr)) {
 518         J2dRlsTraceLn(J2D_TRACE_ERROR,
 519             "GLXGraphicsConfig_getGLXConfigInfo: OpenGL 1.2 is required");
 520         j2d_glXDestroyPbuffer(awt_display, scratch);
 521         j2d_glXDestroyContext(awt_display, context);
 522         return 0L;
 523     }
 524 
 525     // get config-specific capabilities


< prev index next >