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 #include <emmintrin.h> | 8 #include <emmintrin.h> |
9 #include "SkBitmapProcState_opts_SSE2.h" | 9 #include "SkBitmapProcState_opts_SSE2.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 int count, int x, int y) { | 247 int count, int x, int y) { |
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.fPixmap.width() - 1; | 252 const unsigned maxX = s.fPixmap.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 | 255 |
256 const SkBitmapProcStateAutoMapper mapper(s, x, y); | 256 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
257 const SkFixed fy = SkFractionalIntToFixed(mapper.y()); | 257 const SkFixed fy = mapper.fixedY(); |
258 const unsigned maxY = s.fPixmap.height() - 1; | 258 const unsigned maxY = s.fPixmap.height() - 1; |
259 // compute our two Y values up front | 259 // compute our two Y values up front |
260 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); | 260 *xy++ = ClampX_ClampY_pack_filter(fy, maxY, s.fFilterOneY); |
261 // now initialize fx | 261 // now initialize fx |
262 SkFixed fx = SkFractionalIntToFixed(mapper.x()); | 262 SkFixed fx = mapper.fixedX(); |
263 | 263 |
264 // test if we don't need to apply the tile proc | 264 // test if we don't need to apply the tile proc |
265 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && | 265 if (dx > 0 && (unsigned)(fx >> 16) <= maxX && |
266 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { | 266 (unsigned)((fx + dx * (count - 1)) >> 16) < maxX) { |
267 if (count >= 4) { | 267 if (count >= 4) { |
268 // SSE version of decal_filter_scale | 268 // SSE version of decal_filter_scale |
269 while ((size_t(xy) & 0x0F) != 0) { | 269 while ((size_t(xy) & 0x0F) != 0) { |
270 SkASSERT((fx >> (16 + 14)) == 0); | 270 SkASSERT((fx >> (16 + 14)) == 0); |
271 *xy++ = (fx >> 12 << 14) | ((fx >> 16) + 1); | 271 *xy++ = (fx >> 12 << 14) | ((fx >> 16) + 1); |
272 fx += dx; | 272 fx += dx; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 */ | 366 */ |
367 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, | 367 void ClampX_ClampY_nofilter_scale_SSE2(const SkBitmapProcState& s, |
368 uint32_t xy[], int count, int x, int y) { | 368 uint32_t xy[], int count, int x, int y) { |
369 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 369 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
370 SkMatrix::kScale_Mask)) == 0); | 370 SkMatrix::kScale_Mask)) == 0); |
371 | 371 |
372 // we store y, x, x, x, x, x | 372 // we store y, x, x, x, x, x |
373 const unsigned maxX = s.fPixmap.width() - 1; | 373 const unsigned maxX = s.fPixmap.width() - 1; |
374 const SkBitmapProcStateAutoMapper mapper(s, x, y); | 374 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
375 const unsigned maxY = s.fPixmap.height() - 1; | 375 const unsigned maxY = s.fPixmap.height() - 1; |
376 *xy++ = SkClampMax(SkFractionalIntToInt(mapper.y()), maxY); | 376 *xy++ = SkClampMax(mapper.intY(), maxY); |
377 SkFixed fx = SkFractionalIntToFixed(mapper.x()); | 377 SkFixed fx = mapper.fixedX(); |
378 | 378 |
379 if (0 == maxX) { | 379 if (0 == maxX) { |
380 // all of the following X values must be 0 | 380 // all of the following X values must be 0 |
381 memset(xy, 0, count * sizeof(uint16_t)); | 381 memset(xy, 0, count * sizeof(uint16_t)); |
382 return; | 382 return; |
383 } | 383 } |
384 | 384 |
385 const SkFixed dx = s.fInvSx; | 385 const SkFixed dx = s.fInvSx; |
386 | 386 |
387 // test if we don't need to apply the tile proc | 387 // test if we don't need to apply the tile proc |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 | 479 |
480 /* SSE version of ClampX_ClampY_filter_affine() | 480 /* SSE version of ClampX_ClampY_filter_affine() |
481 * portable version is in core/SkBitmapProcState_matrix.h | 481 * portable version is in core/SkBitmapProcState_matrix.h |
482 */ | 482 */ |
483 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, | 483 void ClampX_ClampY_filter_affine_SSE2(const SkBitmapProcState& s, |
484 uint32_t xy[], int count, int x, int y) { | 484 uint32_t xy[], int count, int x, int y) { |
485 const SkBitmapProcStateAutoMapper mapper(s, x, y); | 485 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
486 | 486 |
487 SkFixed oneX = s.fFilterOneX; | 487 SkFixed oneX = s.fFilterOneX; |
488 SkFixed oneY = s.fFilterOneY; | 488 SkFixed oneY = s.fFilterOneY; |
489 SkFixed fx = SkFractionalIntToFixed(mapper.x()); | 489 SkFixed fx = mapper.fixedX(); |
490 SkFixed fy = SkFractionalIntToFixed(mapper.y()); | 490 SkFixed fy = mapper.fixedY(); |
491 SkFixed dx = s.fInvSx; | 491 SkFixed dx = s.fInvSx; |
492 SkFixed dy = s.fInvKy; | 492 SkFixed dy = s.fInvKy; |
493 unsigned maxX = s.fPixmap.width() - 1; | 493 unsigned maxX = s.fPixmap.width() - 1; |
494 unsigned maxY = s.fPixmap.height() - 1; | 494 unsigned maxY = s.fPixmap.height() - 1; |
495 | 495 |
496 if (count >= 2 && (maxX <= 0xFFFF)) { | 496 if (count >= 2 && (maxX <= 0xFFFF)) { |
497 SkFixed dx2 = dx + dx; | 497 SkFixed dx2 = dx + dx; |
498 SkFixed dy2 = dy + dy; | 498 SkFixed dy2 = dy + dy; |
499 | 499 |
500 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy); | 500 __m128i wide_f = _mm_set_epi32(fx + dx, fy + dy, fx, fy); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 */ | 550 */ |
551 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, | 551 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, |
552 uint32_t xy[], int count, int x, int y) { | 552 uint32_t xy[], int count, int x, int y) { |
553 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 553 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
554 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 554 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
555 SkMatrix::kScale_Mask | | 555 SkMatrix::kScale_Mask | |
556 SkMatrix::kAffine_Mask)) == 0); | 556 SkMatrix::kAffine_Mask)) == 0); |
557 | 557 |
558 const SkBitmapProcStateAutoMapper mapper(s, x, y); | 558 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
559 | 559 |
560 SkFixed fx = SkFractionalIntToFixed(mapper.x()); | 560 SkFixed fx = mapper.fixedX(); |
561 SkFixed fy = SkFractionalIntToFixed(mapper.y()); | 561 SkFixed fy = mapper.fixedY(); |
562 SkFixed dx = s.fInvSx; | 562 SkFixed dx = s.fInvSx; |
563 SkFixed dy = s.fInvKy; | 563 SkFixed dy = s.fInvKy; |
564 int maxX = s.fPixmap.width() - 1; | 564 int maxX = s.fPixmap.width() - 1; |
565 int maxY = s.fPixmap.height() - 1; | 565 int maxY = s.fPixmap.height() - 1; |
566 | 566 |
567 if (count >= 4 && (maxX <= 0xFFFF)) { | 567 if (count >= 4 && (maxX <= 0xFFFF)) { |
568 while (((size_t)xy & 0x0F) != 0) { | 568 while (((size_t)xy & 0x0F) != 0) { |
569 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | | 569 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | |
570 SkClampMax(fx >> 16, maxX); | 570 SkClampMax(fx >> 16, maxX); |
571 fx += dx; | 571 fx += dx; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 } // while count >= 4 | 612 } // while count >= 4 |
613 } // if count >= 4 | 613 } // if count >= 4 |
614 | 614 |
615 while (count-- > 0) { | 615 while (count-- > 0) { |
616 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | | 616 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | |
617 SkClampMax(fx >> 16, maxX); | 617 SkClampMax(fx >> 16, maxX); |
618 fx += dx; | 618 fx += dx; |
619 fy += dy; | 619 fy += dy; |
620 } | 620 } |
621 } | 621 } |
OLD | NEW |