/src/xpdf-4.06/splash/SplashMath.h
Line | Count | Source |
1 | | //======================================================================== |
2 | | // |
3 | | // SplashMath.h |
4 | | // |
5 | | // Copyright 2003-2013 Glyph & Cog, LLC |
6 | | // |
7 | | //======================================================================== |
8 | | |
9 | | #ifndef SPLASHMATH_H |
10 | | #define SPLASHMATH_H |
11 | | |
12 | | #include <aconf.h> |
13 | | |
14 | | #if USE_FIXEDPONT |
15 | | # include "FixedPoint.h" |
16 | | #else |
17 | | # include <math.h> |
18 | | # if (defined(__GNUC__) && defined(__SSE2__)) || \ |
19 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) |
20 | | # include <emmintrin.h> |
21 | | # endif |
22 | | #endif |
23 | | #include "SplashTypes.h" |
24 | | |
25 | 167M | static inline SplashCoord splashAbs(SplashCoord x) { |
26 | | #if USE_FIXEDPOINT |
27 | | return FixedPoint::abs(x); |
28 | | #else |
29 | 167M | return fabs(x); |
30 | 167M | #endif |
31 | 167M | } Unexecuted instantiation: fuzz_pdfload.cc:splashAbs(double) Unexecuted instantiation: SplashOutputDev.cc:splashAbs(double) Splash.cc:splashAbs(double) Line | Count | Source | 25 | 351k | static inline SplashCoord splashAbs(SplashCoord x) { | 26 | | #if USE_FIXEDPOINT | 27 | | return FixedPoint::abs(x); | 28 | | #else | 29 | 351k | return fabs(x); | 30 | 351k | #endif | 31 | 351k | } |
Unexecuted instantiation: SplashClip.cc:splashAbs(double) SplashFontEngine.cc:splashAbs(double) Line | Count | Source | 25 | 101k | static inline SplashCoord splashAbs(SplashCoord x) { | 26 | | #if USE_FIXEDPOINT | 27 | | return FixedPoint::abs(x); | 28 | | #else | 29 | 101k | return fabs(x); | 30 | 101k | #endif | 31 | 101k | } |
Unexecuted instantiation: SplashPattern.cc:splashAbs(double) Unexecuted instantiation: SplashState.cc:splashAbs(double) SplashXPath.cc:splashAbs(double) Line | Count | Source | 25 | 167M | static inline SplashCoord splashAbs(SplashCoord x) { | 26 | | #if USE_FIXEDPOINT | 27 | | return FixedPoint::abs(x); | 28 | | #else | 29 | 167M | return fabs(x); | 30 | 167M | #endif | 31 | 167M | } |
Unexecuted instantiation: SplashXPathScanner.cc:splashAbs(double) Unexecuted instantiation: ShadingImage.cc:splashAbs(double) Unexecuted instantiation: SplashFTFontFile.cc:splashAbs(double) Unexecuted instantiation: SplashFont.cc:splashAbs(double) Unexecuted instantiation: SplashScreen.cc:splashAbs(double) Unexecuted instantiation: SplashFTFont.cc:splashAbs(double) |
32 | | |
33 | | // floor() and (int)() are implemented separately, which results |
34 | | // in changing the FPCW multiple times - so we optimize it with |
35 | | // some inline assembly or SSE intrinsics. |
36 | 93.1M | static inline int splashFloor(SplashCoord x) { |
37 | | #if USE_FIXEDPOINT |
38 | | |
39 | | //--- fixed point |
40 | | |
41 | | return FixedPoint::floor(x); |
42 | | |
43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ |
44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) |
45 | | |
46 | | //--- SSE2 intrinsics |
47 | | // NB: 64-bit x86 guarantees availability of SSE2. |
48 | | |
49 | 93.1M | __m128d m1, m2; |
50 | 93.1M | int i, s; |
51 | | |
52 | 93.1M | m1 = _mm_set_sd(x); |
53 | 93.1M | i = _mm_cvttsd_si32(m1); |
54 | 93.1M | m2 = _mm_cvtsi32_sd(m1, i); |
55 | 93.1M | s = _mm_ucomigt_sd(m2, m1); |
56 | 93.1M | return i - s; |
57 | | |
58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) |
59 | | |
60 | | //--- x87 inline assembly (gcc/clang) |
61 | | // (this code fails on OSX for reasons I don't understand) |
62 | | |
63 | | Gushort oldCW, newCW, t; |
64 | | int result; |
65 | | |
66 | | __asm__ volatile("fnstcw %0\n" |
67 | | "movw %0, %3\n" |
68 | | "andw $0xf3ff, %3\n" |
69 | | "orw $0x0400, %3\n" |
70 | | "movw %3, %1\n" // round down |
71 | | "fldcw %1\n" |
72 | | "fistl %2\n" |
73 | | "fldcw %0\n" |
74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) |
75 | | : "t" (x)); |
76 | | return result; |
77 | | |
78 | | #elif defined(_WIN32) && defined(_M_IX86) |
79 | | |
80 | | //--- x87 inline assembly (VC) |
81 | | |
82 | | Gushort oldCW, newCW; |
83 | | int result; |
84 | | |
85 | | __asm fld QWORD PTR x |
86 | | __asm fnstcw WORD PTR oldCW |
87 | | __asm mov ax, WORD PTR oldCW |
88 | | __asm and ax, 0xf3ff |
89 | | __asm or ax, 0x0400 |
90 | | __asm mov WORD PTR newCW, ax // round down |
91 | | __asm fldcw WORD PTR newCW |
92 | | __asm fistp DWORD PTR result |
93 | | __asm fldcw WORD PTR oldCW |
94 | | return result; |
95 | | |
96 | | #else |
97 | | |
98 | | //--- all others |
99 | | |
100 | | return (int)floor(x); |
101 | | |
102 | | #endif |
103 | 93.1M | } Unexecuted instantiation: fuzz_pdfload.cc:splashFloor(double) Unexecuted instantiation: SplashOutputDev.cc:splashFloor(double) Splash.cc:splashFloor(double) Line | Count | Source | 36 | 9.17M | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 9.17M | __m128d m1, m2; | 50 | 9.17M | int i, s; | 51 | | | 52 | 9.17M | m1 = _mm_set_sd(x); | 53 | 9.17M | i = _mm_cvttsd_si32(m1); | 54 | 9.17M | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 9.17M | s = _mm_ucomigt_sd(m2, m1); | 56 | 9.17M | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 9.17M | } |
SplashClip.cc:splashFloor(double) Line | Count | Source | 36 | 95.8k | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 95.8k | __m128d m1, m2; | 50 | 95.8k | int i, s; | 51 | | | 52 | 95.8k | m1 = _mm_set_sd(x); | 53 | 95.8k | i = _mm_cvttsd_si32(m1); | 54 | 95.8k | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 95.8k | s = _mm_ucomigt_sd(m2, m1); | 56 | 95.8k | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 95.8k | } |
Unexecuted instantiation: SplashFontEngine.cc:splashFloor(double) Unexecuted instantiation: SplashPattern.cc:splashFloor(double) Unexecuted instantiation: SplashState.cc:splashFloor(double) SplashXPath.cc:splashFloor(double) Line | Count | Source | 36 | 32.4M | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 32.4M | __m128d m1, m2; | 50 | 32.4M | int i, s; | 51 | | | 52 | 32.4M | m1 = _mm_set_sd(x); | 53 | 32.4M | i = _mm_cvttsd_si32(m1); | 54 | 32.4M | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 32.4M | s = _mm_ucomigt_sd(m2, m1); | 56 | 32.4M | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 32.4M | } |
SplashXPathScanner.cc:splashFloor(double) Line | Count | Source | 36 | 33.7M | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 33.7M | __m128d m1, m2; | 50 | 33.7M | int i, s; | 51 | | | 52 | 33.7M | m1 = _mm_set_sd(x); | 53 | 33.7M | i = _mm_cvttsd_si32(m1); | 54 | 33.7M | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 33.7M | s = _mm_ucomigt_sd(m2, m1); | 56 | 33.7M | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 33.7M | } |
Unexecuted instantiation: ShadingImage.cc:splashFloor(double) Unexecuted instantiation: SplashFTFontFile.cc:splashFloor(double) Unexecuted instantiation: SplashFont.cc:splashFloor(double) SplashScreen.cc:splashFloor(double) Line | Count | Source | 36 | 17.7M | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 17.7M | __m128d m1, m2; | 50 | 17.7M | int i, s; | 51 | | | 52 | 17.7M | m1 = _mm_set_sd(x); | 53 | 17.7M | i = _mm_cvttsd_si32(m1); | 54 | 17.7M | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 17.7M | s = _mm_ucomigt_sd(m2, m1); | 56 | 17.7M | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 17.7M | } |
SplashFTFont.cc:splashFloor(double) Line | Count | Source | 36 | 2.57k | static inline int splashFloor(SplashCoord x) { | 37 | | #if USE_FIXEDPOINT | 38 | | | 39 | | //--- fixed point | 40 | | | 41 | | return FixedPoint::floor(x); | 42 | | | 43 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 44 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 45 | | | 46 | | //--- SSE2 intrinsics | 47 | | // NB: 64-bit x86 guarantees availability of SSE2. | 48 | | | 49 | 2.57k | __m128d m1, m2; | 50 | 2.57k | int i, s; | 51 | | | 52 | 2.57k | m1 = _mm_set_sd(x); | 53 | 2.57k | i = _mm_cvttsd_si32(m1); | 54 | 2.57k | m2 = _mm_cvtsi32_sd(m1, i); | 55 | 2.57k | s = _mm_ucomigt_sd(m2, m1); | 56 | 2.57k | return i - s; | 57 | | | 58 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 59 | | | 60 | | //--- x87 inline assembly (gcc/clang) | 61 | | // (this code fails on OSX for reasons I don't understand) | 62 | | | 63 | | Gushort oldCW, newCW, t; | 64 | | int result; | 65 | | | 66 | | __asm__ volatile("fnstcw %0\n" | 67 | | "movw %0, %3\n" | 68 | | "andw $0xf3ff, %3\n" | 69 | | "orw $0x0400, %3\n" | 70 | | "movw %3, %1\n" // round down | 71 | | "fldcw %1\n" | 72 | | "fistl %2\n" | 73 | | "fldcw %0\n" | 74 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 75 | | : "t" (x)); | 76 | | return result; | 77 | | | 78 | | #elif defined(_WIN32) && defined(_M_IX86) | 79 | | | 80 | | //--- x87 inline assembly (VC) | 81 | | | 82 | | Gushort oldCW, newCW; | 83 | | int result; | 84 | | | 85 | | __asm fld QWORD PTR x | 86 | | __asm fnstcw WORD PTR oldCW | 87 | | __asm mov ax, WORD PTR oldCW | 88 | | __asm and ax, 0xf3ff | 89 | | __asm or ax, 0x0400 | 90 | | __asm mov WORD PTR newCW, ax // round down | 91 | | __asm fldcw WORD PTR newCW | 92 | | __asm fistp DWORD PTR result | 93 | | __asm fldcw WORD PTR oldCW | 94 | | return result; | 95 | | | 96 | | #else | 97 | | | 98 | | //--- all others | 99 | | | 100 | | return (int)floor(x); | 101 | | | 102 | | #endif | 103 | 2.57k | } |
|
104 | | |
105 | | // ceil() and (int)() are implemented separately, which results |
106 | | // in changing the FPCW multiple times - so we optimize it with |
107 | | // some inline assembly or SSE intrinsics. |
108 | 172k | static inline int splashCeil(SplashCoord x) { |
109 | | #if USE_FIXEDPOINT |
110 | | |
111 | | //--- fixed point |
112 | | |
113 | | return FixedPoint::ceil(x); |
114 | | |
115 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ |
116 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) |
117 | | |
118 | | //--- SSE2 intrinsics |
119 | | // NB: 64-bit x86 guarantees availability of SSE2. |
120 | | |
121 | 172k | __m128d m1, m2; |
122 | 172k | int i, s; |
123 | | |
124 | 172k | m1 = _mm_set_sd(x); |
125 | 172k | i = _mm_cvttsd_si32(m1); |
126 | 172k | m2 = _mm_cvtsi32_sd(m1, i); |
127 | 172k | s = _mm_ucomilt_sd(m2, m1); |
128 | 172k | return i + s; |
129 | | |
130 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) |
131 | | |
132 | | //--- x87 inline assembly (gcc/clang) |
133 | | // (this code fails on OSX for reasons I don't understand) |
134 | | |
135 | | Gushort oldCW, newCW, t; |
136 | | int result; |
137 | | |
138 | | __asm__ volatile("fnstcw %0\n" |
139 | | "movw %0, %3\n" |
140 | | "andw $0xf3ff, %3\n" |
141 | | "orw $0x0800, %3\n" |
142 | | "movw %3, %1\n" // round up |
143 | | "fldcw %1\n" |
144 | | "fistl %2\n" |
145 | | "fldcw %0\n" |
146 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) |
147 | | : "t" (x)); |
148 | | return result; |
149 | | |
150 | | #elif defined(_WIN32) && defined(_M_IX86) |
151 | | |
152 | | //--- x87 inline assembly (VC) |
153 | | |
154 | | // ceil() and (int)() are implemented separately, which results |
155 | | // in changing the FPCW multiple times - so we optimize it with |
156 | | // some inline assembly |
157 | | Gushort oldCW, newCW; |
158 | | int result; |
159 | | |
160 | | __asm fld QWORD PTR x |
161 | | __asm fnstcw WORD PTR oldCW |
162 | | __asm mov ax, WORD PTR oldCW |
163 | | __asm and ax, 0xf3ff |
164 | | __asm or ax, 0x0800 |
165 | | __asm mov WORD PTR newCW, ax // round up |
166 | | __asm fldcw WORD PTR newCW |
167 | | __asm fistp DWORD PTR result |
168 | | __asm fldcw WORD PTR oldCW |
169 | | return result; |
170 | | |
171 | | #else |
172 | | |
173 | | //--- all others |
174 | | |
175 | | return (int)ceil(x); |
176 | | |
177 | | #endif |
178 | 172k | } Unexecuted instantiation: fuzz_pdfload.cc:splashCeil(double) Unexecuted instantiation: SplashOutputDev.cc:splashCeil(double) Splash.cc:splashCeil(double) Line | Count | Source | 108 | 234 | static inline int splashCeil(SplashCoord x) { | 109 | | #if USE_FIXEDPOINT | 110 | | | 111 | | //--- fixed point | 112 | | | 113 | | return FixedPoint::ceil(x); | 114 | | | 115 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 116 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 117 | | | 118 | | //--- SSE2 intrinsics | 119 | | // NB: 64-bit x86 guarantees availability of SSE2. | 120 | | | 121 | 234 | __m128d m1, m2; | 122 | 234 | int i, s; | 123 | | | 124 | 234 | m1 = _mm_set_sd(x); | 125 | 234 | i = _mm_cvttsd_si32(m1); | 126 | 234 | m2 = _mm_cvtsi32_sd(m1, i); | 127 | 234 | s = _mm_ucomilt_sd(m2, m1); | 128 | 234 | return i + s; | 129 | | | 130 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 131 | | | 132 | | //--- x87 inline assembly (gcc/clang) | 133 | | // (this code fails on OSX for reasons I don't understand) | 134 | | | 135 | | Gushort oldCW, newCW, t; | 136 | | int result; | 137 | | | 138 | | __asm__ volatile("fnstcw %0\n" | 139 | | "movw %0, %3\n" | 140 | | "andw $0xf3ff, %3\n" | 141 | | "orw $0x0800, %3\n" | 142 | | "movw %3, %1\n" // round up | 143 | | "fldcw %1\n" | 144 | | "fistl %2\n" | 145 | | "fldcw %0\n" | 146 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 147 | | : "t" (x)); | 148 | | return result; | 149 | | | 150 | | #elif defined(_WIN32) && defined(_M_IX86) | 151 | | | 152 | | //--- x87 inline assembly (VC) | 153 | | | 154 | | // ceil() and (int)() are implemented separately, which results | 155 | | // in changing the FPCW multiple times - so we optimize it with | 156 | | // some inline assembly | 157 | | Gushort oldCW, newCW; | 158 | | int result; | 159 | | | 160 | | __asm fld QWORD PTR x | 161 | | __asm fnstcw WORD PTR oldCW | 162 | | __asm mov ax, WORD PTR oldCW | 163 | | __asm and ax, 0xf3ff | 164 | | __asm or ax, 0x0800 | 165 | | __asm mov WORD PTR newCW, ax // round up | 166 | | __asm fldcw WORD PTR newCW | 167 | | __asm fistp DWORD PTR result | 168 | | __asm fldcw WORD PTR oldCW | 169 | | return result; | 170 | | | 171 | | #else | 172 | | | 173 | | //--- all others | 174 | | | 175 | | return (int)ceil(x); | 176 | | | 177 | | #endif | 178 | 234 | } |
SplashClip.cc:splashCeil(double) Line | Count | Source | 108 | 152k | static inline int splashCeil(SplashCoord x) { | 109 | | #if USE_FIXEDPOINT | 110 | | | 111 | | //--- fixed point | 112 | | | 113 | | return FixedPoint::ceil(x); | 114 | | | 115 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 116 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 117 | | | 118 | | //--- SSE2 intrinsics | 119 | | // NB: 64-bit x86 guarantees availability of SSE2. | 120 | | | 121 | 152k | __m128d m1, m2; | 122 | 152k | int i, s; | 123 | | | 124 | 152k | m1 = _mm_set_sd(x); | 125 | 152k | i = _mm_cvttsd_si32(m1); | 126 | 152k | m2 = _mm_cvtsi32_sd(m1, i); | 127 | 152k | s = _mm_ucomilt_sd(m2, m1); | 128 | 152k | return i + s; | 129 | | | 130 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 131 | | | 132 | | //--- x87 inline assembly (gcc/clang) | 133 | | // (this code fails on OSX for reasons I don't understand) | 134 | | | 135 | | Gushort oldCW, newCW, t; | 136 | | int result; | 137 | | | 138 | | __asm__ volatile("fnstcw %0\n" | 139 | | "movw %0, %3\n" | 140 | | "andw $0xf3ff, %3\n" | 141 | | "orw $0x0800, %3\n" | 142 | | "movw %3, %1\n" // round up | 143 | | "fldcw %1\n" | 144 | | "fistl %2\n" | 145 | | "fldcw %0\n" | 146 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 147 | | : "t" (x)); | 148 | | return result; | 149 | | | 150 | | #elif defined(_WIN32) && defined(_M_IX86) | 151 | | | 152 | | //--- x87 inline assembly (VC) | 153 | | | 154 | | // ceil() and (int)() are implemented separately, which results | 155 | | // in changing the FPCW multiple times - so we optimize it with | 156 | | // some inline assembly | 157 | | Gushort oldCW, newCW; | 158 | | int result; | 159 | | | 160 | | __asm fld QWORD PTR x | 161 | | __asm fnstcw WORD PTR oldCW | 162 | | __asm mov ax, WORD PTR oldCW | 163 | | __asm and ax, 0xf3ff | 164 | | __asm or ax, 0x0800 | 165 | | __asm mov WORD PTR newCW, ax // round up | 166 | | __asm fldcw WORD PTR newCW | 167 | | __asm fistp DWORD PTR result | 168 | | __asm fldcw WORD PTR oldCW | 169 | | return result; | 170 | | | 171 | | #else | 172 | | | 173 | | //--- all others | 174 | | | 175 | | return (int)ceil(x); | 176 | | | 177 | | #endif | 178 | 152k | } |
Unexecuted instantiation: SplashFontEngine.cc:splashCeil(double) Unexecuted instantiation: SplashPattern.cc:splashCeil(double) Unexecuted instantiation: SplashState.cc:splashCeil(double) Unexecuted instantiation: SplashXPath.cc:splashCeil(double) SplashXPathScanner.cc:splashCeil(double) Line | Count | Source | 108 | 20.2k | static inline int splashCeil(SplashCoord x) { | 109 | | #if USE_FIXEDPOINT | 110 | | | 111 | | //--- fixed point | 112 | | | 113 | | return FixedPoint::ceil(x); | 114 | | | 115 | | #elif (defined(__GNUC__) && defined(__SSE2__)) || \ | 116 | | (defined(_WIN32) && (_M_IX86_FP == 2 || defined(_M_X64))) | 117 | | | 118 | | //--- SSE2 intrinsics | 119 | | // NB: 64-bit x86 guarantees availability of SSE2. | 120 | | | 121 | 20.2k | __m128d m1, m2; | 122 | 20.2k | int i, s; | 123 | | | 124 | 20.2k | m1 = _mm_set_sd(x); | 125 | 20.2k | i = _mm_cvttsd_si32(m1); | 126 | 20.2k | m2 = _mm_cvtsi32_sd(m1, i); | 127 | 20.2k | s = _mm_ucomilt_sd(m2, m1); | 128 | 20.2k | return i + s; | 129 | | | 130 | | #elif defined(__GNUC__) && defined(__i386__) && !defined(__APPLE__) | 131 | | | 132 | | //--- x87 inline assembly (gcc/clang) | 133 | | // (this code fails on OSX for reasons I don't understand) | 134 | | | 135 | | Gushort oldCW, newCW, t; | 136 | | int result; | 137 | | | 138 | | __asm__ volatile("fnstcw %0\n" | 139 | | "movw %0, %3\n" | 140 | | "andw $0xf3ff, %3\n" | 141 | | "orw $0x0800, %3\n" | 142 | | "movw %3, %1\n" // round up | 143 | | "fldcw %1\n" | 144 | | "fistl %2\n" | 145 | | "fldcw %0\n" | 146 | | : "=m" (oldCW), "=m" (newCW), "=m" (result), "=r" (t) | 147 | | : "t" (x)); | 148 | | return result; | 149 | | | 150 | | #elif defined(_WIN32) && defined(_M_IX86) | 151 | | | 152 | | //--- x87 inline assembly (VC) | 153 | | | 154 | | // ceil() and (int)() are implemented separately, which results | 155 | | // in changing the FPCW multiple times - so we optimize it with | 156 | | // some inline assembly | 157 | | Gushort oldCW, newCW; | 158 | | int result; | 159 | | | 160 | | __asm fld QWORD PTR x | 161 | | __asm fnstcw WORD PTR oldCW | 162 | | __asm mov ax, WORD PTR oldCW | 163 | | __asm and ax, 0xf3ff | 164 | | __asm or ax, 0x0800 | 165 | | __asm mov WORD PTR newCW, ax // round up | 166 | | __asm fldcw WORD PTR newCW | 167 | | __asm fistp DWORD PTR result | 168 | | __asm fldcw WORD PTR oldCW | 169 | | return result; | 170 | | | 171 | | #else | 172 | | | 173 | | //--- all others | 174 | | | 175 | | return (int)ceil(x); | 176 | | | 177 | | #endif | 178 | 20.2k | } |
Unexecuted instantiation: ShadingImage.cc:splashCeil(double) Unexecuted instantiation: SplashFTFontFile.cc:splashCeil(double) Unexecuted instantiation: SplashFont.cc:splashCeil(double) Unexecuted instantiation: SplashScreen.cc:splashCeil(double) Unexecuted instantiation: SplashFTFont.cc:splashCeil(double) |
179 | | |
180 | 49.7M | static inline int splashRound(SplashCoord x) { |
181 | | #if USE_FIXEDPOINT |
182 | | |
183 | | //--- fixed point |
184 | | |
185 | | return FixedPoint::round(x); |
186 | | |
187 | | #else |
188 | | |
189 | | //--- all others |
190 | | |
191 | 49.7M | return splashFloor(x + 0.5); |
192 | | |
193 | 49.7M | #endif |
194 | 49.7M | } Unexecuted instantiation: fuzz_pdfload.cc:splashRound(double) Unexecuted instantiation: SplashOutputDev.cc:splashRound(double) Splash.cc:splashRound(double) Line | Count | Source | 180 | 355k | static inline int splashRound(SplashCoord x) { | 181 | | #if USE_FIXEDPOINT | 182 | | | 183 | | //--- fixed point | 184 | | | 185 | | return FixedPoint::round(x); | 186 | | | 187 | | #else | 188 | | | 189 | | //--- all others | 190 | | | 191 | 355k | return splashFloor(x + 0.5); | 192 | | | 193 | 355k | #endif | 194 | 355k | } |
SplashClip.cc:splashRound(double) Line | Count | Source | 180 | 53.9k | static inline int splashRound(SplashCoord x) { | 181 | | #if USE_FIXEDPOINT | 182 | | | 183 | | //--- fixed point | 184 | | | 185 | | return FixedPoint::round(x); | 186 | | | 187 | | #else | 188 | | | 189 | | //--- all others | 190 | | | 191 | 53.9k | return splashFloor(x + 0.5); | 192 | | | 193 | 53.9k | #endif | 194 | 53.9k | } |
Unexecuted instantiation: SplashFontEngine.cc:splashRound(double) Unexecuted instantiation: SplashPattern.cc:splashRound(double) Unexecuted instantiation: SplashState.cc:splashRound(double) SplashXPath.cc:splashRound(double) Line | Count | Source | 180 | 31.6M | static inline int splashRound(SplashCoord x) { | 181 | | #if USE_FIXEDPOINT | 182 | | | 183 | | //--- fixed point | 184 | | | 185 | | return FixedPoint::round(x); | 186 | | | 187 | | #else | 188 | | | 189 | | //--- all others | 190 | | | 191 | 31.6M | return splashFloor(x + 0.5); | 192 | | | 193 | 31.6M | #endif | 194 | 31.6M | } |
Unexecuted instantiation: SplashXPathScanner.cc:splashRound(double) Unexecuted instantiation: ShadingImage.cc:splashRound(double) Unexecuted instantiation: SplashFTFontFile.cc:splashRound(double) Unexecuted instantiation: SplashFont.cc:splashRound(double) SplashScreen.cc:splashRound(double) Line | Count | Source | 180 | 17.7M | static inline int splashRound(SplashCoord x) { | 181 | | #if USE_FIXEDPOINT | 182 | | | 183 | | //--- fixed point | 184 | | | 185 | | return FixedPoint::round(x); | 186 | | | 187 | | #else | 188 | | | 189 | | //--- all others | 190 | | | 191 | 17.7M | return splashFloor(x + 0.5); | 192 | | | 193 | 17.7M | #endif | 194 | 17.7M | } |
SplashFTFont.cc:splashRound(double) Line | Count | Source | 180 | 2.57k | static inline int splashRound(SplashCoord x) { | 181 | | #if USE_FIXEDPOINT | 182 | | | 183 | | //--- fixed point | 184 | | | 185 | | return FixedPoint::round(x); | 186 | | | 187 | | #else | 188 | | | 189 | | //--- all others | 190 | | | 191 | 2.57k | return splashFloor(x + 0.5); | 192 | | | 193 | 2.57k | #endif | 194 | 2.57k | } |
|
195 | | |
196 | 95.3M | static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) { |
197 | | #if USE_FIXEDPOINT |
198 | | return FixedPoint::avg(x, y); |
199 | | #else |
200 | 95.3M | return 0.5 * (x + y); |
201 | 95.3M | #endif |
202 | 95.3M | } Unexecuted instantiation: fuzz_pdfload.cc:splashAvg(double, double) Unexecuted instantiation: SplashOutputDev.cc:splashAvg(double, double) Splash.cc:splashAvg(double, double) Line | Count | Source | 196 | 95.3M | static inline SplashCoord splashAvg(SplashCoord x, SplashCoord y) { | 197 | | #if USE_FIXEDPOINT | 198 | | return FixedPoint::avg(x, y); | 199 | | #else | 200 | 95.3M | return 0.5 * (x + y); | 201 | 95.3M | #endif | 202 | 95.3M | } |
Unexecuted instantiation: SplashClip.cc:splashAvg(double, double) Unexecuted instantiation: SplashFontEngine.cc:splashAvg(double, double) Unexecuted instantiation: SplashPattern.cc:splashAvg(double, double) Unexecuted instantiation: SplashState.cc:splashAvg(double, double) Unexecuted instantiation: SplashXPath.cc:splashAvg(double, double) Unexecuted instantiation: SplashXPathScanner.cc:splashAvg(double, double) Unexecuted instantiation: ShadingImage.cc:splashAvg(double, double) Unexecuted instantiation: SplashFTFontFile.cc:splashAvg(double, double) Unexecuted instantiation: SplashFont.cc:splashAvg(double, double) Unexecuted instantiation: SplashScreen.cc:splashAvg(double, double) Unexecuted instantiation: SplashFTFont.cc:splashAvg(double, double) |
203 | | |
204 | 10.7M | static inline SplashCoord splashSqrt(SplashCoord x) { |
205 | | #if USE_FIXEDPOINT |
206 | | return FixedPoint::sqrt(x); |
207 | | #else |
208 | 10.7M | return sqrt(x); |
209 | 10.7M | #endif |
210 | 10.7M | } Unexecuted instantiation: fuzz_pdfload.cc:splashSqrt(double) Unexecuted instantiation: SplashOutputDev.cc:splashSqrt(double) Splash.cc:splashSqrt(double) Line | Count | Source | 204 | 10.7M | static inline SplashCoord splashSqrt(SplashCoord x) { | 205 | | #if USE_FIXEDPOINT | 206 | | return FixedPoint::sqrt(x); | 207 | | #else | 208 | 10.7M | return sqrt(x); | 209 | 10.7M | #endif | 210 | 10.7M | } |
Unexecuted instantiation: SplashClip.cc:splashSqrt(double) Unexecuted instantiation: SplashFontEngine.cc:splashSqrt(double) Unexecuted instantiation: SplashPattern.cc:splashSqrt(double) Unexecuted instantiation: SplashState.cc:splashSqrt(double) Unexecuted instantiation: SplashXPath.cc:splashSqrt(double) Unexecuted instantiation: SplashXPathScanner.cc:splashSqrt(double) Unexecuted instantiation: ShadingImage.cc:splashSqrt(double) Unexecuted instantiation: SplashFTFontFile.cc:splashSqrt(double) Unexecuted instantiation: SplashFont.cc:splashSqrt(double) Unexecuted instantiation: SplashScreen.cc:splashSqrt(double) Unexecuted instantiation: SplashFTFont.cc:splashSqrt(double) |
211 | | |
212 | 17.2M | static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { |
213 | | #if USE_FIXEDPOINT |
214 | | return FixedPoint::pow(x, y); |
215 | | #else |
216 | 17.2M | return pow(x, y); |
217 | 17.2M | #endif |
218 | 17.2M | } Unexecuted instantiation: fuzz_pdfload.cc:splashPow(double, double) Unexecuted instantiation: SplashOutputDev.cc:splashPow(double, double) Unexecuted instantiation: Splash.cc:splashPow(double, double) Unexecuted instantiation: SplashClip.cc:splashPow(double, double) Unexecuted instantiation: SplashFontEngine.cc:splashPow(double, double) Unexecuted instantiation: SplashPattern.cc:splashPow(double, double) Unexecuted instantiation: SplashState.cc:splashPow(double, double) Unexecuted instantiation: SplashXPath.cc:splashPow(double, double) Unexecuted instantiation: SplashXPathScanner.cc:splashPow(double, double) Unexecuted instantiation: ShadingImage.cc:splashPow(double, double) Unexecuted instantiation: SplashFTFontFile.cc:splashPow(double, double) Unexecuted instantiation: SplashFont.cc:splashPow(double, double) SplashScreen.cc:splashPow(double, double) Line | Count | Source | 212 | 17.2M | static inline SplashCoord splashPow(SplashCoord x, SplashCoord y) { | 213 | | #if USE_FIXEDPOINT | 214 | | return FixedPoint::pow(x, y); | 215 | | #else | 216 | 17.2M | return pow(x, y); | 217 | 17.2M | #endif | 218 | 17.2M | } |
Unexecuted instantiation: SplashFTFont.cc:splashPow(double, double) |
219 | | |
220 | | static inline SplashCoord splashDist(SplashCoord x0, SplashCoord y0, |
221 | 14.9M | SplashCoord x1, SplashCoord y1) { |
222 | 14.9M | SplashCoord dx, dy; |
223 | 14.9M | dx = x1 - x0; |
224 | 14.9M | dy = y1 - y0; |
225 | | #if USE_FIXEDPOINT |
226 | | // this handles the situation where dx*dx or dy*dy is too large to |
227 | | // fit in the 16.16 fixed point format |
228 | | SplashCoord dxa, dya, d; |
229 | | dxa = splashAbs(dx); |
230 | | dya = splashAbs(dy); |
231 | | if (dxa == 0 && dya == 0) { |
232 | | return 0; |
233 | | } else if (dxa > dya) { |
234 | | d = dya / dxa; |
235 | | return dxa * FixedPoint::sqrt(d*d + 1); |
236 | | } else { |
237 | | d = dxa / dya; |
238 | | return dya * FixedPoint::sqrt(d*d + 1); |
239 | | } |
240 | | #else |
241 | 14.9M | return sqrt(dx * dx + dy * dy); |
242 | 14.9M | #endif |
243 | 14.9M | } Unexecuted instantiation: fuzz_pdfload.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashOutputDev.cc:splashDist(double, double, double, double) Splash.cc:splashDist(double, double, double, double) Line | Count | Source | 221 | 14.9M | SplashCoord x1, SplashCoord y1) { | 222 | 14.9M | SplashCoord dx, dy; | 223 | 14.9M | dx = x1 - x0; | 224 | 14.9M | dy = y1 - y0; | 225 | | #if USE_FIXEDPOINT | 226 | | // this handles the situation where dx*dx or dy*dy is too large to | 227 | | // fit in the 16.16 fixed point format | 228 | | SplashCoord dxa, dya, d; | 229 | | dxa = splashAbs(dx); | 230 | | dya = splashAbs(dy); | 231 | | if (dxa == 0 && dya == 0) { | 232 | | return 0; | 233 | | } else if (dxa > dya) { | 234 | | d = dya / dxa; | 235 | | return dxa * FixedPoint::sqrt(d*d + 1); | 236 | | } else { | 237 | | d = dxa / dya; | 238 | | return dya * FixedPoint::sqrt(d*d + 1); | 239 | | } | 240 | | #else | 241 | 14.9M | return sqrt(dx * dx + dy * dy); | 242 | 14.9M | #endif | 243 | 14.9M | } |
Unexecuted instantiation: SplashClip.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashFontEngine.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashPattern.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashState.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashXPath.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashXPathScanner.cc:splashDist(double, double, double, double) Unexecuted instantiation: ShadingImage.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashFTFontFile.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashFont.cc:splashDist(double, double, double, double) Unexecuted instantiation: SplashScreen.cc:splashDist(double, double, double, double) SplashFTFont.cc:splashDist(double, double, double, double) Line | Count | Source | 221 | 5.14k | SplashCoord x1, SplashCoord y1) { | 222 | 5.14k | SplashCoord dx, dy; | 223 | 5.14k | dx = x1 - x0; | 224 | 5.14k | dy = y1 - y0; | 225 | | #if USE_FIXEDPOINT | 226 | | // this handles the situation where dx*dx or dy*dy is too large to | 227 | | // fit in the 16.16 fixed point format | 228 | | SplashCoord dxa, dya, d; | 229 | | dxa = splashAbs(dx); | 230 | | dya = splashAbs(dy); | 231 | | if (dxa == 0 && dya == 0) { | 232 | | return 0; | 233 | | } else if (dxa > dya) { | 234 | | d = dya / dxa; | 235 | | return dxa * FixedPoint::sqrt(d*d + 1); | 236 | | } else { | 237 | | d = dxa / dya; | 238 | | return dya * FixedPoint::sqrt(d*d + 1); | 239 | | } | 240 | | #else | 241 | 5.14k | return sqrt(dx * dx + dy * dy); | 242 | 5.14k | #endif | 243 | 5.14k | } |
|
244 | | |
245 | | static inline GBool splashCheckDet(SplashCoord m11, SplashCoord m12, |
246 | | SplashCoord m21, SplashCoord m22, |
247 | 83.5k | SplashCoord epsilon) { |
248 | | #if USE_FIXEDPOINT |
249 | | return FixedPoint::checkDet(m11, m12, m21, m22, epsilon); |
250 | | #else |
251 | 83.5k | return fabs(m11 * m22 - m12 * m21) >= epsilon; |
252 | 83.5k | #endif |
253 | 83.5k | } Unexecuted instantiation: fuzz_pdfload.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashOutputDev.cc:splashCheckDet(double, double, double, double, double) Splash.cc:splashCheckDet(double, double, double, double, double) Line | Count | Source | 247 | 68.4k | SplashCoord epsilon) { | 248 | | #if USE_FIXEDPOINT | 249 | | return FixedPoint::checkDet(m11, m12, m21, m22, epsilon); | 250 | | #else | 251 | 68.4k | return fabs(m11 * m22 - m12 * m21) >= epsilon; | 252 | 68.4k | #endif | 253 | 68.4k | } |
Unexecuted instantiation: SplashClip.cc:splashCheckDet(double, double, double, double, double) SplashFontEngine.cc:splashCheckDet(double, double, double, double, double) Line | Count | Source | 247 | 15.1k | SplashCoord epsilon) { | 248 | | #if USE_FIXEDPOINT | 249 | | return FixedPoint::checkDet(m11, m12, m21, m22, epsilon); | 250 | | #else | 251 | 15.1k | return fabs(m11 * m22 - m12 * m21) >= epsilon; | 252 | 15.1k | #endif | 253 | 15.1k | } |
Unexecuted instantiation: SplashPattern.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashState.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashXPath.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashXPathScanner.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: ShadingImage.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashFTFontFile.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashFont.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashScreen.cc:splashCheckDet(double, double, double, double, double) Unexecuted instantiation: SplashFTFont.cc:splashCheckDet(double, double, double, double, double) |
254 | | |
255 | | // Perform stroke adjustment on a SplashCoord range [xMin, xMax), |
256 | | // resulting in an int range [*xMinI, *xMaxI). |
257 | | // |
258 | | // There are several options: |
259 | | // |
260 | | // 1. Round both edge coordinates. |
261 | | // Pro: adjacent strokes/fills line up without any gaps or |
262 | | // overlaps |
263 | | // Con: lines with the same original floating point width can |
264 | | // end up with different integer widths, e.g.: |
265 | | // xMin = 10.1 xMax = 11.3 (width = 1.2) |
266 | | // --> xMinI = 10 xMaxI = 11 (width = 1) |
267 | | // but |
268 | | // xMin = 10.4 xMax = 11.6 (width = 1.2) |
269 | | // --> xMinI = 10 xMaxI = 12 (width = 2) |
270 | | // |
271 | | // 2. Round the min coordinate; add the ceiling of the width. |
272 | | // Pro: lines with the same original floating point width will |
273 | | // always end up with the same integer width |
274 | | // Con: adjacent strokes/fills can have overlaps (which is |
275 | | // problematic with transparency) |
276 | | // (This could use floor on the min coordinate, instead of |
277 | | // rounding, with similar results.) |
278 | | // (If the width is rounded instead of using ceiling, the results |
279 | | // Are similar, except that adjacent strokes/fills can have gaps |
280 | | // as well as overlaps.) |
281 | | // |
282 | | // 3. Use floor on the min coordinate and ceiling on the max |
283 | | // coordinate. |
284 | | // Pro: lines always end up at least as wide as the original |
285 | | // floating point width |
286 | | // Con: adjacent strokes/fills can have overlaps, and lines with |
287 | | // the same original floating point width can end up with |
288 | | // different integer widths; the integer width can be more |
289 | | // than one pixel wider than the original width, e.g.: |
290 | | // xMin = 10.9 xMax = 12.1 (width = 1.2) |
291 | | // --> xMinI = 10 xMaxI = 13 (width = 3) |
292 | | // but |
293 | | // xMin = 10.1 xMax = 11.3 (width = 1.2) |
294 | | // --> xMinI = 10 xMaxI = 12 (width = 2) |
295 | | // |
296 | | // 4. Use a hybrid approach, choosing between two of the above |
297 | | // options, based on width. E.g., use #2 if width <= 4, and use #1 |
298 | | // if width > 4. |
299 | | // |
300 | | // If w >= 0 and strokeAdjMode is splashStrokeAdjustCAD then a special |
301 | | // mode for projecting line caps is enabled, with w being the |
302 | | // transformed line width. |
303 | | |
304 | | static inline void splashStrokeAdjust(SplashCoord xMin, SplashCoord xMax, |
305 | | int *xMinI, int *xMaxI, |
306 | | SplashStrokeAdjustMode strokeAdjMode, |
307 | 15.9M | SplashCoord w = -1) { |
308 | 15.9M | int x0, x1; |
309 | | |
310 | | // make sure the coords fit in 32-bit ints |
311 | | #if USE_FIXEDPOINT |
312 | | if (xMin < -32767) { |
313 | | xMin = -32767; |
314 | | } else if (xMin > 32767) { |
315 | | xMin = 32767; |
316 | | } |
317 | | if (xMax < -32767) { |
318 | | xMax = -32767; |
319 | | } else if (xMax > 32767) { |
320 | | xMax = 32767; |
321 | | } |
322 | | #else |
323 | 15.9M | if (xMin < -1e9) { |
324 | 32.5k | xMin = -1e9; |
325 | 15.9M | } else if (xMin > 1e9) { |
326 | 24.1k | xMin = 1e9; |
327 | 24.1k | } |
328 | 15.9M | if (xMax < -1e9) { |
329 | 23.7k | xMax = -1e9; |
330 | 15.9M | } else if (xMax > 1e9) { |
331 | 48.7k | xMax = 1e9; |
332 | 48.7k | } |
333 | 15.9M | #endif |
334 | | |
335 | | // this will never be called with strokeAdjMode == splashStrokeAdjustOff |
336 | 15.9M | if (strokeAdjMode == splashStrokeAdjustCAD) { |
337 | 0 | x0 = splashRound(xMin); |
338 | 0 | if (w >= 0) { |
339 | 0 | x1 = splashRound(xMax - w) + splashRound(w); |
340 | 0 | } else { |
341 | 0 | x1 = x0 + splashRound(xMax - xMin); |
342 | 0 | } |
343 | 15.9M | } else { |
344 | | // NB: enable exactly one of these. |
345 | 15.9M | #if 1 // 1. Round both edge coordinates. |
346 | 15.9M | x0 = splashRound(xMin); |
347 | 15.9M | x1 = splashRound(xMax); |
348 | 15.9M | #endif |
349 | | #if 0 // 2. Round the min coordinate; add the ceiling of the width. |
350 | | x0 = splashRound(xMin); |
351 | | x1 = x0 + splashCeil(xMax - xMin); |
352 | | #endif |
353 | | #if 0 // 3. Use floor on the min coord and ceiling on the max coord. |
354 | | x0 = splashFloor(xMin); |
355 | | x1 = splashCeil(xMax); |
356 | | #endif |
357 | | #if 0 // 4. Hybrid. |
358 | | SplashCoord w = xMax - xMin; |
359 | | x0 = splashRound(xMin); |
360 | | if (w > 4) { |
361 | | x1 = splashRound(xMax); |
362 | | } else { |
363 | | x1 = x0 + splashRound(w); |
364 | | } |
365 | | #endif |
366 | 15.9M | } |
367 | 15.9M | if (x0 == x1) { |
368 | 15.1M | if (xMin + xMax < 2 * x0) { |
369 | 28 | --x0; |
370 | 15.1M | } else { |
371 | 15.1M | ++x1; |
372 | 15.1M | } |
373 | 15.1M | } |
374 | 15.9M | *xMinI = x0; |
375 | 15.9M | *xMaxI = x1; |
376 | 15.9M | } Unexecuted instantiation: fuzz_pdfload.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashOutputDev.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Splash.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Line | Count | Source | 307 | 83.6k | SplashCoord w = -1) { | 308 | 83.6k | int x0, x1; | 309 | | | 310 | | // make sure the coords fit in 32-bit ints | 311 | | #if USE_FIXEDPOINT | 312 | | if (xMin < -32767) { | 313 | | xMin = -32767; | 314 | | } else if (xMin > 32767) { | 315 | | xMin = 32767; | 316 | | } | 317 | | if (xMax < -32767) { | 318 | | xMax = -32767; | 319 | | } else if (xMax > 32767) { | 320 | | xMax = 32767; | 321 | | } | 322 | | #else | 323 | 83.6k | if (xMin < -1e9) { | 324 | 32.5k | xMin = -1e9; | 325 | 51.0k | } else if (xMin > 1e9) { | 326 | 24.1k | xMin = 1e9; | 327 | 24.1k | } | 328 | 83.6k | if (xMax < -1e9) { | 329 | 23.7k | xMax = -1e9; | 330 | 59.8k | } else if (xMax > 1e9) { | 331 | 48.7k | xMax = 1e9; | 332 | 48.7k | } | 333 | 83.6k | #endif | 334 | | | 335 | | // this will never be called with strokeAdjMode == splashStrokeAdjustOff | 336 | 83.6k | if (strokeAdjMode == splashStrokeAdjustCAD) { | 337 | 0 | x0 = splashRound(xMin); | 338 | 0 | if (w >= 0) { | 339 | 0 | x1 = splashRound(xMax - w) + splashRound(w); | 340 | 0 | } else { | 341 | 0 | x1 = x0 + splashRound(xMax - xMin); | 342 | 0 | } | 343 | 83.6k | } else { | 344 | | // NB: enable exactly one of these. | 345 | 83.6k | #if 1 // 1. Round both edge coordinates. | 346 | 83.6k | x0 = splashRound(xMin); | 347 | 83.6k | x1 = splashRound(xMax); | 348 | 83.6k | #endif | 349 | | #if 0 // 2. Round the min coordinate; add the ceiling of the width. | 350 | | x0 = splashRound(xMin); | 351 | | x1 = x0 + splashCeil(xMax - xMin); | 352 | | #endif | 353 | | #if 0 // 3. Use floor on the min coord and ceiling on the max coord. | 354 | | x0 = splashFloor(xMin); | 355 | | x1 = splashCeil(xMax); | 356 | | #endif | 357 | | #if 0 // 4. Hybrid. | 358 | | SplashCoord w = xMax - xMin; | 359 | | x0 = splashRound(xMin); | 360 | | if (w > 4) { | 361 | | x1 = splashRound(xMax); | 362 | | } else { | 363 | | x1 = x0 + splashRound(w); | 364 | | } | 365 | | #endif | 366 | 83.6k | } | 367 | 83.6k | if (x0 == x1) { | 368 | 50.5k | if (xMin + xMax < 2 * x0) { | 369 | 28 | --x0; | 370 | 50.5k | } else { | 371 | 50.5k | ++x1; | 372 | 50.5k | } | 373 | 50.5k | } | 374 | 83.6k | *xMinI = x0; | 375 | 83.6k | *xMaxI = x1; | 376 | 83.6k | } |
SplashClip.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Line | Count | Source | 307 | 26.9k | SplashCoord w = -1) { | 308 | 26.9k | int x0, x1; | 309 | | | 310 | | // make sure the coords fit in 32-bit ints | 311 | | #if USE_FIXEDPOINT | 312 | | if (xMin < -32767) { | 313 | | xMin = -32767; | 314 | | } else if (xMin > 32767) { | 315 | | xMin = 32767; | 316 | | } | 317 | | if (xMax < -32767) { | 318 | | xMax = -32767; | 319 | | } else if (xMax > 32767) { | 320 | | xMax = 32767; | 321 | | } | 322 | | #else | 323 | 26.9k | if (xMin < -1e9) { | 324 | 0 | xMin = -1e9; | 325 | 26.9k | } else if (xMin > 1e9) { | 326 | 0 | xMin = 1e9; | 327 | 0 | } | 328 | 26.9k | if (xMax < -1e9) { | 329 | 0 | xMax = -1e9; | 330 | 26.9k | } else if (xMax > 1e9) { | 331 | 0 | xMax = 1e9; | 332 | 0 | } | 333 | 26.9k | #endif | 334 | | | 335 | | // this will never be called with strokeAdjMode == splashStrokeAdjustOff | 336 | 26.9k | if (strokeAdjMode == splashStrokeAdjustCAD) { | 337 | 0 | x0 = splashRound(xMin); | 338 | 0 | if (w >= 0) { | 339 | 0 | x1 = splashRound(xMax - w) + splashRound(w); | 340 | 0 | } else { | 341 | 0 | x1 = x0 + splashRound(xMax - xMin); | 342 | 0 | } | 343 | 26.9k | } else { | 344 | | // NB: enable exactly one of these. | 345 | 26.9k | #if 1 // 1. Round both edge coordinates. | 346 | 26.9k | x0 = splashRound(xMin); | 347 | 26.9k | x1 = splashRound(xMax); | 348 | 26.9k | #endif | 349 | | #if 0 // 2. Round the min coordinate; add the ceiling of the width. | 350 | | x0 = splashRound(xMin); | 351 | | x1 = x0 + splashCeil(xMax - xMin); | 352 | | #endif | 353 | | #if 0 // 3. Use floor on the min coord and ceiling on the max coord. | 354 | | x0 = splashFloor(xMin); | 355 | | x1 = splashCeil(xMax); | 356 | | #endif | 357 | | #if 0 // 4. Hybrid. | 358 | | SplashCoord w = xMax - xMin; | 359 | | x0 = splashRound(xMin); | 360 | | if (w > 4) { | 361 | | x1 = splashRound(xMax); | 362 | | } else { | 363 | | x1 = x0 + splashRound(w); | 364 | | } | 365 | | #endif | 366 | 26.9k | } | 367 | 26.9k | if (x0 == x1) { | 368 | 2.22k | if (xMin + xMax < 2 * x0) { | 369 | 0 | --x0; | 370 | 2.22k | } else { | 371 | 2.22k | ++x1; | 372 | 2.22k | } | 373 | 2.22k | } | 374 | 26.9k | *xMinI = x0; | 375 | 26.9k | *xMaxI = x1; | 376 | 26.9k | } |
Unexecuted instantiation: SplashFontEngine.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashPattern.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashState.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) SplashXPath.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Line | Count | Source | 307 | 15.8M | SplashCoord w = -1) { | 308 | 15.8M | int x0, x1; | 309 | | | 310 | | // make sure the coords fit in 32-bit ints | 311 | | #if USE_FIXEDPOINT | 312 | | if (xMin < -32767) { | 313 | | xMin = -32767; | 314 | | } else if (xMin > 32767) { | 315 | | xMin = 32767; | 316 | | } | 317 | | if (xMax < -32767) { | 318 | | xMax = -32767; | 319 | | } else if (xMax > 32767) { | 320 | | xMax = 32767; | 321 | | } | 322 | | #else | 323 | 15.8M | if (xMin < -1e9) { | 324 | 0 | xMin = -1e9; | 325 | 15.8M | } else if (xMin > 1e9) { | 326 | 0 | xMin = 1e9; | 327 | 0 | } | 328 | 15.8M | if (xMax < -1e9) { | 329 | 0 | xMax = -1e9; | 330 | 15.8M | } else if (xMax > 1e9) { | 331 | 0 | xMax = 1e9; | 332 | 0 | } | 333 | 15.8M | #endif | 334 | | | 335 | | // this will never be called with strokeAdjMode == splashStrokeAdjustOff | 336 | 15.8M | if (strokeAdjMode == splashStrokeAdjustCAD) { | 337 | 0 | x0 = splashRound(xMin); | 338 | 0 | if (w >= 0) { | 339 | 0 | x1 = splashRound(xMax - w) + splashRound(w); | 340 | 0 | } else { | 341 | 0 | x1 = x0 + splashRound(xMax - xMin); | 342 | 0 | } | 343 | 15.8M | } else { | 344 | | // NB: enable exactly one of these. | 345 | 15.8M | #if 1 // 1. Round both edge coordinates. | 346 | 15.8M | x0 = splashRound(xMin); | 347 | 15.8M | x1 = splashRound(xMax); | 348 | 15.8M | #endif | 349 | | #if 0 // 2. Round the min coordinate; add the ceiling of the width. | 350 | | x0 = splashRound(xMin); | 351 | | x1 = x0 + splashCeil(xMax - xMin); | 352 | | #endif | 353 | | #if 0 // 3. Use floor on the min coord and ceiling on the max coord. | 354 | | x0 = splashFloor(xMin); | 355 | | x1 = splashCeil(xMax); | 356 | | #endif | 357 | | #if 0 // 4. Hybrid. | 358 | | SplashCoord w = xMax - xMin; | 359 | | x0 = splashRound(xMin); | 360 | | if (w > 4) { | 361 | | x1 = splashRound(xMax); | 362 | | } else { | 363 | | x1 = x0 + splashRound(w); | 364 | | } | 365 | | #endif | 366 | 15.8M | } | 367 | 15.8M | if (x0 == x1) { | 368 | 15.1M | if (xMin + xMax < 2 * x0) { | 369 | 0 | --x0; | 370 | 15.1M | } else { | 371 | 15.1M | ++x1; | 372 | 15.1M | } | 373 | 15.1M | } | 374 | 15.8M | *xMinI = x0; | 375 | 15.8M | *xMaxI = x1; | 376 | 15.8M | } |
Unexecuted instantiation: SplashXPathScanner.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: ShadingImage.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashFTFontFile.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashFont.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashScreen.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) Unexecuted instantiation: SplashFTFont.cc:splashStrokeAdjust(double, double, int*, int*, SplashStrokeAdjustMode, double) |
377 | | |
378 | | #endif |