| 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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 SkPoint pt; | 589 SkPoint pt; |
| 590 | |
| 591 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS | |
| 592 fInvProc(fInvMatrix, SK_ScalarHalf, SK_ScalarHalf, &pt); | |
| 593 #else | |
| 594 const SkBitmapProcStateAutoMapper mapper(*this, 0, 0, &pt); | 590 const SkBitmapProcStateAutoMapper mapper(*this, 0, 0, &pt); |
| 595 #endif | |
| 596 | 591 |
| 597 /* | 592 /* |
| 598 * if the translate is larger than our ints, we can get random results, or | 593 * if the translate is larger than our ints, we can get random results, or |
| 599 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't | 594 * worse, we might get 0x80000000, which wreaks havoc on us, since we can't |
| 600 * negate it. | 595 * negate it. |
| 601 */ | 596 */ |
| 602 const SkScalar too_big = SkIntToScalar(1 << 30); | 597 const SkScalar too_big = SkIntToScalar(1 << 30); |
| 603 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) { | 598 if (SkScalarAbs(pt.fX) > too_big || SkScalarAbs(pt.fY) > too_big) { |
| 604 return false; | 599 return false; |
| 605 } | 600 } |
| 606 | 601 |
| 607 #ifdef SK_SUPPORT_LEGACY_SAMPLER_BIAS | |
| 608 fFilterOneX = SkScalarFloorToInt(pt.fX); | |
| 609 fFilterOneY = SkScalarFloorToInt(pt.fY); | |
| 610 #else | |
| 611 // Since we know we're not filtered, we re-purpose these fields allow | 602 // Since we know we're not filtered, we re-purpose these fields allow |
| 612 // us to go from device -> src coordinates w/ just an integer add, | 603 // us to go from device -> src coordinates w/ just an integer add, |
| 613 // rather than running through the inverse-matrix | 604 // rather than running through the inverse-matrix |
| 614 fFilterOneX = SkFractionalIntToInt(mapper.x()); | 605 fFilterOneX = SkFractionalIntToInt(mapper.x()); |
| 615 fFilterOneY = SkFractionalIntToInt(mapper.y()); | 606 fFilterOneY = SkFractionalIntToInt(mapper.y()); |
| 616 #endif | |
| 617 | 607 |
| 618 return true; | 608 return true; |
| 619 } | 609 } |
| 620 | 610 |
| 621 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { | 611 SkBitmapProcState::ShaderProc32 SkBitmapProcState::chooseShaderProc32() { |
| 622 | 612 |
| 623 if (kN32_SkColorType != fPixmap.colorType()) { | 613 if (kN32_SkColorType != fPixmap.colorType()) { |
| 624 return nullptr; | 614 return nullptr; |
| 625 } | 615 } |
| 626 | 616 |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 826 fx += dx; | 816 fx += dx; |
| 827 } | 817 } |
| 828 } else { | 818 } else { |
| 829 for (int i = 0; i < count; ++i) { | 819 for (int i = 0; i < count; ++i) { |
| 830 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; | 820 dst[i] = src[SkClampMax(SkFractionalIntToInt(fx), maxX)]; |
| 831 fx += dx; | 821 fx += dx; |
| 832 } | 822 } |
| 833 } | 823 } |
| 834 } | 824 } |
| 835 | 825 |
| OLD | NEW |