コード例 #1
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
  /**
   * Note: This should only be called from the QFT under the AWT lock. This method is kept separate
   * from the initSurface() method below just to keep the code a bit cleaner.
   */
  private void initSurfaceNow(int width, int height) {
    boolean isOpaque = (getTransparency() == Transparency.OPAQUE);
    boolean success = false;

    switch (type) {
      case PBUFFER:
        success =
            initPbuffer(
                getNativeOps(), graphicsConfig.getNativeConfigInfo(), isOpaque, width, height);
        break;

      case TEXTURE:
        success =
            initTexture(
                getNativeOps(),
                isOpaque,
                isTexNonPow2Available(),
                isTexRectAvailable(),
                width,
                height);
        break;

      case FBOBJECT:
        success =
            initFBObject(
                getNativeOps(),
                isOpaque,
                isTexNonPow2Available(),
                isTexRectAvailable(),
                width,
                height);
        break;

      case FLIP_BACKBUFFER:
        success = initFlipBackbuffer(getNativeOps());
        break;

      default:
        break;
    }

    if (!success) {
      throw new OutOfMemoryError("can't create offscreen surface");
    }
  }
コード例 #2
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 @Override
 protected MaskFill getMaskFill(SunGraphics2D sg2d) {
   if (sg2d.paintState > sg2d.PAINT_ALPHACOLOR) {
     /*
      * We can only accelerate non-Color MaskFill operations if
      * all of the following conditions hold true:
      *   - there is an implementation for the given paintState
      *   - the current Paint can be accelerated for this destination
      *   - multitexturing is available (since we need to modulate
      *     the alpha mask texture with the paint texture)
      *
      * In all other cases, we return null, in which case the
      * validation code will choose a more general software-based loop.
      */
     if (!OGLPaints.isValid(sg2d) || !graphicsConfig.isCapPresent(CAPS_MULTITEXTURE)) {
       return null;
     }
   }
   return super.getMaskFill(sg2d);
 }
コード例 #3
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 /**
  * Returns true if OpenGL textures can have non-power-of-two dimensions when using the
  * GL_TEXTURE_RECTANGLE_ARB target (only available when the GL_ARB_texture_rectangle extension is
  * present).
  */
 boolean isTexRectAvailable() {
   return graphicsConfig.isCapPresent(CAPS_EXT_TEXRECT);
 }
コード例 #4
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 /**
  * Returns true if OpenGL textures can have non-power-of-two dimensions when using the basic
  * GL_TEXTURE_2D target.
  */
 boolean isTexNonPow2Available() {
   return graphicsConfig.isCapPresent(CAPS_TEXNONPOW2);
 }
コード例 #5
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
  public void validatePipe(SunGraphics2D sg2d) {
    TextPipe textpipe;
    boolean validated = false;

    // OGLTextRenderer handles both AA and non-AA text, but
    // only works with the following modes:
    // (Note: For LCD text we only enter this code path if
    // canRenderLCDText() has already validated that the mode is
    // CompositeType.SrcNoEa (opaque color), which will be subsumed
    // by the CompositeType.SrcNoEa (any color) test below.)

    if (
    /* CompositeType.SrcNoEa (any color) */
    (sg2d.compositeState <= sg2d.COMP_ISCOPY && sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)
        ||

        /* CompositeType.SrcOver (any color) */
        (sg2d.compositeState == sg2d.COMP_ALPHA
            && sg2d.paintState <= sg2d.PAINT_ALPHACOLOR
            && (((AlphaComposite) sg2d.composite).getRule() == AlphaComposite.SRC_OVER))
        ||

        /* CompositeType.Xor (any color) */
        (sg2d.compositeState == sg2d.COMP_XOR && sg2d.paintState <= sg2d.PAINT_ALPHACOLOR)) {
      textpipe = oglTextPipe;
    } else {
      // do this to initialize textpipe correctly; we will attempt
      // to override the non-text pipes below
      super.validatePipe(sg2d);
      textpipe = sg2d.textpipe;
      validated = true;
    }

    PixelToParallelogramConverter txPipe = null;
    OGLRenderer nonTxPipe = null;

    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
      if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
        if (sg2d.compositeState <= sg2d.COMP_XOR) {
          txPipe = oglTxRenderPipe;
          nonTxPipe = oglRenderPipe;
        }
      } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) {
        if (OGLPaints.isValid(sg2d)) {
          txPipe = oglTxRenderPipe;
          nonTxPipe = oglRenderPipe;
        }
        // custom paints handled by super.validatePipe() below
      }
    } else {
      if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
        if (graphicsConfig.isCapPresent(CAPS_PS30)
            && (sg2d.imageComp == CompositeType.SrcOverNoEa
                || sg2d.imageComp == CompositeType.SrcOver)) {
          if (!validated) {
            super.validatePipe(sg2d);
            validated = true;
          }
          PixelToParallelogramConverter aaConverter =
              new PixelToParallelogramConverter(
                  sg2d.shapepipe, oglAAPgramPipe, 1.0 / 8.0, 0.499, false);
          sg2d.drawpipe = aaConverter;
          sg2d.fillpipe = aaConverter;
          sg2d.shapepipe = aaConverter;
        } else if (sg2d.compositeState == sg2d.COMP_XOR) {
          // install the solid pipes when AA and XOR are both enabled
          txPipe = oglTxRenderPipe;
          nonTxPipe = oglRenderPipe;
        }
      }
      // other cases handled by super.validatePipe() below
    }

    if (txPipe != null) {
      if (sg2d.transformState >= sg2d.TRANSFORM_TRANSLATESCALE) {
        sg2d.drawpipe = txPipe;
        sg2d.fillpipe = txPipe;
      } else if (sg2d.strokeState != sg2d.STROKE_THIN) {
        sg2d.drawpipe = txPipe;
        sg2d.fillpipe = nonTxPipe;
      } else {
        sg2d.drawpipe = nonTxPipe;
        sg2d.fillpipe = nonTxPipe;
      }
      // Note that we use the transforming pipe here because it
      // will examine the shape and possibly perform an optimized
      // operation if it can be simplified.  The simplifications
      // will be valid for all STROKE and TRANSFORM types.
      sg2d.shapepipe = txPipe;
    } else {
      if (!validated) {
        super.validatePipe(sg2d);
      }
    }

    // install the text pipe based on our earlier decision
    sg2d.textpipe = textpipe;

    // always override the image pipe with the specialized OGL pipe
    sg2d.imagepipe = oglImagePipe;
  }
コード例 #6
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 /**
  * For now, we can only render LCD text if: - the fragment shader extension is available, and -
  * blending is disabled, and - the source color is opaque
  *
  * <p>Eventually, we could enhance the native OGL text rendering code and remove the above
  * restrictions, but that would require significantly more code just to support a few uncommon
  * cases.
  */
 public boolean canRenderLCDText(SunGraphics2D sg2d) {
   return graphicsConfig.isCapPresent(CAPS_EXT_LCD_SHADER)
       && sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY
       && sg2d.paintState <= SunGraphics2D.PAINT_OPAQUECOLOR;
 }
コード例 #7
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 /** Returns the OGLContext for the GraphicsConfig associated with this surface. */
 public final OGLContext getContext() {
   return graphicsConfig.getContext();
 }
コード例 #8
0
ファイル: OGLSurfaceData.java プロジェクト: feiwei9696/ae-awt
 protected OGLSurfaceData(OGLGraphicsConfig gc, ColorModel cm, int type) {
   super(getCustomSurfaceType(type), cm);
   this.graphicsConfig = gc;
   this.type = type;
   setBlitProxyKey(gc.getProxyKey());
 }