Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 This file is part of LilyPond, the GNU music typesetter. | 2 This file is part of LilyPond, the GNU music typesetter. |
3 | 3 |
4 Copyright (C) 2012--2020 Mike Solomon <mike@mikesolomon.org> | 4 Copyright (C) 2012--2020 Mike Solomon <mike@mikesolomon.org> |
5 | 5 |
6 LilyPond is free software: you can redistribute it and/or modify | 6 LilyPond is free software: you can redistribute it and/or modify |
7 it under the terms of the GNU General Public License as published by | 7 it under the terms of the GNU General Public License as published by |
8 the Free Software Foundation, either version 3 of the License, or | 8 the Free Software Foundation, either version 3 of the License, or |
9 (at your option) any later version. | 9 (at your option) any later version. |
10 | 10 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 scm_list_n (scm_from_double (rad), | 406 scm_list_n (scm_from_double (rad), |
407 scm_from_double (rad), | 407 scm_from_double (rad), |
408 scm_from_double (angle - 90.01), | 408 scm_from_double (angle - 90.01), |
409 scm_from_double (angle + 90.01), | 409 scm_from_double (angle + 90.01), |
410 scm_from_double (0.0), | 410 scm_from_double (0.0), |
411 SCM_BOOL_F, | 411 SCM_BOOL_F, |
412 SCM_BOOL_F, | 412 SCM_BOOL_F, |
413 SCM_UNDEFINED)); | 413 SCM_UNDEFINED)); |
414 } | 414 } |
415 | 415 |
416 // TODO - remove once https://codereview.appspot.com/583750044/ is in. | |
417 Offset | |
418 get_normal (Offset o) | |
419 { | |
420 return o.normal (); | |
421 } | |
422 | 416 |
423 void | 417 void |
424 make_draw_bezier_boxes (vector<Box> &boxes, | 418 make_draw_bezier_boxes (vector<Box> &boxes, |
425 vector<Drul_array<Offset> > &buildings, | 419 vector<Drul_array<Offset> > &buildings, |
426 SCM trans, SCM expr) | 420 SCM trans, SCM expr) |
427 { | 421 { |
428 Real th = robust_scm2double (scm_car (expr), 0.0); | 422 Real th = robust_scm2double (scm_car (expr), 0.0); |
429 expr = scm_cdr (expr); | 423 expr = scm_cdr (expr); |
430 Real x0 = robust_scm2double (scm_car (expr), 0.0); | 424 Real x0 = robust_scm2double (scm_car (expr), 0.0); |
431 expr = scm_cdr (expr); | 425 expr = scm_cdr (expr); |
(...skipping 25 matching lines...) Expand all Loading... | |
457 Drul_array<vector<Offset> > points; | 451 Drul_array<vector<Offset> > points; |
458 int quantization = int (((temp1 - temp0).length () | 452 int quantization = int (((temp1 - temp0).length () |
459 + (temp2 - temp1).length () | 453 + (temp2 - temp1).length () |
460 + (temp3 - temp2).length ()) | 454 + (temp3 - temp2).length ()) |
461 / QUANTIZATION_UNIT); | 455 / QUANTIZATION_UNIT); |
462 | 456 |
463 Offset d0; | 457 Offset d0; |
464 Offset d1; | 458 Offset d1; |
465 | 459 |
466 Offset normal; | 460 Offset normal; |
461 | |
462 // This code is shared between curves with thickness (th > 0.0) and | |
463 // font contours (th == 0.0). We avoid some calculations on Font | |
464 // contour by not evaluating thicknesses. This makes the code a bit | |
465 // more convoluted, but it's fairly hot path. | |
dak
2020/04/24 21:18:12
Sorry for not being clear: the question was not wh
hanwenn
2020/05/02 22:26:12
Acknowledged.
| |
467 if (th > 0) | 466 if (th > 0) |
468 { | 467 { |
469 d0 = curve.dir_at_point (0.0); | 468 d0 = curve.dir_at_point (0.0); |
470 normal = get_normal ((th / 2) * d0); | 469 normal = (th / 2) * d0.normal (); |
471 } | 470 } |
472 | 471 |
473 for (DOWN_and_UP (d)) | 472 for (DOWN_and_UP (d)) |
474 { | 473 { |
475 if (th == 0.0 && d == UP) | |
476 break; | |
477 points[d].push_back ( | 474 points[d].push_back ( |
478 scm_transform (trans, curve.control_[0] + d * normal)); | 475 scm_transform (trans, curve.control_[0] + d * normal)); |
476 if (th == 0.0) | |
477 break; | |
479 } | 478 } |
480 | 479 |
481 for (vsize i = 1; i < (vsize) quantization; i++) | 480 for (vsize i = 1; i < (vsize) quantization; i++) |
482 { | 481 { |
483 Real pt = static_cast<Real> (i) / quantization; | 482 Real pt = static_cast<Real> (i) / quantization; |
484 Offset norm = get_normal ((th / 2) * curve.dir_at_point (pt)); | 483 Offset norm; |
484 if (th > 0.0) | |
485 norm = (th / 2) * curve.dir_at_point (pt).normal (); | |
485 | 486 |
486 for (DOWN_and_UP (d)) | 487 for (DOWN_and_UP (d)) |
487 { | 488 { |
488 if (th == 0.0 && d == UP) | |
489 break; | |
490 points[d].push_back ( | 489 points[d].push_back ( |
491 scm_transform (trans, curve.curve_point (pt) + d * norm)); | 490 scm_transform (trans, curve.curve_point (pt) + d * norm)); |
491 if (th == 0.0) | |
492 break; | |
492 } | 493 } |
493 } | 494 } |
494 | 495 |
495 if (th > 0) | 496 if (th > 0) |
496 { | 497 { |
497 d1 = curve.dir_at_point (1.0); | 498 d1 = curve.dir_at_point (1.0); |
498 normal = get_normal ((th / 2) * d1); | 499 normal = (th / 2) * d1.normal (); |
499 } | 500 } |
500 | 501 |
501 for (DOWN_and_UP (d)) | 502 for (DOWN_and_UP (d)) |
502 { | 503 { |
503 if (th == 0.0 && d == UP) | |
504 break; | |
505 points[d].push_back ( | 504 points[d].push_back ( |
506 scm_transform (trans, curve.control_[3] + d * normal)); | 505 scm_transform (trans, curve.control_[3] + d * normal)); |
506 if (th == 0.0) | |
507 break; | |
507 } | 508 } |
508 | 509 |
509 for (vsize i = 0; i < points[DOWN].size () - 1; i++) | 510 for (vsize i = 0; i < points[DOWN].size () - 1; i++) |
510 { | 511 { |
511 Box b; | 512 Box b; |
512 for (DOWN_and_UP (d)) | 513 for (DOWN_and_UP (d)) |
513 { | 514 { |
514 if (th == 0.0 && d == UP) | |
515 break; | |
516 b.add_point (points[d][i]); | 515 b.add_point (points[d][i]); |
517 b.add_point (points[d][i + 1]); | 516 b.add_point (points[d][i + 1]); |
517 if (th == 0.0) | |
518 break; | |
518 } | 519 } |
519 boxes.push_back (b); | 520 boxes.push_back (b); |
520 } | 521 } |
521 | 522 |
522 if (th > 0) | 523 if (th > 0) |
523 { | 524 { |
524 // beg line cap | 525 // beg line cap |
525 create_path_cap (boxes, buildings, trans, curve.control_[0], th / 2, -d0); | 526 create_path_cap (boxes, buildings, trans, curve.control_[0], th / 2, -d0); |
526 | 527 |
527 // end line cap | 528 // end line cap |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1218 | 1219 |
1219 MAKE_SCHEME_CALLBACK (Grob, pure_horizontal_skylines_from_element_stencils, 3); | 1220 MAKE_SCHEME_CALLBACK (Grob, pure_horizontal_skylines_from_element_stencils, 3); |
1220 SCM | 1221 SCM |
1221 Grob::pure_horizontal_skylines_from_element_stencils (SCM smob, SCM beg_scm, SCM end_scm) | 1222 Grob::pure_horizontal_skylines_from_element_stencils (SCM smob, SCM beg_scm, SCM end_scm) |
1222 { | 1223 { |
1223 Grob *me = unsmob<Grob> (smob); | 1224 Grob *me = unsmob<Grob> (smob); |
1224 int beg = robust_scm2int (beg_scm, 0); | 1225 int beg = robust_scm2int (beg_scm, 0); |
1225 int end = robust_scm2int (end_scm, 0); | 1226 int end = robust_scm2int (end_scm, 0); |
1226 return internal_skylines_from_element_stencils (me, Y_AXIS, true, beg, end); | 1227 return internal_skylines_from_element_stencils (me, Y_AXIS, true, beg, end); |
1227 } | 1228 } |
OLD | NEW |