Skip to content

Commit 6d1e0f7

Browse files
committed
fix handling of flags 1-3 in tensor shading
pi is an index in the stream and is explained on page 201 of the 32000-spec (however 1-based there), and ps is an index to something in PDF.js. I used the code from flag 0 (which works) to understand which is which. It is also important to understand that for flags 1,2 and 3, the stream is always assigned to the same coordinates and colors. What changes is which "old" coordinates and colors are assigned to what is "missing" in the stream. This is why for these flags, the code is identical except for the assignments in the first "row". (Same principle as in #6304). Note that this change will not improve the lamp_cairo.pdf file, only the two files mentioned in #6305.
1 parent 1da7e89 commit 6d1e0f7

File tree

1 file changed

+21
-18
lines changed

1 file changed

+21
-18
lines changed

src/core/pattern.js

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -618,29 +618,32 @@ Shadings.Mesh = (function MeshClosure() {
618618
break;
619619
case 1:
620620
tmp1 = ps[12]; tmp2 = ps[13]; tmp3 = ps[14]; tmp4 = ps[15];
621-
ps[12] = pi + 5; ps[13] = pi + 4; ps[14] = pi + 3; ps[15] = pi + 2;
622-
ps[ 8] = pi + 6; ps[ 9] = pi + 11; ps[10] = pi + 10; ps[11] = pi + 1;
623-
ps[ 4] = pi + 7; ps[ 5] = pi + 8; ps[ 6] = pi + 9; ps[ 7] = pi;
624-
ps[ 0] = tmp1; ps[ 1] = tmp2; ps[ 2] = tmp3; ps[ 3] = tmp4;
621+
ps[12] = tmp4; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
622+
ps[ 8] = tmp3; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
623+
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
624+
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
625625
tmp1 = cs[2]; tmp2 = cs[3];
626-
cs[2] = ci + 1; cs[3] = ci;
627-
cs[0] = tmp1; cs[1] = tmp2;
626+
cs[2] = tmp2; cs[3] = ci;
627+
cs[0] = tmp1; cs[1] = ci + 1;
628628
break;
629629
case 2:
630-
ps[12] = ps[15]; ps[13] = pi + 7; ps[14] = pi + 6; ps[15] = pi + 5;
631-
ps[ 8] = ps[11]; ps[ 9] = pi + 8; ps[10] = pi + 11; ps[11] = pi + 4;
632-
ps[ 4] = ps[7]; ps[ 5] = pi + 9; ps[ 6] = pi + 10; ps[ 7] = pi + 3;
633-
ps[ 0] = ps[3]; ps[ 1] = pi; ps[ 2] = pi + 1; ps[ 3] = pi + 2;
634-
cs[2] = cs[3]; cs[3] = ci + 1;
635-
cs[0] = cs[1]; cs[1] = ci;
630+
tmp1 = ps[15];
631+
tmp2 = ps[11];
632+
ps[12] = ps[3]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
633+
ps[ 8] = ps[7]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
634+
ps[ 4] = tmp2; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
635+
ps[ 0] = tmp1; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
636+
tmp1 = cs[3];
637+
cs[2] = cs[1]; cs[3] = ci;
638+
cs[0] = tmp1; cs[1] = ci + 1;
636639
break;
637640
case 3:
638-
ps[12] = ps[0]; ps[13] = ps[1]; ps[14] = ps[2]; ps[15] = ps[3];
639-
ps[ 8] = pi; ps[ 9] = pi + 9; ps[10] = pi + 8; ps[11] = pi + 7;
640-
ps[ 4] = pi + 1; ps[ 5] = pi + 10; ps[ 6] = pi + 11; ps[ 7] = pi + 6;
641-
ps[ 0] = pi + 2; ps[ 1] = pi + 3; ps[ 2] = pi + 4; ps[ 3] = pi + 5;
642-
cs[2] = cs[0]; cs[3] = cs[1];
643-
cs[0] = ci; cs[1] = ci + 1;
641+
ps[12] = ps[0]; ps[13] = pi + 0; ps[14] = pi + 1; ps[15] = pi + 2;
642+
ps[ 8] = ps[1]; ps[ 9] = pi + 9; ps[10] = pi + 10; ps[11] = pi + 3;
643+
ps[ 4] = ps[2]; ps[ 5] = pi + 8; ps[ 6] = pi + 11; ps[ 7] = pi + 4;
644+
ps[ 0] = ps[3]; ps[ 1] = pi + 7; ps[ 2] = pi + 6; ps[ 3] = pi + 5;
645+
cs[2] = cs[0]; cs[3] = ci;
646+
cs[0] = cs[1]; cs[1] = ci + 1;
644647
break;
645648
}
646649
mesh.figures.push({

0 commit comments

Comments
 (0)