< prev index next >
src/java.desktop/share/classes/sun/java2d/marlin/Renderer.java
Print this page
*** 146,157 ****
private final int[] aux_edgePtrs_initial = new int[INITIAL_SMALL_ARRAY + 1]; // 4K
//////////////////////////////////////////////////////////////////////////////
// EDGE LIST
//////////////////////////////////////////////////////////////////////////////
! private float edgeMinY = Float.POSITIVE_INFINITY;
! private float edgeMaxY = Float.NEGATIVE_INFINITY;
private float edgeMinX = Float.POSITIVE_INFINITY;
private float edgeMaxX = Float.NEGATIVE_INFINITY;
// edges [floats|ints] stored in off-heap memory
private final OffHeapArray edges;
--- 146,157 ----
private final int[] aux_edgePtrs_initial = new int[INITIAL_SMALL_ARRAY + 1]; // 4K
//////////////////////////////////////////////////////////////////////////////
// EDGE LIST
//////////////////////////////////////////////////////////////////////////////
! private int edgeMinY = Integer.MAX_VALUE;
! private int edgeMaxY = Integer.MIN_VALUE;
private float edgeMinX = Float.POSITIVE_INFINITY;
private float edgeMaxX = Float.NEGATIVE_INFINITY;
// edges [floats|ints] stored in off-heap memory
private final OffHeapArray edges;
*** 355,376 ****
if (doStats) {
RendererContext.stats.stat_rdr_addLine_skip.add(1);
}
return;
}
! // edge min/max X/Y are in subpixel space (inclusive)
! if (y1 < edgeMinY) {
! edgeMinY = y1;
}
! if (y2 > edgeMaxY) {
! edgeMaxY = y2;
}
// Use double-precision for improved accuracy:
final double x1d = x1;
final double y1d = y1;
! final double slope = (x2 - x1d) / (y2 - y1d);
if (slope >= 0.0) { // <==> x1 < x2
if (x1 < edgeMinX) {
edgeMinX = x1;
}
--- 355,379 ----
if (doStats) {
RendererContext.stats.stat_rdr_addLine_skip.add(1);
}
return;
}
!
! // edge min/max X/Y are in subpixel space (inclusive) within bounds:
! // note: Use integer crossings to ensure consistent range within
! // edgeBuckets / edgeBucketCounts arrays in case of NaN values (int = 0)
! if (firstCrossing < edgeMinY) {
! edgeMinY = firstCrossing;
}
! if (lastCrossing > edgeMaxY) {
! edgeMaxY = lastCrossing;
}
// Use double-precision for improved accuracy:
final double x1d = x1;
final double y1d = y1;
! final double slope = (x1d - x2) / (y1d - y2);
if (slope >= 0.0) { // <==> x1 < x2
if (x1 < edgeMinX) {
edgeMinX = x1;
}
*** 502,512 ****
// Current drawing position, i.e., final point of last segment
private float x0, y0;
// Position of most recent 'moveTo' command
! private float pix_sx0, pix_sy0;
// per-thread renderer context
final RendererContext rdrCtx;
// dirty curve
private final Curve curve;
--- 505,515 ----
// Current drawing position, i.e., final point of last segment
private float x0, y0;
// Position of most recent 'moveTo' command
! private float sx0, sy0;
// per-thread renderer context
final RendererContext rdrCtx;
// dirty curve
private final Curve curve;
*** 568,579 ****
}
edgeBuckets = rdrCtx.getIntArray(edgeBucketsLength);
edgeBucketCounts = rdrCtx.getIntArray(edgeBucketsLength);
}
! edgeMinY = Float.POSITIVE_INFINITY;
! edgeMaxY = Float.NEGATIVE_INFINITY;
edgeMinX = Float.POSITIVE_INFINITY;
edgeMaxX = Float.NEGATIVE_INFINITY;
// reset used mark:
edgeCount = 0;
--- 571,582 ----
}
edgeBuckets = rdrCtx.getIntArray(edgeBucketsLength);
edgeBucketCounts = rdrCtx.getIntArray(edgeBucketsLength);
}
! edgeMinY = Integer.MAX_VALUE;
! edgeMaxY = Integer.MIN_VALUE;
edgeMinX = Float.POSITIVE_INFINITY;
edgeMaxX = Float.NEGATIVE_INFINITY;
// reset used mark:
edgeCount = 0;
*** 626,636 ****
if (blkFlags != blkFlags_initial) {
rdrCtx.putIntArray(blkFlags, 0, 0); // already zero filled
blkFlags = blkFlags_initial;
}
! if (edgeMinY != Float.POSITIVE_INFINITY) {
// if context is maked as DIRTY:
if (rdrCtx.dirty) {
// may happen if an exception if thrown in the pipeline processing:
// clear completely buckets arrays:
buckets_minY = 0;
--- 629,639 ----
if (blkFlags != blkFlags_initial) {
rdrCtx.putIntArray(blkFlags, 0, 0); // already zero filled
blkFlags = blkFlags_initial;
}
! if (edgeMinY != Integer.MAX_VALUE) {
// if context is maked as DIRTY:
if (rdrCtx.dirty) {
// may happen if an exception if thrown in the pipeline processing:
// clear completely buckets arrays:
buckets_minY = 0;
*** 686,705 ****
}
@Override
public void moveTo(float pix_x0, float pix_y0) {
closePath();
! this.pix_sx0 = pix_x0;
! this.pix_sy0 = pix_y0;
! this.y0 = tosubpixy(pix_y0);
! this.x0 = tosubpixx(pix_x0);
}
@Override
public void lineTo(float pix_x1, float pix_y1) {
! float x1 = tosubpixx(pix_x1);
! float y1 = tosubpixy(pix_y1);
addLine(x0, y0, x1, y1);
x0 = x1;
y0 = y1;
}
--- 689,710 ----
}
@Override
public void moveTo(float pix_x0, float pix_y0) {
closePath();
! final float sx = tosubpixx(pix_x0);
! final float sy = tosubpixy(pix_y0);
! this.sx0 = sx;
! this.sy0 = sy;
! this.x0 = sx;
! this.y0 = sy;
}
@Override
public void lineTo(float pix_x1, float pix_y1) {
! final float x1 = tosubpixx(pix_x1);
! final float y1 = tosubpixy(pix_y1);
addLine(x0, y0, x1, y1);
x0 = x1;
y0 = y1;
}
*** 727,738 ****
y0 = ye;
}
@Override
public void closePath() {
! // lineTo expects its input in pixel coordinates.
! lineTo(pix_sx0, pix_sy0);
}
@Override
public void pathDone() {
closePath();
--- 732,744 ----
y0 = ye;
}
@Override
public void closePath() {
! addLine(x0, y0, sx0, sy0);
! x0 = sx0;
! y0 = sy0;
}
@Override
public void pathDone() {
closePath();
*** 1394,1419 ****
boolean endRendering() {
if (doMonitors) {
RendererContext.stats.mon_rdr_endRendering.start();
}
! if (edgeMinY == Float.POSITIVE_INFINITY) {
return false; // undefined edges bounds
}
final int _boundsMinY = boundsMinY;
final int _boundsMaxY = boundsMaxY;
// bounds as inclusive intervals
final int spminX = FloatMath.max(FloatMath.ceil_int(edgeMinX - 0.5f), boundsMinX);
final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5f), boundsMaxX - 1);
! // y1 (and y2) are already biased by -0.5 in tosubpixy():
! final int spminY = FloatMath.max(FloatMath.ceil_int(edgeMinY), _boundsMinY);
! int maxY = FloatMath.ceil_int(edgeMaxY);
!
final int spmaxY;
if (maxY <= _boundsMaxY - 1) {
spmaxY = maxY;
} else {
spmaxY = _boundsMaxY - 1;
--- 1400,1424 ----
boolean endRendering() {
if (doMonitors) {
RendererContext.stats.mon_rdr_endRendering.start();
}
! if (edgeMinY == Integer.MAX_VALUE) {
return false; // undefined edges bounds
}
final int _boundsMinY = boundsMinY;
final int _boundsMaxY = boundsMaxY;
// bounds as inclusive intervals
final int spminX = FloatMath.max(FloatMath.ceil_int(edgeMinX - 0.5f), boundsMinX);
final int spmaxX = FloatMath.min(FloatMath.ceil_int(edgeMaxX - 0.5f), boundsMaxX - 1);
! // edge Min/Max Y are already rounded to subpixels within bounds:
! final int spminY = edgeMinY;
final int spmaxY;
+ int maxY = edgeMaxY;
if (maxY <= _boundsMaxY - 1) {
spmaxY = maxY;
} else {
spmaxY = _boundsMaxY - 1;
< prev index next >