gfx/skia/trunk/src/opts/SkBitmapProcState_opts_arm.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2009 The Android Open Source Project
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8
michael@0 9 #include "SkBitmapProcState.h"
michael@0 10 #include "SkColorPriv.h"
michael@0 11 #include "SkPaint.h"
michael@0 12 #include "SkTypes.h"
michael@0 13 #include "SkUtils.h"
michael@0 14 #include "SkUtilsArm.h"
michael@0 15
michael@0 16 #include "SkConvolver.h"
michael@0 17
michael@0 18 #if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 19 void SI8_D16_nofilter_DX_arm(
michael@0 20 const SkBitmapProcState& s,
michael@0 21 const uint32_t* SK_RESTRICT xy,
michael@0 22 int count,
michael@0 23 uint16_t* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1;
michael@0 24
michael@0 25 void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s,
michael@0 26 const uint32_t* SK_RESTRICT xy,
michael@0 27 int count, uint16_t* SK_RESTRICT colors) {
michael@0 28 SkASSERT(count > 0 && colors != NULL);
michael@0 29 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
michael@0 30 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel);
michael@0 31
michael@0 32 const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->lock16BitCache();
michael@0 33 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
michael@0 34
michael@0 35 // buffer is y32, x16, x16, x16, x16, x16
michael@0 36 // bump srcAddr to the proper row, since we're told Y never changes
michael@0 37 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
michael@0 38 srcAddr = (const uint8_t*)((const char*)srcAddr +
michael@0 39 xy[0] * s.fBitmap->rowBytes());
michael@0 40
michael@0 41 uint8_t src;
michael@0 42
michael@0 43 if (1 == s.fBitmap->width()) {
michael@0 44 src = srcAddr[0];
michael@0 45 uint16_t dstValue = table[src];
michael@0 46 sk_memset16(colors, dstValue, count);
michael@0 47 } else {
michael@0 48 int i;
michael@0 49 int count8 = count >> 3;
michael@0 50 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1);
michael@0 51
michael@0 52 asm volatile (
michael@0 53 "cmp %[count8], #0 \n\t" // compare loop counter with 0
michael@0 54 "beq 2f \n\t" // if loop counter == 0, exit
michael@0 55 "1: \n\t"
michael@0 56 "ldmia %[xx]!, {r5, r7, r9, r11} \n\t" // load ptrs to pixels 0-7
michael@0 57 "subs %[count8], %[count8], #1 \n\t" // decrement loop counter
michael@0 58 "uxth r4, r5 \n\t" // extract ptr 0
michael@0 59 "mov r5, r5, lsr #16 \n\t" // extract ptr 1
michael@0 60 "uxth r6, r7 \n\t" // extract ptr 2
michael@0 61 "mov r7, r7, lsr #16 \n\t" // extract ptr 3
michael@0 62 "ldrb r4, [%[srcAddr], r4] \n\t" // load pixel 0 from image
michael@0 63 "uxth r8, r9 \n\t" // extract ptr 4
michael@0 64 "ldrb r5, [%[srcAddr], r5] \n\t" // load pixel 1 from image
michael@0 65 "mov r9, r9, lsr #16 \n\t" // extract ptr 5
michael@0 66 "ldrb r6, [%[srcAddr], r6] \n\t" // load pixel 2 from image
michael@0 67 "uxth r10, r11 \n\t" // extract ptr 6
michael@0 68 "ldrb r7, [%[srcAddr], r7] \n\t" // load pixel 3 from image
michael@0 69 "mov r11, r11, lsr #16 \n\t" // extract ptr 7
michael@0 70 "ldrb r8, [%[srcAddr], r8] \n\t" // load pixel 4 from image
michael@0 71 "add r4, r4, r4 \n\t" // double pixel 0 for RGB565 lookup
michael@0 72 "ldrb r9, [%[srcAddr], r9] \n\t" // load pixel 5 from image
michael@0 73 "add r5, r5, r5 \n\t" // double pixel 1 for RGB565 lookup
michael@0 74 "ldrb r10, [%[srcAddr], r10] \n\t" // load pixel 6 from image
michael@0 75 "add r6, r6, r6 \n\t" // double pixel 2 for RGB565 lookup
michael@0 76 "ldrb r11, [%[srcAddr], r11] \n\t" // load pixel 7 from image
michael@0 77 "add r7, r7, r7 \n\t" // double pixel 3 for RGB565 lookup
michael@0 78 "ldrh r4, [%[table], r4] \n\t" // load pixel 0 RGB565 from colmap
michael@0 79 "add r8, r8, r8 \n\t" // double pixel 4 for RGB565 lookup
michael@0 80 "ldrh r5, [%[table], r5] \n\t" // load pixel 1 RGB565 from colmap
michael@0 81 "add r9, r9, r9 \n\t" // double pixel 5 for RGB565 lookup
michael@0 82 "ldrh r6, [%[table], r6] \n\t" // load pixel 2 RGB565 from colmap
michael@0 83 "add r10, r10, r10 \n\t" // double pixel 6 for RGB565 lookup
michael@0 84 "ldrh r7, [%[table], r7] \n\t" // load pixel 3 RGB565 from colmap
michael@0 85 "add r11, r11, r11 \n\t" // double pixel 7 for RGB565 lookup
michael@0 86 "ldrh r8, [%[table], r8] \n\t" // load pixel 4 RGB565 from colmap
michael@0 87 "ldrh r9, [%[table], r9] \n\t" // load pixel 5 RGB565 from colmap
michael@0 88 "ldrh r10, [%[table], r10] \n\t" // load pixel 6 RGB565 from colmap
michael@0 89 "ldrh r11, [%[table], r11] \n\t" // load pixel 7 RGB565 from colmap
michael@0 90 "pkhbt r5, r4, r5, lsl #16 \n\t" // pack pixels 0 and 1
michael@0 91 "pkhbt r6, r6, r7, lsl #16 \n\t" // pack pixels 2 and 3
michael@0 92 "pkhbt r8, r8, r9, lsl #16 \n\t" // pack pixels 4 and 5
michael@0 93 "pkhbt r10, r10, r11, lsl #16 \n\t" // pack pixels 6 and 7
michael@0 94 "stmia %[colors]!, {r5, r6, r8, r10} \n\t" // store last 8 pixels
michael@0 95 "bgt 1b \n\t" // loop if counter > 0
michael@0 96 "2: \n\t"
michael@0 97 : [xx] "+r" (xx), [count8] "+r" (count8), [colors] "+r" (colors)
michael@0 98 : [table] "r" (table), [srcAddr] "r" (srcAddr)
michael@0 99 : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11"
michael@0 100 );
michael@0 101
michael@0 102 for (i = (count & 7); i > 0; --i) {
michael@0 103 src = srcAddr[*xx++]; *colors++ = table[src];
michael@0 104 }
michael@0 105 }
michael@0 106
michael@0 107 s.fBitmap->getColorTable()->unlock16BitCache();
michael@0 108 }
michael@0 109
michael@0 110 void SI8_opaque_D32_nofilter_DX_arm(
michael@0 111 const SkBitmapProcState& s,
michael@0 112 const uint32_t* SK_RESTRICT xy,
michael@0 113 int count,
michael@0 114 SkPMColor* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1;
michael@0 115
michael@0 116 void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s,
michael@0 117 const uint32_t* SK_RESTRICT xy,
michael@0 118 int count, SkPMColor* SK_RESTRICT colors) {
michael@0 119 SkASSERT(count > 0 && colors != NULL);
michael@0 120 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask));
michael@0 121 SkASSERT(SkPaint::kNone_FilterLevel == s.fFilterLevel);
michael@0 122
michael@0 123 const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->lockColors();
michael@0 124 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels();
michael@0 125
michael@0 126 // buffer is y32, x16, x16, x16, x16, x16
michael@0 127 // bump srcAddr to the proper row, since we're told Y never changes
michael@0 128 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height());
michael@0 129 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowBytes());
michael@0 130
michael@0 131 if (1 == s.fBitmap->width()) {
michael@0 132 uint8_t src = srcAddr[0];
michael@0 133 SkPMColor dstValue = table[src];
michael@0 134 sk_memset32(colors, dstValue, count);
michael@0 135 } else {
michael@0 136 const uint16_t* xx = (const uint16_t*)(xy + 1);
michael@0 137
michael@0 138 asm volatile (
michael@0 139 "subs %[count], %[count], #8 \n\t" // decrement count by 8, set flags
michael@0 140 "blt 2f \n\t" // if count < 0, branch to singles
michael@0 141 "1: \n\t" // eights loop
michael@0 142 "ldmia %[xx]!, {r5, r7, r9, r11} \n\t" // load ptrs to pixels 0-7
michael@0 143 "uxth r4, r5 \n\t" // extract ptr 0
michael@0 144 "mov r5, r5, lsr #16 \n\t" // extract ptr 1
michael@0 145 "uxth r6, r7 \n\t" // extract ptr 2
michael@0 146 "mov r7, r7, lsr #16 \n\t" // extract ptr 3
michael@0 147 "ldrb r4, [%[srcAddr], r4] \n\t" // load pixel 0 from image
michael@0 148 "uxth r8, r9 \n\t" // extract ptr 4
michael@0 149 "ldrb r5, [%[srcAddr], r5] \n\t" // load pixel 1 from image
michael@0 150 "mov r9, r9, lsr #16 \n\t" // extract ptr 5
michael@0 151 "ldrb r6, [%[srcAddr], r6] \n\t" // load pixel 2 from image
michael@0 152 "uxth r10, r11 \n\t" // extract ptr 6
michael@0 153 "ldrb r7, [%[srcAddr], r7] \n\t" // load pixel 3 from image
michael@0 154 "mov r11, r11, lsr #16 \n\t" // extract ptr 7
michael@0 155 "ldrb r8, [%[srcAddr], r8] \n\t" // load pixel 4 from image
michael@0 156 "ldrb r9, [%[srcAddr], r9] \n\t" // load pixel 5 from image
michael@0 157 "ldrb r10, [%[srcAddr], r10] \n\t" // load pixel 6 from image
michael@0 158 "ldrb r11, [%[srcAddr], r11] \n\t" // load pixel 7 from image
michael@0 159 "ldr r4, [%[table], r4, lsl #2] \n\t" // load pixel 0 SkPMColor from colmap
michael@0 160 "ldr r5, [%[table], r5, lsl #2] \n\t" // load pixel 1 SkPMColor from colmap
michael@0 161 "ldr r6, [%[table], r6, lsl #2] \n\t" // load pixel 2 SkPMColor from colmap
michael@0 162 "ldr r7, [%[table], r7, lsl #2] \n\t" // load pixel 3 SkPMColor from colmap
michael@0 163 "ldr r8, [%[table], r8, lsl #2] \n\t" // load pixel 4 SkPMColor from colmap
michael@0 164 "ldr r9, [%[table], r9, lsl #2] \n\t" // load pixel 5 SkPMColor from colmap
michael@0 165 "ldr r10, [%[table], r10, lsl #2] \n\t" // load pixel 6 SkPMColor from colmap
michael@0 166 "ldr r11, [%[table], r11, lsl #2] \n\t" // load pixel 7 SkPMColor from colmap
michael@0 167 "subs %[count], %[count], #8 \n\t" // decrement loop counter
michael@0 168 "stmia %[colors]!, {r4-r11} \n\t" // store 8 pixels
michael@0 169 "bge 1b \n\t" // loop if counter >= 0
michael@0 170 "2: \n\t"
michael@0 171 "adds %[count], %[count], #8 \n\t" // fix up counter, set flags
michael@0 172 "beq 4f \n\t" // if count == 0, branch to exit
michael@0 173 "3: \n\t" // singles loop
michael@0 174 "ldrh r4, [%[xx]], #2 \n\t" // load pixel ptr
michael@0 175 "subs %[count], %[count], #1 \n\t" // decrement loop counter
michael@0 176 "ldrb r5, [%[srcAddr], r4] \n\t" // load pixel from image
michael@0 177 "ldr r6, [%[table], r5, lsl #2] \n\t" // load SkPMColor from colmap
michael@0 178 "str r6, [%[colors]], #4 \n\t" // store pixel, update ptr
michael@0 179 "bne 3b \n\t" // loop if counter != 0
michael@0 180 "4: \n\t" // exit
michael@0 181 : [xx] "+r" (xx), [count] "+r" (count), [colors] "+r" (colors)
michael@0 182 : [table] "r" (table), [srcAddr] "r" (srcAddr)
michael@0 183 : "memory", "cc", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r11"
michael@0 184 );
michael@0 185 }
michael@0 186
michael@0 187 s.fBitmap->getColorTable()->unlockColors();
michael@0 188 }
michael@0 189 #endif // SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 190
michael@0 191 ///////////////////////////////////////////////////////////////////////////////
michael@0 192
michael@0 193 /* If we replace a sampleproc, then we null-out the associated shaderproc,
michael@0 194 otherwise the shader won't even look at the matrix/sampler
michael@0 195 */
michael@0 196 void SkBitmapProcState::platformProcs() {
michael@0 197 bool isOpaque = 256 == fAlphaScale;
michael@0 198 bool justDx = false;
michael@0 199
michael@0 200 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) {
michael@0 201 justDx = true;
michael@0 202 }
michael@0 203
michael@0 204 switch (fBitmap->config()) {
michael@0 205 case SkBitmap::kIndex8_Config:
michael@0 206 #if SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN)
michael@0 207 if (justDx && SkPaint::kNone_FilterLevel == fFilterLevel) {
michael@0 208 #if 0 /* crashing on android device */
michael@0 209 fSampleProc16 = SI8_D16_nofilter_DX_arm;
michael@0 210 fShaderProc16 = NULL;
michael@0 211 #endif
michael@0 212 if (isOpaque) {
michael@0 213 // this one is only very slighty faster than the C version
michael@0 214 fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm;
michael@0 215 fShaderProc32 = NULL;
michael@0 216 }
michael@0 217 }
michael@0 218 #endif
michael@0 219 break;
michael@0 220 default:
michael@0 221 break;
michael@0 222 }
michael@0 223 }
michael@0 224
michael@0 225 ///////////////////////////////////////////////////////////////////////////////
michael@0 226
michael@0 227 extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs);
michael@0 228
michael@0 229 void platformConvolutionProcs_arm(SkConvolutionProcs* procs) {
michael@0 230 }
michael@0 231
michael@0 232 void SkBitmapProcState::platformConvolutionProcs(SkConvolutionProcs* procs) {
michael@0 233 SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs);
michael@0 234 }

mercurial