Skip to content

Commit 5538802

Browse files
authored
Save math operation results to save proc ticks
1 parent 76edb33 commit 5538802

File tree

1 file changed

+57
-16
lines changed

1 file changed

+57
-16
lines changed

plugins/acroform.js

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -553,25 +553,51 @@ Q\n";
553553
AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4;
554554
// The Borderpadding...
555555
DotRadius *= 0.9;
556-
var c = AcroForm.Appearance.internal.Bezier_C;
556+
// Save results for later use; no need to waste processor ticks on doing math
557+
var k = DotRadius * 2;
558+
// var c = AcroForm.Appearance.internal.Bezier_C;
559+
var kc = k * AcroForm.Appearance.internal.Bezier_C;
560+
var dc = DotRadius * AcroForm.Appearance.internal.Bezier_C;
561+
// stream += "0.749023 g\n\
562+
// q\n\
563+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
564+
// " + DotRadius * 2 + " 0 m\n\
565+
// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
566+
// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
567+
// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
568+
// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
569+
// f\n\
570+
// Q\n\
571+
// 0 g\n\
572+
// q\n\
573+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
574+
// " + DotRadius + " 0 m\n\
575+
// " + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\
576+
// -" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\
577+
// -" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
578+
// " + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\
579+
// f\n\
580+
// Q\n";
581+
582+
// FASTER VERSION with less processor ticks spent on math operations
557583
stream += "0.749023 g\n\
558584
q\n\
559585
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
560-
" + DotRadius * 2 + " 0 m\n\
561-
" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
562-
-" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
563-
-" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
564-
" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
586+
" + k + " 0 m\n\
587+
" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\
588+
-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\
589+
-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\
590+
" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\
565591
f\n\
566592
Q\n\
567593
0 g\n\
568594
q\n\
569595
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
570596
" + DotRadius + " 0 m\n\
571-
" + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\
572-
-" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\
573-
-" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
574-
" + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\
597+
" + DotRadius + " " + dc + " " + dc + " " + DotRadius + " 0 " + DotRadius + " c\n\
598+
-" + dc + " " + DotRadius + " -" + DotRadius + " " + dc + " -" + DotRadius + " 0 c\n\
599+
-" + DotRadius + " -" + dc + " -" + dc + " -" + DotRadius + " 0 -" + DotRadius + " c\n\
600+
" + dc + " -" + DotRadius + " " + DotRadius + " -" + dc + " " + DotRadius + " 0 c\n\
575601
f\n\
576602
Q\n";
577603
xobj.stream = stream;
@@ -584,15 +610,30 @@ Q\n";
584610
AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4;
585611
// The Borderpadding...
586612
DotRadius *= 0.9;
587-
var c = AcroForm.Appearance.internal.Bezier_C;
613+
// Save results for later use; no need to waste processor ticks on doing math
614+
var k = DotRadius * 2;
615+
// var c = AcroForm.Appearance.internal.Bezier_C;
616+
var kc = k * AcroForm.Appearance.internal.Bezier_C;
617+
// stream += "0.749023 g\n\
618+
// q\n\
619+
// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
620+
// " + DotRadius * 2 + " 0 m\n\
621+
// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
622+
// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
623+
// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
624+
// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
625+
// f\n\
626+
// Q\n";
627+
628+
// FASTER VERSION with less processor ticks spent on math operations
588629
stream += "0.749023 g\n\
589630
q\n\
590631
1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\
591-
" + DotRadius * 2 + " 0 m\n\
592-
" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\
593-
-" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\
594-
-" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\
595-
" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\
632+
" + k + " 0 m\n\
633+
" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\
634+
-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\
635+
-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\
636+
" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\
596637
f\n\
597638
Q\n";
598639
xobj.stream = stream;

0 commit comments

Comments
 (0)