Search in sources :

Example 1 with InvalidPipeException

use of sun.java2d.InvalidPipeException in project jdk8u_jdk by JetBrains.

the class OGLRenderer method validateContext.

@Override
protected void validateContext(SunGraphics2D sg2d) {
    int ctxflags = sg2d.paint.getTransparency() == Transparency.OPAQUE ? OGLContext.SRC_IS_OPAQUE : 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);
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Example 2 with InvalidPipeException

use of sun.java2d.InvalidPipeException in project jdk8u_jdk by JetBrains.

the class OGLRenderer method copyArea.

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 ? OGLContext.SRC_IS_OPAQUE : 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, 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();
    }
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Example 3 with InvalidPipeException

use of sun.java2d.InvalidPipeException in project jdk8u_jdk by JetBrains.

the class OGLTextRenderer method validateContext.

@Override
protected void validateContext(SunGraphics2D sg2d, Composite comp) {
    // assert rq.lock.isHeldByCurrentThread();
    OGLSurfaceData oglDst;
    try {
        oglDst = (OGLSurfaceData) sg2d.surfaceData;
    } catch (ClassCastException e) {
        throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
    }
    OGLContext.validateContext(oglDst, oglDst, sg2d.getCompClip(), comp, null, sg2d.paint, sg2d, OGLContext.NO_CONTEXT_FLAGS);
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Example 4 with InvalidPipeException

use of sun.java2d.InvalidPipeException in project jdk8u_jdk by JetBrains.

the class DrawImage method renderImageScale.

// 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) {
    // for ScaledBlit operations.
    if (interpType != AffineTransformOp.TYPE_NEAREST_NEIGHBOR) {
        return false;
    }
    Region clip = sg.getCompClip();
    SurfaceData dstData = sg.surfaceData;
    int attempts = 0;
    // and try it once more
    while (true) {
        SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.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;
            // ensures sg.surfaceData is valid
            clip = sg.getCompClip();
            dstData = sg.surfaceData;
            if (SurfaceData.isNull(dstData) || SurfaceData.isNull(srcData) || (attempts > 1)) {
                return false;
            }
        }
    }
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException) SurfaceData(sun.java2d.SurfaceData) SurfaceType(sun.java2d.loops.SurfaceType)

Example 5 with InvalidPipeException

use of sun.java2d.InvalidPipeException in project jdk8u_jdk by JetBrains.

the class XRTextRenderer method drawGlyphList.

protected void drawGlyphList(SunGraphics2D sg2d, GlyphList gl) {
    if (gl.getNumGlyphs() == 0) {
        return;
    }
    try {
        SunToolkit.awtLock();
        XRSurfaceData x11sd;
        try {
            x11sd = (XRSurfaceData) sg2d.surfaceData;
        } catch (ClassCastException e) {
            throw new InvalidPipeException("wrong surface data type: " + sg2d.surfaceData);
        }
        x11sd.validateAsDestination(null, sg2d.getCompClip());
        x11sd.maskBuffer.validateCompositeState(sg2d.composite, sg2d.transform, sg2d.paint, sg2d);
        float advX = gl.getX();
        float advY = gl.getY();
        int oldPosX = 0, oldPosY = 0;
        if (gl.isSubPixPos()) {
            advX += 0.1666667f;
            advY += 0.1666667f;
        } else {
            advX += 0.5f;
            advY += 0.5f;
        }
        XRGlyphCacheEntry[] cachedGlyphs = glyphCache.cacheGlyphs(gl);
        boolean containsLCDGlyphs = false;
        int activeGlyphSet = cachedGlyphs[0].getGlyphSet();
        int eltIndex = -1;
        gl.startGlyphIteration();
        float[] positions = gl.getPositions();
        for (int i = 0; i < gl.getNumGlyphs(); i++) {
            gl.setGlyphIndex(i);
            XRGlyphCacheEntry cacheEntry = cachedGlyphs[i];
            eltList.getGlyphs().addInt(cacheEntry.getGlyphID());
            int glyphSet = cacheEntry.getGlyphSet();
            containsLCDGlyphs |= (glyphSet == glyphCache.lcdGlyphSet);
            int posX = 0, posY = 0;
            if (gl.usePositions() || cacheEntry.getXAdvance() != ((float) cacheEntry.getXOff()) || cacheEntry.getYAdvance() != ((float) cacheEntry.getYOff()) || glyphSet != activeGlyphSet || eltIndex < 0 || eltList.getCharCnt(eltIndex) == MAX_ELT_GLYPH_COUNT) {
                eltIndex = eltList.getNextIndex();
                eltList.setCharCnt(eltIndex, 1);
                activeGlyphSet = glyphSet;
                eltList.setGlyphSet(eltIndex, glyphSet);
                if (gl.usePositions()) {
                    // In this case advX only stores rounding errors
                    float x = positions[i * 2] + advX;
                    float y = positions[i * 2 + 1] + advY;
                    posX = (int) Math.floor(x);
                    posY = (int) Math.floor(y);
                    advX -= cacheEntry.getXOff();
                    advY -= cacheEntry.getYOff();
                } else {
                    /*
                         * Calculate next glyph's position in the case of
                         * relative positioning. In XRender we can only position
                         * glyphs using integer coordinates, therefor we sum all
                         * the advances up as float, and convert them to integer
                         * later. This way rounding-error can be corrected, and
                         * is required to be consistent with the software loops.
                         */
                    posX = (int) Math.floor(advX);
                    posY = (int) Math.floor(advY);
                    // Advance of ELT = difference between stored relative
                    // positioning information and required float.
                    advX += (cacheEntry.getXAdvance() - cacheEntry.getXOff());
                    advY += (cacheEntry.getYAdvance() - cacheEntry.getYOff());
                }
                // Offset of the current glyph is the difference
                // to the last glyph and this one
                eltList.setXOff(eltIndex, (posX - oldPosX));
                eltList.setYOff(eltIndex, (posY - oldPosY));
                oldPosX = posX;
                oldPosY = posY;
            } else {
                eltList.setCharCnt(eltIndex, eltList.getCharCnt(eltIndex) + 1);
            }
        }
        int maskFormat = containsLCDGlyphs ? XRUtils.PictStandardARGB32 : XRUtils.PictStandardA8;
        maskBuffer.compositeText(x11sd, (int) gl.getX(), (int) gl.getY(), 0, maskFormat, eltList);
        eltList.clear();
    } finally {
        SunToolkit.awtUnlock();
    }
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Aggregations

InvalidPipeException (sun.java2d.InvalidPipeException)21 SurfaceData (sun.java2d.SurfaceData)3 Color (java.awt.Color)2 SurfaceType (sun.java2d.loops.SurfaceType)2 Component (java.awt.Component)1 Composite (java.awt.Composite)1 Paint (java.awt.Paint)1 InvocationEvent (java.awt.event.InvocationEvent)1 AffineTransform (java.awt.geom.AffineTransform)1 Path2D (java.awt.geom.Path2D)1 ColorModel (java.awt.image.ColorModel)1 Win32GraphicsConfig (sun.awt.Win32GraphicsConfig)1 WComponentPeer (sun.awt.windows.WComponentPeer)1 SunGraphics2D (sun.java2d.SunGraphics2D)1 Region (sun.java2d.pipe.Region)1 AccelSurface (sun.java2d.pipe.hw.AccelSurface)1 GDIWindowSurfaceData (sun.java2d.windows.GDIWindowSurfaceData)1