OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2009 The Android Open Source Project | 3 * Copyright 2009 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #include <emmintrin.h> | 10 #include <emmintrin.h> |
11 #include "SkBitmapProcState_opts_SSE2.h" | 11 #include "SkBitmapProcState_opts_SSE2.h" |
12 #include "SkUtils.h" | 12 #include "SkUtils.h" |
13 | 13 |
14 void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s, | 14 void S32_opaque_D32_filter_DX_SSE2(const SkBitmapProcState& s, |
15 const uint32_t* xy, | 15 const uint32_t* xy, |
16 int count, uint32_t* colors) { | 16 int count, uint32_t* colors) { |
17 SkASSERT(count > 0 && colors != NULL); | 17 SkASSERT(count > 0 && colors != NULL); |
18 SkASSERT(s.fDoFilter); | 18 SkASSERT(s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter); |
19 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); | 19 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); |
20 SkASSERT(s.fAlphaScale == 256); | 20 SkASSERT(s.fAlphaScale == 256); |
21 | 21 |
22 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); | 22 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); |
23 size_t rb = s.fBitmap->rowBytes(); | 23 size_t rb = s.fBitmap->rowBytes(); |
24 uint32_t XY = *xy++; | 24 uint32_t XY = *xy++; |
25 unsigned y0 = XY >> 14; | 25 unsigned y0 = XY >> 14; |
26 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); | 26 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); |
27 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); | 27 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); |
28 unsigned subY = y0 & 0xF; | 28 unsigned subY = y0 & 0xF; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 // Extract low int and store. | 115 // Extract low int and store. |
116 *colors++ = _mm_cvtsi128_si32(sum); | 116 *colors++ = _mm_cvtsi128_si32(sum); |
117 } while (--count > 0); | 117 } while (--count > 0); |
118 } | 118 } |
119 | 119 |
120 void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s, | 120 void S32_alpha_D32_filter_DX_SSE2(const SkBitmapProcState& s, |
121 const uint32_t* xy, | 121 const uint32_t* xy, |
122 int count, uint32_t* colors) { | 122 int count, uint32_t* colors) { |
123 SkASSERT(count > 0 && colors != NULL); | 123 SkASSERT(count > 0 && colors != NULL); |
124 SkASSERT(s.fDoFilter); | 124 SkASSERT(s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter); |
125 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); | 125 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); |
126 SkASSERT(s.fAlphaScale < 256); | 126 SkASSERT(s.fAlphaScale < 256); |
127 | 127 |
128 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); | 128 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); |
129 size_t rb = s.fBitmap->rowBytes(); | 129 size_t rb = s.fBitmap->rowBytes(); |
130 uint32_t XY = *xy++; | 130 uint32_t XY = *xy++; |
131 unsigned y0 = XY >> 14; | 131 unsigned y0 = XY >> 14; |
132 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); | 132 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); |
133 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); | 133 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); |
134 unsigned subY = y0 & 0xF; | 134 unsigned subY = y0 & 0xF; |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 248 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
249 SkMatrix::kScale_Mask)) == 0); | 249 SkMatrix::kScale_Mask)) == 0); |
250 SkASSERT(s.fInvKy == 0); | 250 SkASSERT(s.fInvKy == 0); |
251 | 251 |
252 const unsigned maxX = s.fBitmap->width() - 1; | 252 const unsigned maxX = s.fBitmap->width() - 1; |
253 const SkFixed one = s.fFilterOneX; | 253 const SkFixed one = s.fFilterOneX; |
254 const SkFixed dx = s.fInvSx; | 254 const SkFixed dx = s.fInvSx; |
255 SkFixed fx; | 255 SkFixed fx; |
256 | 256 |
257 SkPoint pt; | 257 SkPoint pt; |
258 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 258 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
259 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 259 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
260 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); | 260 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); |
261 const unsigned maxY = s.fBitmap->height() - 1; | 261 const unsigned maxY = s.fBitmap->height() - 1; |
262 // compute our two Y values up front | 262 // compute our two Y values up front |
263 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); | 263 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); |
264 // now initialize fx | 264 // now initialize fx |
265 fx = SkScalarToFixed(pt.fX) - (one >> 1); | 265 fx = SkScalarToFixed(pt.fX) - (one >> 1); |
266 | 266 |
267 // test if we don't need to apply the tile proc | 267 // test if we don't need to apply the tile proc |
268 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && | 268 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && |
269 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { | 269 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 */ | 369 */ |
370 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, | 370 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, |
371 uint32_t xy[], int count, int x, int y) { | 371 uint32_t xy[], int count, int x, int y) { |
372 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 372 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
373 SkMatrix::kScale_Mask)) == 0); | 373 SkMatrix::kScale_Mask)) == 0); |
374 | 374 |
375 // we store y, x, x, x, x, x | 375 // we store y, x, x, x, x, x |
376 const unsigned maxX = s.fBitmap->width() - 1; | 376 const unsigned maxX = s.fBitmap->width() - 1; |
377 SkFixed fx; | 377 SkFixed fx; |
378 SkPoint pt; | 378 SkPoint pt; |
379 s.fInvProc(*s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 379 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
380 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 380 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
381 fx = SkScalarToFixed(pt.fY); | 381 fx = SkScalarToFixed(pt.fY); |
382 const unsigned maxY = s.fBitmap->height() - 1; | 382 const unsigned maxY = s.fBitmap->height() - 1; |
383 *xy++ = SkClampMax(fx >> 16, maxY); | 383 *xy++ = SkClampMax(fx >> 16, maxY); |
384 fx = SkScalarToFixed(pt.fX); | 384 fx = SkScalarToFixed(pt.fX); |
385 | 385 |
386 if (0 == maxX) { | 386 if (0 == maxX) { |
387 // all of the following X values must be 0 | 387 // all of the following X values must be 0 |
388 memset(xy, 0, count * sizeof(uint16_t)); | 388 memset(xy, 0, count * sizeof(uint16_t)); |
389 return; | 389 return; |
390 } | 390 } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 } | 483 } |
484 } | 484 } |
485 } | 485 } |
486 | 486 |
487 /* SSE version of ClampX_ClampY_filter_affine() | 487 /* SSE version of ClampX_ClampY_filter_affine() |
488 * portable version is in core/SkBitmapProcState_matrix.h | 488 * portable version is in core/SkBitmapProcState_matrix.h |
489 */ | 489 */ |
490 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, | 490 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, |
491 uint32_t xy[], int count, int x, int y) { | 491 uint32_t xy[], int count, int x, int y) { |
492 SkPoint srcPt; | 492 SkPoint srcPt; |
493 s.fInvProc(*s.fInvMatrix, | 493 s.fInvProc(s.fInvMatrix, |
494 SkIntToScalar(x) + SK_ScalarHalf, | 494 SkIntToScalar(x) + SK_ScalarHalf, |
495 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 495 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
496 | 496 |
497 SkFixed oneX = s.fFilterOneX; | 497 SkFixed oneX = s.fFilterOneX; |
498 SkFixed oneY = s.fFilterOneY; | 498 SkFixed oneY = s.fFilterOneY; |
499 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); | 499 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); |
500 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); | 500 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); |
501 SkFixed dx = s.fInvSx; | 501 SkFixed dx = s.fInvSx; |
502 SkFixed dy = s.fInvKy; | 502 SkFixed dy = s.fInvKy; |
503 unsigned maxX = s.fBitmap->width() - 1; | 503 unsigned maxX = s.fBitmap->width() - 1; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
559 * portable version is in core/SkBitmapProcState_matrix.h | 559 * portable version is in core/SkBitmapProcState_matrix.h |
560 */ | 560 */ |
561 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, | 561 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, |
562 uint32_t xy[], int count, int x, int y) { | 562 uint32_t xy[], int count, int x, int y) { |
563 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 563 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
564 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 564 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
565 SkMatrix::kScale_Mask | | 565 SkMatrix::kScale_Mask | |
566 SkMatrix::kAffine_Mask)) == 0); | 566 SkMatrix::kAffine_Mask)) == 0); |
567 | 567 |
568 SkPoint srcPt; | 568 SkPoint srcPt; |
569 s.fInvProc(*s.fInvMatrix, | 569 s.fInvProc(s.fInvMatrix, |
570 SkIntToScalar(x) + SK_ScalarHalf, | 570 SkIntToScalar(x) + SK_ScalarHalf, |
571 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 571 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
572 | 572 |
573 SkFixed fx = SkScalarToFixed(srcPt.fX); | 573 SkFixed fx = SkScalarToFixed(srcPt.fX); |
574 SkFixed fy = SkScalarToFixed(srcPt.fY); | 574 SkFixed fy = SkScalarToFixed(srcPt.fY); |
575 SkFixed dx = s.fInvSx; | 575 SkFixed dx = s.fInvSx; |
576 SkFixed dy = s.fInvKy; | 576 SkFixed dy = s.fInvKy; |
577 int maxX = s.fBitmap->width() - 1; | 577 int maxX = s.fBitmap->width() - 1; |
578 int maxY = s.fBitmap->height() - 1; | 578 int maxY = s.fBitmap->height() - 1; |
579 | 579 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 } | 634 } |
635 | 635 |
636 /* SSE version of S32_D16_filter_DX_SSE2 | 636 /* SSE version of S32_D16_filter_DX_SSE2 |
637 * Definition is in section of "D16 functions for SRC == 8888" in SkBitmapProcS
tate.cpp | 637 * Definition is in section of "D16 functions for SRC == 8888" in SkBitmapProcS
tate.cpp |
638 * It combines S32_opaque_D32_filter_DX_SSE2 and SkPixel32ToPixel16 | 638 * It combines S32_opaque_D32_filter_DX_SSE2 and SkPixel32ToPixel16 |
639 */ | 639 */ |
640 void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s, | 640 void S32_D16_filter_DX_SSE2(const SkBitmapProcState& s, |
641 const uint32_t* xy, | 641 const uint32_t* xy, |
642 int count, uint16_t* colors) { | 642 int count, uint16_t* colors) { |
643 SkASSERT(count > 0 && colors != NULL); | 643 SkASSERT(count > 0 && colors != NULL); |
644 SkASSERT(s.fDoFilter); | 644 SkASSERT(s.fFilterQuality != SkBitmapProcState::kNone_BitmapFilter); |
645 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); | 645 SkASSERT(s.fBitmap->config() == SkBitmap::kARGB_8888_Config); |
646 SkASSERT(s.fBitmap->isOpaque()); | 646 SkASSERT(s.fBitmap->isOpaque()); |
647 | 647 |
648 SkPMColor dstColor; | 648 SkPMColor dstColor; |
649 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); | 649 const char* srcAddr = static_cast<const char*>(s.fBitmap->getPixels()); |
650 size_t rb = s.fBitmap->rowBytes(); | 650 size_t rb = s.fBitmap->rowBytes(); |
651 uint32_t XY = *xy++; | 651 uint32_t XY = *xy++; |
652 unsigned y0 = XY >> 14; | 652 unsigned y0 = XY >> 14; |
653 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); | 653 const uint32_t* row0 = reinterpret_cast<const uint32_t*>(srcAddr + (y0 >> 4)
* rb); |
654 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); | 654 const uint32_t* row1 = reinterpret_cast<const uint32_t*>(srcAddr + (XY & 0x3
FFF) * rb); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 unsigned g = (g32 & ((1<<6) -1)) << 5; | 756 unsigned g = (g32 & ((1<<6) -1)) << 5; |
757 | 757 |
758 _m_temp2 = _mm_srli_epi32(_m_temp2, 9); | 758 _m_temp2 = _mm_srli_epi32(_m_temp2, 9); |
759 unsigned int b32 = _mm_cvtsi128_si32(_m_temp2); | 759 unsigned int b32 = _mm_cvtsi128_si32(_m_temp2); |
760 unsigned b = (b32 & ((1<<5) -1)); | 760 unsigned b = (b32 & ((1<<5) -1)); |
761 | 761 |
762 *colors++ = r | g | b; | 762 *colors++ = r | g | b; |
763 | 763 |
764 } while (--count > 0); | 764 } while (--count > 0); |
765 } | 765 } |
OLD | NEW |