Пример #1
0
 /**
  * This method is called on a destination SurfaceData to choose the best SurfaceData from a source
  * Image for an imaging operation, with help from its SurfaceManager. The method may determine
  * that the default SurfaceData was really the best choice in the first place, or it may decide to
  * use a cached surface. Some general decisions about whether acceleration is enabled are made by
  * this method, but any decision based on the type of the source image is made in the makeProxyFor
  * method below when it comes up with the appropriate SurfaceDataProxy instance. The parameters
  * describe the type of imaging operation being performed.
  *
  * <p>If a blitProxyKey was supplied by the subclass then it is used to potentially override the
  * choice of source SurfaceData. The outline of this process is:
  *
  * <ol>
  *   <li>Image pipeline asks destSD to find an appropriate srcSD for a given source Image object.
  *   <li>destSD gets the SurfaceManager of the source Image and first retrieves the default SD
  *       from it using getPrimarySurfaceData()
  *   <li>destSD uses its "blit proxy key" (if set) to look for some cached data stored in the
  *       source SurfaceManager
  *   <li>If the cached data is null then makeProxyFor() is used to create some cached data which
  *       is stored back in the source SurfaceManager under the same key for future uses.
  *   <li>The cached data will be a SurfaceDataProxy object.
  *   <li>The SurfaceDataProxy object is then consulted to return a replacement SurfaceData object
  *       (typically a cached copy if appropriate, or the original if not).
  * </ol>
  */
 public SurfaceData getSourceSurfaceData(
     Image img, int txtype, CompositeType comp, Color bgColor) {
   SurfaceManager srcMgr = SurfaceManager.getManager(img);
   SurfaceData srcData = srcMgr.getPrimarySurfaceData();
   if (img.getAccelerationPriority() > 0.0f && blitProxyKey != null) {
     SurfaceDataProxy sdp = (SurfaceDataProxy) srcMgr.getCacheData(blitProxyKey);
     if (sdp == null || !sdp.isValid()) {
       if (srcData.getState() == State.UNTRACKABLE) {
         sdp = SurfaceDataProxy.UNCACHED;
       } else {
         sdp = makeProxyFor(srcData);
       }
       srcMgr.setCacheData(blitProxyKey, sdp);
     }
     srcData = sdp.replaceData(srcData, txtype, comp, bgColor);
   }
   return srcData;
 }
Пример #2
0
  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;
  }
Пример #3
0
 public static void markDirty(Image img) {
   SurfaceData.getPrimarySurfaceData(img).markDirty();
 }