gfx/skia/patches/archive/arm-fixes.patch

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 diff --git a/gfx/skia/include/core/SkMath.h b/gfx/skia/include/core/SkMath.h
michael@0 2 --- a/gfx/skia/include/core/SkMath.h
michael@0 3 +++ b/gfx/skia/include/core/SkMath.h
michael@0 4 @@ -148,20 +148,17 @@ static inline bool SkIsPow2(int value) {
michael@0 5 }
michael@0 6
michael@0 7 ///////////////////////////////////////////////////////////////////////////////
michael@0 8
michael@0 9 /** SkMulS16(a, b) multiplies a * b, but requires that a and b are both int16_t.
michael@0 10 With this requirement, we can generate faster instructions on some
michael@0 11 architectures.
michael@0 12 */
michael@0 13 -#if defined(__arm__) \
michael@0 14 - && !defined(__thumb__) \
michael@0 15 - && !defined(__ARM_ARCH_4T__) \
michael@0 16 - && !defined(__ARM_ARCH_5T__)
michael@0 17 +#ifdef SK_ARM_HAS_EDSP
michael@0 18 static inline int32_t SkMulS16(S16CPU x, S16CPU y) {
michael@0 19 SkASSERT((int16_t)x == x);
michael@0 20 SkASSERT((int16_t)y == y);
michael@0 21 int32_t product;
michael@0 22 asm("smulbb %0, %1, %2 \n"
michael@0 23 : "=r"(product)
michael@0 24 : "r"(x), "r"(y)
michael@0 25 );
michael@0 26 diff --git a/gfx/skia/include/core/SkPostConfig.h b/gfx/skia/include/core/SkPostConfig.h
michael@0 27 --- a/gfx/skia/include/core/SkPostConfig.h
michael@0 28 +++ b/gfx/skia/include/core/SkPostConfig.h
michael@0 29 @@ -300,8 +300,53 @@
michael@0 30 #endif
michael@0 31 #endif
michael@0 32
michael@0 33 //////////////////////////////////////////////////////////////////////
michael@0 34
michael@0 35 #ifndef SK_ALLOW_STATIC_GLOBAL_INITIALIZERS
michael@0 36 #define SK_ALLOW_STATIC_GLOBAL_INITIALIZERS 1
michael@0 37 #endif
michael@0 38 +
michael@0 39 +//////////////////////////////////////////////////////////////////////
michael@0 40 +// ARM defines
michael@0 41 +
michael@0 42 +#if defined(__GNUC__) && defined(__arm__)
michael@0 43 +
michael@0 44 +# define SK_ARM_ARCH 3
michael@0 45 +
michael@0 46 +# if defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) \
michael@0 47 + || defined(_ARM_ARCH_4)
michael@0 48 +# undef SK_ARM_ARCH
michael@0 49 +# define SK_ARM_ARCH 4
michael@0 50 +# endif
michael@0 51 +
michael@0 52 +# if defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5T__) \
michael@0 53 + || defined(__ARM_ARCH_5E__) || defined(__ARM_ARCH_5TE__) \
michael@0 54 + || defined(__ARM_ARCH_5TEJ__) || defined(_ARM_ARCH_5)
michael@0 55 +# undef SK_ARM_ARCH
michael@0 56 +# define SK_ARM_ARCH 5
michael@0 57 +# endif
michael@0 58 +
michael@0 59 +# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \
michael@0 60 + || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) \
michael@0 61 + || defined(__ARM_ARCH_6ZK__) || defined(__ARM_ARCH_6T2__) \
michael@0 62 + || defined(__ARM_ARCH_6M__) || defined(_ARM_ARCH_6)
michael@0 63 +# undef SK_ARM_ARCH
michael@0 64 +# define SK_ARM_ARCH 6
michael@0 65 +# endif
michael@0 66 +
michael@0 67 +# if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \
michael@0 68 + || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \
michael@0 69 + || defined(__ARM_ARCH_7EM__) || defined(_ARM_ARCH_7)
michael@0 70 +# undef SK_ARM_ARCH
michael@0 71 +# define SK_ARM_ARCH 7
michael@0 72 +# endif
michael@0 73 +
michael@0 74 +# undef SK_ARM_HAS_EDSP
michael@0 75 +# if defined(__thumb2__) && (SK_ARM_ARCH >= 6) \
michael@0 76 + || !defined(__thumb__) \
michael@0 77 + && ((SK_ARM_ARCH > 5) || defined(__ARM_ARCH_5E__) \
michael@0 78 + || defined(__ARM_ARCH_5TE__) || defined(__ARM_ARCH_5TEJ__))
michael@0 79 +# define SK_ARM_HAS_EDSP 1
michael@0 80 +# endif
michael@0 81 +
michael@0 82 +#endif
michael@0 83 diff --git a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
michael@0 84 --- a/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
michael@0 85 +++ b/gfx/skia/src/opts/SkBitmapProcState_opts_arm.cpp
michael@0 86 @@ -6,17 +6,17 @@
michael@0 87 * found in the LICENSE file.
michael@0 88 */
michael@0 89
michael@0 90
michael@0 91 #include "SkBitmapProcState.h"
michael@0 92 #include "SkColorPriv.h"
michael@0 93 #include "SkUtils.h"
michael@0 94
michael@0 95 -#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 96 +#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 97 void SI8_D16_nofilter_DX_arm(
michael@0 98 const SkBitmapProcState& s,
michael@0 99 const uint32_t* SK_RESTRICT xy,
michael@0 100 int count,
michael@0 101 uint16_t* SK_RESTRICT colors) __attribute__((optimize("O1")));
michael@0 102
michael@0 103 void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
michael@0 104 const uint32_t* SK_RESTRICT xy,
michael@0 105 @@ -177,17 +177,17 @@ void SI8_opaque_D32_nofilter_DX_arm(cons
michael@0 106 : [xx] "+r" (xx), [count] "+r" (count), [colors] "+r" (colors)
michael@0 107 : [table] "r" (table), [srcAddr] "r" (srcAddr)
michael@0 108 : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11"
michael@0 109 );
michael@0 110 }
michael@0 111
michael@0 112 s.fBitmap->getColorTable()->unlockColors(false);
michael@0 113 }
michael@0 114 -#endif //__ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 115 +#endif // SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 116
michael@0 117 ///////////////////////////////////////////////////////////////////////////////
michael@0 118
michael@0 119 /* If we replace a sampleproc, then we null-out the associated shaderproc,
michael@0 120 otherwise the shader won't even look at the matrix/sampler
michael@0 121 */
michael@0 122 void SkBitmapProcState::platformProcs() {
michael@0 123 bool doFilter = fDoFilter;
michael@0 124 @@ -195,17 +195,17 @@ void SkBitmapProcState::platformProcs()
michael@0 125 bool justDx = false;
michael@0 126
michael@0 127 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
michael@0 128 justDx = true;
michael@0 129 }
michael@0 130
michael@0 131 switch (fBitmap->config()) {
michael@0 132 case SkBitmap::kIndex8_Config:
michael@0 133 -#if __ARM_ARCH__ >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 134 +#if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 135 if (justDx && !doFilter) {
michael@0 136 #if 0 /* crashing on android device */
michael@0 137 fSampleProc16 = SI8_D16_nofilter_DX_arm;
michael@0 138 fShaderProc16 = NULL;
michael@0 139 #endif
michael@0 140 if (isOpaque) {
michael@0 141 // this one is only very slighty faster than the C version
michael@0 142 fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm;
michael@0 143 diff --git a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
michael@0 144 --- a/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
michael@0 145 +++ b/gfx/skia/src/opts/SkBlitRow_opts_arm.cpp
michael@0 146 @@ -669,18 +669,23 @@ static void __attribute((noinline,optimi
michael@0 147 /* Double Loop */
michael@0 148 "1: \n\t" /* <double loop> */
michael@0 149 "ldm %[src]!, {r5, r6} \n\t" /* loading src pointers into r5 and r6 */
michael@0 150 "ldm %[dst], {r7, r8} \n\t" /* loading dst pointers into r7 and r8 */
michael@0 151
michael@0 152 /* dst1_scale and dst2_scale*/
michael@0 153 "lsr r9, r5, #24 \n\t" /* src >> 24 */
michael@0 154 "lsr r10, r6, #24 \n\t" /* src >> 24 */
michael@0 155 +#ifdef SK_ARM_HAS_EDSP
michael@0 156 "smulbb r9, r9, %[alpha] \n\t" /* r9 = SkMulS16 r9 with src_scale */
michael@0 157 "smulbb r10, r10, %[alpha] \n\t" /* r10 = SkMulS16 r10 with src_scale */
michael@0 158 +#else
michael@0 159 + "mul r9, r9, %[alpha] \n\t" /* r9 = SkMulS16 r9 with src_scale */
michael@0 160 + "mul r10, r10, %[alpha] \n\t" /* r10 = SkMulS16 r10 with src_scale */
michael@0 161 +#endif
michael@0 162 "lsr r9, r9, #8 \n\t" /* r9 >> 8 */
michael@0 163 "lsr r10, r10, #8 \n\t" /* r10 >> 8 */
michael@0 164 "rsb r9, r9, #256 \n\t" /* dst1_scale = r9 = 255 - r9 + 1 */
michael@0 165 "rsb r10, r10, #256 \n\t" /* dst2_scale = r10 = 255 - r10 + 1 */
michael@0 166
michael@0 167 /* ---------------------- */
michael@0 168
michael@0 169 /* src1, src1_scale */
michael@0 170 @@ -739,17 +744,21 @@ static void __attribute((noinline,optimi
michael@0 171 /* else get into the single loop */
michael@0 172 /* Single Loop */
michael@0 173 "2: \n\t" /* <single loop> */
michael@0 174 "ldr r5, [%[src]], #4 \n\t" /* loading src pointer into r5: r5=src */
michael@0 175 "ldr r7, [%[dst]] \n\t" /* loading dst pointer into r7: r7=dst */
michael@0 176
michael@0 177 "lsr r6, r5, #24 \n\t" /* src >> 24 */
michael@0 178 "and r8, r12, r5, lsr #8 \n\t" /* ag = r8 = r5 masked by r12 lsr by #8 */
michael@0 179 +#ifdef SK_ARM_HAS_EDSP
michael@0 180 "smulbb r6, r6, %[alpha] \n\t" /* r6 = SkMulS16 with src_scale */
michael@0 181 +#else
michael@0 182 + "mul r6, r6, %[alpha] \n\t" /* r6 = SkMulS16 with src_scale */
michael@0 183 +#endif
michael@0 184 "and r9, r12, r5 \n\t" /* rb = r9 = r5 masked by r12 */
michael@0 185 "lsr r6, r6, #8 \n\t" /* r6 >> 8 */
michael@0 186 "mul r8, r8, %[alpha] \n\t" /* ag = r8 times scale */
michael@0 187 "rsb r6, r6, #256 \n\t" /* r6 = 255 - r6 + 1 */
michael@0 188
michael@0 189 /* src, src_scale */
michael@0 190 "mul r9, r9, %[alpha] \n\t" /* rb = r9 times scale */
michael@0 191 "and r8, r8, r12, lsl #8 \n\t" /* ag masked by reverse mask (r12) */

mercurial