| 407 | } |
| 408 | |
| 409 | static int filterEdgeHitAtPixel(int mx, int loX, int hiX, int grabPx) |
| 410 | { |
| 411 | const int left = std::min(loX, hiX); |
| 412 | const int right = std::max(loX, hiX); |
| 413 | const bool insidePassband = mx >= left && mx <= right; |
| 414 | if (insidePassband && right - left <= kFilterPassbandMinBodyPx) { |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | const int insideGrabPx = filterInteriorGrabPx(loX, hiX, grabPx); |
| 419 | const bool lowIsLeft = loX <= hiX; |
| 420 | const bool lowHit = lowIsLeft |
| 421 | ? (mx >= loX - grabPx && mx <= loX + insideGrabPx) |
| 422 | : (mx >= loX - insideGrabPx && mx <= loX + grabPx); |
| 423 | const bool highHit = lowIsLeft |
| 424 | ? (mx >= hiX - insideGrabPx && mx <= hiX + grabPx) |
| 425 | : (mx >= hiX - grabPx && mx <= hiX + insideGrabPx); |
| 426 | |
| 427 | if (lowHit && highHit) { |
| 428 | return (std::abs(mx - loX) <= std::abs(mx - hiX)) ? -1 : 1; |
| 429 | } |
| 430 | if (lowHit) { |
| 431 | return -1; |
| 432 | } |
| 433 | if (highHit) { |
| 434 | return 1; |
| 435 | } |
| 436 | return 0; |
| 437 | } |
| 438 | |
| 439 | static bool filterPassbandBodyHitAtPixel(int mx, int loX, int hiX, int grabPx) |
| 440 | { |
no test coverage detected