Search in sources :

Example 11 with InvalidPipeException

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

the class D3DRenderer method validateContextAA.

@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);
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Example 12 with InvalidPipeException

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

the class DrawImage method renderImageCopy.

// 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;
    // and try it once more
    while (true) {
        SurfaceData srcData = dstData.getSourceSurfaceData(img, SunGraphics2D.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;
            // 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 13 with InvalidPipeException

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

the class BufferedContext method validate.

/**
     * Validates the given parameters against the current state for this
     * context.  If this context is not current, it will be made current
     * for the given source and destination surfaces, and the viewport will
     * be updated.  Then each part of the context state (clip, composite,
     * etc.) is checked against the previous value.  If the value has changed
     * since the last call to validate(), it will be updated accordingly.
     *
     * Note that the SunGraphics2D parameter is only used for the purposes
     * of validating a (non-null) Paint parameter.  In all other cases it
     * is safe to pass a null SunGraphics2D and it will be ignored.
     *
     * Note: must be called while the RenderQueue lock is held.
     *
     * It's assumed that the type of surfaces has been checked by the Renderer
     *
     * @throws InvalidPipeException if either src or dest surface is not valid
     * or lost
     */
public void validate(AccelSurface srcData, AccelSurface dstData, Region clip, Composite comp, AffineTransform xform, Paint paint, SunGraphics2D sg2d, int flags) {
    // assert rq.lock.isHeldByCurrentThread();
    boolean updateClip = false;
    boolean updatePaint = false;
    if (!dstData.isValid() || dstData.isSurfaceLost() || srcData.isSurfaceLost()) {
        invalidateContext();
        throw new InvalidPipeException("bounds changed or surface lost");
    }
    if (paint instanceof Color) {
        // REMIND: not 30-bit friendly
        int newRGB = ((Color) paint).getRGB();
        if (isValidatedPaintJustAColor) {
            if (newRGB != validatedRGB) {
                validatedRGB = newRGB;
                updatePaint = true;
            }
        } else {
            validatedRGB = newRGB;
            updatePaint = true;
            isValidatedPaintJustAColor = true;
        }
    } else if (validPaintRef.get() != paint) {
        updatePaint = true;
        // this should be set when we are switching from paint to color
        // in which case this condition will be true
        isValidatedPaintJustAColor = false;
    }
    final AccelSurface validatedSrcData = validSrcDataRef.get();
    final AccelSurface validatedDstData = validDstDataRef.get();
    if ((currentContext != this) || (srcData != validatedSrcData) || (dstData != validatedDstData)) {
        if (dstData != validatedDstData) {
            // the clip is dependent on the destination surface, so we
            // need to update it if we have a new destination surface
            updateClip = true;
        }
        if (paint == null) {
            // make sure we update the color state (otherwise, it might
            // not be updated if this is the first time the context
            // is being validated)
            updatePaint = true;
        }
        // update the current source and destination surfaces
        setSurfaces(srcData, dstData);
        currentContext = this;
        validSrcDataRef = new WeakReference<>(srcData);
        validDstDataRef = new WeakReference<>(dstData);
    }
    // validate clip
    final Region validatedClip = validClipRef.get();
    if ((clip != validatedClip) || updateClip) {
        if (clip != null) {
            if (updateClip || validatedClip == null || !(validatedClip.isRectangular() && clip.isRectangular()) || ((clip.getLoX() != validatedClip.getLoX() || clip.getLoY() != validatedClip.getLoY() || clip.getHiX() != validatedClip.getHiX() || clip.getHiY() != validatedClip.getHiY()))) {
                setClip(clip);
            }
        } else {
            resetClip();
        }
        validClipRef = new WeakReference<>(clip);
    }
    // composite has not changed)
    if ((comp != validCompRef.get()) || (flags != validatedFlags)) {
        if (comp != null) {
            setComposite(comp, flags);
        } else {
            resetComposite();
        }
        // the paint state is dependent on the composite state, so make
        // sure we update the color below
        updatePaint = true;
        validCompRef = new WeakReference<>(comp);
        validatedFlags = flags;
    }
    // validate transform
    boolean txChanged = false;
    if (xform == null) {
        if (xformInUse) {
            resetTransform();
            xformInUse = false;
            txChanged = true;
        } else if (sg2d != null && !sg2d.transform.equals(transform)) {
            txChanged = true;
        }
        if (sg2d != null && txChanged) {
            transform = new AffineTransform(sg2d.transform);
        }
    } else {
        setTransform(xform);
        xformInUse = true;
        txChanged = true;
    }
    // non-Color paints may require paint revalidation
    if (!isValidatedPaintJustAColor && txChanged) {
        updatePaint = true;
    }
    // validate paint
    if (updatePaint) {
        if (paint != null) {
            BufferedPaints.setPaint(rq, sg2d, paint, flags);
        } else {
            BufferedPaints.resetPaint(rq);
        }
        validPaintRef = new WeakReference<>(paint);
    }
    // mark dstData dirty
    // REMIND: is this really needed now? we do it in SunGraphics2D..
    dstData.markDirty();
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException) AccelSurface(sun.java2d.pipe.hw.AccelSurface) Color(java.awt.Color) AffineTransform(java.awt.geom.AffineTransform) Paint(java.awt.Paint)

Example 14 with InvalidPipeException

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

the class OGLMaskFill method validateContext.

@Override
protected void validateContext(SunGraphics2D sg2d, Composite comp, int ctxflags) {
    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(), comp, null, sg2d.paint, sg2d, ctxflags);
}
Also used : InvalidPipeException(sun.java2d.InvalidPipeException)

Example 15 with InvalidPipeException

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

the class OGLRenderer method validateContextAA.

@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);
}
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