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[]; | 24 extern const SkBitmapProcState::SampleProc16 gSkBitmapProcStateSample16_neon[]; |
25 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; | 25 extern const SkBitmapProcState::SampleProc32 gSkBitmapProcStateSample32_neon[]; |
26 extern void S16_D16_filter_DX_neon(const SkBitmapProcState&, const uint32_t*, i
nt, uint16_t*); | 26 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 SkBitmapProcState&, i
nt, int, uint16_t*, int); | 27 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 SkBitmapProcState&,
int, int, uint16_t*, int); | 28 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*); | 29 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 SkBitmapProcState&,
int, int, uint32_t*, int); | 30 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 SkBitmapProcSt
ate&, int, int, uint32_t*, int); | 31 extern void Clamp_SI8_opaque_D32_filter_DX_shaderproc_neon(const void*, int, in
t, uint32_t*, int); |
32 #endif | 32 #endif |
33 | 33 |
34 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState&
, int, int, uint32_t*, int); | 34 extern void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void*, int, int, u
int32_t*, int); |
35 | 35 |
36 #define NAME_WRAP(x) x | 36 #define NAME_WRAP(x) x |
37 #include "SkBitmapProcState_filter.h" | 37 #include "SkBitmapProcState_filter.h" |
38 #include "SkBitmapProcState_procs.h" | 38 #include "SkBitmapProcState_procs.h" |
39 | 39 |
40 SkBitmapProcState::SkBitmapProcState(const SkBitmapProvider& provider, | 40 SkBitmapProcState::SkBitmapProcState(const SkBitmapProvider& provider, |
41 SkShader::TileMode tmx, SkShader::TileMode
tmy) | 41 SkShader::TileMode tmx, SkShader::TileMode
tmy) |
42 : fProvider(provider) | 42 : fProvider(provider) |
43 , fBMState(nullptr) | 43 , fBMState(nullptr) |
44 { | 44 { |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
384 fShaderProc32 = this->chooseShaderProc32(); | 384 fShaderProc32 = this->chooseShaderProc32(); |
385 } | 385 } |
386 } | 386 } |
387 | 387 |
388 // see if our platform has any accelerated overrides | 388 // see if our platform has any accelerated overrides |
389 this->platformProcs(); | 389 this->platformProcs(); |
390 | 390 |
391 return true; | 391 return true; |
392 } | 392 } |
393 | 393 |
394 static void Clamp_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 394 static void Clamp_S32_D32_nofilter_trans_shaderproc(const void* sIn, |
395 int x, int y, | 395 int x, int y, |
396 SkPMColor* SK_RESTRICT color
s, | 396 SkPMColor* SK_RESTRICT color
s, |
397 int count) { | 397 int count) { |
| 398 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); |
398 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 399 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
399 SkASSERT(s.fInvKy == 0); | 400 SkASSERT(s.fInvKy == 0); |
400 SkASSERT(count > 0 && colors != nullptr); | 401 SkASSERT(count > 0 && colors != nullptr); |
401 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | 402 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
402 | 403 |
403 const int maxX = s.fPixmap.width() - 1; | 404 const int maxX = s.fPixmap.width() - 1; |
404 const int maxY = s.fPixmap.height() - 1; | 405 const int maxY = s.fPixmap.height() - 1; |
405 int ix = s.fFilterOneX + x; | 406 int ix = s.fFilterOneX + x; |
406 int iy = SkClampMax(s.fFilterOneY + y, maxY); | 407 int iy = SkClampMax(s.fFilterOneY + y, maxY); |
407 #ifdef SK_DEBUG | 408 #ifdef SK_DEBUG |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 } | 459 } |
459 | 460 |
460 static inline int sk_int_mirror(int x, int n) { | 461 static inline int sk_int_mirror(int x, int n) { |
461 x = sk_int_mod(x, 2 * n); | 462 x = sk_int_mod(x, 2 * n); |
462 if (x >= n) { | 463 if (x >= n) { |
463 x = n + ~(x - n); | 464 x = n + ~(x - n); |
464 } | 465 } |
465 return x; | 466 return x; |
466 } | 467 } |
467 | 468 |
468 static void Repeat_S32_D32_nofilter_trans_shaderproc(const SkBitmapProcState& s, | 469 static void Repeat_S32_D32_nofilter_trans_shaderproc(const void* sIn, |
469 int x, int y, | 470 int x, int y, |
470 SkPMColor* SK_RESTRICT colo
rs, | 471 SkPMColor* SK_RESTRICT colo
rs, |
471 int count) { | 472 int count) { |
| 473 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); |
472 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); | 474 SkASSERT(((s.fInvType & ~SkMatrix::kTranslate_Mask)) == 0); |
473 SkASSERT(s.fInvKy == 0); | 475 SkASSERT(s.fInvKy == 0); |
474 SkASSERT(count > 0 && colors != nullptr); | 476 SkASSERT(count > 0 && colors != nullptr); |
475 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); | 477 SkASSERT(kNone_SkFilterQuality == s.fFilterLevel); |
476 | 478 |
477 const int stopX = s.fPixmap.width(); | 479 const int stopX = s.fPixmap.width(); |
478 const int stopY = s.fPixmap.height(); | 480 const int stopY = s.fPixmap.height(); |
479 int ix = s.fFilterOneX + x; | 481 int ix = s.fFilterOneX + x; |
480 int iy = sk_int_mod(s.fFilterOneY + y, stopY); | 482 int iy = sk_int_mod(s.fFilterOneY + y, stopY); |
481 #ifdef SK_DEBUG | 483 #ifdef SK_DEBUG |
(...skipping 16 matching lines...) Expand all Loading... |
498 memcpy(colors, row + ix, n * sizeof(SkPMColor)); | 500 memcpy(colors, row + ix, n * sizeof(SkPMColor)); |
499 count -= n; | 501 count -= n; |
500 if (0 == count) { | 502 if (0 == count) { |
501 return; | 503 return; |
502 } | 504 } |
503 colors += n; | 505 colors += n; |
504 ix = 0; | 506 ix = 0; |
505 } | 507 } |
506 } | 508 } |
507 | 509 |
508 static void S32_D32_constX_shaderproc(const SkBitmapProcState& s, | 510 static void S32_D32_constX_shaderproc(const void* sIn, |
509 int x, int y, | 511 int x, int y, |
510 SkPMColor* SK_RESTRICT colors, | 512 SkPMColor* SK_RESTRICT colors, |
511 int count) { | 513 int count) { |
| 514 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); |
512 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))
== 0); | 515 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | SkMatrix::kScale_Mask))
== 0); |
513 SkASSERT(s.fInvKy == 0); | 516 SkASSERT(s.fInvKy == 0); |
514 SkASSERT(count > 0 && colors != nullptr); | 517 SkASSERT(count > 0 && colors != nullptr); |
515 SkASSERT(1 == s.fPixmap.width()); | 518 SkASSERT(1 == s.fPixmap.width()); |
516 | 519 |
517 int iY0; | 520 int iY0; |
518 int iY1 SK_INIT_TO_AVOID_WARNING; | 521 int iY1 SK_INIT_TO_AVOID_WARNING; |
519 int iSubY SK_INIT_TO_AVOID_WARNING; | 522 int iSubY SK_INIT_TO_AVOID_WARNING; |
520 | 523 |
521 if (kNone_SkFilterQuality != s.fFilterLevel) { | 524 if (kNone_SkFilterQuality != s.fFilterLevel) { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 if (s.fAlphaScale < 256) { | 614 if (s.fAlphaScale < 256) { |
612 color = SkAlphaMulQ(*row0, s.fAlphaScale); | 615 color = SkAlphaMulQ(*row0, s.fAlphaScale); |
613 } else { | 616 } else { |
614 color = *row0; | 617 color = *row0; |
615 } | 618 } |
616 } | 619 } |
617 | 620 |
618 sk_memset32(colors, color, count); | 621 sk_memset32(colors, color, count); |
619 } | 622 } |
620 | 623 |
621 static void DoNothing_shaderproc(const SkBitmapProcState&, int x, int y, | 624 static void DoNothing_shaderproc(const void*, int x, int y, |
622 SkPMColor* SK_RESTRICT colors, int count) { | 625 SkPMColor* SK_RESTRICT colors, int count) { |
623 // if we get called, the matrix is too tricky, so we just draw nothing | 626 // if we get called, the matrix is too tricky, so we just draw nothing |
624 sk_memset32(colors, 0, count); | 627 sk_memset32(colors, 0, count); |
625 } | 628 } |
626 | 629 |
627 bool SkBitmapProcState::setupForTranslate() { | 630 bool SkBitmapProcState::setupForTranslate() { |
628 SkPoint pt; | 631 SkPoint pt; |
629 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); | 632 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); |
630 | 633 |
631 /* | 634 /* |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 | 807 |
805 if (fFilterLevel != kNone_SkFilterQuality) { | 808 if (fFilterLevel != kNone_SkFilterQuality) { |
806 size >>= 1; | 809 size >>= 1; |
807 } | 810 } |
808 | 811 |
809 return size; | 812 return size; |
810 } | 813 } |
811 | 814 |
812 /////////////////////// | 815 /////////////////////// |
813 | 816 |
814 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const SkBitmapProcState& s, in
t x, int y, | 817 void Clamp_S32_opaque_D32_nofilter_DX_shaderproc(const void* sIn, int x, int y, |
815 SkPMColor* SK_RESTRICT dst, in
t count) { | 818 SkPMColor* SK_RESTRICT dst, in
t count) { |
| 819 const SkBitmapProcState& s = *static_cast<const SkBitmapProcState*>(sIn); |
816 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 820 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
817 SkMatrix::kScale_Mask)) == 0); | 821 SkMatrix::kScale_Mask)) == 0); |
818 | 822 |
819 const unsigned maxX = s.fPixmap.width() - 1; | 823 const unsigned maxX = s.fPixmap.width() - 1; |
820 SkFractionalInt fx; | 824 SkFractionalInt fx; |
821 int dstY; | 825 int dstY; |
822 { | 826 { |
823 const SkBitmapProcStateAutoMapper mapper(s, x, y); | 827 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
824 const unsigned maxY = s.fPixmap.height() - 1; | 828 const unsigned maxY = s.fPixmap.height() - 1; |
825 dstY = SkClampMax(SkFixedFloorToInt(mapper.y()), maxY); | 829 dstY = SkClampMax(SkFixedFloorToInt(mapper.y()), maxY); |
(...skipping 26 matching lines...) Expand all Loading... |
852 *dst++ = src[index]; | 856 *dst++ = src[index]; |
853 fx += dx; | 857 fx += dx; |
854 } | 858 } |
855 } else { | 859 } else { |
856 for (int i = 0; i < count; ++i) { | 860 for (int i = 0; i < count; ++i) { |
857 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 861 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
858 fx += dx; | 862 fx += dx; |
859 } | 863 } |
860 } | 864 } |
861 } | 865 } |
OLD | NEW |