1 /* |
1 /* |
2 * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
178 * clean up before reusing this instance |
178 * clean up before reusing this instance |
179 */ |
179 */ |
180 void dispose() { |
180 void dispose() { |
181 reverse.dispose(); |
181 reverse.dispose(); |
182 |
182 |
183 if (doCleanDirty) { |
183 if (DO_CLEAN_DIRTY) { |
184 // Force zero-fill dirty arrays: |
184 // Force zero-fill dirty arrays: |
185 Arrays.fill(offset0, 0f); |
185 Arrays.fill(offset0, 0f); |
186 Arrays.fill(offset1, 0f); |
186 Arrays.fill(offset1, 0f); |
187 Arrays.fill(offset2, 0f); |
187 Arrays.fill(offset2, 0f); |
188 Arrays.fill(miter, 0f); |
188 Arrays.fill(miter, 0f); |
224 private void drawRoundJoin(float x, float y, |
224 private void drawRoundJoin(float x, float y, |
225 float omx, float omy, float mx, float my, |
225 float omx, float omy, float mx, float my, |
226 boolean rev, |
226 boolean rev, |
227 float threshold) |
227 float threshold) |
228 { |
228 { |
229 if ((omx == 0 && omy == 0) || (mx == 0 && my == 0)) { |
229 if ((omx == 0f && omy == 0f) || (mx == 0f && my == 0f)) { |
230 return; |
230 return; |
231 } |
231 } |
232 |
232 |
233 float domx = omx - mx; |
233 float domx = omx - mx; |
234 float domy = omy - my; |
234 float domy = omy - my; |
336 |
336 |
337 emitCurveTo(x1, y1, x2, y2, x3, y3, x4, y4, rev); |
337 emitCurveTo(x1, y1, x2, y2, x3, y3, x4, y4, rev); |
338 } |
338 } |
339 |
339 |
340 private void drawRoundCap(float cx, float cy, float mx, float my) { |
340 private void drawRoundCap(float cx, float cy, float mx, float my) { |
341 emitCurveTo(cx+mx-C*my, cy+my+C*mx, |
341 final float Cmx = C * mx; |
342 cx-my+C*mx, cy+mx+C*my, |
342 final float Cmy = C * my; |
343 cx-my, cy+mx); |
343 emitCurveTo(cx + mx - Cmy, cy + my + Cmx, |
344 emitCurveTo(cx-my-C*mx, cy+mx-C*my, |
344 cx - my + Cmx, cy + mx + Cmy, |
345 cx-mx-C*my, cy-my+C*mx, |
345 cx - my, cy + mx); |
346 cx-mx, cy-my); |
346 emitCurveTo(cx - my - Cmx, cy + mx - Cmy, |
|
347 cx - mx - Cmy, cy - my + Cmx, |
|
348 cx - mx, cy - my); |
347 } |
349 } |
348 |
350 |
349 // Put the intersection point of the lines (x0, y0) -> (x1, y1) |
351 // Put the intersection point of the lines (x0, y0) -> (x1, y1) |
350 // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1]. |
352 // and (x0p, y0p) -> (x1p, y1p) in m[off] and m[off+1]. |
351 // If the lines are parallel, it will put a non finite number in m. |
353 // If the lines are parallel, it will put a non finite number in m. |
410 if (prev == DRAWING_OP_TO) { |
412 if (prev == DRAWING_OP_TO) { |
411 finish(); |
413 finish(); |
412 } |
414 } |
413 this.sx0 = this.cx0 = x0; |
415 this.sx0 = this.cx0 = x0; |
414 this.sy0 = this.cy0 = y0; |
416 this.sy0 = this.cy0 = y0; |
415 this.cdx = this.sdx = 1; |
417 this.cdx = this.sdx = 1f; |
416 this.cdy = this.sdy = 0; |
418 this.cdy = this.sdy = 0f; |
417 this.prev = MOVE_TO; |
419 this.prev = MOVE_TO; |
418 } |
420 } |
419 |
421 |
420 @Override |
422 @Override |
421 public void lineTo(float x1, float y1) { |
423 public void lineTo(float x1, float y1) { |
450 if (prev != DRAWING_OP_TO) { |
452 if (prev != DRAWING_OP_TO) { |
451 if (prev == CLOSE) { |
453 if (prev == CLOSE) { |
452 return; |
454 return; |
453 } |
455 } |
454 emitMoveTo(cx0, cy0 - lineWidth2); |
456 emitMoveTo(cx0, cy0 - lineWidth2); |
455 this.cmx = this.smx = 0; |
457 this.cmx = this.smx = 0f; |
456 this.cmy = this.smy = -lineWidth2; |
458 this.cmy = this.smy = -lineWidth2; |
457 this.cdx = this.sdx = 1; |
459 this.cdx = this.sdx = 1f; |
458 this.cdy = this.sdy = 0; |
460 this.cdy = this.sdy = 0f; |
459 finish(); |
461 finish(); |
460 return; |
462 return; |
461 } |
463 } |
462 |
464 |
463 if (cx0 != sx0 || cy0 != sy0) { |
465 if (cx0 != sx0 || cy0 != sy0) { |
1270 } |
1272 } |
1271 |
1273 |
1272 private void ensureSpace(final int n) { |
1274 private void ensureSpace(final int n) { |
1273 // use substraction to avoid integer overflow: |
1275 // use substraction to avoid integer overflow: |
1274 if (curves.length - end < n) { |
1276 if (curves.length - end < n) { |
1275 if (doStats) { |
1277 if (DO_STATS) { |
1276 RendererContext.stats.stat_array_stroker_polystack_curves |
1278 rdrCtx.stats.stat_array_stroker_polystack_curves |
1277 .add(end + n); |
1279 .add(end + n); |
1278 } |
1280 } |
1279 curves = rdrCtx.widenDirtyFloatArray(curves, end, end + n); |
1281 curves = rdrCtx.widenDirtyFloatArray(curves, end, end + n); |
1280 } |
1282 } |
1281 if (curveTypes.length <= numCurves) { |
1283 if (curveTypes.length <= numCurves) { |
1282 if (doStats) { |
1284 if (DO_STATS) { |
1283 RendererContext.stats.stat_array_stroker_polystack_curveTypes |
1285 rdrCtx.stats.stat_array_stroker_polystack_curveTypes |
1284 .add(numCurves + 1); |
1286 .add(numCurves + 1); |
1285 } |
1287 } |
1286 curveTypes = rdrCtx.widenDirtyByteArray(curveTypes, |
1288 curveTypes = rdrCtx.widenDirtyByteArray(curveTypes, |
1287 numCurves, |
1289 numCurves, |
1288 numCurves + 1); |
1290 numCurves + 1); |
1321 curveTypes[numCurves++] = TYPE_LINETO; |
1323 curveTypes[numCurves++] = TYPE_LINETO; |
1322 curves[end++] = x; curves[end++] = y; |
1324 curves[end++] = x; curves[end++] = y; |
1323 } |
1325 } |
1324 |
1326 |
1325 void popAll(PathConsumer2D io) { |
1327 void popAll(PathConsumer2D io) { |
1326 if (doStats) { |
1328 if (DO_STATS) { |
1327 // update used marks: |
1329 // update used marks: |
1328 if (numCurves > curveTypesUseMark) { |
1330 if (numCurves > curveTypesUseMark) { |
1329 curveTypesUseMark = numCurves; |
1331 curveTypesUseMark = numCurves; |
1330 } |
1332 } |
1331 if (end > curvesUseMark) { |
1333 if (end > curvesUseMark) { |