| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
| 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 "SkBitmapCache.h" | 8 #include "SkBitmapCache.h" |
| 9 #include "SkBitmapController.h" | 9 #include "SkBitmapController.h" |
| 10 #include "SkBitmapProcState.h" | 10 #include "SkBitmapProcState.h" |
| (...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 sk_memset32(colors, color, count); | 579 sk_memset32(colors, color, count); |
| 580 } | 580 } |
| 581 | 581 |
| 582 static void DoNothing_shaderproc(const void*, int x, int y, | 582 static void DoNothing_shaderproc(const void*, int x, int y, |
| 583 SkPMColor* SK_RESTRICT colors, int count) { | 583 SkPMColor* SK_RESTRICT colors, int count) { |
| 584 // if we get called, the matrix is too tricky, so we just draw nothing | 584 // if we get called, the matrix is too tricky, so we just draw nothing |
| 585 sk_memset32(colors, 0, count); | 585 sk_memset32(colors, 0, count); |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool SkBitmapProcState::setupForTranslate() { | 588 bool SkBitmapProcState::setupForTranslate() { |
| 589 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS |
| 589 SkPoint pt; | 590 SkPoint pt; |
| 590 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); | 591 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); |
| 591 | 592 |
| 593 const SkScalar too_big = SkIntToScalar(1 << 30); |
| 594 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) { |
| 595 return false; |
| 596 } |
| 597 |
| 598 fFilterOneX = SkScalarFloorToInt(pt.fX); |
| 599 fFilterOneY = SkScalarFloorToInt(pt.fY); |
| 600 #else |
| 601 SkBitmapProcStateAutoMapper mapper(*this, 0, 0); |
| 602 |
| 592 /* | 603 /* |
| 593 * if the translate is larger than our ints, we can get random results, or | 604 * if the translate is larger than our ints, we can get random results, or |
| 594 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't | 605 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't |
| 595 * negate it. | 606 * negate it. |
| 596 */ | 607 */ |
| 597 const SkScalar too_big = SkIntToScalar(1 << 30); | 608 if (mapper.isOverflow()) { |
| 598 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) { | |
| 599 return false; | 609 return false; |
| 600 } | 610 } |
| 601 | 611 |
| 602 // Since we know we're not filtered, we re-purpose these fields allow | 612 // Since we know we're not filtered, we re-purpose these fields allow |
| 603 // us to go from device -> src coordinates w/ just an integer add, | 613 // us to go from device -> src coordinates w/ just an integer add, |
| 604 // rather than running through the inverse-matrix | 614 // rather than running through the inverse-matrix |
| 605 fFilterOneX = SkScalarFloorToInt(pt.fX); | 615 fFilterOneX = SkFractionalIntToInt(mapper.x()); |
| 606 fFilterOneY = SkScalarFloorToInt(pt.fY); | 616 fFilterOneY = SkFractionalIntToInt(mapper.y()); |
| 617 #endif |
| 618 |
| 607 return true; | 619 return true; |
| 608 } | 620 } |
| 609 | 621 |
| 610 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { | 622 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
| 611 | 623 |
| 612 if (kN32_SkColorType != fPixmap.colorType()) { | 624 if (kN32_SkColorType != fPixmap.colorType()) { |
| 613 return nullptr; | 625 return nullptr; |
| 614 } | 626 } |
| 615 | 627 |
| 616 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M
ask; | 628 static const unsigned kMask = SkMatrix::kTranslate_Mask | SkMatrix::kScale_M
ask; |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 815 fx += dx; | 827 fx += dx; |
| 816 } | 828 } |
| 817 } else { | 829 } else { |
| 818 for (int i = 0; i < count; ++i) { | 830 for (int i = 0; i < count; ++i) { |
| 819 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 831 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
| 820 fx += dx; | 832 fx += dx; |
| 821 } | 833 } |
| 822 } | 834 } |
| 823 } | 835 } |
| 824 | 836 |
| OLD | NEW |