summaryrefslogtreecommitdiff
path: root/source/codes/Qr.mc
diff options
context:
space:
mode:
Diffstat (limited to 'source/codes/Qr.mc')
-rw-r--r--source/codes/Qr.mc30
1 files changed, 28 insertions, 2 deletions
diff --git a/source/codes/Qr.mc b/source/codes/Qr.mc
index 1fac051..5ced89e 100644
--- a/source/codes/Qr.mc
+++ b/source/codes/Qr.mc
@@ -49,6 +49,8 @@ module Qr {
const WRITE_CHARS_PER_STEP = 300;
// Phase 1: data symbols times EC symbols per step (about 35 bytecodes each).
const ECC_WORK_PER_STEP = 400;
+ // Cumulative percent at the end of each phase 0-6 (see QrJob.percent).
+ const PHASE_ENDS = [8, 16, 18, 27, 39, 93, 100];
// Phase 2: codewords interleaved per step.
const INTERLEAVE_PER_STEP = 600;
const PREP_SEGMENT = 0;
@@ -366,9 +368,33 @@ module Qr {
_version = forceVersion;
}
- // Progress 0-100 for the UI.
+ // Progress 0-100 for the UI: the share of each phase of the work
+ // (simulator timings of a version 6, a version 40 and a level H
+ // code; mask scoring is about half of it), and inside the long ones
+ // how far they have got.
function percent() as Number {
- return _phase * 100 / 7;
+ var done = 0;
+ var total = 0;
+ if (_phase == 1 && _blocks.size() > 0) { // blocks done, and the current one
+ var e = _encoder;
+ done = _cursor * 100 + (e != null ? e.percent() : 0);
+ total = _blocks.size() * 100;
+ } else if (_phase == 3) { // column pairs, right to left
+ done = _size - 1 - _cursor;
+ total = _size - 1;
+ } else if (_phase == 5) { // lines of the masks scored so far
+ done = (_maskIndex * 2 + _maskPass) * _size + _cursor;
+ total = 16 * _size;
+ } else if (_phase == 6) { // rows masked
+ done = _cursor;
+ total = _size;
+ }
+ return Codes.phased(PHASE_ENDS, _phase, done, total);
+ }
+
+ // Packing and runs: about 92 / 2 / 6 % of a whole display job.
+ function stageEnds() as Array<Number> {
+ return [92, 94];
}
// The code as a generic matrix with QR's 4-module quiet zone.