From 55388021d9fc6c1102e8ed0f610237a0ca60f828 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bojan=20Bili=C4=87?= Date: Sat, 27 Aug 2016 10:44:50 +0200 Subject: [PATCH] Save math operation results to save proc ticks --- plugins/acroform.js | 73 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/plugins/acroform.js b/plugins/acroform.js index 223ea125a..911ac8dce 100644 --- a/plugins/acroform.js +++ b/plugins/acroform.js @@ -553,25 +553,51 @@ Q\n"; AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4; // The Borderpadding... DotRadius *= 0.9; - var c = AcroForm.Appearance.internal.Bezier_C; + // Save results for later use; no need to waste processor ticks on doing math + var k = DotRadius * 2; + // var c = AcroForm.Appearance.internal.Bezier_C; + var kc = k * AcroForm.Appearance.internal.Bezier_C; + var dc = DotRadius * AcroForm.Appearance.internal.Bezier_C; +// stream += "0.749023 g\n\ +// q\n\ +// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ +// " + DotRadius * 2 + " 0 m\n\ +// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\ +// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\ +// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\ +// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\ +// f\n\ +// Q\n\ +// 0 g\n\ +// q\n\ +// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ +// " + DotRadius + " 0 m\n\ +// " + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\ +// -" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\ +// -" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\ +// " + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\ +// f\n\ +// Q\n"; + +// FASTER VERSION with less processor ticks spent on math operations stream += "0.749023 g\n\ q\n\ 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ -" + DotRadius * 2 + " 0 m\n\ -" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\ --" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\ --" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\ -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\ +" + k + " 0 m\n\ +" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\ +-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\ +-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\ +" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\ f\n\ Q\n\ 0 g\n\ q\n\ 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ " + DotRadius + " 0 m\n\ -" + DotRadius + " " + DotRadius * c + " " + DotRadius * c + " " + DotRadius + " 0 " + DotRadius + " c\n\ --" + DotRadius * c + " " + DotRadius + " -" + DotRadius + " " + DotRadius * c + " -" + DotRadius + " 0 c\n\ --" + DotRadius + " -" + DotRadius * c + " -" + DotRadius * c + " -" + DotRadius + " 0 -" + DotRadius + " c\n\ -" + DotRadius * c + " -" + DotRadius + " " + DotRadius + " -" + DotRadius * c + " " + DotRadius + " 0 c\n\ +" + DotRadius + " " + dc + " " + dc + " " + DotRadius + " 0 " + DotRadius + " c\n\ +-" + dc + " " + DotRadius + " -" + DotRadius + " " + dc + " -" + DotRadius + " 0 c\n\ +-" + DotRadius + " -" + dc + " -" + dc + " -" + DotRadius + " 0 -" + DotRadius + " c\n\ +" + dc + " -" + DotRadius + " " + DotRadius + " -" + dc + " " + DotRadius + " 0 c\n\ f\n\ Q\n"; xobj.stream = stream; @@ -584,15 +610,30 @@ Q\n"; AcroForm.Appearance.internal.getWidth(formObject) / 4 : AcroForm.Appearance.internal.getHeight(formObject) / 4; // The Borderpadding... DotRadius *= 0.9; - var c = AcroForm.Appearance.internal.Bezier_C; + // Save results for later use; no need to waste processor ticks on doing math + var k = DotRadius * 2; + // var c = AcroForm.Appearance.internal.Bezier_C; + var kc = k * AcroForm.Appearance.internal.Bezier_C; +// stream += "0.749023 g\n\ +// q\n\ +// 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ +// " + DotRadius * 2 + " 0 m\n\ +// " + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\ +// -" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\ +// -" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\ +// " + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\ +// f\n\ +// Q\n"; + +// FASTER VERSION with less processor ticks spent on math operations stream += "0.749023 g\n\ q\n\ 1 0 0 1 " + AcroForm.Appearance.internal.getWidth(formObject) / 2 + " " + AcroForm.Appearance.internal.getHeight(formObject) / 2 + " cm\n\ -" + DotRadius * 2 + " 0 m\n\ -" + DotRadius * 2 + " " + DotRadius * 2 * c + " " + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 " + DotRadius * 2 + " c\n\ --" + DotRadius * 2 * c + " " + DotRadius * 2 + " -" + DotRadius * 2 + " " + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 c\n\ --" + DotRadius * 2 + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " 0 -" + DotRadius * 2 + " c\n\ -" + DotRadius * 2 * c + " -" + DotRadius * 2 + " " + DotRadius * 2 + " -" + DotRadius * 2 * c + " " + DotRadius * 2 + " 0 c\n\ +" + k + " 0 m\n\ +" + k + " " + kc + " " + kc + " " + k + " 0 " + k + " c\n\ +-" + kc + " " + k + " -" + k + " " + kc + " -" + k + " 0 c\n\ +-" + k + " -" + kc + " -" + kc + " -" + k + " 0 -" + k + " c\n\ +" + kc + " -" + k + " " + k + " -" + kc + " " + k + " 0 c\n\ f\n\ Q\n"; xobj.stream = stream;