| 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 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 /* SSE version of ClampX_ClampY_nofilter_scale() | 367 /* SSE version of ClampX_ClampY_nofilter_scale() |
| 368 * portable version is in core/SkBitmapProcState_matrix.h | 368 * portable version is in core/SkBitmapProcState_matrix.h |
| 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.fPixmap.width() - 1; | 376 const unsigned maxX = s.fPixmap.width() - 1; |
| 377 SkFixed fx; | 377 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
| 378 SkPoint pt; | |
| 379 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | |
| 380 SkIntToScalar(y) + SK_ScalarHalf, &pt); | |
| 381 fx = SkScalarToFixed(pt.fY); | |
| 382 const unsigned maxY = s.fPixmap.height() - 1; | 378 const unsigned maxY = s.fPixmap.height() - 1; |
| 383 *xy++ = SkClampMax(fx >> 16, maxY); | 379 *xy++ = SkClampMax(SkFractionalIntToInt(mapper.y()), maxY); |
| 384 fx = SkScalarToFixed(pt.fX); | 380 SkFixed fx = SkFractionalIntToFixed(mapper.x()); |
| 385 | 381 |
| 386 if (0 == maxX) { | 382 if (0 == maxX) { |
| 387 // all of the following X values must be 0 | 383 // all of the following X values must be 0 |
| 388 memset(xy, 0, count * sizeof(uint16_t)); | 384 memset(xy, 0, count * sizeof(uint16_t)); |
| 389 return; | 385 return; |
| 390 } | 386 } |
| 391 | 387 |
| 392 const SkFixed dx = s.fInvSx; | 388 const SkFixed dx = s.fInvSx; |
| 393 | 389 |
| 394 // test if we don't need to apply the tile proc | 390 // test if we don't need to apply the tile proc |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 /* SSE version of ClampX_ClampY_nofilter_affine() | 554 /* SSE version of ClampX_ClampY_nofilter_affine() |
| 559 * portable version is in core/SkBitmapProcState_matrix.h | 555 * portable version is in core/SkBitmapProcState_matrix.h |
| 560 */ | 556 */ |
| 561 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, | 557 void ClampX_ClampY_nofilter_affine_SSE2(const SkBitmapProcState& s, |
| 562 uint32_t xy[], int count, int x, int y) { | 558 uint32_t xy[], int count, int x, int y) { |
| 563 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); | 559 SkASSERT(s.fInvType & SkMatrix::kAffine_Mask); |
| 564 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 560 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 565 SkMatrix::kScale_Mask | | 561 SkMatrix::kScale_Mask | |
| 566 SkMatrix::kAffine_Mask)) == 0); | 562 SkMatrix::kAffine_Mask)) == 0); |
| 567 | 563 |
| 568 SkPoint srcPt; | 564 const SkBitmapProcStateAutoMapper mapper(s, x, y); |
| 569 s.fInvProc(s.fInvMatrix, | |
| 570 SkIntToScalar(x) + SK_ScalarHalf, | |
| 571 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | |
| 572 | 565 |
| 573 SkFixed fx = SkScalarToFixed(srcPt.fX); | 566 SkFixed fx = SkFractionalIntToFixed(mapper.x()); |
| 574 SkFixed fy = SkScalarToFixed(srcPt.fY); | 567 SkFixed fy = SkFractionalIntToFixed(mapper.y()); |
| 575 SkFixed dx = s.fInvSx; | 568 SkFixed dx = s.fInvSx; |
| 576 SkFixed dy = s.fInvKy; | 569 SkFixed dy = s.fInvKy; |
| 577 int maxX = s.fPixmap.width() - 1; | 570 int maxX = s.fPixmap.width() - 1; |
| 578 int maxY = s.fPixmap.height() - 1; | 571 int maxY = s.fPixmap.height() - 1; |
| 579 | 572 |
| 580 if (count >= 4 && (maxX <= 0xFFFF)) { | 573 if (count >= 4 && (maxX <= 0xFFFF)) { |
| 581 while (((size_t)xy & 0x0F) != 0) { | 574 while (((size_t)xy & 0x0F) != 0) { |
| 582 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | | 575 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | |
| 583 SkClampMax(fx >> 16, maxX); | 576 SkClampMax(fx >> 16, maxX); |
| 584 fx += dx; | 577 fx += dx; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 625 } // while count >= 4 | 618 } // while count >= 4 |
| 626 } // if count >= 4 | 619 } // if count >= 4 |
| 627 | 620 |
| 628 while (count-- > 0) { | 621 while (count-- > 0) { |
| 629 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | | 622 *xy++ = (SkClampMax(fy >> 16, maxY) << 16) | |
| 630 SkClampMax(fx >> 16, maxX); | 623 SkClampMax(fx >> 16, maxX); |
| 631 fx += dx; | 624 fx += dx; |
| 632 fy += dy; | 625 fy += dy; |
| 633 } | 626 } |
| 634 } | 627 } |
| OLD | NEW |