OLD | NEW |
1 #include "Test.h" | 1 #include "Test.h" |
2 | 2 |
3 #include "SkMallocPixelRef.h" | 3 #include "SkMallocPixelRef.h" |
4 #include "SkPixelRef.h" | 4 #include "SkPixelRef.h" |
5 | 5 |
6 static void test_info(skiatest::Reporter* reporter) { | 6 static void test_info(skiatest::Reporter* reporter) { |
7 static const struct { | 7 static const struct { |
8 SkBitmap::Config fConfig; | 8 SkBitmap::Config fConfig; |
9 SkAlphaType fAlphaType; | 9 SkAlphaType fAlphaType; |
10 SkColorType fExpectedColorType; | 10 SkColorType fExpectedColorType; |
(...skipping 12 matching lines...) Expand all Loading... |
23 }; | 23 }; |
24 | 24 |
25 SkBitmap bitmap; | 25 SkBitmap bitmap; |
26 SkImageInfo info; | 26 SkImageInfo info; |
27 | 27 |
28 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 28 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
29 bool success = bitmap.setConfig(gRec[i].fConfig, 10, 10, 0, gRec[i].fAlp
haType); | 29 bool success = bitmap.setConfig(gRec[i].fConfig, 10, 10, 0, gRec[i].fAlp
haType); |
30 REPORTER_ASSERT(reporter, success); | 30 REPORTER_ASSERT(reporter, success); |
31 success = bitmap.asImageInfo(&info); | 31 success = bitmap.asImageInfo(&info); |
32 REPORTER_ASSERT(reporter, success == gRec[i].fExpectedSuccess); | 32 REPORTER_ASSERT(reporter, success == gRec[i].fExpectedSuccess); |
33 if (gRec[i].fExpectedSuccess) { | 33 if (success && gRec[i].fExpectedSuccess) { |
34 REPORTER_ASSERT(reporter, info.fAlphaType == gRec[i].fAlphaType); | 34 REPORTER_ASSERT(reporter, info.fAlphaType == gRec[i].fAlphaType); |
35 REPORTER_ASSERT(reporter, info.fColorType == gRec[i].fExpectedColorT
ype); | 35 REPORTER_ASSERT(reporter, info.fColorType == gRec[i].fExpectedColorT
ype); |
36 } | 36 } |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 class TestListener : public SkPixelRef::GenIDChangeListener { | 40 class TestListener : public SkPixelRef::GenIDChangeListener { |
41 public: | 41 public: |
42 explicit TestListener(int* ptr) : fPtr(ptr) {} | 42 explicit TestListener(int* ptr) : fPtr(ptr) {} |
43 virtual void onChange() SK_OVERRIDE { (*fPtr)++; } | 43 virtual void onChange() SK_OVERRIDE { (*fPtr)++; } |
(...skipping 29 matching lines...) Expand all Loading... |
73 pixelRef->notifyPixelsChanged(); | 73 pixelRef->notifyPixelsChanged(); |
74 REPORTER_ASSERT(r, 1 == count); | 74 REPORTER_ASSERT(r, 1 == count); |
75 | 75 |
76 // Quick check that NULL is safe. | 76 // Quick check that NULL is safe. |
77 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); | 77 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); |
78 pixelRef->addGenIDChangeListener(NULL); | 78 pixelRef->addGenIDChangeListener(NULL); |
79 pixelRef->notifyPixelsChanged(); | 79 pixelRef->notifyPixelsChanged(); |
80 | 80 |
81 test_info(r); | 81 test_info(r); |
82 } | 82 } |
OLD | NEW |