Java Code Examples for sun.java2d.pipe.Region#getTranslatedRegion()

The following examples show how to use sun.java2d.pipe.Region#getTranslatedRegion() . 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 check out the related API usage on the sidebar.
Example 1
Source File: LWContainerPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes bounds of children above specific child from the region. If above
 * is null removes all bounds of children.
 */
final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
    boolean aboveFound = above == null;
    for (final LWComponentPeer<?, ?> child : getChildren()) {
        if (!aboveFound && child == above) {
            aboveFound = true;
            continue;
        }
        if (aboveFound) {
            if(child.isVisible()){
                final Rectangle cb = child.getBounds();
                final Region cr = child.getRegion();
                final Region tr = cr.getTranslatedRegion(cb.x, cb.y);
                r = r.getDifference(tr.getIntersection(getContentSize()));
            }
        }
    }
    return r;
}
 
Example 2
Source File: LWContainerPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes bounds of children above specific child from the region. If above
 * is null removes all bounds of children.
 */
final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
    boolean aboveFound = above == null;
    for (final LWComponentPeer<?, ?> child : getChildren()) {
        if (!aboveFound && child == above) {
            aboveFound = true;
            continue;
        }
        if (aboveFound) {
            if(child.isVisible()){
                final Rectangle cb = child.getBounds();
                final Region cr = child.getRegion();
                final Region tr = cr.getTranslatedRegion(cb.x, cb.y);
                r = r.getDifference(tr.getIntersection(getContentSize()));
            }
        }
    }
    return r;
}
 
Example 3
Source File: LWContainerPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes bounds of children above specific child from the region. If above
 * is null removes all bounds of children.
 */
final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
    boolean aboveFound = above == null;
    for (final LWComponentPeer<?, ?> child : getChildren()) {
        if (!aboveFound && child == above) {
            aboveFound = true;
            continue;
        }
        if (aboveFound) {
            if(child.isVisible()){
                final Rectangle cb = child.getBounds();
                final Region cr = child.getRegion();
                final Region tr = cr.getTranslatedRegion(cb.x, cb.y);
                r = r.getDifference(tr.getIntersection(getContentSize()));
            }
        }
    }
    return r;
}
 
Example 4
Source File: LWContainerPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes bounds of children above specific child from the region. If above
 * is null removes all bounds of children.
 */
final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
    boolean aboveFound = above == null;
    for (final LWComponentPeer<?, ?> child : getChildren()) {
        if (!aboveFound && child == above) {
            aboveFound = true;
            continue;
        }
        if (aboveFound) {
            if(child.isVisible()){
                final Rectangle cb = child.getBounds();
                final Region cr = child.getRegion();
                final Region tr = cr.getTranslatedRegion(cb.x, cb.y);
                r = r.getDifference(tr.getIntersection(getContentSize()));
            }
        }
    }
    return r;
}
 
Example 5
Source File: LWContainerPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Removes bounds of children above specific child from the region. If above
 * is null removes all bounds of children.
 */
final Region cutChildren(Region r, final LWComponentPeer<?, ?> above) {
    boolean aboveFound = above == null;
    for (final LWComponentPeer<?, ?> child : getChildren()) {
        if (!aboveFound && child == above) {
            aboveFound = true;
            continue;
        }
        if (aboveFound) {
            if(child.isVisible()){
                final Rectangle cb = child.getBounds();
                final Region cr = child.getRegion();
                final Region tr = cr.getTranslatedRegion(cb.x, cb.y);
                r = r.getDifference(tr.getIntersection(getContentSize()));
            }
        }
    }
    return r;
}
 
Example 6
Source File: SunGraphics2D.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 7
Source File: SunGraphics2D.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 8
Source File: SunGraphics2D.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 9
Source File: LWComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 10
Source File: SunGraphics2D.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 11
Source File: LWComponentPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 12
Source File: SunGraphics2D.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 13
Source File: LWComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 14
Source File: LWComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 15
Source File: SunGraphics2D.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 16
Source File: SunGraphics2D.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 17
Source File: LWComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 18
Source File: SunGraphics2D.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constrain rendering for lightweight objects.
 */
public void constrain(int x, int y, int w, int h, Region region) {
    if ((x | y) != 0) {
        translate(x, y);
    }
    if (transformState > TRANSFORM_TRANSLATESCALE) {
        clipRect(0, 0, w, h);
        return;
    }
    // changes parameters according to the current scale and translate.
    final double scaleX = transform.getScaleX();
    final double scaleY = transform.getScaleY();
    x = constrainX = (int) transform.getTranslateX();
    y = constrainY = (int) transform.getTranslateY();
    w = Region.dimAdd(x, Region.clipScale(w, scaleX));
    h = Region.dimAdd(y, Region.clipScale(h, scaleY));

    Region c = constrainClip;
    if (c == null) {
        c = Region.getInstanceXYXY(x, y, w, h);
    } else {
        c = c.getIntersectionXYXY(x, y, w, h);
    }
    if (region != null) {
        region = region.getScaledRegion(scaleX, scaleY);
        region = region.getTranslatedRegion(x, y);
        c = c.getIntersection(region);
    }

    if (c == constrainClip) {
        // Common case to ignore
        return;
    }

    constrainClip = c;
    if (!devClip.isInsideQuickCheck(c)) {
        devClip = devClip.getIntersection(c);
        validateCompClip();
    }
}
 
Example 19
Source File: LWComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static final Region computeVisibleRect(final LWComponentPeer<?, ?> c,
                                       Region region) {
    final LWContainerPeer<?, ?> p = c.getContainerPeer();
    if (p != null) {
        final Rectangle r = c.getBounds();
        region = region.getTranslatedRegion(r.x, r.y);
        region = region.getIntersection(p.getRegion());
        region = region.getIntersection(p.getContentSize());
        region = p.cutChildren(region, c);
        region = computeVisibleRect(p, region);
        region = region.getTranslatedRegion(-r.x, -r.y);
    }
    return region;
}
 
Example 20
Source File: OGLBlitLoops.java    From Bytecoder with Apache License 2.0 4 votes vote down vote up
public synchronized void Blit(SurfaceData src, SurfaceData dst,
                              Composite comp, Region clip,
                              int sx, int sy, int dx, int dy,
                              int w, int h)
{
    if (convertsrc != null) {
        SurfaceData cachedSrc = null;
        if (srcTmp != null) {
            // use cached intermediate surface, if available
            cachedSrc = srcTmp.get();
        }
        // convert source to IntArgbPre
        src = convertFrom(convertsrc, src, sx, sy, w, h, cachedSrc,
                          BufferedImage.TYPE_INT_ARGB_PRE);
        if (src != cachedSrc) {
            // cache the intermediate surface
            srcTmp = new WeakReference<>(src);
        }
    }

    SurfaceData cachedDst = null;

    if (dstTmp != null) {
        // use cached intermediate surface, if available
        cachedDst = dstTmp.get();
    }

    // convert destination to IntArgbPre
    SurfaceData dstBuffer = convertFrom(convertdst, dst, dx, dy, w, h,
                      cachedDst, BufferedImage.TYPE_INT_ARGB_PRE);
    Region bufferClip =
            clip == null ? null : clip.getTranslatedRegion(-dx, -dy);

    Blit performop = Blit.getFromCache(src.getSurfaceType(),
            CompositeType.Any, dstBuffer.getSurfaceType());
    performop.Blit(src, dstBuffer, comp, bufferClip, sx, sy, 0, 0, w, h);

    if (dstBuffer != cachedDst) {
        // cache the intermediate surface
        dstTmp = new WeakReference<>(dstBuffer);
    }
    // now blit the buffer back to the destination
    convertresult.Blit(dstBuffer, dst, AlphaComposite.Src, clip, 0, 0, dx,
                       dy, w, h);
}