| 392 | |
| 393 | |
| 394 | int qrcodegen::QrCode::handleConstructorMasking(int mask) { |
| 395 | if (mask == -1) { // Automatically choose best mask |
| 396 | int32_t minPenalty = INT32_MAX; |
| 397 | for (int i = 0; i < 8; i++) { |
| 398 | drawFormatBits(i); |
| 399 | applyMask(i); |
| 400 | int penalty = getPenaltyScore(); |
| 401 | if (penalty < minPenalty) { |
| 402 | mask = i; |
| 403 | minPenalty = penalty; |
| 404 | } |
| 405 | applyMask(i); // Undoes the mask due to XOR |
| 406 | } |
| 407 | } |
| 408 | if (mask < 0 || mask > 7) |
| 409 | throw "Assertion error"; |
| 410 | drawFormatBits(mask); // Overwrite old format bits |
| 411 | applyMask(mask); // Apply the final choice of mask |
| 412 | return mask; // The caller shall assign this value to the final-declared field |
| 413 | } |
| 414 | |
| 415 | |
| 416 | int qrcodegen::QrCode::getPenaltyScore() const { |
nothing calls this directly
no test coverage detected