use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.
the class Component method subtractAndApplyShapeBelowMe.
final void subtractAndApplyShapeBelowMe() {
checkTreeLock();
Container parent = getContainer();
if (parent != null && isShowing()) {
Region opaqueShape = getOpaqueShape();
// First, cut my siblings
parent.recursiveSubtractAndApplyShape(opaqueShape, getSiblingIndexBelow());
// Second, if my container is non-opaque, cut siblings of my container
Container parent2 = parent.getContainer();
while (!parent.isOpaque() && parent2 != null) {
parent2.recursiveSubtractAndApplyShape(opaqueShape, parent.getSiblingIndexBelow());
parent = parent2;
parent2 = parent.getContainer();
}
}
}
use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.
the class Component method calculateCurrentShape.
private Region calculateCurrentShape() {
checkTreeLock();
Region s = getNormalShape();
if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
mixingLog.fine("this = " + this + "; normalShape=" + s);
}
if (getContainer() != null) {
Component comp = this;
Container cont = comp.getContainer();
while (cont != null) {
for (int index = comp.getSiblingIndexAbove(); index != -1; --index) {
/* It is assumed that:
*
* getComponent(getContainer().getComponentZOrder(comp)) == comp
*
* The assumption has been made according to the current
* implementation of the Container class.
*/
Component c = cont.getComponent(index);
if (c.isLightweight() && c.isShowing()) {
s = s.getDifference(c.getOpaqueShape());
}
}
if (cont.isLightweight()) {
s = s.getIntersection(cont.getNormalShape());
} else {
break;
}
comp = cont;
cont = cont.getContainer();
}
}
if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
mixingLog.fine("currentShape=" + s);
}
return s;
}
use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.
the class Component method mixOnZOrderChanging.
void mixOnZOrderChanging(int oldZorder, int newZorder) {
synchronized (getTreeLock()) {
boolean becameHigher = newZorder < oldZorder;
Container parent = getContainer();
if (mixingLog.isLoggable(PlatformLogger.Level.FINE)) {
mixingLog.fine("this = " + this + "; oldZorder=" + oldZorder + "; newZorder=" + newZorder + "; parent=" + parent);
}
if (!isMixingNeeded()) {
return;
}
if (isLightweight()) {
if (becameHigher) {
if (parent != null && isShowing()) {
parent.recursiveSubtractAndApplyShape(getOpaqueShape(), getSiblingIndexBelow(), oldZorder);
}
} else {
if (parent != null) {
parent.recursiveApplyCurrentShape(oldZorder, newZorder);
}
}
} else {
if (becameHigher) {
applyCurrentShape();
} else {
if (parent != null) {
Region shape = getAppliedShape();
for (int index = oldZorder; index < newZorder; index++) {
Component c = parent.getComponent(index);
if (c.isLightweight() && c.isShowing()) {
shape = shape.getDifference(c.getOpaqueShape());
}
}
applyCompoundShape(shape);
}
}
}
}
}
use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.
the class XorCopyArgbToAny method getRegionOfInterest.
public static Region getRegionOfInterest(SurfaceData src, SurfaceData dst, Region clip, int srcx, int srcy, int dstx, int dsty, int w, int h) {
/*
* Intersect all of:
* - operation area (dstx, dsty, w, h)
* - destination bounds
* - (translated) src bounds
* - supplied clip (may be non-rectangular)
* Intersect the rectangular regions first since those are
* simpler operations.
*/
Region ret = Region.getInstanceXYWH(dstx, dsty, w, h);
ret = ret.getIntersection(dst.getBounds());
Rectangle r = src.getBounds();
// srcxy in src space maps to dstxy in dst space
r.translate(dstx - srcx, dsty - srcy);
ret = ret.getIntersection(r);
if (clip != null) {
// Intersect with clip last since it may be non-rectangular
ret = ret.getIntersection(clip);
}
return ret;
}
use of sun.java2d.pipe.Region in project jdk8u_jdk by JetBrains.
the class SunGraphics2D method constrain.
/**
* 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();
}
}
Aggregations