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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 public: | 835 public: |
836 DummyDecoder() {} | 836 DummyDecoder() {} |
837 protected: | 837 protected: |
838 virtual bool onDecode(SkStream*, SkBitmap*, SkImageDecoder::Mode) SK_OVERRID
E { | 838 virtual bool onDecode(SkStream*, SkBitmap*, SkImageDecoder::Mode) SK_OVERRID
E { |
839 return false; | 839 return false; |
840 } | 840 } |
841 }; | 841 }; |
842 | 842 |
843 void test_row_proc_choice(); | 843 void test_row_proc_choice(); |
844 void test_row_proc_choice() { | 844 void test_row_proc_choice() { |
| 845 const SkColorType colorTypes[] = { |
| 846 kAlpha_8_SkColorType, kIndex_8_SkColorType, kRGB_565_SkColorType, kARGB_
4444_SkColorType, |
| 847 kN32_SkColorType |
| 848 }; |
| 849 |
845 SkBitmap dummyBitmap; | 850 SkBitmap dummyBitmap; |
846 DummyDecoder dummyDecoder; | 851 DummyDecoder dummyDecoder; |
847 size_t procCounter = 0; | 852 size_t procCounter = 0; |
848 for (int sc = SkScaledBitmapSampler::kGray; sc <= SkScaledBitmapSampler::kRG
B_565; ++sc) { | 853 for (int sc = SkScaledBitmapSampler::kGray; sc <= SkScaledBitmapSampler::kRG
B_565; ++sc) { |
849 for (int c = SkBitmap::kA8_Config; c <= SkBitmap::kARGB_8888_Config; ++c
) { | 854 for (size_t c = 0; c < SK_ARRAY_COUNT(colorTypes); ++c) { |
850 for (int unpremul = 0; unpremul <= 1; ++unpremul) { | 855 for (int unpremul = 0; unpremul <= 1; ++unpremul) { |
851 for (int dither = 0; dither <= 1; ++dither) { | 856 for (int dither = 0; dither <= 1; ++dither) { |
852 // Arbitrary width/height/sampleSize to allow SkScaledBitmap
Sampler to | 857 // Arbitrary width/height/sampleSize to allow SkScaledBitmap
Sampler to |
853 // be considered valid. | 858 // be considered valid. |
854 SkScaledBitmapSampler sampler(10, 10, 1); | 859 SkScaledBitmapSampler sampler(10, 10, 1); |
855 dummyBitmap.setConfig((SkBitmap::Config) c, 10, 10); | 860 dummyBitmap.setInfo(SkImageInfo::Make(10, 10, |
| 861 colorTypes[c], kPremul
_SkAlphaType)); |
856 dummyDecoder.setDitherImage(SkToBool(dither)); | 862 dummyDecoder.setDitherImage(SkToBool(dither)); |
857 dummyDecoder.setRequireUnpremultipliedColors(SkToBool(unprem
ul)); | 863 dummyDecoder.setRequireUnpremultipliedColors(SkToBool(unprem
ul)); |
858 sampler.begin(&dummyBitmap, (SkScaledBitmapSampler::SrcConfi
g) sc, | 864 sampler.begin(&dummyBitmap, (SkScaledBitmapSampler::SrcConfi
g) sc, |
859 dummyDecoder); | 865 dummyDecoder); |
860 SkScaledBitmapSampler::RowProc expected = gTestProcs[procCou
nter]; | 866 SkScaledBitmapSampler::RowProc expected = gTestProcs[procCou
nter]; |
861 SkScaledBitmapSampler::RowProc actual = RowProcTester::getRo
wProc(sampler); | 867 SkScaledBitmapSampler::RowProc actual = RowProcTester::getRo
wProc(sampler); |
862 SkASSERT(expected == actual); | 868 SkASSERT(expected == actual); |
863 procCounter++; | 869 procCounter++; |
864 } | 870 } |
865 } | 871 } |
866 } | 872 } |
867 } | 873 } |
868 SkASSERT(SK_ARRAY_COUNT(gTestProcs) == procCounter); | 874 SkASSERT(SK_ARRAY_COUNT(gTestProcs) == procCounter); |
869 } | 875 } |
870 #endif // SK_DEBUG | 876 #endif // SK_DEBUG |
OLD | NEW |