示例#1
0
 /**
  * Initializes the appropriate OpenGL offscreen surface based on the value of the type parameter.
  * If the surface creation fails for any reason, an OutOfMemoryError will be thrown.
  */
 protected void initSurface(final int width, final int height) {
   OGLRenderQueue rq = OGLRenderQueue.getInstance();
   rq.lock();
   try {
     switch (type) {
       case TEXTURE:
       case PBUFFER:
       case FBOBJECT:
         // need to make sure the context is current before
         // creating the texture (or pbuffer, or fbobject)
         OGLContext.setScratchSurface(graphicsConfig);
         break;
       default:
         break;
     }
     rq.flushAndInvokeNow(
         new Runnable() {
           public void run() {
             initSurfaceNow(width, height);
           }
         });
   } finally {
     rq.unlock();
   }
 }
示例#2
0
 public Rectangle getNativeBounds() {
   OGLRenderQueue rq = OGLRenderQueue.getInstance();
   rq.lock();
   try {
     return new Rectangle(nativeWidth, nativeHeight);
   } finally {
     rq.unlock();
   }
 }
示例#3
0
 static void swapBuffers(long window) {
   OGLRenderQueue rq = OGLRenderQueue.getInstance();
   rq.lock();
   try {
     RenderBuffer buf = rq.getBuffer();
     rq.ensureCapacityAndAlignment(12, 4);
     buf.putInt(SWAP_BUFFERS);
     buf.putLong(window);
     rq.flushNow();
   } finally {
     rq.unlock();
   }
 }
示例#4
0
  static {
    if (!GraphicsEnvironment.isHeadless()) {
      // fbobject currently enabled by default; use "false" to disable
      String fbo =
          (String)
              java.security.AccessController.doPrivileged(
                  new sun.security.action.GetPropertyAction("sun.java2d.opengl.fbobject"));
      isFBObjectEnabled = !"false".equals(fbo);

      // lcdshader currently enabled by default; use "false" to disable
      String lcd =
          (String)
              java.security.AccessController.doPrivileged(
                  new sun.security.action.GetPropertyAction("sun.java2d.opengl.lcdshader"));
      isLCDShaderEnabled = !"false".equals(lcd);

      // biopshader currently enabled by default; use "false" to disable
      String biop =
          (String)
              java.security.AccessController.doPrivileged(
                  new sun.security.action.GetPropertyAction("sun.java2d.opengl.biopshader"));
      isBIOpShaderEnabled = !"false".equals(biop);

      // gradshader currently enabled by default; use "false" to disable
      String grad =
          (String)
              java.security.AccessController.doPrivileged(
                  new sun.security.action.GetPropertyAction("sun.java2d.opengl.gradshader"));
      isGradShaderEnabled = !"false".equals(grad);

      OGLRenderQueue rq = OGLRenderQueue.getInstance();
      oglImagePipe = new OGLDrawImage();
      oglTextPipe = new OGLTextRenderer(rq);
      oglRenderPipe = new OGLRenderer(rq);
      if (GraphicsPrimitive.tracingEnabled()) {
        oglTextPipe = oglTextPipe.traceWrap();
        // The wrapped oglRenderPipe will wrap the AA pipe as well...
        // oglAAPgramPipe = oglRenderPipe.traceWrap();
      }
      oglAAPgramPipe = oglRenderPipe.getAAParallelogramPipe();
      oglTxRenderPipe =
          new PixelToParallelogramConverter(oglRenderPipe, oglRenderPipe, 1.0, 0.25, true);

      OGLBlitLoops.register();
      OGLMaskFill.register();
      OGLMaskBlit.register();
    }
  }
示例#5
0
  /**
   * Disposes the native resources associated with the given OGLSurfaceData (referenced by the pData
   * parameter). This method is invoked from the native Dispose() method from the Disposer thread
   * when the Java-level OGLSurfaceData object is about to go away. Note that we also pass a
   * reference to the native GLX/WGLGraphicsConfigInfo (pConfigInfo) for the purposes of making a
   * context current.
   */
  static void dispose(long pData, long pConfigInfo) {
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
      // make sure we have a current context before
      // disposing the native resources (e.g. texture object)
      OGLContext.setScratchSurface(pConfigInfo);

      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(DISPOSE_SURFACE);
      buf.putLong(pData);

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }
示例#6
0
  public void flush() {
    invalidate();
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
      // make sure we have a current context before
      // disposing the native resources (e.g. texture object)
      OGLContext.setScratchSurface(graphicsConfig);

      RenderBuffer buf = rq.getBuffer();
      rq.ensureCapacityAndAlignment(12, 4);
      buf.putInt(FLUSH_SURFACE);
      buf.putLong(getNativeOps());

      // this call is expected to complete synchronously, so flush now
      rq.flushNow();
    } finally {
      rq.unlock();
    }
  }