< prev index next >

openjfx9/modules/javafx.graphics/src/main/java/com/sun/marlin/RendererNoAA.java

Print this page

        

*** 23,55 **** * questions. */ package com.sun.marlin; import static com.sun.marlin.OffHeapArray.SIZE_INT; import jdk.internal.misc.Unsafe; ! public final class Renderer implements MarlinRenderer, MarlinConst { static final boolean DISABLE_RENDER = false; private static final int ALL_BUT_LSB = 0xfffffffe; private static final int ERR_STEP_MAX = 0x7fffffff; // = 2^31 - 1 private static final double POWER_2_TO_32 = 0x1.0p32; - // use float to make tosubpix methods faster (no int to float conversion) - static final float F_SUBPIXEL_POSITIONS_X - = (float) SUBPIXEL_POSITIONS_X; - static final float F_SUBPIXEL_POSITIONS_Y - = (float) SUBPIXEL_POSITIONS_Y; - static final int SUBPIXEL_MASK_X = SUBPIXEL_POSITIONS_X - 1; - static final int SUBPIXEL_MASK_Y = SUBPIXEL_POSITIONS_Y - 1; - // 2048 (pixelSize) pixels (height) x 8 subpixels = 64K ! static final int INITIAL_BUCKET_ARRAY ! = INITIAL_PIXEL_DIM * SUBPIXEL_POSITIONS_Y; // crossing capacity = edges count / 4 ~ 1024 static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 2; // common to all types of input path segments. --- 23,47 ---- * questions. */ package com.sun.marlin; + import com.sun.javafx.geom.Rectangle; import static com.sun.marlin.OffHeapArray.SIZE_INT; import jdk.internal.misc.Unsafe; ! public final class RendererNoAA implements MarlinRenderer, MarlinConst { static final boolean DISABLE_RENDER = false; private static final int ALL_BUT_LSB = 0xfffffffe; private static final int ERR_STEP_MAX = 0x7fffffff; // = 2^31 - 1 private static final double POWER_2_TO_32 = 0x1.0p32; // 2048 (pixelSize) pixels (height) x 8 subpixels = 64K ! static final int INITIAL_BUCKET_ARRAY = INITIAL_PIXEL_DIM; // crossing capacity = edges count / 4 ~ 1024 static final int INITIAL_CROSSING_COUNT = INITIAL_EDGES_COUNT >> 2; // common to all types of input path segments.
*** 66,79 **** 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 float CUB_DEC_ERR_SUBPIX ! = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels // cubic error in subpixels to increment step private static final float CUB_INC_ERR_SUBPIX ! = 0.4f * (NORM_SUBPIXELS / 8f); // 0.4 subpixel for typical 8x8 subpixels // cubic bind length to decrement step = 8 * error in subpixels // multiply by 8 = error scale factor: public static final float CUB_DEC_BND = 8f * CUB_DEC_ERR_SUBPIX; --- 58,71 ---- 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 float CUB_DEC_ERR_SUBPIX ! = 1f * (1f / 8f); // 1 pixel for typical 1x1 subpixels // cubic error in subpixels to increment step private static final float CUB_INC_ERR_SUBPIX ! = 0.4f * (1f / 8f); // 0.4 pixel for typical 1x1 subpixels // cubic bind length to decrement step = 8 * error in subpixels // multiply by 8 = error scale factor: public static final float CUB_DEC_BND = 8f * CUB_DEC_ERR_SUBPIX;
*** 97,107 **** private static final float CUB_INV_COUNT_3 = 1f / CUB_COUNT_3; // quad break into lines // quadratic error in subpixels private static final float QUAD_DEC_ERR_SUBPIX ! = 1f * (NORM_SUBPIXELS / 8f); // 1 subpixel for typical 8x8 subpixels // quadratic bind length to decrement step = 8 * error in subpixels public static final float QUAD_DEC_BND = 8f * QUAD_DEC_ERR_SUBPIX; --- 89,99 ---- private static final float CUB_INV_COUNT_3 = 1f / CUB_COUNT_3; // quad break into lines // quadratic error in subpixels private static final float QUAD_DEC_ERR_SUBPIX ! = 1f * (1f / 8f); // 1 pixel for typical 1x1 subpixels // quadratic bind length to decrement step = 8 * error in subpixels public static final float QUAD_DEC_BND = 8f * QUAD_DEC_ERR_SUBPIX;
*** 510,520 **** private int[] blkFlags; // blkFlags ref (clean) private final IntArrayCache.Reference blkFlags_ref; ! Renderer(final RendererContext rdrCtx) { this.rdrCtx = rdrCtx; this.edges = rdrCtx.newOffHeapArray(INITIAL_EDGES_CAPACITY); // 96K this.curve = rdrCtx.curve; --- 502,512 ---- private int[] blkFlags; // blkFlags ref (clean) private final IntArrayCache.Reference blkFlags_ref; ! RendererNoAA(final RendererContext rdrCtx) { this.rdrCtx = rdrCtx; this.edges = rdrCtx.newOffHeapArray(INITIAL_EDGES_CAPACITY); // 96K this.curve = rdrCtx.curve;
*** 541,563 **** blkFlags_ref = rdrCtx.newCleanIntArrayRef(INITIAL_ARRAY); // 1K = 1 tile line blkFlags = blkFlags_ref.initial; } ! public Renderer init(final int pix_boundsX, final int pix_boundsY, final int pix_boundsWidth, final int pix_boundsHeight, final int windingRule) { this.windingRule = windingRule; // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY ! this.boundsMinX = pix_boundsX << SUBPIXEL_LG_POSITIONS_X; ! this.boundsMaxX = ! (pix_boundsX + pix_boundsWidth) << SUBPIXEL_LG_POSITIONS_X; ! this.boundsMinY = pix_boundsY << SUBPIXEL_LG_POSITIONS_Y; ! this.boundsMaxY = ! (pix_boundsY + pix_boundsHeight) << SUBPIXEL_LG_POSITIONS_Y; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("boundsXY = [" + boundsMinX + " ... " + boundsMaxX + "[ [" + boundsMinY + " ... " + boundsMaxY + "["); --- 533,553 ---- blkFlags_ref = rdrCtx.newCleanIntArrayRef(INITIAL_ARRAY); // 1K = 1 tile line blkFlags = blkFlags_ref.initial; } ! public RendererNoAA init(final int pix_boundsX, final int pix_boundsY, final int pix_boundsWidth, final int pix_boundsHeight, final int windingRule) { this.windingRule = windingRule; // bounds as half-open intervals: minX <= x < maxX and minY <= y < maxY ! this.boundsMinX = pix_boundsX; ! this.boundsMaxX = pix_boundsX + pix_boundsWidth; ! this.boundsMinY = pix_boundsY; ! this.boundsMaxY = pix_boundsY + pix_boundsHeight; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("boundsXY = [" + boundsMinX + " ... " + boundsMaxX + "[ [" + boundsMinY + " ... " + boundsMaxY + "[");
*** 649,664 **** rdrCtx.stats.mon_rdr_endRendering.stop(); } } private static float tosubpixx(final float pix_x) { ! return F_SUBPIXEL_POSITIONS_X * pix_x; } private static float tosubpixy(final float pix_y) { // shift y by -0.5 for fast ceil(y - 0.5): ! return F_SUBPIXEL_POSITIONS_Y * pix_y - 0.5f; } @Override public void moveTo(float pix_x0, float pix_y0) { closePath(); --- 639,654 ---- rdrCtx.stats.mon_rdr_endRendering.stop(); } } private static float tosubpixx(final float pix_x) { ! return pix_x; } private static float tosubpixy(final float pix_y) { // shift y by -0.5 for fast ceil(y - 0.5): ! return pix_y - 0.5f; } @Override public void moveTo(float pix_x0, float pix_y0) { closePath();
*** 759,773 **** // unsafe I/O: final Unsafe _unsafe = OffHeapArray.UNSAFE; final long addr0 = _edges.address; long addr; - final int _SUBPIXEL_LG_POSITIONS_X = SUBPIXEL_LG_POSITIONS_X; - final int _SUBPIXEL_LG_POSITIONS_Y = SUBPIXEL_LG_POSITIONS_Y; - final int _SUBPIXEL_MASK_X = SUBPIXEL_MASK_X; - final int _SUBPIXEL_MASK_Y = SUBPIXEL_MASK_Y; - final int _SUBPIXEL_POSITIONS_X = SUBPIXEL_POSITIONS_X; final int _MIN_VALUE = Integer.MIN_VALUE; final int _MAX_VALUE = Integer.MAX_VALUE; // Now we iterate through the scanlines. We must tell emitRow the coord --- 749,758 ----
*** 789,799 **** int ptrLen = 0, newCount, ptrEnd; int bucketcount, i, j, ecur; int cross, lastCross; int x0, x1, tmp, sum, prev, curx, curxo, crorientation, err; - int pix_x, pix_xmaxm1, pix_xmax; int low, high, mid, prevNumCrossings; boolean useBinarySearch; final int[] _blkFlags = blkFlags; --- 774,783 ----
*** 1165,1210 **** if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices x1 -= bboxx0; // in the alpha array. ! pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; ! pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; ! if (pix_x == pix_xmaxm1) { ! // Start and end in same pixel ! tmp = (x1 - x0); // number of subpixels ! _alpha[pix_x ] += tmp; ! _alpha[pix_x + 1] -= tmp; ! ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_x + 1) >> _BLK_SIZE_LG] = 1; ! } ! } else { ! tmp = (x0 & _SUBPIXEL_MASK_X); ! _alpha[pix_x ] ! += (_SUBPIXEL_POSITIONS_X - tmp); ! _alpha[pix_x + 1] ! += tmp; ! ! pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; ! ! tmp = (x1 & _SUBPIXEL_MASK_X); ! _alpha[pix_xmax ] ! -= (_SUBPIXEL_POSITIONS_X - tmp); ! _alpha[pix_xmax + 1] ! -= tmp; ! ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[ pix_x >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_x + 1) >> _BLK_SIZE_LG] = 1; ! _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_xmax + 1) >> _BLK_SIZE_LG] = 1; ! } } } } sum += crorientation; --- 1149,1165 ---- if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices x1 -= bboxx0; // in the alpha array. ! _alpha[x0] += 1; ! _alpha[x1] -= 1; ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[x0 >> _BLK_SIZE_LG] = 1; ! _blkFlags[x1 >> _BLK_SIZE_LG] = 1; } } } sum += crorientation;
*** 1236,1281 **** if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices x1 -= bboxx0; // in the alpha array. ! pix_x = x0 >> _SUBPIXEL_LG_POSITIONS_X; ! pix_xmaxm1 = (x1 - 1) >> _SUBPIXEL_LG_POSITIONS_X; ! if (pix_x == pix_xmaxm1) { ! // Start and end in same pixel ! tmp = (x1 - x0); // number of subpixels ! _alpha[pix_x ] += tmp; ! _alpha[pix_x + 1] -= tmp; ! ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[pix_x >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_x + 1) >> _BLK_SIZE_LG] = 1; ! } ! } else { ! tmp = (x0 & _SUBPIXEL_MASK_X); ! _alpha[pix_x ] ! += (_SUBPIXEL_POSITIONS_X - tmp); ! _alpha[pix_x + 1] ! += tmp; ! ! pix_xmax = x1 >> _SUBPIXEL_LG_POSITIONS_X; ! ! tmp = (x1 & _SUBPIXEL_MASK_X); ! _alpha[pix_xmax ] ! -= (_SUBPIXEL_POSITIONS_X - tmp); ! _alpha[pix_xmax + 1] ! -= tmp; ! ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[ pix_x >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_x + 1) >> _BLK_SIZE_LG] = 1; ! _blkFlags[pix_xmax >> _BLK_SIZE_LG] = 1; ! _blkFlags[(pix_xmax + 1) >> _BLK_SIZE_LG] = 1; ! } } } prev = _MAX_VALUE; } --- 1191,1207 ---- if (x0 < x1) { x0 -= bboxx0; // turn x0, x1 from coords to indices x1 -= bboxx0; // in the alpha array. ! _alpha[x0] += 1; ! _alpha[x1] -= 1; ! if (useBlkFlags) { ! // flag used blocks: ! _blkFlags[x0 >> _BLK_SIZE_LG] = 1; ! _blkFlags[x1 >> _BLK_SIZE_LG] = 1; } } prev = _MAX_VALUE; }
*** 1293,1308 **** } // numCrossings > 0 // even if this last row had no crossings, alpha will be zeroed // from the last emitRow call. But this doesn't matter because // maxX < minX, so no row will be emitted to the AlphaConsumer. ! if ((y & _SUBPIXEL_MASK_Y) == _SUBPIXEL_MASK_Y) { ! lastY = y >> _SUBPIXEL_LG_POSITIONS_Y; // convert subpixel to pixel coordinate within boundaries: ! minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; ! maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[ --- 1219,1234 ---- } // numCrossings > 0 // even if this last row had no crossings, alpha will be zeroed // from the last emitRow call. But this doesn't matter because // maxX < minX, so no row will be emitted to the AlphaConsumer. ! if (true) { ! lastY = y; // convert subpixel to pixel coordinate within boundaries: ! minX = FloatMath.max(minX, bboxx0); ! maxX = FloatMath.min(maxX, bboxx1); if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[
*** 1341,1355 **** } } // scan line iterator // Emit final row y--; - y >>= _SUBPIXEL_LG_POSITIONS_Y; // convert subpixel to pixel coordinate within boundaries: ! minX = FloatMath.max(minX, bboxx0) >> _SUBPIXEL_LG_POSITIONS_X; ! maxX = FloatMath.min(maxX, bboxx1) >> _SUBPIXEL_LG_POSITIONS_X; if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[ --- 1267,1280 ---- } } // scan line iterator // Emit final row y--; // convert subpixel to pixel coordinate within boundaries: ! minX = FloatMath.max(minX, bboxx0); ! maxX = FloatMath.min(maxX, bboxx1); if (maxX >= minX) { // note: alpha array will be zeroed by copyAARow() // +1 because alpha [pix_minX; pix_maxX[ // fix range [x0; x1[
*** 1412,1428 **** return; } // half open intervals // inclusive: ! final int pminX = spminX >> SUBPIXEL_LG_POSITIONS_X; // exclusive: ! final int pmaxX = (spmaxX + SUBPIXEL_MASK_X) >> SUBPIXEL_LG_POSITIONS_X; // inclusive: ! final int pminY = spminY >> SUBPIXEL_LG_POSITIONS_Y; // exclusive: ! final int pmaxY = (spmaxY + SUBPIXEL_MASK_Y) >> SUBPIXEL_LG_POSITIONS_Y; // store BBox to answer ptg.getBBox(): initConsumer(pminX, pminY, pmaxX, pmaxY); // Heuristics for using block flags: --- 1337,1353 ---- return; } // half open intervals // inclusive: ! final int pminX = spminX; // exclusive: ! final int pmaxX = spmaxX + 1; // +1 to ensure proper upper bound // inclusive: ! final int pminY = spminY; // exclusive: ! final int pmaxY = spmaxY + 1; // +1 to ensure proper upper bound // store BBox to answer ptg.getBBox(): initConsumer(pminX, pminY, pmaxX, pmaxY); // Heuristics for using block flags:
*** 1442,1458 **** // memorize the rendering bounding box: /* note: bbox_spminX and bbox_spmaxX must be pixel boundaries to have correct coverage computation */ // inclusive: ! bbox_spminX = pminX << SUBPIXEL_LG_POSITIONS_X; // exclusive: ! bbox_spmaxX = pmaxX << SUBPIXEL_LG_POSITIONS_X; // inclusive: ! bbox_spminY = spminY; // exclusive: ! bbox_spmaxY = FloatMath.min(spmaxY + 1, pmaxY << SUBPIXEL_LG_POSITIONS_Y); if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("pXY = [" + pminX + " ... " + pmaxX + "[ [" + pminY + " ... " + pmaxY + "["); MarlinUtils.logInfo("bbox_spXY = [" + bbox_spminX + " ... " --- 1367,1383 ---- // memorize the rendering bounding box: /* note: bbox_spminX and bbox_spmaxX must be pixel boundaries to have correct coverage computation */ // inclusive: ! bbox_spminX = pminX; // exclusive: ! bbox_spmaxX = pmaxX; // inclusive: ! bbox_spminY = pminY; // exclusive: ! bbox_spmaxY = pmaxY; if (DO_LOG_BOUNDS) { MarlinUtils.logInfo("pXY = [" + pminX + " ... " + pmaxX + "[ [" + pminY + " ... " + pmaxY + "["); MarlinUtils.logInfo("bbox_spXY = [" + bbox_spminX + " ... "
*** 1501,1511 **** } private int bbox_spminX, bbox_spmaxX, bbox_spminY, bbox_spmaxY; public void produceAlphas(final MarlinAlphaConsumer ac) { ! ac.setMaxAlpha(MAX_AA_ALPHA); if (enableBlkFlags && !ac.supportBlockFlags()) { // consumer does not support block flag optimization: enableBlkFlags = false; prevUseBlkFlags = false; --- 1426,1436 ---- } private int bbox_spminX, bbox_spmaxX, bbox_spminY, bbox_spmaxY; public void produceAlphas(final MarlinAlphaConsumer ac) { ! ac.setMaxAlpha(1); if (enableBlkFlags && !ac.supportBlockFlags()) { // consumer does not support block flag optimization: enableBlkFlags = false; prevUseBlkFlags = false;
< prev index next >