| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2009 The Android Open Source Project | 2 * Copyright 2009 The Android Open Source Project |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 | 8 |
| 9 #include "SkBitmapScaler.h" | 9 #include "SkBitmapScaler.h" |
| 10 #include "SkBitmapProcState.h" | 10 #include "SkBitmapProcState.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 int count, | 23 int count, |
| 24 uint16_t* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; | 24 uint16_t* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; |
| 25 | 25 |
| 26 void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s, | 26 void SI8_D16_nofilter_DX_arm(const SkBitmapProcState& s, |
| 27 const uint32_t* SK_RESTRICT xy, | 27 const uint32_t* SK_RESTRICT xy, |
| 28 int count, uint16_t* SK_RESTRICT colors) { | 28 int count, uint16_t* SK_RESTRICT colors) { |
| 29 SkASSERT(count > 0 && colors != NULL); | 29 SkASSERT(count > 0 && colors != NULL); |
| 30 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); | 30 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); |
| 31 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | 31 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
| 32 | 32 |
| 33 const uint16_t* SK_RESTRICT table = s.fBitmap->getColorTable()->read16BitCac
he(); | 33 const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache(); |
| 34 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); | 34 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); |
| 35 | 35 |
| 36 // buffer is y32, x16, x16, x16, x16, x16 | 36 // buffer is y32, x16, x16, x16, x16, x16 |
| 37 // bump srcAddr to the proper row, since we're told Y never changes | 37 // bump srcAddr to the proper row, since we're told Y never changes |
| 38 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); | 38 SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); |
| 39 srcAddr = (const uint8_t*)((const char*)srcAddr + | 39 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes
()); |
| 40 xy[0] * s.fBitmap->rowBytes()); | |
| 41 | 40 |
| 42 uint8_t src; | 41 uint8_t src; |
| 43 | 42 |
| 44 if (1 == s.fBitmap->width()) { | 43 if (1 == s.fPixmap.width()) { |
| 45 src = srcAddr[0]; | 44 src = srcAddr[0]; |
| 46 uint16_t dstValue = table[src]; | 45 uint16_t dstValue = table[src]; |
| 47 sk_memset16(colors, dstValue, count); | 46 sk_memset16(colors, dstValue, count); |
| 48 } else { | 47 } else { |
| 49 int i; | 48 int i; |
| 50 int count8 = count >> 3; | 49 int count8 = count >> 3; |
| 51 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1); | 50 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1); |
| 52 | 51 |
| 53 asm volatile ( | 52 asm volatile ( |
| 54 "cmp %[count8], #0 \n\t" // compare loop co
unter with 0 | 53 "cmp %[count8], #0 \n\t" // compare loop co
unter with 0 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 int count, | 111 int count, |
| 113 SkPMColor* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; | 112 SkPMColor* SK_RESTRICT colors) SK_ATTRIBUTE_OPTIMIZE_O1; |
| 114 | 113 |
| 115 void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s, | 114 void SI8_opaque_D32_nofilter_DX_arm(const SkBitmapProcState& s, |
| 116 const uint32_t* SK_RESTRICT xy, | 115 const uint32_t* SK_RESTRICT xy, |
| 117 int count, SkPMColor* SK_RESTRICT colors) { | 116 int count, SkPMColor* SK_RESTRICT colors) { |
| 118 SkASSERT(count > 0 && colors != NULL); | 117 SkASSERT(count > 0 && colors != NULL); |
| 119 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); | 118 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); |
| 120 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | 119 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
| 121 | 120 |
| 122 const SkPMColor* SK_RESTRICT table = s.fBitmap->getColorTable()->readColors(
); | 121 const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors(); |
| 123 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fBitmap->getPixels(); | 122 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); |
| 124 | 123 |
| 125 // buffer is y32, x16, x16, x16, x16, x16 | 124 // buffer is y32, x16, x16, x16, x16, x16 |
| 126 // bump srcAddr to the proper row, since we're told Y never changes | 125 // bump srcAddr to the proper row, since we're told Y never changes |
| 127 SkASSERT((unsigned)xy[0] < (unsigned)s.fBitmap->height()); | 126 SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); |
| 128 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fBitmap->rowByte
s()); | 127 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes
()); |
| 129 | 128 |
| 130 if (1 == s.fBitmap->width()) { | 129 if (1 == s.fPixmap.width()) { |
| 131 uint8_t src = srcAddr[0]; | 130 uint8_t src = srcAddr[0]; |
| 132 SkPMColor dstValue = table[src]; | 131 SkPMColor dstValue = table[src]; |
| 133 sk_memset32(colors, dstValue, count); | 132 sk_memset32(colors, dstValue, count); |
| 134 } else { | 133 } else { |
| 135 const uint16_t* xx = (const uint16_t*)(xy + 1); | 134 const uint16_t* xx = (const uint16_t*)(xy + 1); |
| 136 | 135 |
| 137 asm volatile ( | 136 asm volatile ( |
| 138 "subs %[count], %[count], #8 \n\t" // decrement count
by 8, set flags | 137 "subs %[count], %[count], #8 \n\t" // decrement count
by 8, set flags |
| 139 "blt 2f \n\t" // if count < 0, b
ranch to singles | 138 "blt 2f \n\t" // if count < 0, b
ranch to singles |
| 140 "1: \n\t" // eights loop | 139 "1: \n\t" // eights loop |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 */ | 191 */ |
| 193 void SkBitmapProcState::platformProcs() { | 192 void SkBitmapProcState::platformProcs() { |
| 194 #if !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN) | 193 #if !defined(SK_CPU_ARM64) && SK_ARM_ARCH >= 6 && !defined(SK_CPU_BENDIAN) |
| 195 bool isOpaque = 256 == fAlphaScale; | 194 bool isOpaque = 256 == fAlphaScale; |
| 196 bool justDx = false; | 195 bool justDx = false; |
| 197 | 196 |
| 198 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 197 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
| 199 justDx = true; | 198 justDx = true; |
| 200 } | 199 } |
| 201 | 200 |
| 202 switch (fBitmap->colorType()) { | 201 switch (fPixmap.colorType()) { |
| 203 case kIndex_8_SkColorType: | 202 case kIndex_8_SkColorType: |
| 204 if (justDx && kNone_SkFilterQuality == fFilterLevel) { | 203 if (justDx && kNone_SkFilterQuality == fFilterLevel) { |
| 205 #if 0 /* crashing on android device */ | 204 #if 0 /* crashing on android device */ |
| 206 fSampleProc16 = SI8_D16_nofilter_DX_arm; | 205 fSampleProc16 = SI8_D16_nofilter_DX_arm; |
| 207 fShaderProc16 = NULL; | 206 fShaderProc16 = NULL; |
| 208 #endif | 207 #endif |
| 209 if (isOpaque) { | 208 if (isOpaque) { |
| 210 // this one is only very slighty faster than the C version | 209 // this one is only very slighty faster than the C version |
| 211 fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm; | 210 fSampleProc32 = SI8_opaque_D32_nofilter_DX_arm; |
| 212 fShaderProc32 = NULL; | 211 fShaderProc32 = NULL; |
| 213 } | 212 } |
| 214 } | 213 } |
| 215 break; | 214 break; |
| 216 default: | 215 default: |
| 217 break; | 216 break; |
| 218 } | 217 } |
| 219 #endif | 218 #endif |
| 220 } | 219 } |
| 221 | 220 |
| 222 /////////////////////////////////////////////////////////////////////////////// | 221 /////////////////////////////////////////////////////////////////////////////// |
| 223 | 222 |
| 224 extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs); | 223 extern void platformConvolutionProcs_arm_neon(SkConvolutionProcs* procs); |
| 225 | 224 |
| 226 void platformConvolutionProcs_arm(SkConvolutionProcs* procs) { | 225 void platformConvolutionProcs_arm(SkConvolutionProcs* procs) { |
| 227 } | 226 } |
| 228 | 227 |
| 229 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { | 228 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs* procs) { |
| 230 SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs); | 229 SK_ARM_NEON_WRAP(platformConvolutionProcs_arm)(procs); |
| 231 } | 230 } |
| OLD | NEW |