[pdf] Fix complex mirrored gradients in Preview.
An undocumented feature of Preview 11.0 (1033.3) is that `a n mod r eq` (with a and n both integers, r integer or real) early aborts a function when false would be put on the stack. Work around this by re-writing `t 2 mod 1 eq` as `t 2 mod 0 gt`. Bug: chromium:1316377, chromium:1170345 Change-Id: Ibb6eaaf36f276e9ef2906159622ab44b35289492 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542638 Reviewed-by: Herb Derby <herb@google.com> Commit-Queue: Ben Wagner <bungeman@google.com>
This commit is contained in:
parent
9c8b5c6566
commit
d2fba4ac94
@ -300,16 +300,20 @@ static void tileModeCode(SkTileMode mode, SkDynamicMemoryWStream* result) {
|
||||
}
|
||||
|
||||
if (mode == SkTileMode::kMirror) {
|
||||
// In Preview 11.0 (1033.3) `a n mod r eq` (with a and n both integers, r integer or real)
|
||||
// early aborts the function when false would be put on the stack.
|
||||
// Work around this by re-writing `t 2 mod 1 eq` as `t 2 mod 0 gt`.
|
||||
|
||||
// Map t mod 2 into [0, 1, 1, 0].
|
||||
// Code Stack
|
||||
result->writeText("abs " // Map negative to positive.
|
||||
"dup " // t.s t.s
|
||||
"truncate " // t.s t
|
||||
"dup " // t.s t t
|
||||
"cvi " // t.s t T
|
||||
"2 mod " // t.s t (i mod 2)
|
||||
"1 eq " // t.s t true|false
|
||||
"3 1 roll " // true|false t.s t
|
||||
// Code Stack t
|
||||
result->writeText("abs " // +t
|
||||
"dup " // +t.s +t.s
|
||||
"truncate " // +t.s +t
|
||||
"dup " // +t.s +t +t
|
||||
"cvi " // +t.s +t +T
|
||||
"2 mod " // +t.s +t (+T mod 2)
|
||||
/*"1 eq "*/ "0 gt " // +t.s +t true|false
|
||||
"3 1 roll " // true|false +t.s +t
|
||||
"sub " // true|false 0.s
|
||||
"exch " // 0.s true|false
|
||||
"{1 exch sub} if\n"); // 1 - 0.s|0.s
|
||||
|
Loading…
Reference in New Issue
Block a user