OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The Android Open Source Project | 2 * Copyright 2007 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 | 8 |
9 #include "SkScaledBitmapSampler.h" | 9 #include "SkScaledBitmapSampler.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (srcYMinusY0 % fDY != 0) { | 755 if (srcYMinusY0 % fDY != 0) { |
756 // This line is not part of the output, so return false for alpha, since
we have | 756 // This line is not part of the output, so return false for alpha, since
we have |
757 // not added an alpha to the output. | 757 // not added an alpha to the output. |
758 return false; | 758 return false; |
759 } | 759 } |
760 // Unlike in next(), where the data is used sequentially, this function skip
s around, | 760 // Unlike in next(), where the data is used sequentially, this function skip
s around, |
761 // so fDstRow and fCurrY are never updated. fDstRow must always be the start
ing point | 761 // so fDstRow and fCurrY are never updated. fDstRow must always be the start
ing point |
762 // of the destination bitmap's pixels, which is used to calculate the destin
ation row | 762 // of the destination bitmap's pixels, which is used to calculate the destin
ation row |
763 // each time this function is called. | 763 // each time this function is called. |
764 const int dstY = srcYMinusY0 / fDY; | 764 const int dstY = srcYMinusY0 / fDY; |
765 SkASSERT(dstY < fScaledHeight); | 765 if (dstY >= fScaledHeight) { |
| 766 return false; |
| 767 } |
766 char* dstRow = fDstRow + dstY * fDstRowBytes; | 768 char* dstRow = fDstRow + dstY * fDstRowBytes; |
767 return fRowProc(dstRow, src + fX0 * fSrcPixelSize, fScaledWidth, | 769 return fRowProc(dstRow, src + fX0 * fSrcPixelSize, fScaledWidth, |
768 fDX * fSrcPixelSize, dstY, fCTable); | 770 fDX * fSrcPixelSize, dstY, fCTable); |
769 } | 771 } |
770 | 772 |
771 #ifdef SK_DEBUG | 773 #ifdef SK_DEBUG |
772 // The following code is for a test to ensure that changing the method to get th
e right row proc | 774 // The following code is for a test to ensure that changing the method to get th
e right row proc |
773 // did not change the row proc unintentionally. Tested by ImageDecodingTest.cpp | 775 // did not change the row proc unintentionally. Tested by ImageDecodingTest.cpp |
774 | 776 |
775 // friend of SkScaledBitmapSampler solely for the purpose of accessing fRowProc. | 777 // friend of SkScaledBitmapSampler solely for the purpose of accessing fRowProc. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 SkScaledBitmapSampler::RowProc actual = RowProcTester::getRo
wProc(sampler); | 868 SkScaledBitmapSampler::RowProc actual = RowProcTester::getRo
wProc(sampler); |
867 SkASSERT(expected == actual); | 869 SkASSERT(expected == actual); |
868 procCounter++; | 870 procCounter++; |
869 } | 871 } |
870 } | 872 } |
871 } | 873 } |
872 } | 874 } |
873 SkASSERT(SK_ARRAY_COUNT(gTestProcs) == procCounter); | 875 SkASSERT(SK_ARRAY_COUNT(gTestProcs) == procCounter); |
874 } | 876 } |
875 #endif // SK_DEBUG | 877 #endif // SK_DEBUG |
OLD | NEW |