OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
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 #include "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
9 #include "SkBitmapController.h" | 9 #include "SkBitmapController.h" |
10 #include "SkBitmapProcState.h" | 10 #include "SkBitmapProcState.h" |
11 #include "SkColorPriv.h" | 11 #include "SkColorPriv.h" |
12 #include "SkFilterProc.h" | 12 #include "SkFilterProc.h" |
13 #include "SkPaint.h" | 13 #include "SkPaint.h" |
14 #include "SkShader.h" // for tilemodes | 14 #include "SkShader.h" // for tilemodes |
15 #include "SkUtilsArm.h" | 15 #include "SkUtilsArm.h" |
16 #include "SkBitmapScaler.h" | 16 #include "SkBitmapScaler.h" |
17 #include "SkMipMap.h" | 17 #include "SkMipMap.h" |
18 #include "SkPixelRef.h" | 18 #include "SkPixelRef.h" |
19 #include "SkImageEncoder.h" | 19 #include "SkImageEncoder.h" |
20 #include "SkResourceCache.h" | 20 #include "SkResourceCache.h" |
21 | 21 |
22 #if !SK_ARM_NEON_IS_NONE | 22 #if !SK_ARM_NEON_IS_NONE |
23 // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp | 23 // These are defined in src/opts/SkBitmapProcState_arm_neon.cpp |
24 extern const SkBitmapProcState::SampleProc16 gSkBitmapProcStateSample16_neon[]; | |
25 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; | 24 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; |
26 extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, i
nt, uint16_t*); | 25 extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, i
nt, uint16_t*); |
27 extern void Clamp_S16_D16_filter_DX_shaderproc_neon(const void *, int, int, uin
t16_t*, int); | 26 extern void Clamp_S16_D16_filter_DX_shaderproc_neon(const void *, int, int, uin
t16_t*, int); |
28 extern void Repeat_S16_D16_filter_DX_shaderproc_neon(const void *, int, int, ui
nt16_t*, int); | 27 extern void Repeat_S16_D16_filter_DX_shaderproc_neon(const void *, int, int, ui
nt16_t*, int); |
29 extern void SI8_opaque_D32_filter_DX_neon(const SkBitmapProcState&, const uint3
2_t*, int, SkPMColor*); | 28 extern void SI8_opaque_D32_filter_DX_neon(const SkBitmapProcState&, const uint3
2_t*, int, SkPMColor*); |
30 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const void *, int, int, ui
nt32_t*, int); | 29 extern void SI8_opaque_D32_filter_DX_shaderproc_neon(const void *, int, int, ui
nt32_t*, int); |
31 extern void Clamp_SI8_opaque_D32_filter_DX_shaderproc_neon(const void*, int, in
t, uint32_t*, int); | 30 extern void Clamp_SI8_opaque_D32_filter_DX_shaderproc_neon(const void*, int, in
t, uint32_t*, int); |
32 #endif | 31 #endif |
33 | 32 |
34 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u
int32_t*, int); | 33 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u
int32_t*, int); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); | 185 fInvSx = SkScalarToFixed(fInvMatrix.getScaleX()); |
187 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); | 186 fInvSxFractionalInt = SkScalarToFractionalInt(fInvMatrix.getScaleX()); |
188 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); | 187 fInvKy = SkScalarToFixed(fInvMatrix.getSkewY()); |
189 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); | 188 fInvKyFractionalInt = SkScalarToFractionalInt(fInvMatrix.getSkewY()); |
190 | 189 |
191 fAlphaScale = SkAlpha255To256(paint.getAlpha()); | 190 fAlphaScale = SkAlpha255To256(paint.getAlpha()); |
192 | 191 |
193 fShaderProc32 = nullptr; | 192 fShaderProc32 = nullptr; |
194 fShaderProc16 = nullptr; | 193 fShaderProc16 = nullptr; |
195 fSampleProc32 = nullptr; | 194 fSampleProc32 = nullptr; |
196 fSampleProc16 = nullptr; | |
197 | 195 |
198 // recompute the triviality of the matrix here because we may have | 196 // recompute the triviality of the matrix here because we may have |
199 // changed it! | 197 // changed it! |
200 | 198 |
201 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; | 199 trivialMatrix = (fInvMatrix.getType() & ~SkMatrix::kTranslate_Mask) == 0; |
202 | 200 |
203 if (kLow_SkFilterQuality == fFilterLevel) { | 201 if (kLow_SkFilterQuality == fFilterLevel) { |
204 // Only try bilerp if the matrix is "interesting" and | 202 // Only try bilerp if the matrix is "interesting" and |
205 // the image has a suitable size. | 203 // the image has a suitable size. |
206 | 204 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 // todo: possibly specialize on opaqueness | 327 // todo: possibly specialize on opaqueness |
330 SG8_alpha_D32_nofilter_DXDY, | 328 SG8_alpha_D32_nofilter_DXDY, |
331 SG8_alpha_D32_nofilter_DXDY, | 329 SG8_alpha_D32_nofilter_DXDY, |
332 SG8_alpha_D32_nofilter_DX, | 330 SG8_alpha_D32_nofilter_DX, |
333 SG8_alpha_D32_nofilter_DX, | 331 SG8_alpha_D32_nofilter_DX, |
334 SG8_alpha_D32_filter_DXDY, | 332 SG8_alpha_D32_filter_DXDY, |
335 SG8_alpha_D32_filter_DXDY, | 333 SG8_alpha_D32_filter_DXDY, |
336 SG8_alpha_D32_filter_DX, | 334 SG8_alpha_D32_filter_DX, |
337 SG8_alpha_D32_filter_DX | 335 SG8_alpha_D32_filter_DX |
338 }; | 336 }; |
339 | |
340 static const SampleProc16 gSkBitmapProcStateSample16[] = { | |
341 S32_D16_nofilter_DXDY, | |
342 S32_D16_nofilter_DX, | |
343 S32_D16_filter_DXDY, | |
344 S32_D16_filter_DX, | |
345 | |
346 S16_D16_nofilter_DXDY, | |
347 S16_D16_nofilter_DX, | |
348 S16_D16_filter_DXDY, | |
349 S16_D16_filter_DX, | |
350 | |
351 SI8_D16_nofilter_DXDY, | |
352 SI8_D16_nofilter_DX, | |
353 SI8_D16_filter_DXDY, | |
354 SI8_D16_filter_DX, | |
355 | |
356 // Don't support 4444 -> 565 | |
357 nullptr, nullptr, nullptr, nullptr, | |
358 // Don't support A8 -> 565 | |
359 nullptr, nullptr, nullptr, nullptr, | |
360 // Don't support G8 -> 565 (but we could) | |
361 nullptr, nullptr, nullptr, nullptr | |
362 }; | |
363 #endif | 337 #endif |
364 | 338 |
365 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; | 339 fSampleProc32 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample32)[index]; |
366 index >>= 1; // shift away any opaque/alpha distinction | 340 index >>= 1; // shift away any opaque/alpha distinction |
367 fSampleProc16 = SK_ARM_NEON_WRAP(gSkBitmapProcStateSample16)[index]; | |
368 | 341 |
369 // our special-case shaderprocs | 342 // our special-case shaderprocs |
370 if (SK_ARM_NEON_WRAP(S16_D16_filter_DX) == fSampleProc16) { | 343 if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 && clamp
Clamp) { |
371 if (clampClamp) { | |
372 fShaderProc16 = SK_ARM_NEON_WRAP(Clamp_S16_D16_filter_DX_shaderp
roc); | |
373 } else if (SkShader::kRepeat_TileMode == fTileModeX && | |
374 SkShader::kRepeat_TileMode == fTileModeY) { | |
375 fShaderProc16 = SK_ARM_NEON_WRAP(Repeat_S16_D16_filter_DX_shader
proc); | |
376 } | |
377 } else if (SK_ARM_NEON_WRAP(SI8_opaque_D32_filter_DX) == fSampleProc32 &
& clampClamp) { | |
378 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad
erproc); | 344 fShaderProc32 = SK_ARM_NEON_WRAP(Clamp_SI8_opaque_D32_filter_DX_shad
erproc); |
379 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) { | 345 } else if (S32_opaque_D32_nofilter_DX == fSampleProc32 && clampClamp) { |
380 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc; | 346 fShaderProc32 = Clamp_S32_opaque_D32_nofilter_DX_shaderproc; |
381 } | 347 } |
382 | 348 |
383 if (nullptr == fShaderProc32) { | 349 if (nullptr == fShaderProc32) { |
384 fShaderProc32 = this->chooseShaderProc32(); | 350 fShaderProc32 = this->chooseShaderProc32(); |
385 } | 351 } |
386 } | 352 } |
387 | 353 |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 fx += dx; | 823 fx += dx; |
858 } | 824 } |
859 } else { | 825 } else { |
860 for (int i = 0; i < count; ++i) { | 826 for (int i = 0; i < count; ++i) { |
861 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 827 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
862 fx += dx; | 828 fx += dx; |
863 } | 829 } |
864 } | 830 } |
865 } | 831 } |
866 | 832 |
OLD | NEW |