Java Code Examples for sun.java2d.SunGraphics2D

The following examples show how to use sun.java2d.SunGraphics2D. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: hottub   Source File: GlyphListLoopPipe.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl,
                             int aaHint) {
    switch (aaHint) {
     case SunHints.INTVAL_TEXT_ANTIALIAS_OFF:
         sg2d.loops.drawGlyphListLoop.
             DrawGlyphList(sg2d, sg2d.surfaceData, gl);
         return;
     case SunHints.INTVAL_TEXT_ANTIALIAS_ON:
         sg2d.loops.drawGlyphListAALoop.
             DrawGlyphListAA(sg2d, sg2d.surfaceData, gl);
         return;
    case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_HRGB:
    case SunHints.INTVAL_TEXT_ANTIALIAS_LCD_VRGB:
        sg2d.loops.drawGlyphListLCDLoop.
            DrawGlyphListLCD(sg2d,sg2d.surfaceData, gl);
        return;
    }
}
 
Example 2
Source Project: hottub   Source File: XRSurfaceData.java    License: GNU General Public License v2.0 6 votes vote down vote up
protected MaskFill getMaskFill(SunGraphics2D sg2d) {
    AlphaComposite aComp = null;
    if(sg2d.composite != null
            && sg2d.composite instanceof AlphaComposite) {
        aComp = (AlphaComposite) sg2d.composite;
    }

    boolean supportedPaint = sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR
            || XRPaints.isValid(sg2d);

    boolean supportedCompOp = false;
    if(aComp != null) {
        int rule = aComp.getRule();
        supportedCompOp = XRUtils.isMaskEvaluated(XRUtils.j2dAlphaCompToXR(rule));
    }

    return (supportedPaint && supportedCompOp) ?  super.getMaskFill(sg2d) : null;
}
 
Example 3
Source Project: jdk8u-dev-jdk   Source File: MaskFill.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void MaskFill(SunGraphics2D sg2d,
                     SurfaceData sData,
                     Composite comp,
                     int x, int y, int w, int h,
                     byte mask[], int offset, int scan)
{
    BufferedImage dstBI =
        new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
    SurfaceData tmpData = BufImgSurfaceData.createData(dstBI);

    // REMIND: This is not pretty.  It would be nicer if we
    // passed a "FillData" object to the Pixel loops, instead
    // of a SunGraphics2D parameter...
    Region clip = sg2d.clipRegion;
    sg2d.clipRegion = null;
    int pixel = sg2d.pixel;
    sg2d.pixel = tmpData.pixelFor(sg2d.getColor());
    fillop.FillRect(sg2d, tmpData, 0, 0, w, h);
    sg2d.pixel = pixel;
    sg2d.clipRegion = clip;

    maskop.MaskBlit(tmpData, sData, comp, null,
                    0, 0, x, y, w, h,
                    mask, offset, scan);
}
 
Example 4
Source Project: openjdk-jdk9   Source File: DrawImage.java    License: GNU General Public License v2.0 6 votes vote down vote up
public boolean scaleImage(SunGraphics2D sg, Image img,
                          int dx1, int dy1, int dx2, int dy2,
                          int sx1, int sy1, int sx2, int sy2,
                          Color bgColor,
                          ImageObserver observer) {
    if (!(img instanceof ToolkitImage)) {
        return scaleImage(sg, img, dx1, dy1, dx2, dy2,
                          sx1, sy1, sx2, sy2, bgColor);
    } else {
        ToolkitImage sunimg = (ToolkitImage)img;
        if (!imageReady(sunimg, observer)) {
            return false;
        }
        ImageRepresentation ir = sunimg.getImageRep();
        return ir.drawToBufImage(sg, sunimg, dx1, dy1, dx2, dy2,
                                 sx1, sy1, sx2, sy2, bgColor, observer);
    }
}
 
Example 5
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
 
Example 6
Source Project: openjdk-jdk8u   Source File: D3DRenderer.java    License: GNU General Public License v2.0 6 votes vote down vote up
void copyArea(SunGraphics2D sg2d,
              int x, int y, int w, int h, int dx, int dy)
{
    rq.lock();
    try {
        int ctxflags =
            sg2d.surfaceData.getTransparency() == Transparency.OPAQUE ?
                D3DContext.SRC_IS_OPAQUE : D3DContext.NO_CONTEXT_FLAGS;
        D3DSurfaceData dstData;
        try {
            dstData = (D3DSurfaceData)sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        D3DContext.validateContext(dstData, dstData,
                                   sg2d.getCompClip(), sg2d.composite,
                                   null, null, null, ctxflags);

        rq.ensureCapacity(28);
        buf.putInt(COPY_AREA);
        buf.putInt(x).putInt(y).putInt(w).putInt(h);
        buf.putInt(dx).putInt(dy);
    } finally {
        rq.unlock();
    }
}
 
Example 7
@Override
public void transformImage(SunGraphics2D sg, BufferedImage img,
                           BufferedImageOp op, int x, int y)
{
    if (op != null) {
        if (op instanceof AffineTransformOp) {
            AffineTransformOp atop = (AffineTransformOp) op;
            transformImage(sg, img, x, y,
                           atop.getTransform(),
                           atop.getInterpolationType());
            return;
        } else {
            if (D3DBufImgOps.renderImageWithOp(sg, img, op, x, y)) {
                return;
            }
        }
        img = op.filter(img, null);
    }
    copyImage(sg, img, x, y, null);
}
 
Example 8
Source Project: jdk8u-jdk   Source File: BufferedRenderPipe.java    License: GNU General Public License v2.0 6 votes vote down vote up
public void fillRect(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    rq.lock();
    try {
        validateContext(sg2d);
        rq.ensureCapacity(20);
        buf.putInt(FILL_RECT);
        buf.putInt(x + sg2d.transX);
        buf.putInt(y + sg2d.transY);
        buf.putInt(width);
        buf.putInt(height);
    } finally {
        rq.unlock();
    }
}
 
Example 9
Source Project: openjdk-jdk9   Source File: D3DPaints.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns true if the given MultipleGradientPaint instance can be
 * used by the accelerated D3DPaints.MultiGradient implementation.
 * A MultipleGradientPaint is considered valid if the following
 * conditions are met:
 *   - the number of gradient "stops" is <= MAX_FRACTIONS
 *   - the destination has support for fragment shaders
 */
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    MultipleGradientPaint paint = (MultipleGradientPaint)sg2d.paint;
    // REMIND: ugh, this creates garbage; would be nicer if
    // we had a MultipleGradientPaint.getNumStops() method...
    if (paint.getFractions().length > MULTI_MAX_FRACTIONS_D3D) {
        return false;
    }

    D3DSurfaceData dstData = (D3DSurfaceData)sg2d.surfaceData;
    D3DGraphicsDevice gd = (D3DGraphicsDevice)
        dstData.getDeviceConfiguration().getDevice();
    if (!gd.isCapPresent(CAPS_LCD_SHADER)) {
        return false;
    }
    return true;
}
 
Example 10
Source Project: jdk8u-dev-jdk   Source File: AlphaPaintPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public TileContext(SunGraphics2D sg, PaintContext pc) {
    sunG2D = sg;
    paintCtxt = pc;
    paintModel = pc.getColorModel();
    dstData = sg.getSurfaceData();
    synchronized (AlphaPaintPipe.class) {
        if (cachedLastColorModel != null &&
            cachedLastColorModel.get() == paintModel)
        {
            this.lastRaster = cachedLastRaster;
            this.lastData = cachedLastData;
        }
    }
}
 
Example 11
Source Project: TencentKona-8   Source File: D3DRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void validateContextAA(SunGraphics2D sg2d) {
    int ctxflags = D3DContext.NO_CONTEXT_FLAGS;
    D3DSurfaceData dstData;
    try {
        dstData = (D3DSurfaceData)sg2d.surfaceData;
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
    D3DContext.validateContext(dstData, dstData,
                               sg2d.getCompClip(), sg2d.composite,
                               null, sg2d.paint, sg2d, ctxflags);
}
 
Example 12
Source Project: jdk8u-jdk   Source File: MaskFill.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void FillAAPgram(SunGraphics2D sg2d, SurfaceData sData,
                        Composite comp,
                        double x, double y,
                        double dx1, double dy1,
                        double dx2, double dy2)
{
    tracePrimitive(fillPgramTarget);
    target.FillAAPgram(sg2d, sData, comp,
                       x, y, dx1, dy1, dx2, dy2);
}
 
Example 13
Source Project: jdk8u-jdk   Source File: LoopPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void fillRect(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    sg2d.loops.fillRectLoop.FillRect(sg2d, sg2d.getSurfaceData(),
                                     x + sg2d.transX,
                                     y + sg2d.transY,
                                     width, height);
}
 
Example 14
Source Project: openjdk-jdk8u   Source File: X11Renderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void drawOval(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawOval(sg2d.surfaceData.getNativeOps(), xgc,
                  x+sg2d.transX, y+sg2d.transY, width, height);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 15
Source Project: jdk8u-dev-jdk   Source File: ValidatePipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean copyImage(SunGraphics2D sg, Image img,
                         int dx, int dy, int sx, int sy, int w, int h,
                         Color bgColor,
                         ImageObserver observer) {
    if (validate(sg)) {
        return sg.imagepipe.copyImage(sg, img, dx, dy, sx, sy, w, h,
                                      bgColor, observer);
    } else {
        return false;
    }
}
 
Example 16
Source Project: TencentKona-8   Source File: LoopPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void fill(SunGraphics2D sg2d, Shape s) {
    if (sg2d.strokeState == SunGraphics2D.STROKE_THIN) {
        Path2D.Float p2df;
        int transX;
        int transY;
        if (sg2d.transformState <= SunGraphics2D.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 == SunGraphics2D.TRANSFORM_ISIDENT)
             ? null
             : sg2d.transform);
        sr.appendPath(s.getPathIterator(at));
        fillSpans(sg2d, sr);
    } finally {
        sr.dispose();
    }
}
 
Example 17
Source Project: hottub   Source File: OGLSurfaceData.java    License: GNU General Public License v2.0 5 votes vote down vote up
public boolean copyArea(SunGraphics2D sg2d,
                        int x, int y, int w, int h, int dx, int dy)
{
    if (sg2d.transformState < SunGraphics2D.TRANSFORM_TRANSLATESCALE &&
        sg2d.compositeState < SunGraphics2D.COMP_XOR)
    {
        x += sg2d.transX;
        y += sg2d.transY;

        oglRenderPipe.copyArea(sg2d, x, y, w, h, dx, dy);

        return true;
    }
    return false;
}
 
Example 18
Source Project: jdk8u60   Source File: OGLMaskFill.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void validateContext(SunGraphics2D sg2d,
                               Composite comp, int ctxflags)
{
    OGLSurfaceData dstData = (OGLSurfaceData)sg2d.surfaceData;
    OGLContext.validateContext(dstData, dstData,
                               sg2d.getCompClip(), comp,
                               null, sg2d.paint, sg2d, ctxflags);
}
 
Example 19
Source Project: jdk8u-dev-jdk   Source File: OGLPaints.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
boolean isPaintValid(SunGraphics2D sg2d) {
    LinearGradientPaint paint = (LinearGradientPaint)sg2d.paint;

    if (paint.getFractions().length == 2 &&
        paint.getCycleMethod() != CycleMethod.REPEAT &&
        paint.getColorSpace() != ColorSpaceType.LINEAR_RGB)
    {
        // we can delegate to the optimized two-color gradient
        // codepath, which does not require fragment shader support
        return true;
    }

    return super.isPaintValid(sg2d);
}
 
Example 20
public void drawLine(SunGraphics2D sg2d,
                     int x1, int y1, int x2, int y2)
{
    if (!drawGeneralLine(sg2d, x1, y1, x2, y2)) {
        super.drawLine(sg2d, x1, y1, x2, y2);
    }
}
 
Example 21
Source Project: jdk8u-jdk   Source File: X11Renderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void drawRect(SunGraphics2D sg2d,
                     int x, int y, int width, int height)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawRect(sg2d.surfaceData.getNativeOps(), xgc,
                  x+sg2d.transX, y+sg2d.transY, width, height);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 22
public void fill(SunGraphics2D sg2d, Shape s) {
    if (s instanceof Rectangle2D) {
        Rectangle2D r2d = (Rectangle2D) s;
        double w = r2d.getWidth();
        double h = r2d.getHeight();
        if (w > 0 && h > 0) {
            double x = r2d.getX();
            double y = r2d.getY();
            fillRectangle(sg2d, x, y, w, h);
        }
        return;
    }

    outpipe.fill(sg2d, s);
}
 
Example 23
Source Project: jdk8u-jdk   Source File: DrawPolygons.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void DrawPolygons(SunGraphics2D sg2d, SurfaceData sData,
                         int xPoints[], int yPoints[],
                         int nPoints[], int numPolys,
                         int transX, int transY,
                         boolean close)
{
    tracePrimitive(target);
    target.DrawPolygons(sg2d, sData,
                        xPoints, yPoints, nPoints, numPolys,
                        transX, transY, close);
}
 
Example 24
Source Project: jdk8u-dev-jdk   Source File: GlyphListPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void drawChars(SunGraphics2D sg2d,
                      char data[], int offset, int length,
                      int ix, int iy)
{
    FontInfo info = sg2d.getFontInfo();
    float x, y;
    if (info.pixelHeight > OutlineTextRenderer.THRESHHOLD) {
        SurfaceData.outlineTextRenderer.drawChars(
                                    sg2d, data, offset, length, ix, iy);
        return;
    }
    if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
        double origin[] = {ix + info.originX, iy + info.originY};
        sg2d.transform.transform(origin, 0, origin, 0, 1);
        x = (float) origin[0];
        y = (float) origin[1];
    } else {
        x = ix + info.originX + sg2d.transX;
        y = iy + info.originY + sg2d.transY;
    }
    GlyphList gl = GlyphList.getInstance();
    if (gl.setFromChars(info, data, offset, length, x, y)) {
        drawGlyphList(sg2d, gl);
        gl.dispose();
    } else {
        gl.dispose(); // release this asap.
        TextLayout tl = new TextLayout(new String(data, offset, length),
                                       sg2d.getFont(),
                                       sg2d.getFontRenderContext());
        tl.draw(sg2d, ix, iy);

    }
}
 
Example 25
Source Project: openjdk-jdk8u   Source File: OGLRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void validateContextAA(SunGraphics2D sg2d) {
    int ctxflags = OGLContext.NO_CONTEXT_FLAGS;
    OGLSurfaceData dstData;
    try {
        dstData = (OGLSurfaceData)sg2d.surfaceData;
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
    OGLContext.validateContext(dstData, dstData,
                               sg2d.getCompClip(), sg2d.composite,
                               null, sg2d.paint, sg2d, ctxflags);
}
 
Example 26
public void FillParallelogram(SunGraphics2D sg2d, SurfaceData dest,
                              double x0, double y0,
                              double dx1, double dy1,
                              double dx2, double dy2)
{
    tracePrimitive(target);
    target.FillParallelogram(sg2d, dest, x0, y0, dx1, dy1, dx2, dy2);
}
 
Example 27
Source Project: openjdk-jdk8u   Source File: XRRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * This method needs to be called prior to each draw/fillPath()
 * operation to ensure the clip bounds are up to date.
 */
void validate(SunGraphics2D sg2d) {
    Region clip = sg2d.getCompClip();
    setBounds(clip.getLoX(), clip.getLoY(),
              clip.getHiX(), clip.getHiY(), sg2d.strokeHint);
    validateSurface(sg2d);
}
 
Example 28
Source Project: openjdk-jdk8u   Source File: X11Renderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void drawRoundRect(SunGraphics2D sg2d,
                          int x, int y, int width, int height,
                          int arcWidth, int arcHeight)
{
    SunToolkit.awtLock();
    try {
        long xgc = validate(sg2d);
        XDrawRoundRect(sg2d.surfaceData.getNativeOps(), xgc,
                       x+sg2d.transX, y+sg2d.transY, width, height,
                       arcWidth, arcHeight);
    } finally {
        SunToolkit.awtUnlock();
    }
}
 
Example 29
Source Project: jdk8u60   Source File: Test8004859.java    License: GNU General Public License v2.0 5 votes vote down vote up
private static void test(final Graphics2D g) {
    for (final Shape clip : clips) {
        g.setClip(clip);
        if (!g.getClip().equals(clip)) {
            System.err.println("Expected clip: " + clip);
            System.err.println("Actual clip: " + g.getClip());
            System.err.println("bounds="+g.getClip().getBounds2D());
            System.err.println("bounds="+g.getClip().getBounds());
            status = false;
        }
        final Rectangle bounds = g.getClipBounds();
        if (!clip.equals(bounds)) {
            System.err.println("Expected getClipBounds(): " + clip);
            System.err.println("Actual getClipBounds(): " + bounds);
            status = false;
        }
        g.getClipBounds(bounds);
        if (!clip.equals(bounds)) {
            System.err.println("Expected getClipBounds(r): " + clip);
            System.err.println("Actual getClipBounds(r): " + bounds);
            status = false;
        }
        if (!clip.getBounds2D().isEmpty() && ((SunGraphics2D) g).clipRegion
                .isEmpty()) {
            System.err.println("clipRegion should not be empty");
            status = false;
        }
    }
}
 
Example 30
Source Project: openjdk-jdk8u   Source File: OGLUtilities.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Invokes the given Runnable on the OGL QueueFlusher thread with the
 * OpenGL context corresponding to the given Graphics object made
 * current.  It is legal for OpenGL code executed in the given
 * Runnable to change the current OpenGL context; it will be reset
 * once the Runnable completes.  No guarantees are made as to the
 * state of the OpenGL context of the Graphics object; for
 * example, calling code must set the scissor box using the return
 * value from {@link #getOGLScissorBox} to avoid drawing
 * over other Swing components, and must typically set the OpenGL
 * viewport using the return value from {@link #getOGLViewport} to
 * make the client's OpenGL rendering appear in the correct place
 * relative to the scissor region.
 *
 * In order to avoid deadlock, it is important that the given Runnable
 * does not attempt to acquire the AWT lock, as that will be handled
 * automatically as part of the <code>rq.flushAndInvokeNow()</code> step.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * if null, the step making a context current to the destination surface
 * will be skipped
 * @param r the action to be performed on the QFT; cannot be null
 * @return true if the operation completed successfully, or false if
 * there was any problem making a context current to the surface
 * associated with the given Graphics object
 */
public static boolean invokeWithOGLContextCurrent(Graphics g, Runnable r) {
    OGLRenderQueue rq = OGLRenderQueue.getInstance();
    rq.lock();
    try {
        if (g != null) {
            if (!(g instanceof SunGraphics2D)) {
                return false;
            }
            SurfaceData sData = ((SunGraphics2D)g).surfaceData;
            if (!(sData instanceof OGLSurfaceData)) {
                return false;
            }

            // make a context current to the destination surface
            OGLContext.validateContext((OGLSurfaceData)sData);
        }

        // invoke the given runnable on the QFT
        rq.flushAndInvokeNow(r);

        // invalidate the current context so that the next time we render
        // with Java 2D, the context state will be completely revalidated
        OGLContext.invalidateCurrentContext();
    } finally {
        rq.unlock();
    }

    return true;
}
 
Example 31
Source Project: openjdk-8   Source File: LoopPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example 32
Source Project: jdk8u_jdk   Source File: LoopPipe.java    License: GNU General Public License v2.0 5 votes vote down vote up
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();
    }
}
 
Example 33
public void fillRectangle(SunGraphics2D sg2d,
                          double rx, double ry,
                          double rw, double rh)
{
    double px, py;
    double dx1, dy1, dx2, dy2;
    AffineTransform txform = sg2d.transform;
    dx1 = txform.getScaleX();
    dy1 = txform.getShearY();
    dx2 = txform.getShearX();
    dy2 = txform.getScaleY();
    px = rx * dx1 + ry * dx2 + txform.getTranslateX();
    py = rx * dy1 + ry * dy2 + txform.getTranslateY();
    dx1 *= rw;
    dy1 *= rw;
    dx2 *= rh;
    dy2 *= rh;
    if (adjustfill &&
        sg2d.strokeState < SunGraphics2D.STROKE_CUSTOM &&
        sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE)
    {
        double newx = normalize(px);
        double newy = normalize(py);
        dx1 = normalize(px + dx1) - newx;
        dy1 = normalize(py + dy1) - newy;
        dx2 = normalize(px + dx2) - newx;
        dy2 = normalize(py + dy2) - newy;
        px = newx;
        py = newy;
    }
    outrenderer.fillParallelogram(sg2d, rx, ry, rx+rw, ry+rh,
                                  px, py, dx1, dy1, dx2, dy2);
}
 
Example 34
Source Project: openjdk-jdk8u   Source File: XRRenderer.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Common validate method, used by all XRRender functions to validate the
 * destination context.
 */
private final void validateSurface(SunGraphics2D sg2d) {
    XRSurfaceData xrsd;
    try {
        xrsd = (XRSurfaceData) sg2d.surfaceData;
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
    xrsd.validateAsDestination(sg2d, sg2d.getCompClip());
    xrsd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform,
                                           sg2d.paint, sg2d);
}
 
Example 35
Source Project: openjdk-jdk9   Source File: CGLSurfaceData.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static long createOGLContextOnSurface(Graphics g, long sharedContext) {
    SurfaceData sd = ((SunGraphics2D) g).surfaceData;
    if ((sd instanceof CGLSurfaceData) == true) {
        CGLSurfaceData cglsd = (CGLSurfaceData) sd;
        return createCGLContextOnSurface(cglsd, sharedContext);
    } else {
        return 0L;
    }
}
 
Example 36
Source Project: openjdk-8-source   Source File: MaskFill.java    License: GNU General Public License v2.0 5 votes vote down vote up
public void DrawAAPgram(SunGraphics2D sg2d, SurfaceData sData,
                        Composite comp,
                        double x, double y,
                        double dx1, double dy1,
                        double dx2, double dy2,
                        double lw1, double lw2)
{
    tracePrimitive(drawPgramTarget);
    target.DrawAAPgram(sg2d, sData, comp,
                       x, y, dx1, dy1, dx2, dy2, lw1, lw2);
}
 
Example 37
Source Project: openjdk-jdk9   Source File: DrawGlyphListAA.java    License: GNU General Public License v2.0 4 votes vote down vote up
public void DrawGlyphListAA(SunGraphics2D sg2d, SurfaceData dest,
                            GlyphList glyphs)
{
    tracePrimitive(target);
    target.DrawGlyphListAA(sg2d, dest, glyphs);
}
 
Example 38
public void fillRect(SunGraphics2D sg,
                     int x, int y, int w, int h) {
    outpipe.fill(sg, new Rectangle(x, y, w, h));
}
 
Example 39
Source Project: openjdk-jdk8u   Source File: CompositePipe.java    License: GNU General Public License v2.0 4 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle dev,
int[] abox);
 
Example 40
Source Project: jdk8u-jdk   Source File: XRSurfaceData.java    License: GNU General Public License v2.0 4 votes vote down vote up
@Override
public void validatePipe(SunGraphics2D sg2d) {
    TextPipe textpipe;
    boolean validated = false;

    /*
     * The textpipe for now can't handle TexturePaint when extra-alpha is
     * specified nore XOR mode
     */
    if ((textpipe = getTextPipe(sg2d)) == null)
    {
        super.validatePipe(sg2d);
        textpipe = sg2d.textpipe;
        validated = true;
    }

    PixelToShapeConverter txPipe = null;
    XRRenderer nonTxPipe = null;

    /*
     * TODO: Can we rely on the GC for ARGB32 surfaces?
     */
    if (sg2d.antialiasHint != SunHints.INTVAL_ANTIALIAS_ON) {
        if (sg2d.paintState <= SunGraphics2D.PAINT_ALPHACOLOR) {
            if (sg2d.compositeState <= SunGraphics2D.COMP_XOR) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
        } else if (sg2d.compositeState <= SunGraphics2D.COMP_ALPHA) {
            if (XRPaints.isValid(sg2d)) {
                txPipe = xrtxpipe;
                nonTxPipe = xrpipe;
            }
            // custom paints handled by super.validatePipe() below
        }
    }

    if (sg2d.antialiasHint == SunHints.INTVAL_ANTIALIAS_ON &&
        JulesPathBuf.isCairoAvailable())
    {
        sg2d.shapepipe = aaShapePipe;
        sg2d.drawpipe = aaPixelToShapeConv;
        sg2d.fillpipe = aaPixelToShapeConv;
    } else {
        if (txPipe != null) {
            if (sg2d.transformState >= SunGraphics2D.TRANSFORM_TRANSLATESCALE) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = txPipe;
            } else if (sg2d.strokeState != SunGraphics2D.STROKE_THIN) {
                sg2d.drawpipe = txPipe;
                sg2d.fillpipe = nonTxPipe;
            } else {
                sg2d.drawpipe = nonTxPipe;
                sg2d.fillpipe = nonTxPipe;
            }
            sg2d.shapepipe = nonTxPipe;
        } 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 XRender pipe
    sg2d.imagepipe = xrDrawImage;
}