OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2014 The Android Open Source Project | 2 * Copyright 2014 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 "SkBitmapProcState.h" | 9 #include "SkBitmapProcState.h" |
10 #include "SkBitmapScaler.h" | 10 #include "SkBitmapScaler.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkPaint.h" | 12 #include "SkPaint.h" |
13 #include "SkUtils.h" | 13 #include "SkUtils.h" |
14 | 14 |
15 static void SI8_D16_nofilter_DX_mips_dsp(const SkBitmapProcState& s, | |
16 const uint32_t* SK_RESTRICT xy, | |
17 int count, uint16_t* SK_RESTRICT colors
) { | |
18 SkASSERT(count > 0 && colors != nullptr); | |
19 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); | |
20 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | |
21 const uint16_t* SK_RESTRICT table = s.fPixmap.ctable()->read16BitCache(); | |
22 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); | |
23 SkASSERT((unsigned)xy[0] < (unsigned)s.fPixmap.height()); | |
24 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes
()); | |
25 uint8_t src; | |
26 | |
27 if (1 == s.fPixmap.width()) { | |
28 src = srcAddr[0]; | |
29 uint16_t dstValue = table[src]; | |
30 sk_memset16(colors, dstValue, count); | |
31 } else { | |
32 int count8; | |
33 const uint16_t* SK_RESTRICT xx = (const uint16_t*)(xy + 1); | |
34 | |
35 __asm__ volatile ( | |
36 ".set push \n\t" | |
37 ".set noreorder \n\t" | |
38 ".set noat \n\t" | |
39 "sra %[count8], %[count], 3 \n\t" | |
40 "beqz %[count8], 3f \n\t" | |
41 " addiu %[count8], %[count8], -1 \n\t" | |
42 "1: \n\t" | |
43 "beqz %[count8], 2f \n\t" | |
44 " addiu %[count8], %[count8], -1 \n\t" | |
45 "pref 0, 16(%[xx]) \n\t" | |
46 "lhu $t0, 0(%[xx]) \n\t" | |
47 "lhu $t1, 2(%[xx]) \n\t" | |
48 "lhu $t2, 4(%[xx]) \n\t" | |
49 "lhu $t3, 6(%[xx]) \n\t" | |
50 "lhu $t4, 8(%[xx]) \n\t" | |
51 "lhu $t5, 10(%[xx]) \n\t" | |
52 "lhu $t6, 12(%[xx]) \n\t" | |
53 "lhu $t7, 14(%[xx]) \n\t" | |
54 "pref 0, 8(%[srcAddr]) \n\t" | |
55 "lbux $t0, $t0(%[srcAddr]) \n\t" | |
56 "lbux $t1, $t1(%[srcAddr]) \n\t" | |
57 "lbux $t2, $t2(%[srcAddr]) \n\t" | |
58 "lbux $t3, $t3(%[srcAddr]) \n\t" | |
59 "lbux $t4, $t4(%[srcAddr]) \n\t" | |
60 "lbux $t5, $t5(%[srcAddr]) \n\t" | |
61 "lbux $t6, $t6(%[srcAddr]) \n\t" | |
62 "lbux $t7, $t7(%[srcAddr]) \n\t" | |
63 "addu $t0, $t0, $t0 \n\t" | |
64 "addu $t1, $t1, $t1 \n\t" | |
65 "addu $t2, $t2, $t2 \n\t" | |
66 "addu $t3, $t3, $t3 \n\t" | |
67 "addu $t4, $t4, $t4 \n\t" | |
68 "addu $t5, $t5, $t5 \n\t" | |
69 "addu $t6, $t6, $t6 \n\t" | |
70 "addu $t7, $t7, $t7 \n\t" | |
71 "pref 0, 16(%[table]) \n\t" | |
72 "lhx $t0, $t0(%[table]) \n\t" | |
73 "lhx $t1, $t1(%[table]) \n\t" | |
74 "lhx $t2, $t2(%[table]) \n\t" | |
75 "lhx $t3, $t3(%[table]) \n\t" | |
76 "lhx $t4, $t4(%[table]) \n\t" | |
77 "lhx $t5, $t5(%[table]) \n\t" | |
78 "lhx $t6, $t6(%[table]) \n\t" | |
79 "lhx $t7, $t7(%[table]) \n\t" | |
80 "sh $t0, 0(%[colors]) \n\t" | |
81 "sh $t1, 2(%[colors]) \n\t" | |
82 "sh $t2, 4(%[colors]) \n\t" | |
83 "sh $t3, 6(%[colors]) \n\t" | |
84 "sh $t4, 8(%[colors]) \n\t" | |
85 "sh $t5, 10(%[colors]) \n\t" | |
86 "sh $t6, 12(%[colors]) \n\t" | |
87 "sh $t7, 14(%[colors]) \n\t" | |
88 "addiu %[xx], %[xx], 16 \n\t" | |
89 "bgtz %[count8], 1b \n\t" | |
90 " addiu %[colors], %[colors], 16 \n\t" | |
91 "2: \n\t" | |
92 "lhu $t0, 0(%[xx]) \n\t" | |
93 "lhu $t1, 2(%[xx]) \n\t" | |
94 "lhu $t2, 4(%[xx]) \n\t" | |
95 "lhu $t3, 6(%[xx]) \n\t" | |
96 "lhu $t4, 8(%[xx]) \n\t" | |
97 "lhu $t5, 10(%[xx]) \n\t" | |
98 "lhu $t6, 12(%[xx]) \n\t" | |
99 "lhu $t7, 14(%[xx]) \n\t" | |
100 "lbux $t0, $t0(%[srcAddr]) \n\t" | |
101 "lbux $t1, $t1(%[srcAddr]) \n\t" | |
102 "lbux $t2, $t2(%[srcAddr]) \n\t" | |
103 "lbux $t3, $t3(%[srcAddr]) \n\t" | |
104 "lbux $t4, $t4(%[srcAddr]) \n\t" | |
105 "lbux $t5, $t5(%[srcAddr]) \n\t" | |
106 "lbux $t6, $t6(%[srcAddr]) \n\t" | |
107 "lbux $t7, $t7(%[srcAddr]) \n\t" | |
108 "addu $t0, $t0, $t0 \n\t" | |
109 "addu $t1, $t1, $t1 \n\t" | |
110 "addu $t2, $t2, $t2 \n\t" | |
111 "addu $t3, $t3, $t3 \n\t" | |
112 "addu $t4, $t4, $t4 \n\t" | |
113 "addu $t5, $t5, $t5 \n\t" | |
114 "addu $t6, $t6, $t6 \n\t" | |
115 "addu $t7, $t7, $t7 \n\t" | |
116 "lhx $t0, $t0(%[table]) \n\t" | |
117 "lhx $t1, $t1(%[table]) \n\t" | |
118 "lhx $t2, $t2(%[table]) \n\t" | |
119 "lhx $t3, $t3(%[table]) \n\t" | |
120 "lhx $t4, $t4(%[table]) \n\t" | |
121 "lhx $t5, $t5(%[table]) \n\t" | |
122 "lhx $t6, $t6(%[table]) \n\t" | |
123 "lhx $t7, $t7(%[table]) \n\t" | |
124 "sh $t0, 0(%[colors]) \n\t" | |
125 "sh $t1, 2(%[colors]) \n\t" | |
126 "sh $t2, 4(%[colors]) \n\t" | |
127 "sh $t3, 6(%[colors]) \n\t" | |
128 "sh $t4, 8(%[colors]) \n\t" | |
129 "sh $t5, 10(%[colors]) \n\t" | |
130 "sh $t6, 12(%[colors]) \n\t" | |
131 "sh $t7, 14(%[colors]) \n\t" | |
132 "addiu %[xx], %[xx], 16 \n\t" | |
133 "addiu %[colors], %[colors], 16 \n\t" | |
134 "3: \n\t" | |
135 ".set pop \n\t" | |
136 : [xx]"+r"(xx), [count8]"=&r"(count8), [colors]"+r"(colors) | |
137 : [table]"r"(table), [srcAddr]"r"(srcAddr), [count]"r"(count) | |
138 : "memory","t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7" | |
139 ); | |
140 | |
141 for (int i = (count & 7); i > 0; --i) { | |
142 src = srcAddr[*xx++]; *colors++ = table[src]; | |
143 } | |
144 } | |
145 } | |
146 | |
147 static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s, | 15 static void SI8_opaque_D32_nofilter_DX_mips_dsp(const SkBitmapProcState& s, |
148 const uint32_t* SK_RESTRICT xy, | 16 const uint32_t* SK_RESTRICT xy, |
149 int count, SkPMColor* SK_RESTRIC
T colors) { | 17 int count, SkPMColor* SK_RESTRIC
T colors) { |
150 SkASSERT(count > 0 && colors != nullptr); | 18 SkASSERT(count > 0 && colors != nullptr); |
151 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); | 19 SkASSERT(s.fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)); |
152 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | 20 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
153 const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors(); | 21 const SkPMColor* SK_RESTRICT table = s.fPixmap.ctable()->readColors(); |
154 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); | 22 const uint8_t* SK_RESTRICT srcAddr = (const uint8_t*)s.fPixmap.addr(); |
155 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes
()); | 23 srcAddr = (const uint8_t*)((const char*)srcAddr + xy[0] * s.fPixmap.rowBytes
()); |
156 | 24 |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 bool isOpaque = 256 == fAlphaScale; | 240 bool isOpaque = 256 == fAlphaScale; |
373 bool justDx = false; | 241 bool justDx = false; |
374 | 242 |
375 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { | 243 if (fInvType <= (SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask)) { |
376 justDx = true; | 244 justDx = true; |
377 } | 245 } |
378 | 246 |
379 switch (fPixmap.colorType()) { | 247 switch (fPixmap.colorType()) { |
380 case kIndex_8_SkColorType: | 248 case kIndex_8_SkColorType: |
381 if (justDx && kNone_SkFilterQuality == fFilterLevel) { | 249 if (justDx && kNone_SkFilterQuality == fFilterLevel) { |
382 fSampleProc16 = SI8_D16_nofilter_DX_mips_dsp; | |
383 fShaderProc16 = nullptr; | |
384 if (isOpaque) { | 250 if (isOpaque) { |
385 fSampleProc32 = SI8_opaque_D32_nofilter_DX_mips_dsp; | 251 fSampleProc32 = SI8_opaque_D32_nofilter_DX_mips_dsp; |
386 fShaderProc32 = nullptr; | 252 fShaderProc32 = nullptr; |
387 } | 253 } |
388 } | 254 } |
389 break; | 255 break; |
390 default: | 256 default: |
391 break; | 257 break; |
392 } | 258 } |
393 } | 259 } |
394 | 260 |
395 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs*) {} | 261 void SkBitmapScaler::PlatformConvolutionProcs(SkConvolutionProcs*) {} |
OLD | NEW |