예제 #1
0
  public void fill(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == sg2d.STROKE_THIN) {
      Path2D.Float p2df;
      int transX;
      int transY;
      if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
          p2df = (Path2D.Float) s;
        } else {
          p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
      } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
      }
      sg2d.loops.fillPathLoop.FillPath(sg2d, sg2d.getSurfaceData(), transX, transY, p2df);
      return;
    }

    ShapeSpanIterator sr = getFillSSI(sg2d);
    try {
      sr.setOutputArea(sg2d.getCompClip());
      AffineTransform at =
          ((sg2d.transformState == sg2d.TRANSFORM_ISIDENT) ? null : sg2d.transform);
      sr.appendPath(s.getPathIterator(at));
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
 /*     */ public void DrawLine(
     SunGraphics2D paramSunGraphics2D,
     SurfaceData paramSurfaceData,
     int paramInt1,
     int paramInt2,
     int paramInt3,
     int paramInt4)
       /*     */ {
   /* 747 */ PixelWriter localPixelWriter =
       GeneralRenderer.createSolidPixelWriter(paramSunGraphics2D, paramSurfaceData);
   /*     */
   /* 749 */ if (paramInt2 >= paramInt4) {
     /* 750 */ GeneralRenderer.doDrawLine(
         paramSurfaceData,
         localPixelWriter,
         null,
         paramSunGraphics2D.getCompClip(),
         paramInt3,
         paramInt4,
         paramInt1,
         paramInt2);
     /*     */ }
   /*     */ else
   /*     */ {
     /* 754 */ GeneralRenderer.doDrawLine(
         paramSurfaceData,
         localPixelWriter,
         null,
         paramSunGraphics2D.getCompClip(),
         paramInt1,
         paramInt2,
         paramInt3,
         paramInt4);
     /*     */ }
   /*     */ }
예제 #3
0
 private static void fillSpans(SunGraphics2D sg2d, SpanIterator si) {
   // REMIND: Eventually, the plan is that it will not be possible for
   // fs to be null since the FillSpans loop will be the fundamental
   // loop implemented for any destination type...
   if (sg2d.clipState == sg2d.CLIP_SHAPE) {
     si = sg2d.clipRegion.filter(si);
     // REMIND: Region.filter produces a Java-only iterator
     // with no native counterpart...
   } else {
     sun.java2d.loops.FillSpans fs = sg2d.loops.fillSpansLoop;
     if (fs != null) {
       fs.FillSpans(sg2d, sg2d.getSurfaceData(), si);
       return;
     }
   }
   int spanbox[] = new int[4];
   SurfaceData sd = sg2d.getSurfaceData();
   while (si.nextSpan(spanbox)) {
     int x = spanbox[0];
     int y = spanbox[1];
     int w = spanbox[2] - x;
     int h = spanbox[3] - y;
     sg2d.loops.fillRectLoop.FillRect(sg2d, sd, x, y, w, h);
   }
 }
예제 #4
0
  // Render an image using only integer scaling (no transform).
  protected boolean renderImageScale(
      SunGraphics2D sg,
      Image img,
      Color bgColor,
      int interpType,
      int sx1,
      int sy1,
      int sx2,
      int sy2,
      double dx1,
      double dy1,
      double dx2,
      double dy2) {
    // Currently only NEAREST_NEIGHBOR interpolation is implemented
    // for ScaledBlit operations.
    if (interpType != AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
      return false;
    }

    Region clip = sg.getCompClip();
    SurfaceData dstData = sg.surfaceData;

    int attempts = 0;
    // Loop up to twice through; this gives us a chance to
    // revalidate the surfaceData objects in case of an exception
    // and try it once more
    while (true) {
      SurfaceData srcData =
          dstData.getSourceSurfaceData(img, sg.TRANSFORM_TRANSLATESCALE, sg.imageComp, bgColor);

      if (srcData == null || isBgOperation(srcData, bgColor)) {
        return false;
      }

      try {
        SurfaceType srcType = srcData.getSurfaceType();
        SurfaceType dstType = dstData.getSurfaceType();
        return scaleSurfaceData(
            sg, clip, srcData, dstData, srcType, dstType, sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2);
      } catch (NullPointerException e) {
        if (!SurfaceData.isNull(dstData)) {
          // Something else caused the exception, throw it...
          throw e;
        }
        return false;
        // NOP if we have been disposed
      } catch (InvalidPipeException e) {
        // Always catch the exception; try this a couple of times
        // and fail silently if the system is not yet ready to
        // revalidate the source or dest surfaceData objects.
        ++attempts;
        clip = sg.getCompClip(); // ensures sg.surfaceData is valid
        dstData = sg.surfaceData;
        if (SurfaceData.isNull(dstData) || SurfaceData.isNull(srcData) || (attempts > 1)) {
          return false;
        }
      }
    }
  }
예제 #5
0
  public void draw(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == sg2d.STROKE_THIN) {
      Path2D.Float p2df;
      int transX;
      int transY;
      if (sg2d.transformState <= sg2d.TRANSFORM_INT_TRANSLATE) {
        if (s instanceof Path2D.Float) {
          p2df = (Path2D.Float) s;
        } else {
          p2df = new Path2D.Float(s);
        }
        transX = sg2d.transX;
        transY = sg2d.transY;
      } else {
        p2df = new Path2D.Float(s, sg2d.transform);
        transX = 0;
        transY = 0;
      }
      sg2d.loops.drawPathLoop.DrawPath(sg2d, sg2d.getSurfaceData(), transX, transY, p2df);
      return;
    }

    if (sg2d.strokeState == sg2d.STROKE_CUSTOM) {
      fill(sg2d, sg2d.stroke.createStrokedShape(s));
      return;
    }

    ShapeSpanIterator sr = getStrokeSpans(sg2d, s);

    try {
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
예제 #6
0
  private void replaceSurfaceData(
      int newBackBufferCount, BufferCapabilities newBackBufferCaps, boolean blit) {
    synchronized (surfaceDataLock) {
      final SurfaceData oldData = getSurfaceData();
      surfaceData = platformWindow.replaceSurfaceData();
      // TODO: volatile image
      //        VolatileImage oldBB = backBuffer;
      BufferedImage oldBB = backBuffer;
      backBufferCount = newBackBufferCount;
      backBufferCaps = newBackBufferCaps;
      final Rectangle size = getSize();
      if (getSurfaceData() != null && oldData != getSurfaceData()) {
        clearBackground(size.width, size.height);
      }

      if (blit) {
        blitSurfaceData(oldData, getSurfaceData());
      }

      if (oldData != null && oldData != getSurfaceData()) {
        // TODO: drop oldData for D3D/WGL pipelines
        // This can only happen when this peer is being created
        oldData.flush();
      }

      // TODO: volatile image
      //        backBuffer = (VolatileImage)delegate.createBackBuffer();
      backBuffer = (BufferedImage) platformWindow.createBackBuffer();
      if (backBuffer != null) {
        Graphics g = backBuffer.getGraphics();
        try {
          Rectangle r = getBounds();
          if (g instanceof Graphics2D) {
            ((Graphics2D) g).setComposite(AlphaComposite.Src);
          }
          g.setColor(nonOpaqueBackground);
          g.fillRect(0, 0, r.width, r.height);
          if (g instanceof SunGraphics2D) {
            ((SunGraphics2D) g).constrain(0, 0, r.width, r.height, getRegion());
          }
          if (!isTextured()) {
            g.setColor(getBackground());
            g.fillRect(0, 0, r.width, r.height);
          }
          if (oldBB != null) {
            // Draw the old back buffer to the new one
            g.drawImage(oldBB, 0, 0, null);
            oldBB.flush();
          }
        } finally {
          g.dispose();
        }
      }
    }
    flushOnscreenGraphics();
  }
예제 #7
0
  // Render an image using only integer translation
  // (no scale or transform or sub-pixel interpolated translations).
  protected boolean renderImageCopy(
      SunGraphics2D sg, Image img, Color bgColor, int dx, int dy, int sx, int sy, int w, int h) {
    Region clip = sg.getCompClip();
    SurfaceData dstData = sg.surfaceData;

    int attempts = 0;
    // Loop up to twice through; this gives us a chance to
    // revalidate the surfaceData objects in case of an exception
    // and try it once more
    while (true) {
      SurfaceData srcData =
          dstData.getSourceSurfaceData(img, sg.TRANSFORM_ISIDENT, sg.imageComp, bgColor);
      if (srcData == null) {
        return false;
      }

      try {
        SurfaceType srcType = srcData.getSurfaceType();
        SurfaceType dstType = dstData.getSurfaceType();
        blitSurfaceData(
            sg, clip, srcData, dstData, srcType, dstType, sx, sy, dx, dy, w, h, bgColor);
        return true;
      } catch (NullPointerException e) {
        if (!(SurfaceData.isNull(dstData) || SurfaceData.isNull(srcData))) {
          // Something else caused the exception, throw it...
          throw e;
        }
        return false;
        // NOP if we have been disposed
      } catch (InvalidPipeException e) {
        // Always catch the exception; try this a couple of times
        // and fail silently if the system is not yet ready to
        // revalidate the source or dest surfaceData objects.
        ++attempts;
        clip = sg.getCompClip(); // ensures sg.surfaceData is valid
        dstData = sg.surfaceData;
        if (SurfaceData.isNull(dstData) || SurfaceData.isNull(srcData) || (attempts > 1)) {
          return false;
        }
      }
    }
  }
예제 #8
0
  public void fillPolygon(SunGraphics2D sg2d, int xPoints[], int yPoints[], int nPoints) {
    ShapeSpanIterator sr = getFillSSI(sg2d);

    try {
      sr.setOutputArea(sg2d.getCompClip());
      sr.appendPoly(xPoints, yPoints, nPoints, sg2d.transX, sg2d.transY);
      fillSpans(sg2d, sr);
    } finally {
      sr.dispose();
    }
  }
예제 #9
0
 public void drawPolygon(SunGraphics2D sg2d, int xPoints[], int yPoints[], int nPoints) {
   int nPointsArray[] = {nPoints};
   sg2d.loops.drawPolygonsLoop.DrawPolygons(
       sg2d,
       sg2d.getSurfaceData(),
       xPoints,
       yPoints,
       nPointsArray,
       1,
       sg2d.transX,
       sg2d.transY,
       true);
 }
예제 #10
0
  /*
   * Return a ShapeSpanIterator ready to iterate the spans of the wide
   * outline of Shape s using the attributes of the SunGraphics2D
   * object.
   *
   * The ShapeSpanIterator returned will be fully constructed
   * and filled with the geometry from the Shape widened by the
   * appropriate BasicStroke and normalization parameters taken
   * from the SunGraphics2D object and be ready to start returning
   * spans.
   *
   * Note that the caller is responsible for calling dispose()
   * on the returned ShapeSpanIterator inside a try/finally block.
   * <pre>
   *     ShapeSpanIterator ssi = LoopPipe.getStrokeSpans(sg2d, s);
   *     try {
   *         // iterate the spans from ssi and operate on them
   *     } finally {
   *         ssi.dispose();
   *     }
   * </pre>
   *
   * REMIND: This should return a SpanIterator interface object
   * but the caller needs to dispose() the object and that method
   * is only on ShapeSpanIterator.
   * TODO: Add a dispose() method to the SpanIterator interface.
   */
  public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d, Shape s) {
    ShapeSpanIterator sr = new ShapeSpanIterator(false);

    try {
      sr.setOutputArea(sg2d.getCompClip());
      sr.setRule(PathIterator.WIND_NON_ZERO);

      BasicStroke bs = (BasicStroke) sg2d.stroke;
      boolean thin = (sg2d.strokeState <= sg2d.STROKE_THINDASHED);
      boolean normalize = (sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);

      RenderEngine.strokeTo(s, sg2d.transform, bs, thin, normalize, false, sr);
    } catch (Throwable t) {
      sr.dispose();
      sr = null;
      t.printStackTrace();
      throw new InternalError("Unable to Stroke shape (" + t.getMessage() + ")");
    }
    return sr;
  }
예제 #11
0
 public boolean copyArea(SunGraphics2D sg2d, int x, int y, int w, int h, int dx, int dy) {
   CompositeType comptype = sg2d.imageComp;
   if (sg2d.clipState != SunGraphics2D.CLIP_SHAPE
       && (CompositeType.SrcOverNoEa.equals(comptype) || CompositeType.SrcNoEa.equals(comptype))) {
     int dstx1 = x + dx;
     int dsty1 = y + dy;
     int dstx2 = dstx1 + w;
     int dsty2 = dsty1 + h;
     Region clip = sg2d.getCompClip();
     if (dstx1 < clip.getLoX()) dstx1 = clip.getLoX();
     if (dsty1 < clip.getLoY()) dsty1 = clip.getLoY();
     if (dstx2 > clip.getHiX()) dstx2 = clip.getHiX();
     if (dsty2 > clip.getHiY()) dsty2 = clip.getHiY();
     if (dstx1 < dstx2 && dsty1 < dsty2) {
       gdiPipe.devCopyArea(this, dstx1 - dx, dsty1 - dy, dx, dy, dstx2 - dstx1, dsty2 - dsty1);
     }
     return true;
   }
   return false;
 }
예제 #12
0
 private void clearBackground(final int w, final int h) {
   final Graphics g = getOnscreenGraphics(getForeground(), getBackground(), getFont());
   if (g != null) {
     try {
       if (g instanceof Graphics2D) {
         ((Graphics2D) g).setComposite(AlphaComposite.Src);
       }
       if (isTranslucent()) {
         g.setColor(nonOpaqueBackground);
         g.fillRect(0, 0, w, h);
       }
       if (!isTextured()) {
         if (g instanceof SunGraphics2D) {
           ((SunGraphics2D) g).constrain(0, 0, w, h, getRegion());
         }
         g.setColor(getBackground());
         g.fillRect(0, 0, w, h);
       }
     } finally {
       g.dispose();
     }
   }
 }
예제 #13
0
  public void validatePipe(SunGraphics2D sg2d) {
    TextPipe textpipe;
    boolean validated = false;

    // REMIND: the D3D pipeline doesn't support XOR!, more
    // fixes will be needed below. For now we disable D3D rendering
    // for the surface which had any XOR rendering done to.
    if (sg2d.compositeState >= sg2d.COMP_XOR) {
      super.validatePipe(sg2d);
      sg2d.imagepipe = d3dImagePipe;
      disableAccelerationForSurface();
      return;
    }

    // D3DTextRenderer 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 = d3dTextPipe;
    } 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;
    D3DRenderer nonTxPipe = null;

    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
      if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
        if (sg2d.compositeState <= sg2d.COMP_XOR) {
          txPipe = d3dTxRenderPipe;
          nonTxPipe = d3dRenderPipe;
        }
      } else if (sg2d.compositeState <= sg2d.COMP_ALPHA) {
        if (D3DPaints.isValid(sg2d)) {
          txPipe = d3dTxRenderPipe;
          nonTxPipe = d3dRenderPipe;
        }
        // custom paints handled by super.validatePipe() below
      }
    } else {
      if (sg2d.paintState <= sg2d.PAINT_ALPHACOLOR) {
        if (graphicsDevice.isCapPresent(CAPS_AA_SHADER)
            && (sg2d.imageComp == CompositeType.SrcOverNoEa
                || sg2d.imageComp == CompositeType.SrcOver)) {
          if (!validated) {
            super.validatePipe(sg2d);
            validated = true;
          }
          PixelToParallelogramConverter aaConverter =
              new PixelToParallelogramConverter(
                  sg2d.shapepipe, d3dAAPgramPipe, 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 = d3dTxRenderPipe;
          nonTxPipe = d3dRenderPipe;
        }
      }
      // 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 D3D pipe
    sg2d.imagepipe = d3dImagePipe;
  }
예제 #14
0
  protected void renderImageXform(
      SunGraphics2D sg,
      Image img,
      AffineTransform tx,
      int interpType,
      int sx1,
      int sy1,
      int sx2,
      int sy2,
      Color bgColor) {
    Region clip = sg.getCompClip();
    SurfaceData dstData = sg.surfaceData;
    SurfaceData srcData =
        dstData.getSourceSurfaceData(img, sg.TRANSFORM_GENERIC, sg.imageComp, bgColor);

    if (srcData == null) {
      img = getBufferedImage(img);
      srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_GENERIC, sg.imageComp, bgColor);
      if (srcData == null) {
        // REMIND: Is this correct?  Can this happen?
        return;
      }
    }

    if (isBgOperation(srcData, bgColor)) {
      // We cannot perform bg operations during transform so make
      // an opaque temp image with the appropriate background
      // and work from there.
      img = makeBufferedImage(img, bgColor, BufferedImage.TYPE_INT_RGB, sx1, sy1, sx2, sy2);
      // Temp image has appropriate subimage at 0,0 now.
      sx2 -= sx1;
      sy2 -= sy1;
      sx1 = sy1 = 0;

      srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_GENERIC, sg.imageComp, bgColor);
    }

    SurfaceType srcType = srcData.getSurfaceType();
    TransformHelper helper = TransformHelper.getFromCache(srcType);

    if (helper == null) {
      /* We have no helper for this source image type.
       * But we know that we do have helpers for both RGB and ARGB,
       * so convert to one of those types depending on transparency.
       * ARGB_PRE might be a better choice if the source image has
       * alpha, but it may cause some recursion here since we only
       * tend to have converters that convert to ARGB.
       */
      int type =
          ((srcData.getTransparency() == Transparency.OPAQUE)
              ? BufferedImage.TYPE_INT_RGB
              : BufferedImage.TYPE_INT_ARGB);
      img = makeBufferedImage(img, null, type, sx1, sy1, sx2, sy2);
      // Temp image has appropriate subimage at 0,0 now.
      sx2 -= sx1;
      sy2 -= sy1;
      sx1 = sy1 = 0;

      srcData = dstData.getSourceSurfaceData(img, sg.TRANSFORM_GENERIC, sg.imageComp, null);
      srcType = srcData.getSurfaceType();
      helper = TransformHelper.getFromCache(srcType);
      // assert(helper != null);
    }

    AffineTransform itx;
    try {
      itx = tx.createInverse();
    } catch (NoninvertibleTransformException e) {
      // Non-invertible transform means no output
      return;
    }

    /*
     * Find the maximum bounds on the destination that will be
     * affected by the transformed source.  First, transform all
     * four corners of the source and then min and max the resulting
     * destination coordinates of the transformed corners.
     * Note that tx already has the offset to sx1,sy1 accounted
     * for so we use the box (0, 0, sx2-sx1, sy2-sy1) as the
     * source coordinates.
     */
    double coords[] = new double[8];
    /* corner:  UL      UR      LL      LR   */
    /* index:  0  1    2  3    4  5    6  7  */
    /* coord: (0, 0), (w, 0), (0, h), (w, h) */
    coords[2] = coords[6] = sx2 - sx1;
    coords[5] = coords[7] = sy2 - sy1;
    tx.transform(coords, 0, coords, 0, 4);
    double ddx1, ddy1, ddx2, ddy2;
    ddx1 = ddx2 = coords[0];
    ddy1 = ddy2 = coords[1];
    for (int i = 2; i < coords.length; i += 2) {
      double d = coords[i];
      if (ddx1 > d) ddx1 = d;
      else if (ddx2 < d) ddx2 = d;
      d = coords[i + 1];
      if (ddy1 > d) ddy1 = d;
      else if (ddy2 < d) ddy2 = d;
    }
    int dx1 = (int) Math.floor(ddx1);
    int dy1 = (int) Math.floor(ddy1);
    int dx2 = (int) Math.ceil(ddx2);
    int dy2 = (int) Math.ceil(ddy2);

    SurfaceType dstType = dstData.getSurfaceType();
    MaskBlit maskblit;
    Blit blit;
    if (sg.compositeState <= sg.COMP_ALPHA) {
      /* NOTE: We either have, or we can make,
       * a MaskBlit for any alpha composite type
       */
      maskblit = MaskBlit.getFromCache(SurfaceType.IntArgbPre, sg.imageComp, dstType);

      /* NOTE: We can only use the native TransformHelper
       * func to go directly to the dest if both the helper
       * and the MaskBlit are native.
       * All helpers are native at this point, but some MaskBlit
       * objects are implemented in Java, so we need to check.
       */
      if (maskblit.getNativePrim() != 0) {
        // We can render directly.
        helper.Transform(
            maskblit,
            srcData,
            dstData,
            sg.composite,
            clip,
            itx,
            interpType,
            sx1,
            sy1,
            sx2,
            sy2,
            dx1,
            dy1,
            dx2,
            dy2,
            null,
            0,
            0);
        return;
      }
      blit = null;
    } else {
      /* NOTE: We either have, or we can make,
       * a Blit for any composite type, even Custom
       */
      maskblit = null;
      blit = Blit.getFromCache(SurfaceType.IntArgbPre, sg.imageComp, dstType);
    }

    // We need to transform to a temp image and then copy
    // just the pieces that are valid data to the dest.
    BufferedImage tmpimg = new BufferedImage(dx2 - dx1, dy2 - dy1, BufferedImage.TYPE_INT_ARGB);
    SurfaceData tmpData = SurfaceData.getPrimarySurfaceData(tmpimg);
    SurfaceType tmpType = tmpData.getSurfaceType();
    MaskBlit tmpmaskblit =
        MaskBlit.getFromCache(SurfaceType.IntArgbPre, CompositeType.SrcNoEa, tmpType);
    /*
     * The helper function fills a temporary edges buffer
     * for us with the bounding coordinates of each scanline
     * in the following format:
     *
     * edges[0, 1] = [top y, bottom y)
     * edges[2, 3] = [left x, right x) of top row
     * ...
     * edges[h*2, h*2+1] = [left x, right x) of bottom row
     *
     * all coordinates in the edges array will be relative to dx1, dy1
     *
     * edges thus has to be h*2+2 in length
     */
    int edges[] = new int[(dy2 - dy1) * 2 + 2];
    // It is important that edges[0]=edges[1]=0 when we call
    // Transform in case it must return early and we would
    // not want to render anything on an error condition.
    helper.Transform(
        tmpmaskblit,
        srcData,
        tmpData,
        AlphaComposite.Src,
        null,
        itx,
        interpType,
        sx1,
        sy1,
        sx2,
        sy2,
        0,
        0,
        dx2 - dx1,
        dy2 - dy1,
        edges,
        dx1,
        dy1);

    /*
     * Now copy the results, scanline by scanline, into the dest.
     * The edges array helps us minimize the work.
     */
    int index = 2;
    for (int y = edges[0]; y < edges[1]; y++) {
      int relx1 = edges[index++];
      int relx2 = edges[index++];
      if (relx1 >= relx2) {
        continue;
      }
      if (maskblit != null) {
        maskblit.MaskBlit(
            tmpData,
            dstData,
            sg.composite,
            clip,
            relx1,
            y,
            dx1 + relx1,
            dy1 + y,
            relx2 - relx1,
            1,
            null,
            0,
            0);
      } else {
        blit.Blit(
            tmpData, dstData, sg.composite, clip, relx1, y, dx1 + relx1, dy1 + y, relx2 - relx1, 1);
      }
    }
  }
예제 #15
0
 public void drawRect(SunGraphics2D sg2d, int x, int y, int width, int height) {
   sg2d.loops.drawRectLoop.DrawRect(
       sg2d, sg2d.getSurfaceData(), x + sg2d.transX, y + sg2d.transY, width, height);
 }
예제 #16
0
 public void drawLine(SunGraphics2D sg2d, int x1, int y1, int x2, int y2) {
   int tX = sg2d.transX;
   int tY = sg2d.transY;
   sg2d.loops.drawLineLoop.DrawLine(
       sg2d, sg2d.getSurfaceData(), x1 + tX, y1 + tY, x2 + tX, y2 + tY);
 }
예제 #17
0
 @Override
 protected void validateContext(SunGraphics2D sg2d, Composite comp, int ctxflags) {
   D3DSurfaceData dstData = (D3DSurfaceData) sg2d.surfaceData;
   D3DContext.validateContext(
       dstData, dstData, sg2d.getCompClip(), comp, null, sg2d.paint, sg2d, ctxflags);
 }
예제 #18
0
  public void validatePipe(SunGraphics2D sg2d) {
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON
        && sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR
        && (sg2d.compositeState <= SunGraphics2D.COMP_ISCOPY
            || sg2d.compositeState == SunGraphics2D.COMP_XOR)) {
      if (sg2d.clipState == SunGraphics2D.CLIP_SHAPE) {
        // Do this to init textpipe correctly; we will override the
        // other non-text pipes below
        // REMIND: we should clean this up eventually instead of
        // having this work duplicated.
        super.validatePipe(sg2d);
      } else {
        switch (sg2d.textAntialiasHint) {
          case SunHints.INTVAL_TEXT_ANTIALIAS_DEFAULT:
            /* equate DEFAULT to OFF which it is for us */
          case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
            sg2d.textpipe = solidTextRenderer;
            break;

          case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
            sg2d.textpipe = aaTextRenderer;
            break;

          default:
            switch (sg2d.getFontInfo().aaHint) {
              case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
              case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
                sg2d.textpipe = lcdTextRenderer;
                break;

              case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
                sg2d.textpipe = aaTextRenderer;
                break;

              default:
                sg2d.textpipe = solidTextRenderer;
            }
        }
      }
      sg2d.imagepipe = imagepipe;
      if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        sg2d.drawpipe = gdiTxPipe;
        sg2d.fillpipe = gdiTxPipe;
      } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
        sg2d.drawpipe = gdiTxPipe;
        sg2d.fillpipe = gdiPipe;
      } else {
        sg2d.drawpipe = gdiPipe;
        sg2d.fillpipe = gdiPipe;
      }
      sg2d.shapepipe = gdiPipe;
      // This is needed for AA text.
      // Note that even a SolidTextRenderer can dispatch AA text
      // if a GlyphVector overrides the AA setting.
      // We use getRenderLoops() rather than setting solidloops
      // directly so that we get the appropriate loops in XOR mode.
      if (sg2d.loops == null) {
        // assert(some pipe will always be a LoopBasedPipe)
        sg2d.loops = getRenderLoops(sg2d);
      }
    } else {
      super.validatePipe(sg2d);
    }
  }