| OLD | NEW |
| 1 /* |
| 2 * Copyright 2014 Google Inc. |
| 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. |
| 6 */ |
| 1 | 7 |
| 2 #include <arm_neon.h> | 8 #include <arm_neon.h> |
| 3 | 9 |
| 4 | |
| 5 #define SCALE_NOFILTER_NAME MAKENAME(_nofilter_scale) | 10 #define SCALE_NOFILTER_NAME MAKENAME(_nofilter_scale) |
| 6 #define SCALE_FILTER_NAME MAKENAME(_filter_scale) | 11 #define SCALE_FILTER_NAME MAKENAME(_filter_scale) |
| 7 #define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine) | 12 #define AFFINE_NOFILTER_NAME MAKENAME(_nofilter_affine) |
| 8 #define AFFINE_FILTER_NAME MAKENAME(_filter_affine) | 13 #define AFFINE_FILTER_NAME MAKENAME(_filter_affine) |
| 9 #define PERSP_NOFILTER_NAME MAKENAME(_nofilter_persp) | 14 #define PERSP_NOFILTER_NAME MAKENAME(_nofilter_persp) |
| 10 #define PERSP_FILTER_NAME MAKENAME(_filter_persp) | 15 #define PERSP_FILTER_NAME MAKENAME(_filter_persp) |
| 11 | 16 |
| 12 #define PACK_FILTER_X_NAME MAKENAME(_pack_filter_x) | 17 #define PACK_FILTER_X_NAME MAKENAME(_pack_filter_x) |
| 13 #define PACK_FILTER_Y_NAME MAKENAME(_pack_filter_y) | 18 #define PACK_FILTER_Y_NAME MAKENAME(_pack_filter_y) |
| 14 #define PACK_FILTER_X4_NAME MAKENAME(_pack_filter_x4) | 19 #define PACK_FILTER_X4_NAME MAKENAME(_pack_filter_x4) |
| 15 #define PACK_FILTER_Y4_NAME MAKENAME(_pack_filter_y4) | 20 #define PACK_FILTER_Y4_NAME MAKENAME(_pack_filter_y4) |
| 16 | 21 |
| 17 #ifndef PREAMBLE | 22 #ifndef PREAMBLE |
| 18 #define PREAMBLE(state) | 23 #define PREAMBLE(state) |
| 19 #define PREAMBLE_PARAM_X | 24 #define PREAMBLE_PARAM_X |
| 20 #define PREAMBLE_PARAM_Y | 25 #define PREAMBLE_PARAM_Y |
| 21 #define PREAMBLE_ARG_X | 26 #define PREAMBLE_ARG_X |
| 22 #define PREAMBLE_ARG_Y | 27 #define PREAMBLE_ARG_Y |
| 23 #endif | 28 #endif |
| 24 | 29 |
| 25 static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, | 30 static void SCALE_NOFILTER_NAME(const SkBitmapProcState& s, |
| 26 uint32_t xy[], int count, int x, int y) { | 31 uint32_t xy[], int count, int x, int y) { |
| 27 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 32 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 28 SkMatrix::kScale_Mask)) == 0); | 33 SkMatrix::kScale_Mask)) == 0); |
| 29 | 34 |
| 30 PREAMBLE(s); | 35 PREAMBLE(s); |
| 31 | 36 |
| 32 // we store y, x, x, x, x, x | 37 // we store y, x, x, x, x, x |
| 33 const unsigned maxX = s.fBitmap->width() - 1; | 38 const unsigned maxX = s.fPixmap.width() - 1; |
| 34 SkFractionalInt fx; | 39 SkFractionalInt fx; |
| 35 { | 40 { |
| 36 SkPoint pt; | 41 SkPoint pt; |
| 37 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 42 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
| 38 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 43 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
| 39 fx = SkScalarToFractionalInt(pt.fY); | 44 fx = SkScalarToFractionalInt(pt.fY); |
| 40 const unsigned maxY = s.fBitmap->height() - 1; | 45 const unsigned maxY = s.fPixmap.height() - 1; |
| 41 *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); | 46 *xy++ = TILEY_PROCF(SkFractionalIntToFixed(fx), maxY); |
| 42 fx = SkScalarToFractionalInt(pt.fX); | 47 fx = SkScalarToFractionalInt(pt.fX); |
| 43 } | 48 } |
| 44 | 49 |
| 45 if (0 == maxX) { | 50 if (0 == maxX) { |
| 46 // all of the following X values must be 0 | 51 // all of the following X values must be 0 |
| 47 memset(xy, 0, count * sizeof(uint16_t)); | 52 memset(xy, 0, count * sizeof(uint16_t)); |
| 48 return; | 53 return; |
| 49 } | 54 } |
| 50 | 55 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 PREAMBLE(s); | 120 PREAMBLE(s); |
| 116 SkPoint srcPt; | 121 SkPoint srcPt; |
| 117 s.fInvProc(s.fInvMatrix, | 122 s.fInvProc(s.fInvMatrix, |
| 118 SkIntToScalar(x) + SK_ScalarHalf, | 123 SkIntToScalar(x) + SK_ScalarHalf, |
| 119 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 124 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 120 | 125 |
| 121 SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); | 126 SkFractionalInt fx = SkScalarToFractionalInt(srcPt.fX); |
| 122 SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); | 127 SkFractionalInt fy = SkScalarToFractionalInt(srcPt.fY); |
| 123 SkFractionalInt dx = s.fInvSxFractionalInt; | 128 SkFractionalInt dx = s.fInvSxFractionalInt; |
| 124 SkFractionalInt dy = s.fInvKyFractionalInt; | 129 SkFractionalInt dy = s.fInvKyFractionalInt; |
| 125 int maxX = s.fBitmap->width() - 1; | 130 int maxX = s.fPixmap.width() - 1; |
| 126 int maxY = s.fBitmap->height() - 1; | 131 int maxY = s.fPixmap.height() - 1; |
| 127 | 132 |
| 128 if (count >= 8) { | 133 if (count >= 8) { |
| 129 SkFractionalInt dx4 = dx * 4; | 134 SkFractionalInt dx4 = dx * 4; |
| 130 SkFractionalInt dy4 = dy * 4; | 135 SkFractionalInt dy4 = dy * 4; |
| 131 SkFractionalInt dx8 = dx * 8; | 136 SkFractionalInt dx8 = dx * 8; |
| 132 SkFractionalInt dy8 = dy * 8; | 137 SkFractionalInt dy8 = dy * 8; |
| 133 | 138 |
| 134 int32x4_t xbase, ybase; | 139 int32x4_t xbase, ybase; |
| 135 int32x4_t x2base, y2base; | 140 int32x4_t x2base, y2base; |
| 136 int16_t *dst16 = (int16_t *) xy; | 141 int16_t *dst16 = (int16_t *) xy; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 } | 185 } |
| 181 } | 186 } |
| 182 | 187 |
| 183 static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, | 188 static void PERSP_NOFILTER_NAME(const SkBitmapProcState& s, |
| 184 uint32_t* SK_RESTRICT xy, | 189 uint32_t* SK_RESTRICT xy, |
| 185 int count, int x, int y) { | 190 int count, int x, int y) { |
| 186 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); | 191 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); |
| 187 | 192 |
| 188 PREAMBLE(s); | 193 PREAMBLE(s); |
| 189 // max{X,Y} are int here, but later shown/assumed to fit in 16 bits | 194 // max{X,Y} are int here, but later shown/assumed to fit in 16 bits |
| 190 int maxX = s.fBitmap->width() - 1; | 195 int maxX = s.fPixmap.width() - 1; |
| 191 int maxY = s.fBitmap->height() - 1; | 196 int maxY = s.fPixmap.height() - 1; |
| 192 | 197 |
| 193 SkPerspIter iter(s.fInvMatrix, | 198 SkPerspIter iter(s.fInvMatrix, |
| 194 SkIntToScalar(x) + SK_ScalarHalf, | 199 SkIntToScalar(x) + SK_ScalarHalf, |
| 195 SkIntToScalar(y) + SK_ScalarHalf, count); | 200 SkIntToScalar(y) + SK_ScalarHalf, count); |
| 196 | 201 |
| 197 while ((count = iter.next()) != 0) { | 202 while ((count = iter.next()) != 0) { |
| 198 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 203 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
| 199 | 204 |
| 200 if (count >= 8) { | 205 if (count >= 8) { |
| 201 int32_t *mysrc = (int32_t *) srcXY; | 206 int32_t *mysrc = (int32_t *) srcXY; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 } | 291 } |
| 287 | 292 |
| 288 static void SCALE_FILTER_NAME(const SkBitmapProcState& s, | 293 static void SCALE_FILTER_NAME(const SkBitmapProcState& s, |
| 289 uint32_t xy[], int count, int x, int y) { | 294 uint32_t xy[], int count, int x, int y) { |
| 290 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | | 295 SkASSERT((s.fInvType & ~(SkMatrix::kTranslate_Mask | |
| 291 SkMatrix::kScale_Mask)) == 0); | 296 SkMatrix::kScale_Mask)) == 0); |
| 292 SkASSERT(s.fInvKy == 0); | 297 SkASSERT(s.fInvKy == 0); |
| 293 | 298 |
| 294 PREAMBLE(s); | 299 PREAMBLE(s); |
| 295 | 300 |
| 296 const unsigned maxX = s.fBitmap->width() - 1; | 301 const unsigned maxX = s.fPixmap.width() - 1; |
| 297 const SkFixed one = s.fFilterOneX; | 302 const SkFixed one = s.fFilterOneX; |
| 298 const SkFractionalInt dx = s.fInvSxFractionalInt; | 303 const SkFractionalInt dx = s.fInvSxFractionalInt; |
| 299 SkFractionalInt fx; | 304 SkFractionalInt fx; |
| 300 | 305 |
| 301 { | 306 { |
| 302 SkPoint pt; | 307 SkPoint pt; |
| 303 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, | 308 s.fInvProc(s.fInvMatrix, SkIntToScalar(x) + SK_ScalarHalf, |
| 304 SkIntToScalar(y) + SK_ScalarHalf, &pt); | 309 SkIntToScalar(y) + SK_ScalarHalf, &pt); |
| 305 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); | 310 const SkFixed fy = SkScalarToFixed(pt.fY) - (s.fFilterOneY >> 1); |
| 306 const unsigned maxY = s.fBitmap->height() - 1; | 311 const unsigned maxY = s.fPixmap.height() - 1; |
| 307 // compute our two Y values up front | 312 // compute our two Y values up front |
| 308 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); | 313 *xy++ = PACK_FILTER_Y_NAME(fy, maxY, s.fFilterOneY PREAMBLE_ARG_Y); |
| 309 // now initialize fx | 314 // now initialize fx |
| 310 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; | 315 fx = SkScalarToFractionalInt(pt.fX) - (SkFixedToFractionalInt(one) >> 1)
; |
| 311 } | 316 } |
| 312 | 317 |
| 313 #ifdef CHECK_FOR_DECAL | 318 #ifdef CHECK_FOR_DECAL |
| 314 // test if we don't need to apply the tile proc | 319 // test if we don't need to apply the tile proc |
| 315 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { | 320 if (can_truncate_to_fixed_for_decal(fx, dx, count, maxX)) { |
| 316 decal_filter_scale_neon(xy, SkFractionalIntToFixed(fx), | 321 decal_filter_scale_neon(xy, SkFractionalIntToFixed(fx), |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 s.fInvProc(s.fInvMatrix, | 367 s.fInvProc(s.fInvMatrix, |
| 363 SkIntToScalar(x) + SK_ScalarHalf, | 368 SkIntToScalar(x) + SK_ScalarHalf, |
| 364 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); | 369 SkIntToScalar(y) + SK_ScalarHalf, &srcPt); |
| 365 | 370 |
| 366 SkFixed oneX = s.fFilterOneX; | 371 SkFixed oneX = s.fFilterOneX; |
| 367 SkFixed oneY = s.fFilterOneY; | 372 SkFixed oneY = s.fFilterOneY; |
| 368 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); | 373 SkFixed fx = SkScalarToFixed(srcPt.fX) - (oneX >> 1); |
| 369 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); | 374 SkFixed fy = SkScalarToFixed(srcPt.fY) - (oneY >> 1); |
| 370 SkFixed dx = s.fInvSx; | 375 SkFixed dx = s.fInvSx; |
| 371 SkFixed dy = s.fInvKy; | 376 SkFixed dy = s.fInvKy; |
| 372 unsigned maxX = s.fBitmap->width() - 1; | 377 unsigned maxX = s.fPixmap.width() - 1; |
| 373 unsigned maxY = s.fBitmap->height() - 1; | 378 unsigned maxY = s.fPixmap.height() - 1; |
| 374 | 379 |
| 375 if (count >= 4) { | 380 if (count >= 4) { |
| 376 int32x4_t wide_fy, wide_fx; | 381 int32x4_t wide_fy, wide_fx; |
| 377 | 382 |
| 378 wide_fx = vdupq_n_s32(fx); | 383 wide_fx = vdupq_n_s32(fx); |
| 379 wide_fx = vsetq_lane_s32(fx+dx, wide_fx, 1); | 384 wide_fx = vsetq_lane_s32(fx+dx, wide_fx, 1); |
| 380 wide_fx = vsetq_lane_s32(fx+dx+dx, wide_fx, 2); | 385 wide_fx = vsetq_lane_s32(fx+dx+dx, wide_fx, 2); |
| 381 wide_fx = vsetq_lane_s32(fx+dx+dx+dx, wide_fx, 3); | 386 wide_fx = vsetq_lane_s32(fx+dx+dx+dx, wide_fx, 3); |
| 382 | 387 |
| 383 wide_fy = vdupq_n_s32(fy); | 388 wide_fy = vdupq_n_s32(fy); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 413 fx += dx; | 418 fx += dx; |
| 414 } | 419 } |
| 415 } | 420 } |
| 416 | 421 |
| 417 static void PERSP_FILTER_NAME(const SkBitmapProcState& s, | 422 static void PERSP_FILTER_NAME(const SkBitmapProcState& s, |
| 418 uint32_t* SK_RESTRICT xy, int count, | 423 uint32_t* SK_RESTRICT xy, int count, |
| 419 int x, int y) { | 424 int x, int y) { |
| 420 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); | 425 SkASSERT(s.fInvType & SkMatrix::kPerspective_Mask); |
| 421 | 426 |
| 422 PREAMBLE(s); | 427 PREAMBLE(s); |
| 423 unsigned maxX = s.fBitmap->width() - 1; | 428 unsigned maxX = s.fPixmap.width() - 1; |
| 424 unsigned maxY = s.fBitmap->height() - 1; | 429 unsigned maxY = s.fPixmap.height() - 1; |
| 425 SkFixed oneX = s.fFilterOneX; | 430 SkFixed oneX = s.fFilterOneX; |
| 426 SkFixed oneY = s.fFilterOneY; | 431 SkFixed oneY = s.fFilterOneY; |
| 427 | 432 |
| 428 SkPerspIter iter(s.fInvMatrix, | 433 SkPerspIter iter(s.fInvMatrix, |
| 429 SkIntToScalar(x) + SK_ScalarHalf, | 434 SkIntToScalar(x) + SK_ScalarHalf, |
| 430 SkIntToScalar(y) + SK_ScalarHalf, count); | 435 SkIntToScalar(y) + SK_ScalarHalf, count); |
| 431 | 436 |
| 432 while ((count = iter.next()) != 0) { | 437 while ((count = iter.next()) != 0) { |
| 433 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); | 438 const SkFixed* SK_RESTRICT srcXY = iter.getXY(); |
| 434 | 439 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 #undef PERSP_FILTER_NAME | 502 #undef PERSP_FILTER_NAME |
| 498 | 503 |
| 499 #undef PREAMBLE | 504 #undef PREAMBLE |
| 500 #undef PREAMBLE_PARAM_X | 505 #undef PREAMBLE_PARAM_X |
| 501 #undef PREAMBLE_PARAM_Y | 506 #undef PREAMBLE_PARAM_Y |
| 502 #undef PREAMBLE_ARG_X | 507 #undef PREAMBLE_ARG_X |
| 503 #undef PREAMBLE_ARG_Y | 508 #undef PREAMBLE_ARG_Y |
| 504 | 509 |
| 505 #undef TILEX_LOW_BITS | 510 #undef TILEX_LOW_BITS |
| 506 #undef TILEY_LOW_BITS | 511 #undef TILEY_LOW_BITS |
| OLD | NEW |