< prev index next >

modules/javafx.graphics/src/main/java/com/sun/marlin/DRendererNoAA.java

Print this page

        

*** 57,105 **** public static final int SIZEOF_EDGE_BYTES = (int)(OFF_YMAX + SIZE_INT); // curve break into lines // cubic error in subpixels to decrement step private static final double CUB_DEC_ERR_SUBPIX ! = 1d * (1d / 8d); // 1 pixel // cubic error in subpixels to increment step private static final double CUB_INC_ERR_SUBPIX ! = 0.4d * (1d / 8d); // 0.4 pixel // bad paths (59294/100000 == 59,29%, 94335 bad pixels (avg = 1,59), 3966 warnings (avg = 0,07) // cubic bind length to decrement step public static final double CUB_DEC_BND ! = 8d * CUB_DEC_ERR_SUBPIX; // cubic bind length to increment step public static final double CUB_INC_BND ! = 8d * CUB_INC_ERR_SUBPIX; // cubic countlg public static final int CUB_COUNT_LG = 2; // cubic count = 2^countlg private static final int CUB_COUNT = 1 << CUB_COUNT_LG; // cubic count^2 = 4^countlg private static final int CUB_COUNT_2 = 1 << (2 * CUB_COUNT_LG); // cubic count^3 = 8^countlg private static final int CUB_COUNT_3 = 1 << (3 * CUB_COUNT_LG); // cubic dt = 1 / count ! private static final double CUB_INV_COUNT = 1d / CUB_COUNT; // cubic dt^2 = 1 / count^2 = 1 / 4^countlg ! private static final double CUB_INV_COUNT_2 = 1d / CUB_COUNT_2; // cubic dt^3 = 1 / count^3 = 1 / 8^countlg ! private static final double CUB_INV_COUNT_3 = 1d / CUB_COUNT_3; // quad break into lines // quadratic error in subpixels private static final double QUAD_DEC_ERR_SUBPIX ! = 0.5d * (1d / 8d); // 0.5 pixel // bad paths (62916/100000 == 62,92%, 103818 bad pixels (avg = 1,65), 6514 warnings (avg = 0,10) // quadratic bind length to decrement step public static final double QUAD_DEC_BND ! = 8d * QUAD_DEC_ERR_SUBPIX; ////////////////////////////////////////////////////////////////////////////// // SCAN LINE ////////////////////////////////////////////////////////////////////////////// // crossings ie subpixel edge x coordinates --- 57,105 ---- public static final int SIZEOF_EDGE_BYTES = (int)(OFF_YMAX + SIZE_INT); // curve break into lines // cubic error in subpixels to decrement step private static final double CUB_DEC_ERR_SUBPIX ! = 1.0d * (1.0d / 8.0d); // 1 pixel // cubic error in subpixels to increment step private static final double CUB_INC_ERR_SUBPIX ! = 0.4d * (1.0d / 8.0d); // 0.4 pixel // bad paths (59294/100000 == 59,29%, 94335 bad pixels (avg = 1,59), 3966 warnings (avg = 0,07) // cubic bind length to decrement step public static final double CUB_DEC_BND ! = 8.0d * CUB_DEC_ERR_SUBPIX; // cubic bind length to increment step public static final double CUB_INC_BND ! = 8.0d * CUB_INC_ERR_SUBPIX; // cubic countlg public static final int CUB_COUNT_LG = 2; // cubic count = 2^countlg private static final int CUB_COUNT = 1 << CUB_COUNT_LG; // cubic count^2 = 4^countlg private static final int CUB_COUNT_2 = 1 << (2 * CUB_COUNT_LG); // cubic count^3 = 8^countlg private static final int CUB_COUNT_3 = 1 << (3 * CUB_COUNT_LG); // cubic dt = 1 / count ! private static final double CUB_INV_COUNT = 1.0d / CUB_COUNT; // cubic dt^2 = 1 / count^2 = 1 / 4^countlg ! private static final double CUB_INV_COUNT_2 = 1.0d / CUB_COUNT_2; // cubic dt^3 = 1 / count^3 = 1 / 8^countlg ! private static final double CUB_INV_COUNT_3 = 1.0d / CUB_COUNT_3; // quad break into lines // quadratic error in subpixels private static final double QUAD_DEC_ERR_SUBPIX ! = 0.5d * (1.0d / 8.0d); // 0.5 pixel // bad paths (62916/100000 == 62,92%, 103818 bad pixels (avg = 1,65), 6514 warnings (avg = 0,10) // quadratic bind length to decrement step public static final double QUAD_DEC_BND ! = 8.0d * QUAD_DEC_ERR_SUBPIX; ////////////////////////////////////////////////////////////////////////////// // SCAN LINE ////////////////////////////////////////////////////////////////////////////// // crossings ie subpixel edge x coordinates
*** 166,186 **** final double _DEC_BND = QUAD_DEC_BND; while (maxDD >= _DEC_BND) { // divide step by half: ! maxDD /= 4d; // error divided by 2^2 = 4 count <<= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_quadBreak_dec.add(count); } } int nL = 0; // line count if (count > 1) { ! final double icount = 1d / count; // dt final double icount2 = icount * icount; // dt^2 final double ddx = c.dbx * icount2; final double ddy = c.dby * icount2; double dx = c.bx * icount2 + c.cx * icount; --- 166,186 ---- final double _DEC_BND = QUAD_DEC_BND; while (maxDD >= _DEC_BND) { // divide step by half: ! maxDD /= 4.0d; // error divided by 2^2 = 4 count <<= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_quadBreak_dec.add(count); } } int nL = 0; // line count if (count > 1) { ! final double icount = 1.0d / count; // dt final double icount2 = icount * icount; // dt^2 final double ddx = c.dbx * icount2; final double ddy = c.dby * icount2; double dx = c.bx * icount2 + c.cx * icount;
*** 223,234 **** final double icount3 = CUB_INV_COUNT_3; // dt^3 // the dx and dy refer to forward differencing variables, not the last // coefficients of the "points" polynomial double dddx, dddy, ddx, ddy, dx, dy; ! dddx = 2d * c.dax * icount3; ! dddy = 2d * c.day * icount3; ddx = dddx + c.dbx * icount2; ddy = dddy + c.dby * icount2; dx = c.ax * icount3 + c.bx * icount2 + c.cx * icount; dy = c.ay * icount3 + c.by * icount2 + c.cy * icount; --- 223,234 ---- final double icount3 = CUB_INV_COUNT_3; // dt^3 // the dx and dy refer to forward differencing variables, not the last // coefficients of the "points" polynomial double dddx, dddy, ddx, ddy, dx, dy; ! dddx = 2.0d * c.dax * icount3; ! dddy = 2.0d * c.day * icount3; ddx = dddx + c.dbx * icount2; ddy = dddy + c.dby * icount2; dx = c.ax * icount3 + c.bx * icount2 + c.cx * icount; dy = c.ay * icount3 + c.by * icount2 + c.cy * icount;
*** 240,276 **** final double _INC_BND = CUB_INC_BND; while (count > 0) { // divide step by half: while (Math.abs(ddx) + Math.abs(ddy) >= _DEC_BND) { ! dddx /= 8d; ! dddy /= 8d; ! ddx = ddx/4d - dddx; ! ddy = ddy/4d - dddy; ! dx = (dx - ddx) / 2d; ! dy = (dy - ddy) / 2d; count <<= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_curveBreak_dec.add(count); } } // double step: - // TODO: why use first derivative dX|Y instead of second ddX|Y ? - // both scale changes should use speed or acceleration to have the same metric. - // can only do this on even "count" values, because we must divide count by 2 while (count % 2 == 0 && Math.abs(dx) + Math.abs(dy) <= _INC_BND) { ! dx = 2d * dx + ddx; ! dy = 2d * dy + ddy; ! ddx = 4d * (ddx + dddx); ! ddy = 4d * (ddy + dddy); ! dddx *= 8d; ! dddy *= 8d; count >>= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_curveBreak_inc.add(count); } --- 240,273 ---- final double _INC_BND = CUB_INC_BND; while (count > 0) { // divide step by half: while (Math.abs(ddx) + Math.abs(ddy) >= _DEC_BND) { ! dddx /= 8.0d; ! dddy /= 8.0d; ! ddx = ddx / 4.0d - dddx; ! ddy = ddy / 4.0d - dddy; ! dx = (dx - ddx) / 2.0d; ! dy = (dy - ddy) / 2.0d; count <<= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_curveBreak_dec.add(count); } } // double step: // can only do this on even "count" values, because we must divide count by 2 while (count % 2 == 0 && Math.abs(dx) + Math.abs(dy) <= _INC_BND) { ! dx = 2.0d * dx + ddx; ! dy = 2.0d * dy + ddy; ! ddx = 4.0d * (ddx + dddx); ! ddy = 4.0d * (ddy + dddy); ! dddx *= 8.0d; ! dddy *= 8.0d; count >>= 1; if (DO_STATS) { rdrCtx.stats.stat_rdr_curveBreak_inc.add(count); }
*** 338,363 **** rdrCtx.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; } if (x2 > edgeMaxX) { edgeMaxX = x2; --- 335,357 ---- rdrCtx.stats.stat_rdr_addLine_skip.add(1); } return; } ! // edge min/max X/Y are in subpixel space (half-open interval): // 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; } ! final double slope = (x1 - x2) / (y1 - y2); ! if (slope >= 0.0d) { // <==> x1 < x2 if (x1 < edgeMinX) { edgeMinX = x1; } if (x2 > edgeMaxX) { edgeMaxX = x2;
*** 418,428 **** // long x1_fixed = x1_intercept * 2^32; (fixed point 32.32 format) // curx = next VPC = fixed_floor(x1_fixed - 2^31 + 2^32 - 1) // = fixed_floor(x1_fixed + 2^31 - 1) // = fixed_floor(x1_fixed + 0x7FFFFFFF) // and error = fixed_fract(x1_fixed + 0x7FFFFFFF) ! final double x1_intercept = x1d + (firstCrossing - y1d) * slope; // inlined scalb(x1_intercept, 32): final long x1_fixed_biased = ((long) (POWER_2_TO_32 * x1_intercept)) + 0x7FFFFFFFL; // curx: --- 412,422 ---- // long x1_fixed = x1_intercept * 2^32; (fixed point 32.32 format) // curx = next VPC = fixed_floor(x1_fixed - 2^31 + 2^32 - 1) // = fixed_floor(x1_fixed + 2^31 - 1) // = fixed_floor(x1_fixed + 0x7FFFFFFF) // and error = fixed_fract(x1_fixed + 0x7FFFFFFF) ! final double x1_intercept = x1 + (firstCrossing - y1) * slope; // inlined scalb(x1_intercept, 32): final long x1_fixed_biased = ((long) (POWER_2_TO_32 * x1_intercept)) + 0x7FFFFFFFL; // curx:
*** 451,461 **** final int bucketIdx = firstCrossing - _boundsMinY; // pointer from bucket _unsafe.putInt(addr, _edgeBuckets[bucketIdx]); addr += SIZE_INT; ! // y max (inclusive) _unsafe.putInt(addr, lastCrossing); // Update buckets: // directly the edge struct "pointer" _edgeBuckets[bucketIdx] = edgePtr; --- 445,455 ---- final int bucketIdx = firstCrossing - _boundsMinY; // pointer from bucket _unsafe.putInt(addr, _edgeBuckets[bucketIdx]); addr += SIZE_INT; ! // y max (exclusive) _unsafe.putInt(addr, lastCrossing); // Update buckets: // directly the edge struct "pointer" _edgeBuckets[bucketIdx] = edgePtr;
< prev index next >